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

public final class Percent extends Object implements Comparable<Percent>, IValueObject
Percent 0-100. Not DSGVO relevant.
  • Field Summary

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

    Constructors
    Modifier
    Constructor
    Description
    private
    Percent(int percent)
    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 Percent as an int.
    static Percent
    of(int percent)
    Percent factory.
    static Percent
    of(String percent)
    Percent factory.
    Returns the value of this Percent as an String.
    Returns the string representation of this Percent.

    Methods inherited from class java.lang.Object

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

    • percent

      private final int percent
      Percent.
  • Constructor Details

    • Percent

      private Percent(int percent)
      Constructor.
      Parameters:
      percent - Percent 0-100
      Throws:
      IndexOutOfBoundsException - When the percent is less than 0 or greater than 100
  • Method Details

    • of

      public static Percent of(int percent)
      Percent factory.
      Parameters:
      percent - Percent 0-100
      Returns:
      Percent object
    • of

      public static Percent of(String percent)
      Percent factory.
      Parameters:
      percent - Percent 0-100
      Returns:
      Percent object
    • intValue

      public int intValue()
      Returns the value of this Percent 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 Percent 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 Percent. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Percent[percent=0]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Percent
      See Also:
    • compareTo

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