Coverage Report - org.apache.tapestry5.internal.util.Holder
 
Classes in this File Line Coverage Branch Coverage Complexity
Holder
100%
6/6
100%
2/2
0
 
 1  
 // Copyright 2006, 2007 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.util;
 16  
 
 17  
 import java.util.concurrent.atomic.AtomicReference;
 18  
 
 19  
 /**
 20  
  * An object that holds some type of other object. This is useful for communicating information from an inner class
 21  
  * (used as a closure) to the containing method. This is similar to {@link AtomicReference}, except that it is simpler
 22  
  * but <strong>not</strong> thread safe.
 23  
  *
 24  
  * @param <T>
 25  
  */
 26  4180
 public class Holder<T>
 27  
 {
 28  
     private T held;
 29  
 
 30  
     public void put(T object)
 31  
     {
 32  1508
         held = object;
 33  1508
     }
 34  
 
 35  
     public T get()
 36  
     {
 37  1426
         return held;
 38  
     }
 39  
 
 40  
     public boolean hasValue()
 41  
     {
 42  4118
         return held != null;
 43  
     }
 44  
 
 45  
     public static <T> Holder<T> create()
 46  
     {
 47  2520
         return new Holder<T>();
 48  
     }
 49  
 }