Coverage Report - org.kuali.rice.krms.api.repository.term.TermResolverAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
TermResolverAttribute
81%
9/11
N/A
1.286
TermResolverAttribute$1
N/A
N/A
1.286
TermResolverAttribute$Builder
61%
11/18
25%
1/4
1.286
TermResolverAttribute$Builder$1
50%
1/2
N/A
1.286
TermResolverAttribute$Constants
50%
1/2
N/A
1.286
TermResolverAttribute$Elements
0%
0/1
N/A
1.286
 
 1  
 package org.kuali.rice.krms.api.repository.term;
 2  
 
 3  
 import java.io.Serializable;
 4  
 
 5  
 import javax.xml.bind.annotation.XmlAccessType;
 6  
 import javax.xml.bind.annotation.XmlAccessorType;
 7  
 import javax.xml.bind.annotation.XmlElement;
 8  
 import javax.xml.bind.annotation.XmlRootElement;
 9  
 import javax.xml.bind.annotation.XmlType;
 10  
 
 11  
 import org.apache.commons.lang.StringUtils;
 12  
 import org.apache.commons.lang.builder.EqualsBuilder;
 13  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 14  
 import org.apache.commons.lang.builder.ToStringBuilder;
 15  
 import org.kuali.rice.core.api.CoreConstants;
 16  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 17  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 18  
 import org.kuali.rice.krms.api.repository.BaseAttribute;
 19  
 import org.kuali.rice.krms.api.repository.BuilderUtils;
 20  
 import org.kuali.rice.krms.api.repository.BaseAttribute.Builder;
 21  
 import org.kuali.rice.krms.api.repository.BaseAttribute.Elements;
 22  
 import org.kuali.rice.krms.api.repository.BuilderUtils.Transformer;
 23  
 import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition;
 24  
 
 25  
 /**
 26  
  * Concrete model object implementation of {@link TermResolverAttribute}. 
 27  
  * immutable. 
 28  
  * Instances of {@link TermResolverAttribute} can be (un)marshalled to and from XML.
 29  
  *
 30  
  */
 31  
 @XmlRootElement(name = TermResolverAttribute.Constants.ROOT_ELEMENT_NAME)
 32  
 @XmlAccessorType(XmlAccessType.NONE)
 33  
 @XmlType(name = TermResolverAttribute.Constants.TYPE_NAME, propOrder = {
 34  
                 TermResolverAttribute.Elements.ID,
 35  
                 TermResolverAttribute.Elements.TERM_RESOLVER_ID,
 36  
                 TermResolverAttribute.Elements.ATTR_DEFN_ID,
 37  
                 TermResolverAttribute.Elements.VALUE,
 38  
                 TermResolverAttribute.Elements.ATTR_DEFN,
 39  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 40  
 })
 41  1
 public final class TermResolverAttribute extends BaseAttribute implements TermResolverAttributeContract, ModelObjectComplete {        
 42  
         private static final long serialVersionUID = -6126133049308968098L;
 43  
         
 44  
         @XmlElement(name = Elements.TERM_RESOLVER_ID, required=true)
 45  
         private final String termResolverId;
 46  
 
 47  
         /** 
 48  
      * This constructor should never be called.  It is only present for use during JAXB unmarshalling. 
 49  
      */
 50  
     private TermResolverAttribute() {
 51  2
             super();
 52  2
             this.termResolverId = null;
 53  2
     }
 54  
     
 55  
     /**
 56  
          * Constructs a TermResolverAttribute from the given builder.  
 57  
          * This constructor is private and should only ever be invoked from the builder.
 58  
          * 
 59  
          * @param builder the Builder from which to construct the {@link TermResolverAttribute}
 60  
          */
 61  
     private TermResolverAttribute(Builder builder) {
 62  1
             super(builder);
 63  1
         this.termResolverId = builder.getTermResolverId();
 64  1
     }
 65  
     
 66  
         @Override
 67  
         public String getTermResolverId() {
 68  0
                 return this.termResolverId;
 69  
         }
 70  
 
 71  
         /**
 72  
      * This builder is used to construct instances of {@link TermResolverAttribute}.  
 73  
      */
 74  1
     public static class Builder extends BaseAttribute.Builder implements TermResolverAttributeContract, ModelBuilder, Serializable {                
 75  
                 private static final long serialVersionUID = 5799994031051731535L;
 76  
 
 77  
         private String termResolverId;
 78  
 
 79  
                 /**
 80  
                  * {@link Transformer} to ease converting lists of contracts to Builders
 81  
                  */
 82  
                 public static final Transformer<TermResolverAttributeContract, TermResolverAttribute.Builder>
 83  1
                 toBuilder = new Transformer<TermResolverAttributeContract, TermResolverAttribute.Builder>() {
 84  
                         public org.kuali.rice.krms.api.repository.term.TermResolverAttribute.Builder transform(
 85  
                                         TermResolverAttributeContract input) {
 86  0
                                 return TermResolverAttribute.Builder.create(input);
 87  
                         }
 88  
                 };
 89  
         
 90  
         /**
 91  
                  * Private constructor for creating a builder with all of it's required attributes.
 92  
                  */
 93  
         private Builder(String id, String termResolverId, String attributeDefinitionId, String value) {
 94  1
                 super(id, attributeDefinitionId, value);
 95  1
             setTermResolverId(termResolverId);
 96  1
         }
 97  
 
 98  
         public Builder attributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition){
 99  0
                 setAttributeDefinition(attributeDefinition);
 100  0
                 return this;
 101  
         }
 102  
         
 103  
         /**
 104  
          * Creates a builder from the given parameters.
 105  
          * 
 106  
          * @param id the ActionAtribute id
 107  
          * @param actionId the Action Id 
 108  
          * @param attributeDefinitionId The attributeDefinitionId
 109  
          * @param value 
 110  
          * @return an instance of the builder with the fields already populated
 111  
          * @throws IllegalArgumentException if the either the id, name or namespace is null or blank
 112  
          */
 113  
         public static Builder create(String id, String termResolverId, String attributeDefinitionId, String value) {
 114  1
             return new Builder(id, termResolverId, attributeDefinitionId, value);
 115  
         }
 116  
         
 117  
         public static Builder create(TermResolverAttributeContract contract){
 118  0
                 if (contract == null) {
 119  0
                 throw new IllegalArgumentException("contract is null");
 120  
             }
 121  0
                 Builder builder = new Builder(contract.getId(), 
 122  
                                 contract.getTermResolverId(),
 123  
                                 contract.getAttributeDefinitionId(),
 124  
                                 contract.getValue()).attributeDefinition(KrmsAttributeDefinition.Builder
 125  
                                                 .create(contract.getAttributeDefinition()));
 126  0
                 return builder;
 127  
         }
 128  
 
 129  
                 public void setTermResolverId(String termResolverId) {
 130  1
             if (StringUtils.isBlank(termResolverId)) {
 131  0
                 throw new IllegalArgumentException("termResolverId is blank");
 132  
             }
 133  1
                         this.termResolverId = termResolverId;
 134  1
                 }
 135  
                 
 136  
                 @Override
 137  
                 public String getTermResolverId() {
 138  1
                         return termResolverId;
 139  
                 }
 140  
 
 141  
                 /**
 142  
                  * Builds an instance of a ActionAttribute based on the current state of the builder.
 143  
                  * 
 144  
                  * @return the fully-constructed ActionAttribute
 145  
                  */
 146  
         @Override
 147  
         public TermResolverAttribute build() {
 148  1
             return new TermResolverAttribute(this);
 149  
         }
 150  
                 
 151  
     }
 152  
     
 153  
         @Override
 154  
         public int hashCode() {
 155  4
                 return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 156  
         }
 157  
 
 158  
         @Override
 159  
         public boolean equals(Object obj) {
 160  1
                 return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 161  
         }
 162  
 
 163  
         @Override
 164  
         public String toString() {
 165  0
                 return ToStringBuilder.reflectionToString(this);
 166  
         }
 167  
         
 168  
         /**
 169  
          * Defines some internal constants used on this class.
 170  
          */
 171  0
         static class Constants {
 172  
                 final static String ROOT_ELEMENT_NAME = "TermResolverAttribute";
 173  
                 final static String TYPE_NAME = "TermResolverAttributeType";
 174  1
                 final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS };
 175  
         }
 176  
         
 177  
         /**
 178  
          * A private class which exposes constants which define the XML element names to use
 179  
          * when this object is marshalled to XML.
 180  
          */
 181  0
         public static class Elements extends BaseAttribute.Elements {
 182  
                 final static String TERM_RESOLVER_ID = "termResolverId";
 183  
         }
 184  
 }