001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kew.api.rule;
017    
018    import java.io.Serializable;
019    import java.util.Collection;
020    import javax.xml.bind.annotation.XmlAccessType;
021    import javax.xml.bind.annotation.XmlAccessorType;
022    import javax.xml.bind.annotation.XmlAnyElement;
023    import javax.xml.bind.annotation.XmlElement;
024    import javax.xml.bind.annotation.XmlRootElement;
025    import javax.xml.bind.annotation.XmlType;
026    import org.kuali.rice.core.api.CoreConstants;
027    import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
028    import org.kuali.rice.core.api.mo.ModelBuilder;
029    import org.w3c.dom.Element;
030    
031    @XmlRootElement(name = RuleTemplateOption.Constants.ROOT_ELEMENT_NAME)
032    @XmlAccessorType(XmlAccessType.NONE)
033    @XmlType(name = RuleTemplateOption.Constants.TYPE_NAME, propOrder = {
034        RuleTemplateOption.Elements.VALUE,
035        RuleTemplateOption.Elements.RULE_TEMPLATE_ID,
036        RuleTemplateOption.Elements.CODE,
037        RuleTemplateOption.Elements.ID,
038        CoreConstants.CommonElements.VERSION_NUMBER,
039        CoreConstants.CommonElements.FUTURE_ELEMENTS
040    })
041    public final class RuleTemplateOption
042        extends AbstractDataTransferObject
043        implements RuleTemplateOptionContract
044    {
045    
046        @XmlElement(name = Elements.VALUE, required = false)
047        private final String value;
048        @XmlElement(name = Elements.RULE_TEMPLATE_ID, required = false)
049        private final String ruleTemplateId;
050        @XmlElement(name = Elements.CODE, required = false)
051        private final String code;
052        @XmlElement(name = Elements.ID, required = false)
053        private final String id;
054        @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
055        private final Long versionNumber;
056        @SuppressWarnings("unused")
057        @XmlAnyElement
058        private final Collection<Element> _futureElements = null;
059    
060        /**
061         * Private constructor used only by JAXB.
062         * 
063         */
064        private RuleTemplateOption() {
065            this.value = null;
066            this.ruleTemplateId = null;
067            this.code = null;
068            this.id = null;
069            this.versionNumber = null;
070        }
071    
072        private RuleTemplateOption(Builder builder) {
073            this.value = builder.getValue();
074            this.ruleTemplateId = builder.getRuleTemplateId();
075            this.code = builder.getCode();
076            this.id = builder.getId();
077            this.versionNumber = builder.getVersionNumber();
078        }
079    
080        @Override
081        public String getValue() {
082            return this.value;
083        }
084    
085        @Override
086        public String getRuleTemplateId() {
087            return this.ruleTemplateId;
088        }
089    
090        @Override
091        public String getCode() {
092            return this.code;
093        }
094    
095        @Override
096        public String getId() {
097            return this.id;
098        }
099    
100        @Override
101        public Long getVersionNumber() {
102            return this.versionNumber;
103        }
104    
105    
106        /**
107         * A builder which can be used to construct {@link RuleTemplateOption} instances.  Enforces the constraints of the {@link RuleTemplateOptionContract}.
108         * 
109         */
110        public final static class Builder
111            implements Serializable, ModelBuilder, RuleTemplateOptionContract
112        {
113    
114            private String value;
115            private String ruleTemplateId;
116            private String code;
117            private String id;
118            private Long versionNumber;
119    
120            private Builder() {
121                // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
122            }
123    
124            public static Builder create() {
125                // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
126                return new Builder();
127            }
128    
129            public static Builder create(RuleTemplateOptionContract contract) {
130                if (contract == null) {
131                    throw new IllegalArgumentException("contract was null");
132                }
133                // TODO if create() is modified to accept required parameters, this will need to be modified
134                Builder builder = create();
135                builder.setValue(contract.getValue());
136                builder.setRuleTemplateId(contract.getRuleTemplateId());
137                builder.setCode(contract.getCode());
138                builder.setId(contract.getId());
139                builder.setVersionNumber(contract.getVersionNumber());
140                return builder;
141            }
142    
143            public RuleTemplateOption build() {
144                return new RuleTemplateOption(this);
145            }
146    
147            @Override
148            public String getValue() {
149                return this.value;
150            }
151    
152            @Override
153            public String getRuleTemplateId() {
154                return this.ruleTemplateId;
155            }
156    
157            @Override
158            public String getCode() {
159                return this.code;
160            }
161    
162            @Override
163            public String getId() {
164                return this.id;
165            }
166    
167            @Override
168            public Long getVersionNumber() {
169                return this.versionNumber;
170            }
171    
172            public void setValue(String value) {
173                // TODO add validation of input value if required and throw IllegalArgumentException if needed
174                this.value = value;
175            }
176    
177            public void setRuleTemplateId(String ruleTemplateId) {
178                // TODO add validation of input value if required and throw IllegalArgumentException if needed
179                this.ruleTemplateId = ruleTemplateId;
180            }
181    
182            public void setCode(String code) {
183                // TODO add validation of input value if required and throw IllegalArgumentException if needed
184                this.code = code;
185            }
186    
187            public void setId(String id) {
188                // TODO add validation of input value if required and throw IllegalArgumentException if needed
189                this.id = id;
190            }
191    
192            public void setVersionNumber(Long versionNumber) {
193                // TODO add validation of input value if required and throw IllegalArgumentException if needed
194                this.versionNumber = versionNumber;
195            }
196    
197        }
198    
199    
200        /**
201         * Defines some internal constants used on this class.
202         * 
203         */
204        static class Constants {
205    
206            final static String ROOT_ELEMENT_NAME = "ruleTemplateOption";
207            final static String TYPE_NAME = "RuleTemplateOptionType";
208    
209        }
210    
211    
212        /**
213         * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
214         * 
215         */
216        static class Elements {
217    
218            final static String VALUE = "value";
219            final static String RULE_TEMPLATE_ID = "ruleTemplateId";
220            final static String CODE = "code";
221            final static String ID = "id";
222    
223        }
224    
225    }