001/**
002 * Copyright 2005-2016 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 */
016package org.kuali.rice.kew.api.document.node;
017
018import java.io.Serializable;
019import java.util.Collection;
020
021import javax.xml.bind.annotation.XmlAccessType;
022import javax.xml.bind.annotation.XmlAccessorType;
023import javax.xml.bind.annotation.XmlAnyElement;
024import javax.xml.bind.annotation.XmlElement;
025import javax.xml.bind.annotation.XmlRootElement;
026import javax.xml.bind.annotation.XmlType;
027
028import org.kuali.rice.core.api.CoreConstants;
029import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
030import org.kuali.rice.core.api.mo.ModelBuilder;
031import org.w3c.dom.Element;
032
033@XmlRootElement(name = RouteNodeInstanceState.Constants.ROOT_ELEMENT_NAME)
034@XmlAccessorType(XmlAccessType.NONE)
035@XmlType(name = RouteNodeInstanceState.Constants.TYPE_NAME, propOrder = {
036    RouteNodeInstanceState.Elements.VALUE,
037    RouteNodeInstanceState.Elements.KEY,
038    RouteNodeInstanceState.Elements.ID,
039    CoreConstants.CommonElements.FUTURE_ELEMENTS
040})
041public final class RouteNodeInstanceState extends AbstractDataTransferObject
042    implements RouteNodeInstanceStateContract
043{
044
045        @XmlElement(name = Elements.ID, required = false)
046    private final String id;
047    @XmlElement(name = Elements.VALUE, required = false)
048    private final String value;
049    @XmlElement(name = Elements.KEY, required = false)
050    private final String key;
051    @SuppressWarnings("unused")
052    @XmlAnyElement
053    private final Collection<Element> _futureElements = null;
054
055    /**
056     * Private constructor used only by JAXB.
057     * 
058     */
059    private RouteNodeInstanceState() {
060        this.id = null;
061        this.value = null;
062        this.key = null;
063    }
064
065    private RouteNodeInstanceState(Builder builder) {
066        this.id = builder.getId();
067        this.value = builder.getValue();
068        this.key = builder.getKey();
069    }
070
071    @Override
072    public String getId() {
073        return this.id;
074    }
075    
076    @Override
077    public String getValue() {
078        return this.value;
079    }
080
081    @Override
082    public String getKey() {
083        return this.key;
084    }
085
086    /**
087     * A builder which can be used to construct {@link RouteNodeInstanceState} instances.  Enforces the constraints of the {@link RouteNodeInstanceStateContract}.
088     */
089    public final static class Builder
090        implements Serializable, ModelBuilder, RouteNodeInstanceStateContract
091    {
092
093        private String id;
094        private String value;
095        private String key;
096
097        private Builder() {
098            // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
099        }
100
101        public static Builder create() {
102            // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
103            return new Builder();
104        }
105
106        public static Builder create(RouteNodeInstanceStateContract contract) {
107            if (contract == null) {
108                throw new IllegalArgumentException("contract was null");
109            }
110            // TODO if create() is modified to accept required parameters, this will need to be modified
111            Builder builder = create();
112            builder.setId(contract.getId());
113            builder.setValue(contract.getValue());
114            builder.setKey(contract.getKey());
115            return builder;
116        }
117
118        public RouteNodeInstanceState build() {
119            return new RouteNodeInstanceState(this);
120        }
121
122        @Override
123        public String getValue() {
124            return this.value;
125        }
126
127        @Override
128        public String getKey() {
129            return this.key;
130        }
131
132        @Override
133        public String getId() {
134            return this.id;
135        }
136
137        public void setValue(String value) {
138            // TODO add validation of input value if required and throw IllegalArgumentException if needed
139            this.value = value;
140        }
141
142        public void setKey(String key) {
143            // TODO add validation of input value if required and throw IllegalArgumentException if needed
144            this.key = key;
145        }
146
147        public void setId(String id) {
148            // TODO add validation of input value if required and throw IllegalArgumentException if needed
149            this.id = id;
150        }
151
152    }
153
154
155    /**
156     * Defines some internal constants used on this class.
157     * 
158     */
159    static class Constants {
160
161        final static String ROOT_ELEMENT_NAME = "routeNodeInstanceState";
162        final static String TYPE_NAME = "RouteNodeInstanceStateType";
163
164    }
165
166
167    /**
168     * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
169     * 
170     */
171    static class Elements {
172
173        final static String VALUE = "value";
174        final static String KEY = "key";
175        final static String ID = "id";
176
177    }
178
179}
180