Address.java
package gov.nist.secauto.oscal.lib.model;
import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
import gov.nist.secauto.metaschema.core.model.IBoundObject;
import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
import gov.nist.secauto.metaschema.core.model.constraint.IConstraint;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
import gov.nist.secauto.metaschema.databind.model.annotations.Matches;
import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
import java.lang.Override;
import java.lang.String;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* A postal address for the location.
*/
@MetaschemaAssembly(
formalName = "Address",
description = "A postal address for the location.",
name = "address",
moduleClass = OscalMetadataModule.class
)
public class Address implements IBoundObject {
private final IMetaschemaData __metaschemaData;
/**
* "Indicates the type of address."
*/
@BoundFlag(
formalName = "Address Type",
description = "Indicates the type of address.",
name = "type",
typeAdapter = TokenAdapter.class,
valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "home", description = "A home address."), @AllowedValue(value = "work", description = "A work address.")}))
)
private String _type;
@BoundField(
formalName = "Address line",
description = "A single line of an address.",
useName = "addr-line",
maxOccurs = -1,
groupAs = @GroupAs(name = "addr-lines", inJson = JsonGroupAsBehavior.LIST)
)
private List<String> _addrLines;
@BoundField(
formalName = "City",
description = "City, town or geographical region for the mailing address.",
useName = "city"
)
private String _city;
@BoundField(
formalName = "State",
description = "State, province or analogous geographical region for a mailing address.",
useName = "state"
)
private String _state;
@BoundField(
formalName = "Postal Code",
description = "Postal or ZIP code for mailing address.",
useName = "postal-code"
)
private String _postalCode;
@BoundField(
formalName = "Country Code",
description = "The ISO 3166-1 alpha-2 country code for the mailing address.",
useName = "country",
valueConstraints = @ValueConstraints(matches = @Matches(level = IConstraint.Level.ERROR, pattern = "[A-Z]{2}"))
)
private String _country;
public Address() {
this(null);
}
public Address(IMetaschemaData data) {
this.__metaschemaData = data;
}
@Override
public IMetaschemaData getMetaschemaData() {
return __metaschemaData;
}
public String getType() {
return _type;
}
public void setType(String value) {
_type = value;
}
public List<String> getAddrLines() {
return _addrLines;
}
public void setAddrLines(List<String> value) {
_addrLines = value;
}
/**
* Add a new {@link String} item to the underlying collection.
* @param item the item to add
* @return {@code true}
*/
public boolean addAddrLine(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
if (_addrLines == null) {
_addrLines = new LinkedList<>();
}
return _addrLines.add(value);
}
/**
* Remove the first matching {@link String} item from the underlying collection.
* @param item the item to remove
* @return {@code true} if the item was removed or {@code false} otherwise
*/
public boolean removeAddrLine(String item) {
String value = ObjectUtils.requireNonNull(item,"item cannot be null");
return _addrLines != null && _addrLines.remove(value);
}
public String getCity() {
return _city;
}
public void setCity(String value) {
_city = value;
}
public String getState() {
return _state;
}
public void setState(String value) {
_state = value;
}
public String getPostalCode() {
return _postalCode;
}
public void setPostalCode(String value) {
_postalCode = value;
}
public String getCountry() {
return _country;
}
public void setCountry(String value) {
_country = value;
}
@Override
public String toString() {
return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
}
}