Class ImmutableSortedMultiset.Builder<E>

  • Enclosing class:
    ImmutableSortedMultiset<E>

    @Deprecated(since="2022-12-01")
    public static class ImmutableSortedMultiset.Builder<E>
    extends ImmutableMultiset.Builder<E>
    Deprecated.
    The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
    A builder for creating immutable multiset instances, especially public static final multisets ("constant multisets"). Example:
     
    
        public static final ImmutableSortedMultiset<Bean> BEANS =
            new ImmutableSortedMultiset.Builder<Bean>()
                .addCopies(Bean.COCOA, 4)
                .addCopies(Bean.GARDEN, 6)
                .addCopies(Bean.RED, 8)
                .addCopies(Bean.BLACK_EYED, 10)
                .build();

    Builder instances can be reused; it is safe to call build() multiple times to build multiple multisets in series.

    Since:
    12.0
    • Method Detail

      • add

        public ImmutableSortedMultiset.Builder<E> add​(E element)
        Deprecated.
        Adds element to the ImmutableSortedMultiset.
        Overrides:
        add in class ImmutableMultiset.Builder<E>
        Parameters:
        element - the element to add
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if element is null
      • addCopies

        public ImmutableSortedMultiset.Builder<E> addCopies​(E element,
                                                            int occurrences)
        Deprecated.
        Adds a number of occurrences of an element to this ImmutableSortedMultiset.
        Overrides:
        addCopies in class ImmutableMultiset.Builder<E>
        Parameters:
        element - the element to add
        occurrences - the number of occurrences of the element to add. May be zero, in which case no change will be made.
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if element is null
        java.lang.IllegalArgumentException - if occurrences is negative, or if this operation would result in more than Integer.MAX_VALUE occurrences of the element
      • setCount

        public ImmutableSortedMultiset.Builder<E> setCount​(E element,
                                                           int count)
        Deprecated.
        Adds or removes the necessary occurrences of an element such that the element attains the desired count.
        Overrides:
        setCount in class ImmutableMultiset.Builder<E>
        Parameters:
        element - the element to add or remove occurrences of
        count - the desired count of the element in this multiset
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if element is null
        java.lang.IllegalArgumentException - if count is negative
      • add

        public ImmutableSortedMultiset.Builder<E> add​(E... elements)
        Deprecated.
        Adds each element of elements to the ImmutableSortedMultiset.
        Overrides:
        add in class ImmutableMultiset.Builder<E>
        Parameters:
        elements - the elements to add
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if elements is null or contains a null element
      • addAll

        public ImmutableSortedMultiset.Builder<E> addAll​(java.lang.Iterable<? extends E> elements)
        Deprecated.
        Adds each element of elements to the ImmutableSortedMultiset.
        Overrides:
        addAll in class ImmutableMultiset.Builder<E>
        Parameters:
        elements - the Iterable to add to the ImmutableSortedMultiset
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if elements is null or contains a null element
      • addAll

        public ImmutableSortedMultiset.Builder<E> addAll​(java.util.Iterator<? extends E> elements)
        Deprecated.
        Adds each element of elements to the ImmutableSortedMultiset.
        Overrides:
        addAll in class ImmutableMultiset.Builder<E>
        Parameters:
        elements - the elements to add to the ImmutableSortedMultiset
        Returns:
        this Builder object
        Throws:
        java.lang.NullPointerException - if elements is null or contains a null element