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

public final class IPV4Mask extends Object implements Comparable<IPV4Mask>, IValueObject
IP V4 mask. Not DSGVO relevant. TODO IPV4Address filterMin(IPV4Address) 0 TODO IPV4Address filterMax(IPV4Address) 255
  • Field Details

    • ZERO

      private static final String ZERO
      0.
      See Also:
    • BITMASKS

      private static final String[] BITMASKS
      Bitmask array.
    • IPV4_MASK_REGEXP

      private static final Pattern IPV4_MASK_REGEXP
      IP V4 mask regexp.
    • length

      private final int length
      Prefix length.
    • mask

      private final String mask
      Mask.
  • Constructor Details

    • IPV4Mask

      private IPV4Mask(int length)
      Constructor.
      Parameters:
      length - Prefix length (0-32)
      Throws:
      IndexOutOfBoundsException - if the prefix length is < 0 or > 32
  • Method Details

    • maskToLength

      private static int maskToLength(String mask)
      Calculate length from mask.
      Parameters:
      mask - Mask in the form like 255.255.255.0
      Returns:
      Prefix length (0-32)
    • of

      public static IPV4Mask of(int length)
      IPV4Mask factory.
      Parameters:
      length - IP V4 prefix length 0-32
      Returns:
      IPV4Mask object
    • of

      public static IPV4Mask of(String mask)
      IPV4Mask factory.
      Parameters:
      mask - IP V4 network mask in format like 255.255.255.0
      Returns:
      IPV4Mask object TODO mask=length as string (0-32)?
    • intValue

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

      public String stringValue()
      Returns the value of this IPV4Mask as a string.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The text value represented by this object after conversion to type string of format 255.255.255.0.
    • 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 IPV4Address. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "IPV4Mask[length=24, mask=255.255.255.0]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this IPV4Mask
      See Also:
    • compareTo

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