Class PortNumber


  • public final class PortNumber
    extends java.lang.Object
    Representation of a port number.
    • Method Detail

      • portNumber

        public static PortNumber portNumber​(long number)
        Returns the port number representing the specified long value.
        Parameters:
        number - port number as long value
        Returns:
        port number
      • portNumber

        public static PortNumber portNumber​(java.lang.String string)
        Returns the port number representing the specified string value.
        Parameters:
        string - port number as decimal, hexadecimal, or octal number string
        Returns:
        port number
      • portNumber

        public static PortNumber portNumber​(long number,
                                            java.lang.String name)
        Returns the port number representing the specified long value and name.
        Parameters:
        number - port number as long value
        name - port name as string value
        Returns:
        port number
      • fromString

        public static PortNumber fromString​(java.lang.String s)
        Returns PortNumber instance from String representation.
        Parameters:
        s - String representation equivalent to toString()
        Returns:
        PortNumber instance
        Throws:
        java.lang.IllegalArgumentException - if given String was malformed
      • isLogical

        public boolean isLogical()
        Indicates whether or not this port number is a reserved logical one or whether it corresponds to a normal physical port of a device or NIC.
        Returns:
        true if logical port number
      • toLong

        public long toLong()
        Returns the backing long value.
        Returns:
        port number as long
      • name

        public java.lang.String name()
        Returns the backing string value.
        Returns:
        port name as string value
      • hasName

        public boolean hasName()
        Indicates whether this port number was created with a port name, or only with a number.
        Returns:
        true if port was created with name
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • exactlyEquals

        public boolean exactlyEquals​(PortNumber that)
        Indicates whether some other PortNumber object is equal to this one including it's name.
        Parameters:
        that - other PortNumber instance to compare
        Returns:
        true if equal, false otherwise