public class BagsByTag extends Object
Tag<E>
to Collection<E>
, where
E
can be different for each tag. Useful as a container of
co-grouped items, where each tag corresponds to one contributing
pipeline stage.
This is a less typesafe, but more flexible alternative to the TwoBags
and ThreeBags
containers, which have a fixed (and
limited) number of integer-indexed, statically-typed fields. BagsByTag
has a variable number of tag-indexed fields whose whose
static type is encoded in the tags.
Constructor and Description |
---|
BagsByTag() |
Modifier and Type | Method and Description |
---|---|
<E> Collection<E> |
bag(Tag<E> tag)
Retrieves the bag associated with the supplied tag.
|
static BagsByTag |
bagsByTag(Object... tagsAndBags)
Accepts an argument list of alternating tags and collections, interprets
them as a list of tag-bag pairs, and returns a
BagsByTag
populated with these pairs. |
void |
combineWith(BagsByTag that)
Merges the contents of the supplied bag container into this one.
|
<E> Collection<E> |
ensureBag(Tag<E> tag)
Ensures that there is a mapping from the supplied tag to a bag,
creating an empty one if necessary.
|
boolean |
equals(Object o) |
int |
hashCode() |
String |
toString() |
@Nonnull public static BagsByTag bagsByTag(@Nonnull Object... tagsAndBags)
BagsByTag
populated with these pairs. Doesn't retain the supplied collections, but
copies them into newly created ones.@Nonnull public <E> Collection<E> bag(@Nonnull Tag<E> tag)
IllegalArgumentException
if there is none.E
- the type of items in the returned bagtag
- the lookup tagIllegalArgumentException
- if there is no bag associated with the tag@Nonnull public <E> Collection<E> ensureBag(@Nonnull Tag<E> tag)
E
- the type of items in the returned bagtag
- the lookup tagpublic void combineWith(@Nonnull BagsByTag that)
Does not modify the supplied container.
that
- the container to combine with this one.Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.