View Javadoc
1   /**
2    * Copyright 2005-2016 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.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.kuali.rice.core.api.CoreConstants;
29  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
30  import org.kuali.rice.core.api.mo.ModelBuilder;
31  
32  /**
33   * Concrete model object implementation of KRMS Repository AgendaTreeSubAgendaEntry
34   * immutable.
35   * Instances of Agenda can be (un)marshalled to and from XML.
36   * 
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   *
39   */
40  @XmlRootElement(name = AgendaTreeSubAgendaEntry.Constants.ROOT_ELEMENT_NAME)
41  @XmlAccessorType(XmlAccessType.NONE)
42  @XmlType(name = AgendaTreeSubAgendaEntry.Constants.TYPE_NAME, propOrder = {
43  		AgendaTreeSubAgendaEntry.Elements.AGENDA_ITEM_ID,
44  		AgendaTreeSubAgendaEntry.Elements.SUB_AGENDA_ID,
45  		CoreConstants.CommonElements.FUTURE_ELEMENTS
46  })
47  public final class AgendaTreeSubAgendaEntry extends AbstractDataTransferObject implements AgendaTreeEntryDefinitionContract {
48  
49  	private static final long serialVersionUID = 8594116503548506936L;
50  
51  	@XmlElement(name = Elements.AGENDA_ITEM_ID, required = true)
52  	private final String agendaItemId;
53  	
54  	@XmlElement(name = Elements.SUB_AGENDA_ID, required = true)
55  	private final String subAgendaId;
56  		
57  	@SuppressWarnings("unused")
58      @XmlAnyElement
59      private final Collection<org.w3c.dom.Element> _futureElements = null;
60  
61      /**
62       * This constructor should never be called.
63       * It is only present for use during JAXB unmarshalling.
64       */
65  	private AgendaTreeSubAgendaEntry() {
66  		this.agendaItemId = null;
67  		this.subAgendaId = null;
68  	}
69  
70      /**
71       * Constructs a AgendaTreeSubAgendaEntry from the given builder.
72       * This constructor is private and should only ever be invoked from the builder.
73       *
74       * @param builder the Builder from which to construct the AgendaTreeSubAgendaEntry
75       */
76  	private AgendaTreeSubAgendaEntry(Builder builder) {
77  		this.agendaItemId = builder.getAgendaItemId();
78  		this.subAgendaId = builder.getSubAgendaId();
79  	}
80  	
81  	@Override
82  	public String getAgendaItemId() {
83  		return agendaItemId;
84  	}
85  
86      /**
87       * Returns the subAgendId
88       * @return subAgendaId
89       */
90  	public String getSubAgendaId() {
91  		return this.subAgendaId;
92  	}
93  
94      /**
95       * This builder is used to construct instances of AgendaTreeSubAgendaEntry.
96       */
97  	public static class Builder implements ModelBuilder, Serializable {
98          
99  		private static final long serialVersionUID = 3548736700798501429L;
100 		
101 		private String agendaItemId;
102 		private String subAgendaId;
103 
104 		/**
105 		 * Private constructor for creating a builder with all of it's required attributes.
106          * @param agendaItemId to set the agendaItemId value to, must not be null
107          * @param subAgendaId to set the subAgendaId value to, must not be null
108          */
109         private Builder(String agendaItemId, String subAgendaId) {
110         	setAgendaItemId(agendaItemId);
111         	setSubAgendaId(subAgendaId);
112         }
113 
114         /**
115          * Create a builder using the given values
116          *
117          * @param agendaItemId to set the agendaItemId value to, must not be null
118          * @param subAgendaId to set the subAgendaId value to, must not be null
119          * @return Builder with the given values set
120          */
121         public static Builder create(String agendaItemId, String subAgendaId){
122         	return new Builder(agendaItemId, subAgendaId);
123         }
124 
125         /**
126          * Returns the agendaItemId
127          * @return the agendaItemId of the builder
128          */
129         public String getAgendaItemId() {
130 			return this.agendaItemId;
131 		}
132 
133         /**
134          * Returns the subAgendaId
135          * @return the subAgendaId of the builder
136          */
137 		public String getSubAgendaId() {
138 			return this.subAgendaId;
139 		}
140 
141         /**
142          * Sets the agendaItemId of the builder, cannot be null
143          * @param agendaItemId to set the value of the agendaItemId to, must not be null
144          * @throws IllegalArgumentException if the agendaItemId is null
145          */
146 		public void setAgendaItemId(String agendaItemId) {
147 			if (agendaItemId == null) {
148 				throw new IllegalArgumentException("agendaItemId was null");
149 			}
150 			this.agendaItemId = agendaItemId;
151 		}
152 
153         /**
154          * Sets the subAgendaId of the builder, cannot be null
155          * @param subAgendaId to set the subAgendaId value to, must not be null
156          * @throws IllegalArgumentException if the subAgendaId is null
157          */
158 		public void setSubAgendaId(String subAgendaId) {
159 			if (subAgendaId == null) {
160 				throw new IllegalArgumentException("subAgendaId was null");
161 			}
162 			this.subAgendaId = subAgendaId;
163 		}
164 
165 		@Override
166         public AgendaTreeSubAgendaEntry build() {
167             return new AgendaTreeSubAgendaEntry(this);
168         }
169 		
170     }
171 	
172 	/**
173 	 * Defines some internal constants used on this class.
174 	 */
175 	static class Constants {
176 		final static String ROOT_ELEMENT_NAME = "agendaTreeSubAgendaEntry";
177 		final static String TYPE_NAME = "AgendaTreeSubAgendaEntryType";
178 	}
179 	
180 	/**
181 	 * A private class which exposes constants which define the XML element names to use
182 	 * when this object is marshalled to XML.
183 	 */
184 	static class Elements {
185 		final static String AGENDA_ITEM_ID = "agendaItemId";
186 		final static String SUB_AGENDA_ID = "subAgendaId";
187 	}
188 
189 }