001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_implementation-common_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.NonNegativeIntegerAdapter;
006import dev.metaschema.core.datatype.adapter.TokenAdapter;
007import dev.metaschema.core.model.IBoundObject;
008import dev.metaschema.core.model.IMetaschemaData;
009import dev.metaschema.core.model.constraint.IConstraint;
010import dev.metaschema.core.util.ObjectUtils;
011import dev.metaschema.databind.model.annotations.AllowedValue;
012import dev.metaschema.databind.model.annotations.AllowedValues;
013import dev.metaschema.databind.model.annotations.BoundFlag;
014import dev.metaschema.databind.model.annotations.Expect;
015import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
016import dev.metaschema.databind.model.annotations.ValueConstraints;
017import edu.umd.cs.findbugs.annotations.Nullable;
018import java.math.BigInteger;
019import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
020import org.apache.commons.lang3.builder.ToStringStyle;
021
022/**
023 * Where applicable this is the transport layer protocol port range an IPv4-based or IPv6-based service uses.
024 */
025@MetaschemaAssembly(
026    formalName = "Port Range",
027    description = "Where applicable this is the transport layer protocol port range an IPv4-based or IPv6-based service uses.",
028    name = "port-range",
029    moduleClass = OscalImplementationCommonModule.class,
030    remarks = "To be validated as a natural number (integer \\>= 1). A single port uses the same value for start and end. Use multiple 'port-range' entries for non-contiguous ranges.",
031    valueConstraints = @ValueConstraints(expect = {@Expect(id = "oscal-component-protocol-port-range-has-start", level = IConstraint.Level.WARNING, test = "exists(@start)", message = "A port range should have a start port given."), @Expect(id = "oscal-component-protocol-port-range-has-end", level = IConstraint.Level.WARNING, test = "exists(@end)", message = "A port range should have an end port given. To define a single port, the start and end should be the same value."), @Expect(id = "oscal-component-protocol-port-range-starts-before-end", level = IConstraint.Level.WARNING, test = "not(@start > @end)", message = "The port range start should not be after its end.")})
032)
033public class PortRange implements IBoundObject {
034  private final IMetaschemaData __metaschemaData;
035
036  /**
037   * Indicates the starting port number in a port range for a transport layer protocol
038   */
039  @BoundFlag(
040      formalName = "Start",
041      description = "Indicates the starting port number in a port range for a transport layer protocol",
042      name = "start",
043      typeAdapter = NonNegativeIntegerAdapter.class,
044      remarks = "Should be a number within a permitted range"
045  )
046  private BigInteger _start;
047
048  /**
049   * Indicates the ending port number in a port range for a transport layer protocol
050   */
051  @BoundFlag(
052      formalName = "End",
053      description = "Indicates the ending port number in a port range for a transport layer protocol",
054      name = "end",
055      typeAdapter = NonNegativeIntegerAdapter.class,
056      remarks = "Should be a number within a permitted range"
057  )
058  private BigInteger _end;
059
060  /**
061   * Indicates the transport type.
062   */
063  @BoundFlag(
064      formalName = "Transport",
065      description = "Indicates the transport type.",
066      name = "transport",
067      typeAdapter = TokenAdapter.class,
068      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-component-protocol-transport-values", level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "TCP", description = "Transmission Control Protocol"), @AllowedValue(value = "UDP", description = "User Datagram Protocol")}))
069  )
070  private String _transport;
071
072  /**
073   * Constructs a new {@code dev.metaschema.oscal.lib.model.PortRange} instance with no metadata.
074   */
075  public PortRange() {
076    this(null);
077  }
078
079  /**
080   * Constructs a new {@code dev.metaschema.oscal.lib.model.PortRange} instance with the specified metadata.
081   *
082   * @param data
083   *           the metaschema data, or {@code null} if none
084   */
085  public PortRange(IMetaschemaData data) {
086    this.__metaschemaData = data;
087  }
088
089  @Override
090  public IMetaschemaData getMetaschemaData() {
091    return __metaschemaData;
092  }
093
094  /**
095   * Get the "{@literal Start}".
096   *
097   * <p>
098   * Indicates the starting port number in a port range for a transport layer protocol
099   *
100   * @return the start value, or {@code null} if not set
101   */
102  @Nullable
103  public BigInteger getStart() {
104    return _start;
105  }
106
107  /**
108   * Set the "{@literal Start}".
109   *
110   * <p>
111   * Indicates the starting port number in a port range for a transport layer protocol
112   *
113   * @param value
114   *           the start value to set, or {@code null} to clear
115   */
116  public void setStart(@Nullable BigInteger value) {
117    _start = value;
118  }
119
120  /**
121   * Get the "{@literal End}".
122   *
123   * <p>
124   * Indicates the ending port number in a port range for a transport layer protocol
125   *
126   * @return the end value, or {@code null} if not set
127   */
128  @Nullable
129  public BigInteger getEnd() {
130    return _end;
131  }
132
133  /**
134   * Set the "{@literal End}".
135   *
136   * <p>
137   * Indicates the ending port number in a port range for a transport layer protocol
138   *
139   * @param value
140   *           the end value to set, or {@code null} to clear
141   */
142  public void setEnd(@Nullable BigInteger value) {
143    _end = value;
144  }
145
146  /**
147   * Get the "{@literal Transport}".
148   *
149   * <p>
150   * Indicates the transport type.
151   *
152   * @return the transport value, or {@code null} if not set
153   */
154  @Nullable
155  public String getTransport() {
156    return _transport;
157  }
158
159  /**
160   * Set the "{@literal Transport}".
161   *
162   * <p>
163   * Indicates the transport type.
164   *
165   * @param value
166   *           the transport value to set, or {@code null} to clear
167   */
168  public void setTransport(@Nullable String value) {
169    _transport = value;
170  }
171
172  @Override
173  public String toString() {
174    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
175  }
176}