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