TelephoneNumber.java

package gov.nist.secauto.oscal.lib.model;

import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
import gov.nist.secauto.metaschema.binding.model.annotations.Matches;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaField;
import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaFieldValue;
import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
import gov.nist.secauto.metaschema.model.common.datatype.adapter.StringAdapter;
import java.lang.Override;
import java.lang.String;
import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * A telephone service number as defined by <a href="https://www.itu.int/rec/T-REC-E.164-201011-I/en">ITU-T E.164</a>.
 */
@MetaschemaField(
    formalName = "Telephone Number",
    description = "A telephone service number as defined by [ITU-T E.164](https://www.itu.int/rec/T-REC-E.164-201011-I/en).",
    name = "telephone-number",
    metaschema = OscalMetadataMetaschema.class,
    isCollapsible = false
)
@ValueConstraints(
    matches = @Matches(level = IConstraint.Level.WARNING, pattern = "^[0-9]{3}[0-9]{1,12}$", remarks = "Providing a country code provides an international means to interpret the phone number.")
)
public class TelephoneNumber {
  @MetaschemaFieldValue(
      valueKeyName = "number"
  )
  private String _value;

  @BoundFlag(
      formalName = "type flag",
      description = "Indicates the type of phone number.",
      useName = "type",
      typeAdapter = StringAdapter.class
  )
  @ValueConstraints(
      allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "home", description = "A home phone number."), @AllowedValue(value = "office", description = "An office phone number."), @AllowedValue(value = "mobile", description = "A mobile phone number.")})
  )
  private String _type;

  public TelephoneNumber() {
  }

  public String getValue() {
    return _value;
  }

  public void setValue(String value) {
    _value = value;
  }

  public String getType() {
    return _type;
  }

  public void setType(String value) {
    _type = value;
  }

  @Override
  public String toString() {
    return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
  }
}