java.lang.Object
de.powerstat.validation.values.Port
All Implemented Interfaces:
IValueObject, Comparable<Port>

public final class Port extends Object implements Comparable<Port>, IValueObject
Port. Not DSGVO relevant. TODO min, max?
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Port.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Port(int port)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compare with another object.
    boolean
    Is equal with another object.
    int
    Calculate hash code.
    int
    Returns the value of this Port as an int.
    boolean
    Is dynamic port (49152-65535).
    boolean
    Is registered port (1024-49151).
    boolean
    Is system port (0-1023).
    static Port
    of(int port)
    Port factory.
    static Port
    of(String port)
    Port factory.
    Returns the value of this Port as an String.
    Returns the string representation of this Port.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • port

      private final int port
      Port.
  • Constructor Details

    • Port

      private Port(int port)
      Constructor.
      Parameters:
      port - Port 0-65535
      Throws:
      IndexOutOfBoundsException - When the port is less than 0 or greater than 65535
  • Method Details

    • of

      public static Port of(int port)
      Port factory.
      Parameters:
      port - Port 0-65535
      Returns:
      Port object
    • of

      public static Port of(String port)
      Port factory.
      Parameters:
      port - Port 0-65535
      Returns:
      Port object
    • isSystem

      public boolean isSystem()
      Is system port (0-1023).
      Returns:
      true: system port, otherwise false
    • isRegistered

      public boolean isRegistered()
      Is registered port (1024-49151).
      Returns:
      true: registered port, otherwise false
    • isDynamic

      public boolean isDynamic()
      Is dynamic port (49152-65535).
      Returns:
      true: dynamic port, otherwise false
    • intValue

      public int intValue()
      Returns the value of this Port as an int.
      Returns:
      The numeric value represented by this object after conversion to type int.
    • stringValue

      public String stringValue()
      Returns the value of this Port as an String.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The numeric value represented by this object after conversion to type String.
    • hashCode

      public int hashCode()
      Calculate hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Hash
      See Also:
    • equals

      public boolean equals(Object obj)
      Is equal with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object
      Returns:
      true when equal, false otherwise
      See Also:
    • toString

      public String toString()
      Returns the string representation of this Port. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Port[port=0]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Port
      See Also:
    • compareTo

      public int compareTo(Port obj)
      Compare with another object.
      Specified by:
      compareTo in interface Comparable<Port>
      Parameters:
      obj - Object to compare with
      Returns:
      0: equal; 1: greater; -1: smaller
      See Also: