Package com.google.common.collect
Class ImmutableMultiset.Builder<E>
- java.lang.Object
-
- com.google.common.collect.ImmutableCollection.Builder<E>
-
- com.google.common.collect.ImmutableMultiset.Builder<E>
-
- Direct Known Subclasses:
ImmutableSortedMultiset.Builder
- Enclosing class:
- ImmutableMultiset<E>
@Deprecated(since="2022-12-01") public static class ImmutableMultiset.Builder<E> extends ImmutableCollection.Builder<E>
Deprecated.The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023A builder for creating immutable multiset instances, especiallypublic static final
multisets ("constant multisets"). Example:public static final ImmutableMultiset<Bean> BEANS = new ImmutableMultiset.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:
- 2.0 (imported from Google Collections Library)
-
-
Constructor Summary
Constructors Constructor Description Builder()
Deprecated.Creates a new builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ImmutableMultiset.Builder<E>
add(E element)
Deprecated.Addselement
to theImmutableMultiset
.ImmutableMultiset.Builder<E>
add(E... elements)
Deprecated.Adds each element ofelements
to theImmutableMultiset
.ImmutableMultiset.Builder<E>
addAll(java.lang.Iterable<? extends E> elements)
Deprecated.Adds each element ofelements
to theImmutableMultiset
.ImmutableMultiset.Builder<E>
addAll(java.util.Iterator<? extends E> elements)
Deprecated.Adds each element ofelements
to theImmutableMultiset
.ImmutableMultiset.Builder<E>
addCopies(E element, int occurrences)
Deprecated.Adds a number of occurrences of an element to thisImmutableMultiset
.ImmutableMultiset<E>
build()
Deprecated.Returns a newly-createdImmutableMultiset
based on the contents of theBuilder
.ImmutableMultiset.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.
-
-
-
Constructor Detail
-
Builder
public Builder()
Deprecated.Creates a new builder. The returned builder is equivalent to the builder generated byImmutableMultiset.builder()
.
-
-
Method Detail
-
add
public ImmutableMultiset.Builder<E> add(E element)
Deprecated.Addselement
to theImmutableMultiset
.- Specified by:
add
in classImmutableCollection.Builder<E>
- Parameters:
element
- the element to add- Returns:
- this
Builder
object - Throws:
java.lang.NullPointerException
- ifelement
is null
-
addCopies
public ImmutableMultiset.Builder<E> addCopies(E element, int occurrences)
Deprecated.Adds a number of occurrences of an element to thisImmutableMultiset
.- Parameters:
element
- the element to addoccurrences
- 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
- ifelement
is nulljava.lang.IllegalArgumentException
- ifoccurrences
is negative, or if this operation would result in more thanInteger.MAX_VALUE
occurrences of the element
-
setCount
public ImmutableMultiset.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.- Parameters:
element
- the element to add or remove occurrences ofcount
- the desired count of the element in this multiset- Returns:
- this
Builder
object - Throws:
java.lang.NullPointerException
- ifelement
is nulljava.lang.IllegalArgumentException
- ifcount
is negative
-
add
public ImmutableMultiset.Builder<E> add(E... elements)
Deprecated.Adds each element ofelements
to theImmutableMultiset
.- Overrides:
add
in classImmutableCollection.Builder<E>
- Parameters:
elements
- the elements to add- Returns:
- this
Builder
object - Throws:
java.lang.NullPointerException
- ifelements
is null or contains a null element
-
addAll
public ImmutableMultiset.Builder<E> addAll(java.lang.Iterable<? extends E> elements)
Deprecated.Adds each element ofelements
to theImmutableMultiset
.- Overrides:
addAll
in classImmutableCollection.Builder<E>
- Parameters:
elements
- theIterable
to add to theImmutableMultiset
- Returns:
- this
Builder
object - Throws:
java.lang.NullPointerException
- ifelements
is null or contains a null element
-
addAll
public ImmutableMultiset.Builder<E> addAll(java.util.Iterator<? extends E> elements)
Deprecated.Adds each element ofelements
to theImmutableMultiset
.- Overrides:
addAll
in classImmutableCollection.Builder<E>
- Parameters:
elements
- the elements to add to theImmutableMultiset
- Returns:
- this
Builder
object - Throws:
java.lang.NullPointerException
- ifelements
is null or contains a null element
-
build
public ImmutableMultiset<E> build()
Deprecated.Returns a newly-createdImmutableMultiset
based on the contents of theBuilder
.- Specified by:
build
in classImmutableCollection.Builder<E>
-
-