Class AbstractMultiSet.MultiplicityImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int mult
      A positive integer representing a multiplicity.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MultiplicityImpl​(int mult)
      Creates a new Multiplicity instance representing a positive multiplicity.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int add​(int mult)
      Adds the specified multiplicity (which may well be negative) to the wrapped multiplicity mult which is thus modified.
      int compareTo​(MultiSet.Multiplicity mult)
      Defines the natural ordering on natural numbers.
      protected static AbstractMultiSet.MultiplicityImpl create​(int mult)  
      boolean equals​(java.lang.Object obj)
      Returns true if and only if obj is also an instance of Multiplicity and if the wrapped multiplicities coincide.
      int get()
      Returns the wrapped multiplicity.
      int hashCode()  
      int set​(int mult)
      Sets the multiplicity wrapped by this object to the specified value.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • mult

        private int mult
        A positive integer representing a multiplicity.
    • Constructor Detail

      • MultiplicityImpl

        private MultiplicityImpl​(int mult)
        Creates a new Multiplicity instance representing a positive multiplicity.
        Parameters:
        mult - a strictly positive int value representing a multiplicity.
        Throws:
        java.lang.IllegalArgumentException - if mult is not strictly positive.
        See Also:
        set(int)
    • Method Detail

      • set

        public int set​(int mult)
        Sets the multiplicity wrapped by this object to the specified value.
        Specified by:
        set in interface MultiSet.Multiplicity
        Parameters:
        mult - a strictly positive int value representing the old multiplicity.
        Throws:
        java.lang.IllegalArgumentException - if mult is not strictly positive.
      • add

        public int add​(int mult)
        Adds the specified multiplicity (which may well be negative) to the wrapped multiplicity mult which is thus modified.
        Specified by:
        add in interface MultiSet.Multiplicity
        Parameters:
        mult - an int such that this.mult + mult > 0 holds.
        Returns:
        the new multiplicity this.mult + mult.
        Throws:
        java.lang.IllegalArgumentException - if this.mult + mult < 0 holds.
        java.lang.IllegalStateException - if this.mult + mult == 0 holds. This cannot occur: if it does this is a bug within this class.
      • toString

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

        public boolean equals​(java.lang.Object obj)
        Returns true if and only if obj is also an instance of Multiplicity and if the wrapped multiplicities coincide.
        Specified by:
        equals in interface MultiSet.Multiplicity
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - an Object value which may well be null.
        Returns:
        a boolean value which indicates whether obj is also an instance of Multiplicity and whether the wrapped multiplicity coincides with this one.
        See Also:
        compareTo(eu.simuline.util.MultiSet.Multiplicity)
      • hashCode

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