| Modifier and Type | Method and Description |
|---|---|
| public <VV> Bag | collect(Function<? super V, ? extends VV> function)
Redeclares org. Returns a new collection with the results of applying the specified function on each element of the source collection. |
| public BooleanBag | collectBoolean(BooleanFunction<? super V> booleanFunction)
Redeclares org. Returns a new primitive |
| public ByteBag | collectByte(ByteFunction<? super V> byteFunction)
Redeclares org. Returns a new primitive |
| public CharBag | collectChar(CharFunction<? super V> charFunction)
Redeclares org. Returns a new primitive |
| public DoubleBag | collectDouble(DoubleFunction<? super V> doubleFunction)
Redeclares org. Returns a new primitive |
| public FloatBag | collectFloat(FloatFunction<? super V> floatFunction)
Redeclares org. Returns a new primitive |
| public <VV> Bag | collectIf(Predicate<? super V> predicate, Function<? super V, ? extends VV> function)
Redeclares org. Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. |
| public IntBag | collectInt(IntFunction<? super V> intFunction)
Redeclares org. Returns a new primitive |
| public LongBag | collectLong(LongFunction<? super V> longFunction)
Redeclares org. Returns a new primitive |
| public ShortBag | collectShort(ShortFunction<? super V> shortFunction)
Redeclares org. Returns a new primitive |
| public <P, VV> Bag | collectWith(Function2<? super V, ? super P, ? extends VV> function, P parameter)
Redeclares org. Same as |
| public boolean | |
| public boolean | |
| public <VV> Bag | flatCollect(Function<? super V, ? extends Iterable<VV>> function)
Redeclares org.
|
| public default <P, VV> Bag | flatCollectWith(Function2<? super V, ? super P, ? extends Iterable<VV>> function, P parameter)
Overrides default org. Same as flatCollect, only with a Function2 that is passed an extra parameter. |
| public void | |
| public <VV> BagMultimap | groupBy(Function<? super V, ? extends VV> function)
Redeclares org. For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable. |
| public <VV> BagMultimap | groupByEach(Function<? super V, ? extends Iterable<VV>> function)
Redeclares org. Similar to |
| public <VV> UnsortedMapIterable | groupByUniqueKey(Function<? super V, ? extends VV> function)
Redeclares org. For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key. |
| public int | |
| public default Stream | |
| public PartitionBag | partition(Predicate<? super V> predicate)
Redeclares org. Filters a collection into a PartitionedIterable based on the evaluation of the predicate. |
| public <P> PartitionBag | partitionWith(Predicate2<? super V, ? super P> predicate, P parameter)
Redeclares org. Filters a collection into a PartitionIterable based on the evaluation of the predicate. |
| public Bag | reject(Predicate<? super V> predicate)
Redeclares org. Returns all elements of the source collection that return false when evaluating of the predicate. |
| public <P> Bag | rejectWith(Predicate2<? super V, ? super P> predicate, P parameter)
Redeclares org. Similar to |
| public Bag | select(Predicate<? super V> predicate)
Redeclares org. Returns all elements of the source collection that return true when evaluating the predicate. |
| public <S> Bag | selectInstancesOf(Class<S> clazz)
Redeclares org. Returns all elements of the source collection that are instances of the Class |
| public <P> Bag | selectWith(Predicate2<? super V, ? super P> predicate, P parameter)
Redeclares org. Similar to |
| public default Spliterator | spliterator()
Overrides default java. Creates a |
| public default Stream | |
| public String | Returns: a string representation of this PrimitiveObjectMapRedeclares org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. |
| public Collection | |
| public <S> Bag | zip(Iterable<S> that)
Redeclares org.
Deprecated
in 6.0. Use
OrderedIterable#zip(Iterable) instead.
Returns a |
| public UnsortedSetIterable | zipWithIndex()
Redeclares org.
Deprecated
in 6.0. Use
OrderedIterable#zipWithIndex() instead.
Zips this |
| collect | back to summary |
|---|---|
| public <VV> Bag Redeclares org. Doc from org. Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map. Example using a Java 8 lambda expression:
RichIterable<String> names =
people.collect(person -> person.getFirstName() + " " + person.getLastName());
| |
| collectBoolean | back to summary |
|---|---|
| public BooleanBag collectBoolean(BooleanFunction<? super V> booleanFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
BooleanIterable licenses =
people.collectBoolean(person -> person.hasDrivingLicense());
| |
| collectByte | back to summary |
|---|---|
| public ByteBag collectByte(ByteFunction<? super V> byteFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
ByteIterable bytes =
people.collectByte(person -> person.getCode());
| |
| collectChar | back to summary |
|---|---|
| public CharBag collectChar(CharFunction<? super V> charFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
CharIterable chars =
people.collectChar(person -> person.getMiddleInitial());
| |
| collectDouble | back to summary |
|---|---|
| public DoubleBag collectDouble(DoubleFunction<? super V> doubleFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
DoubleIterable doubles =
people.collectDouble(person -> person.getMilesFromNorthPole());
| |
| collectFloat | back to summary |
|---|---|
| public FloatBag collectFloat(FloatFunction<? super V> floatFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
FloatIterable floats =
people.collectFloat(person -> person.getHeightInInches());
| |
| collectIf | back to summary |
|---|---|
| public <VV> Bag Redeclares org. Doc from org. Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function). Example using a Java 8 lambda and method reference: RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString); Example using Predicates factory: RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
| |
| collectInt | back to summary |
|---|---|
| public IntBag collectInt(IntFunction<? super V> intFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
IntIterable ints =
people.collectInt(person -> person.getAge());
| |
| collectLong | back to summary |
|---|---|
| public LongBag collectLong(LongFunction<? super V> longFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
LongIterable longs =
people.collectLong(person -> person.getGuid());
| |
| collectShort | back to summary |
|---|---|
| public ShortBag collectShort(ShortFunction<? super V> shortFunction) Redeclares org. Doc from org. Returns a new primitive Example using a Java 8 lambda expression:
ShortIterable shorts =
people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());
| |
| collectWith | back to summary |
|---|---|
| public <P, VV> Bag Redeclares org. Doc from org. Same as Example using a Java 8 lambda expression:
RichIterable<Integer> integers =
Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Follows the same general contract as
| |
| flatCollect | back to summary |
|---|---|
| public <VV> Bag Redeclares org. Doc from org.
Consider the following example where we have a Function<Person, List<Address>> addressFunction = Person::getAddresses; RichIterable<Person> people = ...;Using collect returns a collection of collections of addresses.
RichIterable<List<Address>> addresses = people.collect(addressFunction);Using flatCollect returns a single flattened list of addresses.
RichIterable<Address> addresses = people.flatCollect(addressFunction);
| |
| flatCollectWith | back to summary |
|---|---|
| public default <P, VV> Bag Overrides default org. Doc from org. Same as flatCollect, only with a Function2 that is passed an extra parameter.
| |
| forEachValue | back to summary |
|---|---|
| public void forEachValue(Procedure<? super V> procedure) | |
| groupBy | back to summary |
|---|---|
| public <VV> BagMultimap Redeclares org. Doc from org. For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable. Example using a Java 8 method reference:
Multimap<String, Person> peopleByLastName =
people.groupBy(Person::getLastName);
| |
| groupByEach | back to summary |
|---|---|
| public <VV> BagMultimap Redeclares org. Doc from org. Similar to
| |
| groupByUniqueKey | back to summary |
|---|---|
| public <VV> UnsortedMapIterable Redeclares org. Doc from org. For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key. The generated keys must each be unique, or else an exception is thrown.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Follows the same general contract as
| |
| parallelStream | back to summary |
|---|---|
public default Stream
| |
| partition | back to summary |
|---|---|
| public PartitionBag Redeclares org. Doc from org. Filters a collection into a PartitionedIterable based on the evaluation of the predicate. Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers =
people.partition(person -> person.getAddress().getState().getName().equals("New York"));
| |
| partitionWith | back to summary |
|---|---|
| public <P> PartitionBag Redeclares org. Doc from org. Filters a collection into a PartitionIterable based on the evaluation of the predicate. Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers =
people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
| |
| reject | back to summary |
|---|---|
| public Bag Redeclares org. Doc from org. Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)). Example using a Java 8 lambda expression:
RichIterable<Person> rejected =
people.reject(person -> person.person.getLastName().equals("Smith"));
| |
| rejectWith | back to summary |
|---|---|
| public <P> Bag Redeclares org. Doc from org. Similar to
E.g. return a Example using a Java 8 lambda expression:
RichIterable<Person> rejected =
people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
| |
| select | back to summary |
|---|---|
| public Bag Redeclares org. Doc from org. Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter. Example using a Java 8 lambda expression:
RichIterable<Person> selected =
people.select(person -> person.getAddress().getCity().equals("London"));
| |
| selectInstancesOf | back to summary |
|---|---|
| public <S> Bag Redeclares org. Doc from org. Returns all elements of the source collection that are instances of the Class
RichIterable<Integer> integers =
List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
| |
| selectWith | back to summary |
|---|---|
| public <P> Bag Redeclares org. Doc from org. Similar to
E.g. return a Example using a Java 8 lambda expression:
RichIterable<Person> selected =
people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
| |
| spliterator | back to summary |
|---|---|
| public default Spliterator Overrides default java. Doc from java. Creates a
| |
| stream | back to summary |
|---|---|
public default Stream
| |
| toString | back to summary |
|---|---|
| public String toString() Redeclares org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. Each key and value is separated by an equals sign.
Assert.assertEquals(
"{1=1, 2=2, 3=3}",
IntObjectMaps.mutable.empty().withKeyValue(1, 1).withKeyValue(2, 2).withKeyValue(3, 3).toString());
| |
| values | back to summary |
|---|---|
| public Collection | |
| zip | back to summary |
|---|---|
| public <S> Bag Redeclares org. Doc from org. Deprecated in 6.0. Use Returns a
| |
| zipWithIndex | back to summary |
|---|---|
| public UnsortedSetIterable Redeclares org. Doc from org. Deprecated in 6.0. Use Zips this
| |