001/** 002 * Copyright 2005-2018 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.doctype; 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.apache.commons.lang.StringUtils; 029import org.kuali.rice.core.api.CoreConstants; 030import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 031import org.kuali.rice.core.api.mo.ModelBuilder; 032import org.w3c.dom.Element; 033 034@XmlRootElement(name = RouteNodeConfigurationParameter.Constants.ROOT_ELEMENT_NAME) 035@XmlAccessorType(XmlAccessType.NONE) 036@XmlType(name = RouteNodeConfigurationParameter.Constants.TYPE_NAME, propOrder = { 037 RouteNodeConfigurationParameter.Elements.ID, 038 RouteNodeConfigurationParameter.Elements.ROUTE_NODE_ID, 039 RouteNodeConfigurationParameter.Elements.KEY, 040 RouteNodeConfigurationParameter.Elements.VALUE, 041 CoreConstants.CommonElements.FUTURE_ELEMENTS 042}) 043public final class RouteNodeConfigurationParameter extends AbstractDataTransferObject 044 implements RouteNodeConfigurationParameterContract { 045 046 private static final long serialVersionUID = 3494982096398369148L; 047 048 @XmlElement(name = Elements.ID, required = false) 049 private final String id; 050 051 @XmlElement(name = Elements.ROUTE_NODE_ID, required = false) 052 private final String routeNodeId; 053 054 @XmlElement(name = Elements.KEY, required = true) 055 private final String key; 056 057 @XmlElement(name = Elements.VALUE, required = false) 058 private final String value; 059 060 @SuppressWarnings("unused") 061 @XmlAnyElement 062 private final Collection<Element> _futureElements = null; 063 064 /** 065 * Private constructor used only by JAXB. 066 */ 067 private RouteNodeConfigurationParameter() { 068 this.id = null; 069 this.routeNodeId = null; 070 this.key = null; 071 this.value = null; 072 } 073 074 private RouteNodeConfigurationParameter(Builder builder) { 075 this.id = builder.getId(); 076 this.routeNodeId = builder.getRouteNodeId(); 077 this.key = builder.getKey(); 078 this.value = builder.getValue(); 079 } 080 081 @Override 082 public String getId() { 083 return this.id; 084 } 085 086 @Override 087 public String getRouteNodeId() { 088 return this.routeNodeId; 089 } 090 091 @Override 092 public String getKey() { 093 return this.key; 094 } 095 096 @Override 097 public String getValue() { 098 return this.value; 099 } 100 101 /** 102 * A builder which can be used to construct {@link RouteNodeConfigurationParameter} instances. 103 * Enforces the constraints of the {@link RouteNodeConfigurationParameterContract}. 104 * 105 */ 106 public final static class Builder 107 implements Serializable, ModelBuilder, RouteNodeConfigurationParameterContract { 108 109 private static final long serialVersionUID = -7040162478345153231L; 110 111 private String id; 112 private String routeNodeId; 113 private String key; 114 private String value; 115 116 private Builder(String key) { 117 setKey(key); 118 } 119 120 public static Builder create(String key) { 121 return new Builder(key); 122 } 123 124 public static Builder create(RouteNodeConfigurationParameterContract contract) { 125 if (contract == null) { 126 throw new IllegalArgumentException("contract was null"); 127 } 128 Builder builder = create(contract.getKey()); 129 builder.setId(contract.getId()); 130 builder.setRouteNodeId(contract.getRouteNodeId()); 131 builder.setValue(contract.getValue()); 132 return builder; 133 } 134 135 public RouteNodeConfigurationParameter build() { 136 return new RouteNodeConfigurationParameter(this); 137 } 138 139 @Override 140 public String getId() { 141 return this.id; 142 } 143 144 @Override 145 public String getRouteNodeId() { 146 return this.routeNodeId; 147 } 148 149 @Override 150 public String getKey() { 151 return this.key; 152 } 153 154 @Override 155 public String getValue() { 156 return this.value; 157 } 158 159 public void setId(String id) { 160 this.id = id; 161 } 162 163 public void setRouteNodeId(String routeNodeId) { 164 this.routeNodeId = routeNodeId; 165 } 166 167 public void setKey(String key) { 168 if (StringUtils.isBlank(key)) { 169 throw new IllegalArgumentException("key was null or blank"); 170 } 171 this.key = key; 172 } 173 174 public void setValue(String value) { 175 this.value = value; 176 } 177 178 } 179 180 /** 181 * Defines some internal constants used on this class. 182 */ 183 static class Constants { 184 final static String ROOT_ELEMENT_NAME = "routeNodeConfigurationParameter"; 185 final static String TYPE_NAME = "RouteNodeConfigurationParameterType"; 186 } 187 188 /** 189 * A private class which exposes constants which define the XML element names to use when this 190 * object is marshalled to XML. 191 */ 192 static class Elements { 193 final static String ID = "id"; 194 final static String ROUTE_NODE_ID = "routeNodeId"; 195 final static String KEY = "key"; 196 final static String VALUE = "value"; 197 } 198 199}