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.kew.api.document.node;
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  import org.w3c.dom.Element;
32  
33  @XmlRootElement(name = RouteNodeInstanceState.Constants.ROOT_ELEMENT_NAME)
34  @XmlAccessorType(XmlAccessType.NONE)
35  @XmlType(name = RouteNodeInstanceState.Constants.TYPE_NAME, propOrder = {
36      RouteNodeInstanceState.Elements.VALUE,
37      RouteNodeInstanceState.Elements.KEY,
38      RouteNodeInstanceState.Elements.ID,
39      CoreConstants.CommonElements.FUTURE_ELEMENTS
40  })
41  public final class RouteNodeInstanceState extends AbstractDataTransferObject
42      implements RouteNodeInstanceStateContract
43  {
44  
45  	@XmlElement(name = Elements.ID, required = false)
46      private final String id;
47      @XmlElement(name = Elements.VALUE, required = false)
48      private final String value;
49      @XmlElement(name = Elements.KEY, required = false)
50      private final String key;
51      @SuppressWarnings("unused")
52      @XmlAnyElement
53      private final Collection<Element> _futureElements = null;
54  
55      /**
56       * Private constructor used only by JAXB.
57       * 
58       */
59      private RouteNodeInstanceState() {
60      	this.id = null;
61          this.value = null;
62          this.key = null;
63      }
64  
65      private RouteNodeInstanceState(Builder builder) {
66      	this.id = builder.getId();
67          this.value = builder.getValue();
68          this.key = builder.getKey();
69      }
70  
71      @Override
72      public String getId() {
73          return this.id;
74      }
75      
76      @Override
77      public String getValue() {
78          return this.value;
79      }
80  
81      @Override
82      public String getKey() {
83          return this.key;
84      }
85  
86      /**
87       * A builder which can be used to construct {@link RouteNodeInstanceState} instances.  Enforces the constraints of the {@link RouteNodeInstanceStateContract}.
88       */
89      public final static class Builder
90          implements Serializable, ModelBuilder, RouteNodeInstanceStateContract
91      {
92  
93          private String id;
94          private String value;
95          private String key;
96  
97          private Builder() {
98              // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
99          }
100 
101         public static Builder create() {
102             // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
103             return new Builder();
104         }
105 
106         public static Builder create(RouteNodeInstanceStateContract contract) {
107             if (contract == null) {
108                 throw new IllegalArgumentException("contract was null");
109             }
110             // TODO if create() is modified to accept required parameters, this will need to be modified
111             Builder builder = create();
112             builder.setId(contract.getId());
113             builder.setValue(contract.getValue());
114             builder.setKey(contract.getKey());
115             return builder;
116         }
117 
118         public RouteNodeInstanceState build() {
119             return new RouteNodeInstanceState(this);
120         }
121 
122         @Override
123         public String getValue() {
124             return this.value;
125         }
126 
127         @Override
128         public String getKey() {
129             return this.key;
130         }
131 
132         @Override
133         public String getId() {
134             return this.id;
135         }
136 
137         public void setValue(String value) {
138             // TODO add validation of input value if required and throw IllegalArgumentException if needed
139             this.value = value;
140         }
141 
142         public void setKey(String key) {
143             // TODO add validation of input value if required and throw IllegalArgumentException if needed
144             this.key = key;
145         }
146 
147         public void setId(String id) {
148             // TODO add validation of input value if required and throw IllegalArgumentException if needed
149             this.id = id;
150         }
151 
152     }
153 
154 
155     /**
156      * Defines some internal constants used on this class.
157      * 
158      */
159     static class Constants {
160 
161         final static String ROOT_ELEMENT_NAME = "routeNodeInstanceState";
162         final static String TYPE_NAME = "RouteNodeInstanceStateType";
163 
164     }
165 
166 
167     /**
168      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
169      * 
170      */
171     static class Elements {
172 
173         final static String VALUE = "value";
174         final static String KEY = "key";
175         final static String ID = "id";
176 
177     }
178 
179 }
180