Coverage Report - org.apache.tapestry5.internal.bindings.LiteralBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
LiteralBinding
100%
6/6
N/A
0
 
 1  
 // Copyright 2006, 2008, 2009 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.internal.bindings;
 16  
 
 17  
 import org.apache.tapestry5.ioc.Location;
 18  
 
 19  
 /**
 20  
  * Binding type for literal, immutable values. Literal bindings are {@linkplain org.apache.tapestry5.Binding#isInvariant()
 21  
  * invariant}; any value provided by a LiteralBinding, even if {@linkplain org.apache.tapestry5.ioc.services.TypeCoercer#coerce(Object,
 22  
  * Class) coerced}, will be cached aggresively by Tapestry cmponent.
 23  
  * <p/>
 24  
  * <p>LiteralBindings are often used for literal string values supplied in-line in the component template, but is used
 25  
  * for many other things as well, any kind of fixed, read-only value.
 26  
  */
 27  
 public class LiteralBinding extends AbstractBinding
 28  
 {
 29  
     private final String description;
 30  
 
 31  
     private final Object value;
 32  
 
 33  
     public LiteralBinding(Location location, String description, Object value)
 34  
     {
 35  2531
         super(location);
 36  2531
         this.description = description;
 37  2531
         this.value = value;
 38  2531
     }
 39  
 
 40  
     public Object get()
 41  
     {
 42  5219
         return value;
 43  
     }
 44  
 
 45  
     @Override
 46  
     public String toString()
 47  
     {
 48  2
         return String.format("LiteralBinding[%s: %s]", description, value);
 49  
     }
 50  
 }