Class Probability

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Probability>

    public class Probability
    extends java.lang.Number
    implements java.lang.Comparable<Probability>
    See Also:
    Serialized Form
    • Method Detail

      • of

        public static Probability of​(java.math.BigDecimal value)
        Static factory method to create a Probability.
      • of

        public static Probability of​(double value)
        Static factory method to create a Probability from a double.
      • of

        public static Probability of​(java.lang.String value)
      • getValue

        public java.math.BigDecimal getValue()
        Getter for the underlying BigDecimal value.
      • add

        public Probability add​(Probability other)
        Adds two probabilities. Throws an exception if the result exceeds 1.
      • subtract

        public Probability subtract​(Probability other)
        Subtracts another probability. Throws an exception if the result is less than 0.
      • divide

        public Probability divide​(Probability other)
        Divides this probability by another. Throws an exception for division by zero or out-of-bound results.
      • toString

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public int intValue()
        Specified by:
        intValue in class java.lang.Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class java.lang.Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class java.lang.Number
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class java.lang.Number
      • compareTo

        public int compareTo​(Probability probability)
        Specified by:
        compareTo in interface java.lang.Comparable<Probability>