View Javadoc

1   package org.kuali.ole.patron.api;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.rice.core.api.CoreConstants;
5   import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
6   import org.kuali.rice.core.api.mo.ModelBuilder;
7   import org.kuali.rice.kim.api.KimConstants;
8   import org.w3c.dom.Element;
9   
10  import javax.xml.bind.annotation.*;
11  import java.io.Serializable;
12  import java.util.Collection;
13  
14  /**
15   * Created with IntelliJ IDEA.
16   * User: ?
17   * Date: 5/24/12
18   * Time: 8:26 PM
19   * To change this template use File | Settings | File Templates.
20   */
21  @XmlRootElement(name = OleAddressSourceDefinition.Constants.ROOT_ELEMENT_NAME)
22  @XmlAccessorType(XmlAccessType.NONE)
23  @XmlType(name = OleAddressSourceDefinition.Constants.TYPE_NAME, propOrder = {
24          OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_ID,
25          OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_CODE,
26          OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_NAME,
27          OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_DESC,
28          OleAddressSourceDefinition.Elements.ACTIVE_INDICATOR,
29  
30          CoreConstants.CommonElements.VERSION_NUMBER,
31          //CoreConstants.CommonElements.OBJECT_ID,
32          CoreConstants.CommonElements.FUTURE_ELEMENTS
33  })
34  public final class OleAddressSourceDefinition extends AbstractDataTransferObject implements OleAddressSourceContract{
35  
36      private static final long serialVersionUID = 1L;
37  
38  
39  
40      @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_ID, required = false)
41      private final String oleAddressSourceId;
42  
43      @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_CODE, required = false)
44      private final String oleAddressSourceCode;
45  
46      @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_NAME, required = false)
47      private final String oleAddressSourceName;
48  
49      @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_DESC, required = false)
50      private final String oleAddressSourceDesc;
51  
52      @XmlElement(name = Elements.ACTIVE_INDICATOR, required = false)
53      private final boolean active;
54  
55      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
56      private final Long versionNumber;
57  
58      /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
59      private final String objectId;*/
60      @SuppressWarnings("unused")
61      @XmlAnyElement
62      private final Collection<Element> _futureElements = null;
63  
64      public OleAddressSourceDefinition() {
65          this.oleAddressSourceId = null;
66          this.oleAddressSourceCode = null;
67          this.oleAddressSourceName = null;
68          this.active = false;
69          this.oleAddressSourceDesc = null;
70          this.versionNumber = null;
71          //this.objectId = null;
72      }
73  
74  
75      private OleAddressSourceDefinition(Builder builder) {
76          this.oleAddressSourceId = builder.getOleAddressSourceId();
77          this.oleAddressSourceCode = builder.getOleAddressSourceCode();
78          this.oleAddressSourceName = builder.getOleAddressSourceName();
79          this.oleAddressSourceDesc = builder.getOleAddressSourceDesc();
80          this.active = builder.isActive();
81  
82          this.versionNumber = builder.getVersionNumber();
83          //this.objectId = builder.getObjectId();
84      }
85  
86  
87      @Override
88      public String getOleAddressSourceId() {
89          return this.oleAddressSourceId;
90      }
91  
92      @Override
93      public String getOleAddressSourceCode() {
94          return this.oleAddressSourceCode;
95      }
96  
97      @Override
98      public String getOleAddressSourceName() {
99          return this.oleAddressSourceName;
100     }
101 
102     @Override
103     public String getOleAddressSourceDesc() {
104         return this.oleAddressSourceDesc;
105     }
106 
107     @Override
108     public boolean isActive() {
109         return this.active;
110     };
111 
112 
113     @Override
114     public String getId() {
115         return this.oleAddressSourceId;
116     }
117 
118 
119     @Override
120     public Long getVersionNumber() {
121         return this.versionNumber;
122     }
123 
124 
125     //@Override
126     /*public OleBorrowerTypeDefinition getOleBorrowerType() {
127         return this.oleBorrowerType;
128     }*/
129 
130     public static class Builder
131             implements Serializable, ModelBuilder, OleAddressSourceContract
132     {
133 
134         private String oleAddressSourceId;
135         private String oleAddressSourceCode;
136         private String oleAddressSourceName;
137         private String oleAddressSourceDesc;
138         private boolean active;
139 
140         private Long versionNumber;
141         private String objectId;
142 
143         private Builder() { }
144 
145         public static Builder create() {
146             return new Builder();
147         }
148 
149         public static Builder create(OleAddressSourceContract contract) {
150             if(contract == null) {
151                 throw new IllegalArgumentException("contract was null");
152             }
153             Builder builder = create();
154             if (contract.getOleAddressSourceId() != null) {
155                 builder.setOleAddressSourceId(contract.getOleAddressSourceId());
156             }
157             if(contract.getOleAddressSourceCode() != null) {
158                 builder.setOleAddressSourceCode(contract.getOleAddressSourceCode());
159             }
160             if(contract.getOleAddressSourceName() != null) {
161                 builder.setOleAddressSourceName(contract.getOleAddressSourceName());
162             }
163             if(contract.isActive()) {
164                 builder.setActive(contract.isActive());
165             }
166             if(contract.getOleAddressSourceDesc() != null) {
167                 builder.setOleAddressSourceDesc(contract.getOleAddressSourceDesc());
168             }
169 
170             builder.setVersionNumber(contract.getVersionNumber());
171             /*builder.setObjectId(contract.getObjectId());
172             builder.setActive(contract.isActive());*/
173             builder.setId(contract.getId());
174             return builder;
175         }
176 
177 
178         public OleAddressSourceDefinition build() {
179             return new OleAddressSourceDefinition(this);
180         }
181 
182         public String getOleAddressSourceId() {
183             return oleAddressSourceId;
184         }
185 
186         public void setOleAddressSourceId(String oleAddressSourceId) {
187             this.oleAddressSourceId = oleAddressSourceId;
188         }
189 
190         public String getOleAddressSourceCode() {
191             return oleAddressSourceCode;
192         }
193 
194         public void setOleAddressSourceCode(String oleAddressSourceCode) {
195             this.oleAddressSourceCode = oleAddressSourceCode;
196         }
197 
198         public String getOleAddressSourceName() {
199             return oleAddressSourceName;
200         }
201 
202         public void setOleAddressSourceName(String oleAddressSourceName) {
203             this.oleAddressSourceName = oleAddressSourceName;
204         }
205 
206         public String getOleAddressSourceDesc() {
207             return oleAddressSourceDesc;
208         }
209 
210         public void setOleAddressSourceDesc(String oleAddressSourceDesc) {
211             this.oleAddressSourceDesc = oleAddressSourceDesc;
212         }
213 
214         public boolean isActive() {
215             return active;
216         }
217 
218         public void setActive(boolean active) {
219             this.active = active;
220         }
221 
222         @Override
223         public Long getVersionNumber() {
224             return versionNumber;
225         }
226 
227         public void setVersionNumber(Long versionNumber) {
228             this.versionNumber = versionNumber;
229         }
230 
231         /*@Override
232         public String getObjectId() {
233             return objectId;
234         }*/
235 
236         public void setObjectId(String objectId) {
237             this.objectId = objectId;
238         }
239 
240         @Override
241         public String getId() {
242             return this.oleAddressSourceId;
243         }
244 
245 
246 
247         public void setId(String id) {
248             if (StringUtils.isWhitespace(id)) {
249                 throw new IllegalArgumentException("id is blank");
250             }
251             this.oleAddressSourceId = id;
252         }
253     }
254 
255     static class Constants {
256 
257         final static String ROOT_ELEMENT_NAME = "oleAddressSource";
258         final static String TYPE_NAME = "OleAddressSourceType";
259         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
260     }
261 
262     static class Elements {
263         final static String OLE_ADDRESS_SOURCE_ID = "oleAddressSourceId";
264         final static String OLE_ADDRESS_SOURCE_CODE = "oleAddressSourceCode";
265         final static String OLE_ADDRESS_SOURCE_NAME = "oleAddressSourceName";
266         final static String OLE_ADDRESS_SOURCE_DESC = "oleAddressSourceDesc";
267         final static String ACTIVE_INDICATOR = "active";
268         //final static String ENTITY_ID = "entityId";
269 
270     }
271     public static class Cache {
272         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + OleAddressSourceDefinition.Constants.TYPE_NAME;
273     }
274 }