Coverage Report - org.kuali.rice.core.api.mo.AbstractDataTransferObject
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractDataTransferObject
100%
8/8
N/A
1
AbstractDataTransferObject$Constants
50%
1/2
N/A
1
 
 1  
 package org.kuali.rice.core.api.mo;
 2  
 
 3  
 import org.apache.commons.lang.builder.EqualsBuilder;
 4  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 5  
 import org.apache.commons.lang.builder.ToStringBuilder;
 6  
 import org.kuali.rice.core.api.CoreConstants;
 7  
 import org.kuali.rice.core.api.util.CollectionUtils;
 8  
 
 9  
 import javax.xml.bind.Unmarshaller;
 10  
 
 11  
 /**
 12  
  * All model object's that are Jaxb annotated should extend this class.
 13  
  *
 14  
  * This class does several important things:
 15  
  * <ol>
 16  
  *     <li>Defines jaxb callback method to ensure that Collection and Map types are unmarshalled into immutable empty forms rather than null values</li>
 17  
  *     <li>Defines equals/hashcode/toString</li>
 18  
  *
 19  
  *     Note: the equals/hashCode implementation excludes {@value CoreConstants.CommonElements.FUTURE_ELEMENTS} field.
 20  
  *     This element should be present on all jaxb annotated classes.
 21  
  * </ol>
 22  
  */
 23  
 public abstract class AbstractDataTransferObject implements ModelObjectComplete {
 24  
 
 25  
     protected AbstractDataTransferObject() {
 26  488
         super();
 27  488
     }
 28  
 
 29  
     @Override
 30  
     public int hashCode() {
 31  408
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 32  
     }
 33  
 
 34  
     @Override
 35  
     public boolean equals(Object obj) {
 36  151
         return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 37  
     }
 38  
 
 39  
     @Override
 40  
     public String toString() {
 41  1
         return ToStringBuilder.reflectionToString(this);
 42  
     }
 43  
 
 44  
     @SuppressWarnings("unused")
 45  
     protected void beforeUnmarshal(Unmarshaller u, Object parent) throws Exception {
 46  173
     }
 47  
 
 48  
     @SuppressWarnings("unused")
 49  
     protected void afterUnmarshal(Unmarshaller u, Object parent) throws Exception {
 50  173
         CollectionUtils.makeUnmodifiableAndNullSafe(this);
 51  173
     }
 52  
 
 53  
     /**
 54  
      * Defines some internal constants used on this class.
 55  
      */
 56  0
     protected static class Constants {
 57  1
         final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS};
 58  
     }
 59  
 }