|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.collect.ImmutableCollection.Builder<E> com.google.common.collect.ImmutableMultiset.Builder<E> com.google.common.collect.ImmutableSortedMultiset.Builder<E>
public static class ImmutableSortedMultiset.Builder<E>
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.
Constructor Summary | |
---|---|
ImmutableSortedMultiset.Builder(Comparator<? super E> comparator)
Creates a new builder. |
Method Summary | |
---|---|
ImmutableSortedMultiset.Builder<E> |
add(E... elements)
Adds each element of elements to the ImmutableSortedMultiset . |
ImmutableSortedMultiset.Builder<E> |
add(E element)
Adds element to the ImmutableSortedMultiset . |
ImmutableSortedMultiset.Builder<E> |
addAll(Iterable<? extends E> elements)
Adds each element of elements to the ImmutableSortedMultiset . |
ImmutableSortedMultiset.Builder<E> |
addAll(Iterator<? extends E> elements)
Adds each element of elements to the ImmutableSortedMultiset . |
ImmutableSortedMultiset.Builder<E> |
addCopies(E element,
int occurrences)
Adds a number of occurrences of an element to this ImmutableSortedMultiset . |
ImmutableSortedMultiset<E> |
build()
Returns a newly-created ImmutableSortedMultiset based on the contents of the Builder . |
ImmutableSortedMultiset.Builder<E> |
setCount(E element,
int count)
Adds or removes the necessary occurrences of an element such that the element attains the desired count. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImmutableSortedMultiset.Builder(Comparator<? super E> comparator)
ImmutableSortedMultiset.orderedBy(Comparator)
.
Method Detail |
---|
public ImmutableSortedMultiset.Builder<E> add(E element)
element
to the ImmutableSortedMultiset
.
add
in class ImmutableMultiset.Builder<E>
element
- the element to add
Builder
object
NullPointerException
- if element
is nullpublic ImmutableSortedMultiset.Builder<E> addCopies(E element, int occurrences)
ImmutableSortedMultiset
.
addCopies
in class ImmutableMultiset.Builder<E>
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.
Builder
object
NullPointerException
- if element
is null
IllegalArgumentException
- if occurrences
is negative, or if this operation
would result in more than Integer.MAX_VALUE
occurrences of the elementpublic ImmutableSortedMultiset.Builder<E> setCount(E element, int count)
setCount
in class ImmutableMultiset.Builder<E>
element
- the element to add or remove occurrences ofcount
- the desired count of the element in this multiset
Builder
object
NullPointerException
- if element
is null
IllegalArgumentException
- if count
is negativepublic ImmutableSortedMultiset.Builder<E> add(E... elements)
elements
to the ImmutableSortedMultiset
.
add
in class ImmutableMultiset.Builder<E>
elements
- the elements to add
Builder
object
NullPointerException
- if elements
is null or contains a null elementpublic ImmutableSortedMultiset.Builder<E> addAll(Iterable<? extends E> elements)
elements
to the ImmutableSortedMultiset
.
addAll
in class ImmutableMultiset.Builder<E>
elements
- the Iterable
to add to the ImmutableSortedMultiset
Builder
object
NullPointerException
- if elements
is null or contains a null elementpublic ImmutableSortedMultiset.Builder<E> addAll(Iterator<? extends E> elements)
elements
to the ImmutableSortedMultiset
.
addAll
in class ImmutableMultiset.Builder<E>
elements
- the elements to add to the ImmutableSortedMultiset
Builder
object
NullPointerException
- if elements
is null or contains a null elementpublic ImmutableSortedMultiset<E> build()
ImmutableSortedMultiset
based on the contents of the Builder
.
build
in class ImmutableMultiset.Builder<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |