Coverage Report - org.kuali.rice.krms.api.repository.agenda.AgendaTreeRuleEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaTreeRuleEntry
90%
19/21
100%
4/4
1.3
AgendaTreeRuleEntry$1
N/A
N/A
1.3
AgendaTreeRuleEntry$Builder
100%
23/23
100%
4/4
1.3
AgendaTreeRuleEntry$Constants
50%
1/2
N/A
1.3
AgendaTreeRuleEntry$Elements
0%
0/1
N/A
1.3
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl1.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krms.api.repository.agenda;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.apache.commons.lang.StringUtils;
 29  
 import org.apache.commons.lang.builder.EqualsBuilder;
 30  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 31  
 import org.apache.commons.lang.builder.ToStringBuilder;
 32  
 import org.kuali.rice.core.api.CoreConstants;
 33  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 34  
 
 35  
 /**
 36  
  * This is a description of what this class does - ewestfal don't forget to fill this in. 
 37  
  * 
 38  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 39  
  *
 40  
  */
 41  
 @XmlRootElement(name = AgendaTreeRuleEntry.Constants.ROOT_ELEMENT_NAME)
 42  
 @XmlAccessorType(XmlAccessType.NONE)
 43  
 @XmlType(name = AgendaTreeRuleEntry.Constants.TYPE_NAME, propOrder = {
 44  
                 AgendaTreeRuleEntry.Elements.AGENDA_ITEM_ID,
 45  
                 AgendaTreeRuleEntry.Elements.RULE_ID,
 46  
                 AgendaTreeRuleEntry.Elements.IF_TRUE,
 47  
                 AgendaTreeRuleEntry.Elements.IF_FALSE,
 48  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 49  
 })
 50  27
 public final class AgendaTreeRuleEntry implements AgendaTreeEntryDefinition {
 51  
 
 52  
         private static final long serialVersionUID = 8594116503548506936L;
 53  
 
 54  
         @XmlElement(name = Elements.AGENDA_ITEM_ID, required = true)
 55  
         private final String agendaItemId;
 56  
         
 57  
         @XmlElement(name = Elements.RULE_ID, required = true)
 58  
         private final String ruleId;
 59  
         
 60  
         @XmlElement(name = Elements.IF_TRUE, required = false)
 61  
         private final AgendaTreeDefinition ifTrue;
 62  
         
 63  
         @XmlElement(name = Elements.IF_FALSE, required = false)
 64  
         private final AgendaTreeDefinition ifFalse;
 65  
                 
 66  76
         @SuppressWarnings("unused")
 67  
     @XmlAnyElement
 68  
     private final Collection<org.w3c.dom.Element> _futureElements = null;
 69  
         
 70  
         /**
 71  
          * Used only by JAXB.
 72  
          */
 73  49
         private AgendaTreeRuleEntry() {
 74  49
                 this.agendaItemId = null;
 75  49
                 this.ruleId = null;
 76  49
                 this.ifTrue = null;
 77  49
                 this.ifFalse = null;
 78  49
         }
 79  
         
 80  27
         private AgendaTreeRuleEntry(Builder builder) {
 81  27
                 this.agendaItemId = builder.getAgendaItemId();
 82  27
                 this.ruleId = builder.getRuleId();
 83  27
                 this.ifTrue = builder.getIfTrue() == null ? null : builder.getIfTrue().build();
 84  27
                 this.ifFalse = builder.getIfFalse() == null ? null : builder.getIfFalse().build();
 85  27
         }
 86  
         
 87  
         @Override
 88  
         public String getAgendaItemId() {
 89  4
                 return agendaItemId;
 90  
         }
 91  
         
 92  
         public String getRuleId() {
 93  18
                 return this.ruleId;
 94  
         }
 95  
 
 96  
         public AgendaTreeDefinition getIfTrue() {
 97  8
                 return this.ifTrue;
 98  
         }
 99  
 
 100  
         public AgendaTreeDefinition getIfFalse() {
 101  6
                 return this.ifFalse;
 102  
         }
 103  
 
 104  27
         public static class Builder implements ModelBuilder, Serializable {
 105  
         
 106  
                 private static final long serialVersionUID = 3548736700798501429L;
 107  
                 
 108  
                 private String agendaItemId;
 109  
                 private String ruleId;
 110  
                 private AgendaTreeDefinition.Builder ifTrue;
 111  
                 private AgendaTreeDefinition.Builder ifFalse;
 112  
 
 113  
                 /**
 114  
                  * Private constructor for creating a builder with all of it's required attributes.
 115  
                  */
 116  40
         private Builder(String agendaItemId, String ruleId) {
 117  40
                 setAgendaItemId(agendaItemId);
 118  36
                 setRuleId(ruleId);
 119  33
         }
 120  
         
 121  
         public static Builder create(String agendaItemId, String ruleId){
 122  40
                 return new Builder(agendaItemId, ruleId);
 123  
         }
 124  
         
 125  
         public String getAgendaItemId() {
 126  27
                         return this.agendaItemId;
 127  
                 }
 128  
 
 129  
                 public String getRuleId() {
 130  27
                         return this.ruleId;
 131  
                 }
 132  
 
 133  
                 public AgendaTreeDefinition.Builder getIfTrue() {
 134  32
                         return this.ifTrue;
 135  
                 }
 136  
 
 137  
                 public AgendaTreeDefinition.Builder getIfFalse() {
 138  32
                         return this.ifFalse;
 139  
                 }
 140  
                 
 141  
                 public void setAgendaItemId(String agendaItemId) {
 142  40
                         if (StringUtils.isBlank(agendaItemId)) {
 143  4
                                 throw new IllegalArgumentException("agendaItemId was null or blank");
 144  
                         }
 145  36
                         this.agendaItemId = agendaItemId;
 146  36
                 }
 147  
 
 148  
                 public void setRuleId(String ruleId) {
 149  36
                         if (StringUtils.isBlank(ruleId)) {
 150  3
                                 throw new IllegalArgumentException("ruleId was null or blank");
 151  
                         }
 152  33
                         this.ruleId = ruleId;
 153  33
                 }
 154  
 
 155  
                 public void setIfTrue(AgendaTreeDefinition.Builder ifTrue) {
 156  8
                         this.ifTrue = ifTrue;
 157  8
                 }
 158  
 
 159  
                 public void setIfFalse(AgendaTreeDefinition.Builder ifFalse) {
 160  8
                         this.ifFalse = ifFalse;
 161  8
                 }
 162  
 
 163  
                 @Override
 164  
         public AgendaTreeRuleEntry build() {
 165  27
             return new AgendaTreeRuleEntry(this);
 166  
         }
 167  
                 
 168  
     }
 169  
     
 170  
         @Override
 171  
         public int hashCode() {
 172  0
                 return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 173  
         }
 174  
 
 175  
         @Override
 176  
         public boolean equals(Object obj) {
 177  14
                 return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 178  
         }
 179  
 
 180  
         @Override
 181  
         public String toString() {
 182  0
                 return ToStringBuilder.reflectionToString(this);
 183  
         }
 184  
         
 185  
         /**
 186  
          * Defines some internal constants used on this class.
 187  
          */
 188  0
         static class Constants {
 189  
                 final static String ROOT_ELEMENT_NAME = "agendaTreeRuleEntry";
 190  
                 final static String TYPE_NAME = "AgendaTreeRuleEntryType";
 191  1
                 final static String[] HASH_CODE_EQUALS_EXCLUDE = { "_futureElements" };
 192  
         }
 193  
         
 194  
         /**
 195  
          * A private class which exposes constants which define the XML element names to use
 196  
          * when this object is marshalled to XML.
 197  
          */
 198  0
         static class Elements {
 199  
                 final static String AGENDA_ITEM_ID = "agendaItemId";
 200  
                 final static String RULE_ID = "ruleId";
 201  
                 final static String IF_TRUE = "ifTrue";
 202  
                 final static String IF_FALSE = "ifFalse";
 203  
         }
 204  
 
 205  
 }