| 1 | |
package org.kuali.rice.krms.api.repository; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
import java.util.Collection; |
| 5 | |
|
| 6 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 7 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 8 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 9 | |
import javax.xml.bind.annotation.XmlElement; |
| 10 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 11 | |
import javax.xml.bind.annotation.XmlType; |
| 12 | |
|
| 13 | |
import org.apache.commons.lang.StringUtils; |
| 14 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
| 15 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
| 16 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 17 | |
import org.kuali.rice.core.api.CoreConstants; |
| 18 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 19 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
@XmlRootElement(name = KrmsAttributeDefinition.Constants.ROOT_ELEMENT_NAME) |
| 29 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 30 | |
@XmlType(name = KrmsAttributeDefinition.Constants.TYPE_NAME, propOrder = { |
| 31 | |
KrmsAttributeDefinition.Elements.ID, |
| 32 | |
KrmsAttributeDefinition.Elements.NAME, |
| 33 | |
KrmsAttributeDefinition.Elements.NAMESPACE, |
| 34 | |
KrmsAttributeDefinition.Elements.LABEL, |
| 35 | |
KrmsAttributeDefinition.Elements.ACTIVE, |
| 36 | |
KrmsAttributeDefinition.Elements.COMPONENT_NAME, |
| 37 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 38 | |
}) |
| 39 | 0 | public final class KrmsAttributeDefinition implements KrmsAttributeDefinitionContract, ModelObjectComplete{ |
| 40 | |
private static final long serialVersionUID = -6356968810972165031L; |
| 41 | |
|
| 42 | |
@XmlElement(name = Elements.ID, required=true) |
| 43 | |
private String id; |
| 44 | |
@XmlElement(name = Elements.NAME, required=true) |
| 45 | |
private String name; |
| 46 | |
@XmlElement(name = Elements.NAMESPACE, required=true) |
| 47 | |
private String namespace; |
| 48 | |
@XmlElement(name = Elements.LABEL, required=false) |
| 49 | |
private String label; |
| 50 | |
@XmlElement(name = Elements.ACTIVE, required=false) |
| 51 | |
private boolean active; |
| 52 | |
@XmlElement(name = Elements.COMPONENT_NAME, required=false) |
| 53 | |
private String componentName; |
| 54 | |
|
| 55 | 0 | @SuppressWarnings("unused") |
| 56 | |
@XmlAnyElement |
| 57 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | 0 | private KrmsAttributeDefinition() { |
| 63 | 0 | this.id = null; |
| 64 | 0 | this.name = null; |
| 65 | 0 | this.namespace = null; |
| 66 | 0 | this.label = null; |
| 67 | 0 | this.active = false; |
| 68 | 0 | this.componentName = null; |
| 69 | 0 | } |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | 0 | private KrmsAttributeDefinition(Builder builder) { |
| 78 | 0 | this.id = builder.getId(); |
| 79 | 0 | this.name = builder.getName(); |
| 80 | 0 | this.namespace = builder.getNamespace(); |
| 81 | 0 | this.label = builder.getLabel(); |
| 82 | 0 | this.active = builder.isActive(); |
| 83 | 0 | this.componentName = builder.getComponentName(); |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
public String getId() { |
| 87 | 0 | return this.id; |
| 88 | |
} |
| 89 | |
|
| 90 | |
public String getName() { |
| 91 | 0 | return this.name; |
| 92 | |
} |
| 93 | |
|
| 94 | |
public String getNamespace() { |
| 95 | 0 | return this.namespace; |
| 96 | |
} |
| 97 | |
|
| 98 | |
public String getLabel() { |
| 99 | 0 | return this.label; |
| 100 | |
} |
| 101 | |
|
| 102 | |
public boolean isActive() { |
| 103 | 0 | return this.active; |
| 104 | |
} |
| 105 | |
|
| 106 | |
public String getComponentName() { |
| 107 | 0 | return this.componentName; |
| 108 | |
} |
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | 0 | public static class Builder implements KrmsAttributeDefinitionContract, ModelBuilder, Serializable { |
| 114 | |
private static final long serialVersionUID = -2110564370088779631L; |
| 115 | |
|
| 116 | |
private String id; |
| 117 | |
private String name; |
| 118 | |
private String namespace; |
| 119 | 0 | private String label = ""; |
| 120 | |
private boolean active; |
| 121 | 0 | private String componentName = ""; |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | 0 | private Builder(String id, String name, String namespace) { |
| 127 | 0 | setId(id); |
| 128 | 0 | setName(name); |
| 129 | 0 | setNamespace(namespace); |
| 130 | 0 | setActive(true); |
| 131 | 0 | } |
| 132 | |
|
| 133 | |
public Builder label(String label){ |
| 134 | 0 | setLabel(label); |
| 135 | 0 | return this; |
| 136 | |
} |
| 137 | |
public Builder componentName(String componentName){ |
| 138 | 0 | setComponentName(componentName); |
| 139 | 0 | return this; |
| 140 | |
} |
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
public static Builder create(String id, String name, String namespace) { |
| 151 | 0 | return new Builder(id, name, namespace); |
| 152 | |
} |
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
public static Builder create(KrmsAttributeDefinitionContract contract) { |
| 161 | 0 | if (contract == null) { |
| 162 | 0 | throw new IllegalArgumentException("contract is null"); |
| 163 | |
} |
| 164 | 0 | Builder builder = new Builder(contract.getId(), contract.getName(), contract.getNamespace()); |
| 165 | 0 | builder.setActive(contract.isActive()); |
| 166 | 0 | builder.setLabel(contract.getLabel()); |
| 167 | 0 | builder.setComponentName(contract.getComponentName()); |
| 168 | 0 | return builder; |
| 169 | |
} |
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
public void setId(String id) { |
| 178 | 0 | if (StringUtils.isBlank(id)) { |
| 179 | 0 | throw new IllegalArgumentException("id is blank"); |
| 180 | |
} |
| 181 | 0 | this.id = id; |
| 182 | 0 | } |
| 183 | |
|
| 184 | |
public void setName(String name) { |
| 185 | 0 | if (StringUtils.isBlank(name)) { |
| 186 | 0 | throw new IllegalArgumentException("name is blank"); |
| 187 | |
} |
| 188 | 0 | this.name = name; |
| 189 | 0 | } |
| 190 | |
|
| 191 | |
public void setNamespace(String namespace) { |
| 192 | 0 | if (StringUtils.isBlank(namespace)) { |
| 193 | 0 | throw new IllegalArgumentException("namespace is blank"); |
| 194 | |
} |
| 195 | 0 | this.namespace = namespace; |
| 196 | 0 | } |
| 197 | |
|
| 198 | |
public void setLabel(String label) { |
| 199 | 0 | this.label = label; |
| 200 | 0 | } |
| 201 | |
|
| 202 | |
public void setComponentName(String componentName) { |
| 203 | 0 | this.componentName = componentName; |
| 204 | 0 | } |
| 205 | |
|
| 206 | |
public void setActive(boolean active) { |
| 207 | 0 | this.active = active; |
| 208 | 0 | } |
| 209 | |
|
| 210 | |
public String getId() { |
| 211 | 0 | return id; |
| 212 | |
} |
| 213 | |
|
| 214 | |
public String getName() { |
| 215 | 0 | return name; |
| 216 | |
} |
| 217 | |
|
| 218 | |
public String getNamespace() { |
| 219 | 0 | return namespace; |
| 220 | |
} |
| 221 | |
|
| 222 | |
public String getComponentName() { |
| 223 | 0 | return componentName; |
| 224 | |
} |
| 225 | |
|
| 226 | |
public String getLabel() { |
| 227 | 0 | return label; |
| 228 | |
} |
| 229 | |
|
| 230 | |
public boolean isActive() { |
| 231 | 0 | return active; |
| 232 | |
} |
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
@Override |
| 240 | |
public KrmsAttributeDefinition build() { |
| 241 | 0 | return new KrmsAttributeDefinition(this); |
| 242 | |
} |
| 243 | |
|
| 244 | |
} |
| 245 | |
@Override |
| 246 | |
public int hashCode() { |
| 247 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 248 | |
} |
| 249 | |
|
| 250 | |
@Override |
| 251 | |
public boolean equals(Object obj) { |
| 252 | 0 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 253 | |
} |
| 254 | |
|
| 255 | |
@Override |
| 256 | |
public String toString() { |
| 257 | 0 | return ToStringBuilder.reflectionToString(this); |
| 258 | |
} |
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | 0 | static class Constants { |
| 264 | |
final static String ROOT_ELEMENT_NAME = "KrmsAttributeDefinition"; |
| 265 | |
final static String TYPE_NAME = "KrmsAttributionDefinitionType"; |
| 266 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
| 267 | |
} |
| 268 | |
|
| 269 | |
|
| 270 | |
|
| 271 | |
|
| 272 | |
|
| 273 | 0 | public static class Elements { |
| 274 | |
final static String ID = "id"; |
| 275 | |
final static String NAME = "name"; |
| 276 | |
final static String NAMESPACE = "namespace"; |
| 277 | |
final static String LABEL = "label"; |
| 278 | |
final static String COMPONENT_NAME = "componentName"; |
| 279 | |
final static String ACTIVE = "active"; |
| 280 | |
} |
| 281 | |
} |