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.OlePatronLocalIdentificationDefinition.Constants.ROOT_ELEMENT_NAME)
022@XmlAccessorType(XmlAccessType.NONE)
023@XmlType(name = org.kuali.ole.deliver.api.OlePatronLocalIdentificationDefinition.Constants.TYPE_NAME, propOrder = {
024        org.kuali.ole.deliver.api.OlePatronLocalIdentificationDefinition.Elements.OLE_PTRN_LOCAL_SEQ_ID,
025        org.kuali.ole.deliver.api.OlePatronLocalIdentificationDefinition.Elements.OLE_PTRN_ID,
026        org.kuali.ole.deliver.api.OlePatronLocalIdentificationDefinition.Elements.LOCAL_ID,
027        //OlePatronDefinition.Elements.OLE_BORROWER_TYPE,
028        //OlePatronDefinition.Elements.ENTITY,
029
030        CoreConstants.CommonElements.VERSION_NUMBER,
031        CoreConstants.CommonElements.OBJECT_ID,
032        CoreConstants.CommonElements.FUTURE_ELEMENTS
033})
034public class OlePatronLocalIdentificationDefinition extends AbstractDataTransferObject implements org.kuali.ole.deliver.api.OlePatronLocalIdentificationContract {
035
036    private static final long serialVersionUID = 1L;
037
038
039    @XmlElement(name = Elements.OLE_PTRN_LOCAL_SEQ_ID, required = false)
040    private final String patronLocalSeqId;
041
042    @XmlElement(name = Elements.OLE_PTRN_ID, required = false)
043    private final String olePatronId;
044
045    @XmlElement(name = Elements.LOCAL_ID, required = false)
046    private final String localId;
047
048    @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
049    private final Long versionNumber;
050
051    @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
052    private final String objectId;
053
054
055    @SuppressWarnings("unused")
056    @XmlAnyElement
057    private final Collection<Element> _futureElements = null;
058
059    public OlePatronLocalIdentificationDefinition() {
060        this.patronLocalSeqId = null;
061        this.olePatronId = null;
062        this.localId = null;
063        this.versionNumber = null;
064        this.objectId = null;
065    }
066
067
068    private OlePatronLocalIdentificationDefinition(Builder builder) {
069        this.patronLocalSeqId = builder.getPatronLocalSeqId();
070        this.olePatronId = builder.getOlePatronId();
071        this.localId = builder.getLocalId();
072        this.versionNumber = builder.getVersionNumber();
073        this.objectId = builder.getObjectId();
074    }
075
076
077    @Override
078    public String getPatronLocalSeqId() {
079        return this.patronLocalSeqId;
080    }
081
082    @Override
083    public String getLocalId() {
084        return this.localId;
085    }
086
087    @Override
088    public String getOlePatronId() {
089        return this.olePatronId;
090    }
091
092    @Override
093    public String getObjectId() {
094        return this.objectId;
095    }
096
097    @Override
098    public Long getVersionNumber() {
099        return this.versionNumber;
100    }
101
102    @Override
103    public String getId() {
104        return this.patronLocalSeqId;
105    }
106
107    public static class Builder
108            implements Serializable, ModelBuilder, org.kuali.ole.deliver.api.OlePatronLocalIdentificationContract {
109        private String patronLocalSeqId;
110        private String localId;
111        private String olePatronId;
112        private Long versionNumber;
113        private String objectId;
114
115        private Builder() {
116        }
117
118        public static Builder create() {
119            return new Builder();
120        }
121
122        public static Builder create(OlePatronLocalIdentificationContract contract) {
123            if (contract == null) {
124                throw new IllegalArgumentException("contract was null");
125            }
126            Builder builder = create();
127            if (contract.getPatronLocalSeqId() != null) {
128                builder.setPatronLocalSeqId(contract.getPatronLocalSeqId());
129            }
130            if (contract.getLocalId() != null) {
131                builder.setLocalId(contract.getLocalId());
132            }
133            if (contract.getOlePatronId() != null) {
134                builder.setOlePatronId(contract.getOlePatronId());
135            }
136
137            builder.setObjectId(contract.getObjectId());
138            builder.setVersionNumber(contract.getVersionNumber());
139            builder.setId(contract.getId());
140            return builder;
141        }
142
143
144        public org.kuali.ole.deliver.api.OlePatronLocalIdentificationDefinition build() {
145            return new org.kuali.ole.deliver.api.OlePatronLocalIdentificationDefinition(this);
146        }
147
148        public String getPatronLocalSeqId() {
149            return patronLocalSeqId;
150        }
151
152        public void setPatronLocalSeqId(String patronLocalSeqId) {
153            this.patronLocalSeqId = patronLocalSeqId;
154        }
155
156        public String getLocalId() {
157            return localId;
158        }
159
160        public void setLocalId(String localId) {
161            this.localId = localId;
162        }
163
164        public String getOlePatronId() {
165            return this.olePatronId;
166        }
167
168        public void setOlePatronId(String olePatronId) {
169            this.olePatronId = olePatronId;
170        }
171
172        @Override
173        public String getId() {
174            return this.patronLocalSeqId;
175        }
176
177
178        public void setId(String id) {
179            if (StringUtils.isWhitespace(id)) {
180                throw new IllegalArgumentException("id is blank");
181            }
182            this.patronLocalSeqId = id;
183        }
184
185        public Long getVersionNumber() {
186            return this.versionNumber;
187        }
188
189        public void setVersionNumber(Long versionNumber) {
190            this.versionNumber = versionNumber;
191        }
192
193        public String getObjectId() {
194            return objectId;
195        }
196
197        public void setObjectId(String objectId) {
198            this.objectId = objectId;
199        }
200    }
201
202    static class Constants {
203
204        final static String ROOT_ELEMENT_NAME = "olePatronLocalIdentification";
205        final static String TYPE_NAME = "OlePatronLocalIdentificationType";
206        final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
207    }
208
209    static class Elements {
210        final static String OLE_PTRN_LOCAL_SEQ_ID = "patronLocalSeqId";
211        final static String LOCAL_ID = "localId";
212        final static String OLE_PTRN_ID = "olePatronId";
213    }
214
215    public static class Cache {
216        public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
217    }
218}