Class Percent

java.lang.Object
io.github.srcimon.screwbox.core.Percent
All Implemented Interfaces:
Serializable

public class Percent extends Object implements Serializable
A percent value between 0.0 and 1.0.
See Also:
  • Method Details

    • of

      public static Percent of(double value)
      Returns a new instance with the given values. Values below 0 returns zero(). Values above 1 returns max().
    • quater

      public static Percent quater()
      Returns 25 percent.
    • half

      public static Percent half()
      Returns 50 percent.
    • threeQuarter

      public static Percent threeQuarter()
      Returns 75 percent.
    • zero

      public static Percent zero()
      Returns 0 percent.
    • max

      public static Percent max()
      Returns 100 percent.
    • value

      public double value()
      Returns the represented value betweeen 0.0 and 1.0.
    • isZero

      public boolean isZero()
      Returns true if value is 0.
    • isMax

      public boolean isMax()
      Returns true if value is 1.0.
    • toString

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

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • invert

      public Percent invert()
      Returns the inverted value of the percentage.
    • add

      public Percent add(double value)
      Returns a new instance with the sum of both values. Returns max() when the sum is above 100 percent.
    • substract

      public Percent substract(double value)
      Returns a new instance with the current value minus the given value. Returns zero() when the sum is below 0 percent.
    • multiply

      public Percent multiply(double value)
      Returns a new instance with the current value multiplied with the given value.