Coverage Report - org.kuali.rice.krms.api.repository.agenda.AgendaTreeDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaTreeDefinition
88%
15/17
100%
2/2
1.533
AgendaTreeDefinition$1
N/A
N/A
1.533
AgendaTreeDefinition$Builder
100%
20/20
100%
6/6
1.533
AgendaTreeDefinition$Constants
50%
1/2
N/A
1.533
AgendaTreeDefinition$Elements
0%
0/1
N/A
1.533
 
 1  
 package org.kuali.rice.krms.api.repository.agenda;
 2  
 
 3  
 import java.io.Serializable;
 4  
 import java.util.ArrayList;
 5  
 import java.util.Collection;
 6  
 import java.util.Collections;
 7  
 import java.util.List;
 8  
 
 9  
 import javax.xml.bind.annotation.XmlAccessType;
 10  
 import javax.xml.bind.annotation.XmlAccessorType;
 11  
 import javax.xml.bind.annotation.XmlAnyElement;
 12  
 import javax.xml.bind.annotation.XmlElement;
 13  
 import javax.xml.bind.annotation.XmlElements;
 14  
 import javax.xml.bind.annotation.XmlRootElement;
 15  
 import javax.xml.bind.annotation.XmlType;
 16  
 
 17  
 import org.apache.commons.lang.StringUtils;
 18  
 import org.apache.commons.lang.builder.EqualsBuilder;
 19  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 20  
 import org.apache.commons.lang.builder.ToStringBuilder;
 21  
 import org.kuali.rice.core.api.CoreConstants;
 22  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 23  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 24  
 
 25  
 /**
 26  
  * Concrete model object implementation of KRMS Repository Agenda 
 27  
  * immutable. 
 28  
  * Instances of Agenda can be (un)marshalled to and from XML.
 29  
  *
 30  
  * @see AgendaDefinitionContract
 31  
  */
 32  
 @XmlRootElement(name = AgendaTreeDefinition.Constants.ROOT_ELEMENT_NAME)
 33  
 @XmlAccessorType(XmlAccessType.NONE)
 34  
 @XmlType(name = AgendaTreeDefinition.Constants.TYPE_NAME, propOrder = {
 35  
                 AgendaTreeDefinition.Elements.AGENDA_ID,
 36  
                 AgendaTreeDefinition.Elements.ENTRIES,
 37  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 38  
 })
 39  16
 public final class AgendaTreeDefinition implements ModelObjectComplete {
 40  
         
 41  
         private static final long serialVersionUID = 3355519740298280591L;
 42  
 
 43  
         @XmlElement(name = Elements.AGENDA_ID, required = false)
 44  
         private final String agendaId;
 45  
         
 46  
         @XmlElements(value = {
 47  
             @XmlElement(name = Elements.RULE, type = AgendaTreeRuleEntry.class, required = false),
 48  
             @XmlElement(name = Elements.SUB_AGENDA, type = AgendaTreeSubAgendaEntry.class, required = false)
 49  
         })
 50  
         private final List<AgendaTreeEntryDefinition> entries;
 51  
                 
 52  49
         @SuppressWarnings("unused")
 53  
     @XmlAnyElement
 54  
     private final Collection<org.w3c.dom.Element> _futureElements = null;
 55  
         
 56  
         /** 
 57  
      * This constructor should never be called.  
 58  
      * It is only present for use during JAXB unmarshalling. 
 59  
      */
 60  33
     private AgendaTreeDefinition() {
 61  33
             this.agendaId = null;
 62  33
             this.entries = null;
 63  33
     }
 64  
     
 65  16
     private AgendaTreeDefinition(Builder builder) {
 66  16
             this.agendaId = builder.getAgendaId();
 67  16
         this.entries = builder.getEntries();
 68  16
     }
 69  
     
 70  
     public String getAgendaId() {
 71  5
             return agendaId;
 72  
     }
 73  
     
 74  
         public List<AgendaTreeEntryDefinition> getEntries() {
 75  25
                 if (entries == null){
 76  1
                         return Collections.emptyList();
 77  
                 }
 78  24
                 return Collections.unmodifiableList(entries);
 79  
         }
 80  
 
 81  6
     public static class Builder implements ModelBuilder, Serializable {
 82  
                         
 83  
                 private static final long serialVersionUID = 7981215392039022620L;
 84  
                 
 85  
                 private String agendaId;
 86  
                 private List<AgendaTreeEntryDefinition> entries;
 87  
 
 88  
                 /**
 89  
                  * Private constructor for creating a builder with all of it's required attributes.
 90  
                  */
 91  26
         private Builder() {
 92  26
                 this.entries = new ArrayList<AgendaTreeEntryDefinition>();
 93  26
         }
 94  
         
 95  
         public static Builder create(){
 96  26
                 return new Builder();
 97  
         }
 98  
         
 99  
         public void setAgendaId(String agendaId) {
 100  22
                         if (StringUtils.isBlank(agendaId)) {
 101  3
                                 throw new IllegalArgumentException("agendaItemId was null or blank");
 102  
                         }
 103  19
                 this.agendaId = agendaId;
 104  19
         }
 105  
         
 106  
         public void addRuleEntry(AgendaTreeRuleEntry ruleEntry) {
 107  20
                 if (ruleEntry == null) {
 108  1
                         throw new IllegalArgumentException("ruleEntry was null");
 109  
                 }
 110  19
                 entries.add(ruleEntry);
 111  19
         }
 112  
         
 113  
         public void addSubAgendaEntry(AgendaTreeSubAgendaEntry subAgendaEntry) {
 114  2
                 if (subAgendaEntry == null) {
 115  1
                         throw new IllegalArgumentException("subAgendaEntry was null");
 116  
                 }
 117  1
                 entries.add(subAgendaEntry);
 118  1
         }
 119  
         
 120  
         public String getAgendaId() {
 121  16
                 return this.agendaId;
 122  
         }
 123  
         
 124  
         public List<AgendaTreeEntryDefinition> getEntries() {
 125  16
                 return this.entries;
 126  
         }
 127  
 
 128  
         @Override
 129  
         public AgendaTreeDefinition build() {
 130  16
             return new AgendaTreeDefinition(this);
 131  
         }
 132  
                 
 133  
     }
 134  
     
 135  
         @Override
 136  
         public int hashCode() {
 137  0
                 return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 138  
         }
 139  
 
 140  
         @Override
 141  
         public boolean equals(Object obj) {
 142  10
                 return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 143  
         }
 144  
 
 145  
         @Override
 146  
         public String toString() {
 147  0
                 return ToStringBuilder.reflectionToString(this);
 148  
         }
 149  
         
 150  
         /**
 151  
          * Defines some internal constants used on this class.
 152  
          */
 153  0
         static class Constants {
 154  
                 final static String ROOT_ELEMENT_NAME = "agendaTreeDefinition";
 155  
                 final static String TYPE_NAME = "AgendaTreeDefinition";
 156  1
                 final static String[] HASH_CODE_EQUALS_EXCLUDE = { "_elements" };
 157  
         }
 158  
         
 159  
         /**
 160  
          * A private class which exposes constants which define the XML element names to use
 161  
          * when this object is marshalled to XML.
 162  
          */
 163  0
         static class Elements {
 164  
                 final static String AGENDA_ID = "agendaId";
 165  
                 final static String ENTRIES = "entries";
 166  
                 final static String RULE = "rule";
 167  
                 final static String SUB_AGENDA = "subAgenda";
 168  
         }
 169  
 
 170  
 }