View Javadoc

1   /**
2    * Copyright 2005-2013 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.action;
17  
18  import org.kuali.rice.core.api.CoreConstants;
19  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
20  import org.kuali.rice.core.api.mo.ModelBuilder;
21  import org.w3c.dom.Element;
22  
23  import javax.xml.bind.annotation.XmlAccessType;
24  import javax.xml.bind.annotation.XmlAccessorType;
25  import javax.xml.bind.annotation.XmlAnyElement;
26  import javax.xml.bind.annotation.XmlElement;
27  import javax.xml.bind.annotation.XmlRootElement;
28  import javax.xml.bind.annotation.XmlType;
29  import java.io.Serializable;
30  import java.util.Collection;
31  
32  
33  /**
34   * A transport object representing an action a user might take
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  @XmlRootElement(name = RoutingReportActionToTake.Constants.ROOT_ELEMENT_NAME)
39  @XmlAccessorType(XmlAccessType.NONE)
40  @XmlType(name = RoutingReportActionToTake.Constants.TYPE_NAME, propOrder = {
41      RoutingReportActionToTake.Elements.ACTION_TO_PERFORM,
42      RoutingReportActionToTake.Elements.PRINCIPAL_ID,
43      RoutingReportActionToTake.Elements.NODE_NAME,
44      CoreConstants.CommonElements.FUTURE_ELEMENTS
45  })
46  public final class RoutingReportActionToTake
47      extends AbstractDataTransferObject
48      implements RoutingReportActionToTakeContract
49  {
50  
51      @XmlElement(name = Elements.ACTION_TO_PERFORM, required = false)
52      private final String actionToPerform;
53      @XmlElement(name = Elements.PRINCIPAL_ID, required = false)
54      private final String principalId;
55      @XmlElement(name = Elements.NODE_NAME, required = false)
56      private final String nodeName;
57      @SuppressWarnings("unused")
58      @XmlAnyElement
59      private final Collection<Element> _futureElements = null;
60  
61      /**
62       * Private constructor used only by JAXB.
63       * 
64       */
65      private RoutingReportActionToTake() {
66          this.actionToPerform = null;
67          this.principalId = null;
68          this.nodeName = null;
69      }
70  
71      private RoutingReportActionToTake(Builder builder) {
72          this.actionToPerform = builder.getActionToPerform();
73          this.principalId = builder.getPrincipalId();
74          this.nodeName = builder.getNodeName();
75      }
76  
77      @Override
78      public String getActionToPerform() {
79          return this.actionToPerform;
80      }
81  
82      @Override
83      public String getPrincipalId() {
84          return this.principalId;
85      }
86  
87      @Override
88      public String getNodeName() {
89          return this.nodeName;
90      }
91  
92  
93      /**
94       * A builder which can be used to construct {@link RoutingReportActionToTake} instances.  Enforces the constraints of the {@link RoutingReportActionToTakeContract}.
95       * 
96       */
97      public final static class Builder
98          implements Serializable, ModelBuilder, RoutingReportActionToTakeContract
99      {
100 
101         private String actionToPerform;
102         private String principalId;
103         private String nodeName;
104 
105         private Builder(String actionToPerform, String principalId, String nodeName) {
106             this.setActionToPerform(actionToPerform);
107             this.setPrincipalId(principalId);
108             this.setNodeName(nodeName);
109         }
110 
111         public static Builder create(String actionToPerform, String principalId, String nodeName) {
112             return new Builder(actionToPerform, principalId, nodeName);
113         }
114 
115         public static Builder create(RoutingReportActionToTakeContract contract) {
116             if (contract == null) {
117                 throw new IllegalArgumentException("contract was null");
118             }
119             return create(contract.getActionToPerform(), contract.getPrincipalId(), contract.getNodeName());
120         }
121 
122         public RoutingReportActionToTake build() {
123             return new RoutingReportActionToTake(this);
124         }
125 
126         @Override
127         public String getActionToPerform() {
128             return this.actionToPerform;
129         }
130 
131         @Override
132         public String getPrincipalId() {
133             return this.principalId;
134         }
135 
136         @Override
137         public String getNodeName() {
138             return this.nodeName;
139         }
140 
141         public void setActionToPerform(String actionToPerform) {
142             this.actionToPerform = actionToPerform;
143         }
144 
145         public void setPrincipalId(String principalId) {
146             this.principalId = principalId;
147         }
148 
149         public void setNodeName(String nodeName) {
150             this.nodeName = nodeName;
151         }
152 
153     }
154 
155 
156     /**
157      * Defines some internal constants used on this class.
158      * 
159      */
160     static class Constants {
161 
162         final static String ROOT_ELEMENT_NAME = "routingReportActionToTake";
163         final static String TYPE_NAME = "RoutingReportActionToTakeType";
164 
165     }
166 
167 
168     /**
169      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
170      * 
171      */
172     static class Elements {
173 
174         final static String ACTION_TO_PERFORM = "actionToPerform";
175         final static String PRINCIPAL_ID = "principalId";
176         final static String NODE_NAME = "nodeName";
177 
178     }
179 
180 }