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.datatype.markup.MarkupMultiline;
008import dev.metaschema.core.datatype.markup.MarkupMultilineAdapter;
009import dev.metaschema.core.model.IBoundObject;
010import dev.metaschema.core.model.IMetaschemaData;
011import dev.metaschema.core.model.constraint.IConstraint;
012import dev.metaschema.core.util.ObjectUtils;
013import dev.metaschema.databind.model.annotations.AllowedValue;
014import dev.metaschema.databind.model.annotations.AllowedValues;
015import dev.metaschema.databind.model.annotations.BoundField;
016import dev.metaschema.databind.model.annotations.BoundFlag;
017import dev.metaschema.databind.model.annotations.Expect;
018import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
019import dev.metaschema.databind.model.annotations.ValueConstraints;
020import edu.umd.cs.findbugs.annotations.Nullable;
021import java.math.BigInteger;
022import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
023import org.apache.commons.lang3.builder.ToStringStyle;
024
025/**
026 * Where applicable this is the transport layer protocol port range an IPv4-based or IPv6-based service uses.
027 */
028@MetaschemaAssembly(
029    formalName = "Port Range",
030    description = "Where applicable this is the transport layer protocol port range an IPv4-based or IPv6-based service uses.",
031    name = "port-range",
032    moduleClass = OscalImplementationCommonModule.class,
033    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.",
034    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.")})
035)
036public class PortRange implements IBoundObject {
037  private final IMetaschemaData __metaschemaData;
038
039  /**
040   * Indicates the starting port number in a port range for a transport layer protocol
041   */
042  @BoundFlag(
043      formalName = "Start",
044      description = "Indicates the starting port number in a port range for a transport layer protocol",
045      name = "start",
046      typeAdapter = NonNegativeIntegerAdapter.class,
047      remarks = "Should be a number within a permitted range"
048  )
049  private BigInteger _start;
050
051  /**
052   * Indicates the ending port number in a port range for a transport layer protocol
053   */
054  @BoundFlag(
055      formalName = "End",
056      description = "Indicates the ending port number in a port range for a transport layer protocol",
057      name = "end",
058      typeAdapter = NonNegativeIntegerAdapter.class,
059      remarks = "Should be a number within a permitted range"
060  )
061  private BigInteger _end;
062
063  /**
064   * Indicates the transport type.
065   */
066  @BoundFlag(
067      formalName = "Transport",
068      description = "Indicates the transport type.",
069      name = "transport",
070      typeAdapter = TokenAdapter.class,
071      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")}))
072  )
073  private String _transport;
074
075  /**
076   * Additional commentary about the containing object.
077   */
078  @BoundField(
079      formalName = "Remarks",
080      description = "Additional commentary about the containing object.",
081      useName = "remarks",
082      typeAdapter = MarkupMultilineAdapter.class
083  )
084  private MarkupMultiline _remarks;
085
086  /**
087   * Constructs a new {@code dev.metaschema.oscal.lib.model.PortRange} instance with no metadata.
088   */
089  public PortRange() {
090    this(null);
091  }
092
093  /**
094   * Constructs a new {@code dev.metaschema.oscal.lib.model.PortRange} instance with the specified metadata.
095   *
096   * @param data
097   *           the metaschema data, or {@code null} if none
098   */
099  public PortRange(IMetaschemaData data) {
100    this.__metaschemaData = data;
101  }
102
103  @Override
104  public IMetaschemaData getMetaschemaData() {
105    return __metaschemaData;
106  }
107
108  /**
109   * Get the "{@literal Start}".
110   *
111   * <p>
112   * Indicates the starting port number in a port range for a transport layer protocol
113   *
114   * @return the start value, or {@code null} if not set
115   */
116  @Nullable
117  public BigInteger getStart() {
118    return _start;
119  }
120
121  /**
122   * Set the "{@literal Start}".
123   *
124   * <p>
125   * Indicates the starting port number in a port range for a transport layer protocol
126   *
127   * @param value
128   *           the start value to set, or {@code null} to clear
129   */
130  public void setStart(@Nullable BigInteger value) {
131    _start = value;
132  }
133
134  /**
135   * Get the "{@literal End}".
136   *
137   * <p>
138   * Indicates the ending port number in a port range for a transport layer protocol
139   *
140   * @return the end value, or {@code null} if not set
141   */
142  @Nullable
143  public BigInteger getEnd() {
144    return _end;
145  }
146
147  /**
148   * Set the "{@literal End}".
149   *
150   * <p>
151   * Indicates the ending port number in a port range for a transport layer protocol
152   *
153   * @param value
154   *           the end value to set, or {@code null} to clear
155   */
156  public void setEnd(@Nullable BigInteger value) {
157    _end = value;
158  }
159
160  /**
161   * Get the "{@literal Transport}".
162   *
163   * <p>
164   * Indicates the transport type.
165   *
166   * @return the transport value, or {@code null} if not set
167   */
168  @Nullable
169  public String getTransport() {
170    return _transport;
171  }
172
173  /**
174   * Set the "{@literal Transport}".
175   *
176   * <p>
177   * Indicates the transport type.
178   *
179   * @param value
180   *           the transport value to set, or {@code null} to clear
181   */
182  public void setTransport(@Nullable String value) {
183    _transport = value;
184  }
185
186  /**
187   * Get the "{@literal Remarks}".
188   *
189   * <p>
190   * Additional commentary about the containing object.
191   *
192   * @return the remarks value, or {@code null} if not set
193   */
194  @Nullable
195  public MarkupMultiline getRemarks() {
196    return _remarks;
197  }
198
199  /**
200   * Set the "{@literal Remarks}".
201   *
202   * <p>
203   * Additional commentary about the containing object.
204   *
205   * @param value
206   *           the remarks value to set, or {@code null} to clear
207   */
208  public void setRemarks(@Nullable MarkupMultiline value) {
209    _remarks = value;
210  }
211
212  @Override
213  public String toString() {
214    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
215  }
216}