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