001package org.kuali.ole.deliver.api;
002
003import org.apache.commons.lang.StringUtils;
004import org.kuali.rice.core.api.CoreConstants;
005import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
006import org.kuali.rice.core.api.mo.ModelBuilder;
007import org.kuali.rice.kim.api.KimConstants;
008import org.w3c.dom.Element;
009
010import javax.xml.bind.annotation.*;
011import java.io.Serializable;
012import java.util.Collection;
013
014/**
015 * Created with IntelliJ IDEA.
016 * User: ?
017 * Date: 5/24/12
018 * Time: 8:26 PM
019 * To change this template use File | Settings | File Templates.
020 */
021@XmlRootElement(name = org.kuali.ole.deliver.api.OleAddressSourceDefinition.Constants.ROOT_ELEMENT_NAME)
022@XmlAccessorType(XmlAccessType.NONE)
023@XmlType(name = org.kuali.ole.deliver.api.OleAddressSourceDefinition.Constants.TYPE_NAME, propOrder = {
024        org.kuali.ole.deliver.api.OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_ID,
025        org.kuali.ole.deliver.api.OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_CODE,
026        org.kuali.ole.deliver.api.OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_NAME,
027        org.kuali.ole.deliver.api.OleAddressSourceDefinition.Elements.OLE_ADDRESS_SOURCE_DESC,
028        org.kuali.ole.deliver.api.OleAddressSourceDefinition.Elements.ACTIVE_INDICATOR,
029
030        CoreConstants.CommonElements.VERSION_NUMBER,
031        //CoreConstants.CommonElements.OBJECT_ID,
032        CoreConstants.CommonElements.FUTURE_ELEMENTS
033})
034public final class OleAddressSourceDefinition extends AbstractDataTransferObject implements OleAddressSourceContract {
035
036    private static final long serialVersionUID = 1L;
037
038
039    @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_ID, required = false)
040    private final String oleAddressSourceId;
041
042    @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_CODE, required = false)
043    private final String oleAddressSourceCode;
044
045    @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_NAME, required = false)
046    private final String oleAddressSourceName;
047
048    @XmlElement(name = Elements.OLE_ADDRESS_SOURCE_DESC, required = false)
049    private final String oleAddressSourceDesc;
050
051    @XmlElement(name = Elements.ACTIVE_INDICATOR, required = false)
052    private final boolean active;
053
054    @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
055    private final Long versionNumber;
056
057    /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
058    private final String objectId;*/
059    @SuppressWarnings("unused")
060    @XmlAnyElement
061    private final Collection<Element> _futureElements = null;
062
063    public OleAddressSourceDefinition() {
064        this.oleAddressSourceId = null;
065        this.oleAddressSourceCode = null;
066        this.oleAddressSourceName = null;
067        this.active = false;
068        this.oleAddressSourceDesc = null;
069        this.versionNumber = null;
070        //this.objectId = null;
071    }
072
073
074    private OleAddressSourceDefinition(Builder builder) {
075        this.oleAddressSourceId = builder.getOleAddressSourceId();
076        this.oleAddressSourceCode = builder.getOleAddressSourceCode();
077        this.oleAddressSourceName = builder.getOleAddressSourceName();
078        this.oleAddressSourceDesc = builder.getOleAddressSourceDesc();
079        this.active = builder.isActive();
080
081        this.versionNumber = builder.getVersionNumber();
082        //this.objectId = builder.getObjectId();
083    }
084
085
086    @Override
087    public String getOleAddressSourceId() {
088        return this.oleAddressSourceId;
089    }
090
091    @Override
092    public String getOleAddressSourceCode() {
093        return this.oleAddressSourceCode;
094    }
095
096    @Override
097    public String getOleAddressSourceName() {
098        return this.oleAddressSourceName;
099    }
100
101    @Override
102    public String getOleAddressSourceDesc() {
103        return this.oleAddressSourceDesc;
104    }
105
106    @Override
107    public boolean isActive() {
108        return this.active;
109    }
110
111    ;
112
113
114    @Override
115    public String getId() {
116        return this.oleAddressSourceId;
117    }
118
119
120    @Override
121    public Long getVersionNumber() {
122        return this.versionNumber;
123    }
124
125
126    //@Override
127    /*public OleBorrowerTypeDefinition getOleBorrowerType() {
128        return this.oleBorrowerType;
129    }*/
130
131    public static class Builder
132            implements Serializable, ModelBuilder, OleAddressSourceContract {
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
146        public static Builder create() {
147            return new Builder();
148        }
149
150        public static Builder create(OleAddressSourceContract contract) {
151            if (contract == null) {
152                throw new IllegalArgumentException("contract was null");
153            }
154            Builder builder = create();
155            if (contract.getOleAddressSourceId() != null) {
156                builder.setOleAddressSourceId(contract.getOleAddressSourceId());
157            }
158            if (contract.getOleAddressSourceCode() != null) {
159                builder.setOleAddressSourceCode(contract.getOleAddressSourceCode());
160            }
161            if (contract.getOleAddressSourceName() != null) {
162                builder.setOleAddressSourceName(contract.getOleAddressSourceName());
163            }
164            if (contract.isActive()) {
165                builder.setActive(contract.isActive());
166            }
167            if (contract.getOleAddressSourceDesc() != null) {
168                builder.setOleAddressSourceDesc(contract.getOleAddressSourceDesc());
169            }
170
171            builder.setVersionNumber(contract.getVersionNumber());
172            /*builder.setObjectId(contract.getObjectId());
173            builder.setActive(contract.isActive());*/
174            builder.setId(contract.getId());
175            return builder;
176        }
177
178
179        public org.kuali.ole.deliver.api.OleAddressSourceDefinition build() {
180            return new org.kuali.ole.deliver.api.OleAddressSourceDefinition(this);
181        }
182
183        public String getOleAddressSourceId() {
184            return oleAddressSourceId;
185        }
186
187        public void setOleAddressSourceId(String oleAddressSourceId) {
188            this.oleAddressSourceId = oleAddressSourceId;
189        }
190
191        public String getOleAddressSourceCode() {
192            return oleAddressSourceCode;
193        }
194
195        public void setOleAddressSourceCode(String oleAddressSourceCode) {
196            this.oleAddressSourceCode = oleAddressSourceCode;
197        }
198
199        public String getOleAddressSourceName() {
200            return oleAddressSourceName;
201        }
202
203        public void setOleAddressSourceName(String oleAddressSourceName) {
204            this.oleAddressSourceName = oleAddressSourceName;
205        }
206
207        public String getOleAddressSourceDesc() {
208            return oleAddressSourceDesc;
209        }
210
211        public void setOleAddressSourceDesc(String oleAddressSourceDesc) {
212            this.oleAddressSourceDesc = oleAddressSourceDesc;
213        }
214
215        public boolean isActive() {
216            return active;
217        }
218
219        public void setActive(boolean active) {
220            this.active = active;
221        }
222
223        @Override
224        public Long getVersionNumber() {
225            return versionNumber;
226        }
227
228        public void setVersionNumber(Long versionNumber) {
229            this.versionNumber = versionNumber;
230        }
231
232        /*@Override
233        public String getObjectId() {
234            return objectId;
235        }*/
236
237        public void setObjectId(String objectId) {
238            this.objectId = objectId;
239        }
240
241        @Override
242        public String getId() {
243            return this.oleAddressSourceId;
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
272    public static class Cache {
273        public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
274    }
275}