Class MaybeWeights


  • public final class MaybeWeights
    extends java.lang.Object
    A pair of weights that express the frequencies of justs vs. nothings in the context of generating Maybe values.

    Either the just weight or the nothing weight can be zero; however, the sum of the weights will always be >= 1.

    • Method Detail

      • maybeWeights

        public static MaybeWeights maybeWeights​(int nothingWeight,
                                                int justWeight)
        Creates a MaybeWeights. The sum of the weights for both choices must be >= 1.
        Parameters:
        nothingWeight - the weight for nothings; must be >= 0
        justWeight - the weight for justs; must be >= 0
        Returns:
        a MaybeWeights
      • getNothingWeight

        public int getNothingWeight()
      • getJustWeight

        public int getJustWeight()
      • 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
      • toString

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