View Javadoc

1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.api.document;
17  
18  import java.util.Collection;
19  
20  import javax.xml.bind.annotation.XmlAccessType;
21  import javax.xml.bind.annotation.XmlAccessorType;
22  import javax.xml.bind.annotation.XmlAnyElement;
23  import javax.xml.bind.annotation.XmlElement;
24  import javax.xml.bind.annotation.XmlRootElement;
25  import javax.xml.bind.annotation.XmlType;
26  
27  import org.apache.commons.lang.StringUtils;
28  import org.kuali.rice.core.api.CoreConstants;
29  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
30  import org.w3c.dom.Element;
31  
32  @XmlRootElement(name = PropertyDefinition.Constants.ROOT_ELEMENT_NAME)
33  @XmlAccessorType(XmlAccessType.NONE)
34  @XmlType(name = PropertyDefinition.Constants.TYPE_NAME, propOrder = {
35          PropertyDefinition.Elements.NAME,
36          PropertyDefinition.Elements.VALUE,
37          CoreConstants.CommonElements.FUTURE_ELEMENTS
38  })
39  public final class PropertyDefinition extends AbstractDataTransferObject {
40  
41      @XmlElement(name = Elements.NAME, required = true)
42      private final String name;
43  
44      @XmlElement(name = Elements.VALUE, required = false)
45      private final String value;
46  
47      @SuppressWarnings("unused")
48      @XmlAnyElement
49      private final Collection<Element> _futureElements = null;
50  
51      @SuppressWarnings("unused")
52      private PropertyDefinition() {
53          this.name = null;
54          this.value = null;
55      }
56  
57      public static PropertyDefinition create(String name, String value) {
58          return new PropertyDefinition(name, value);
59      }
60  
61      private PropertyDefinition(String name, String value) {
62          if (StringUtils.isBlank(name)) {
63              throw new IllegalArgumentException("name is null or blank");
64          }
65          this.name = name;
66          this.value = value;
67      }
68  
69      public String getName() {
70          return name;
71      }
72  
73      public String getValue() {
74          return value;
75      }
76  
77      /**
78       * Defines some internal constants used on this class.
79       */
80      static class Constants {
81          final static String ROOT_ELEMENT_NAME = "propertyDefinition";
82          final static String TYPE_NAME = "PropertyDefinitionType";
83      }
84  
85      /**
86       * A private class which exposes constants which define the XML element names to use when this
87       * object is marshalled to XML.
88       */
89      static class Elements {
90          final static String NAME = "name";
91          final static String VALUE = "value";
92      }
93  
94  }