Coverage Report - net.sourceforge.combean.util.GenericWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
GenericWrapper
56%
9/16
50%
2/4
1,8
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 20.03.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.util;
 23  
 
 24  
 
 25  
 /**
 26  
  * A generic base class for wrapping an object. Provides access to the inner
 27  
  * object and an equality function based on the inner object.
 28  
  * 
 29  
  * @author schickin
 30  
  *
 31  
  */
 32  
 public class GenericWrapper {
 33  
 
 34  10491
     private Object o = null;
 35  
 
 36  
     /**
 37  
      * constructor.
 38  
      * 
 39  
      * @param o the object to wrap
 40  
      */
 41  
     public GenericWrapper(Object o) {
 42  10491
         super();
 43  10491
         this.o = o;
 44  10491
     }
 45  
 
 46  
     /**
 47  
      * Access to inner object.
 48  
      * 
 49  
      * @return the inner object
 50  
      */
 51  
     public final Object getInnerObject() {
 52  20982
         return this.o;
 53  
     }
 54  
 
 55  
     /**
 56  
      * @see java.lang.Object#equals(Object)
 57  
      */
 58  
     public boolean equals(Object o) {
 59  2961
         if (o == null) {
 60  0
             return false;
 61  
         }
 62  2961
             if (! (GenericWrapper.class.isAssignableFrom(o.getClass())) ) {
 63  0
                     return false;
 64  
             }
 65  2961
             return getInnerObject().equals(((GenericWrapper)o).getInnerObject());
 66  
     }
 67  
 
 68  
     /**
 69  
      * @see java.lang.Object#hashCode()
 70  
      */
 71  
     public int hashCode() {
 72  2784
             return getInnerObject().hashCode();
 73  
     }
 74  
     
 75  
     /* (non-Javadoc)
 76  
      * @see java.lang.Object#toString()
 77  
      */
 78  
     public String toString() {
 79  0
         StringBuffer result = new StringBuffer();
 80  0
         result.append(getClass().getName() + " {");
 81  0
         result.append(getInnerObject().toString());
 82  0
         result.append("}");
 83  
         
 84  0
         return result.toString();
 85  
     }
 86  
 }