Class AbstractSynchronizedMapIterable<K,V>

java.lang.Object
org.eclipse.collections.impl.collection.AbstractSynchronizedRichIterable<V>
org.eclipse.collections.impl.map.AbstractSynchronizedMapIterable<K,V>
All Implemented Interfaces:
Iterable<V>, Map<K,V>, InternalIterable<V>, MapIterable<K,V>, MutableMapIterable<K,V>, RichIterable<V>
Direct Known Subclasses:
SynchronizedBiMap, SynchronizedMutableMap, SynchronizedSortedMap

public abstract class AbstractSynchronizedMapIterable<K,V> extends AbstractSynchronizedRichIterable<V> implements MutableMapIterable<K,V>
A synchronized view of a map.
  • Method Details

    • get

      public V get(Object key)
      Specified by:
      get in interface Map<K,V>
      Specified by:
      get in interface MapIterable<K,V>
      See Also:
    • getIfAbsent

      public V getIfAbsent(K key, Function0<? extends V> function)
      Description copied from interface: MapIterable
      Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified Function0.
      Specified by:
      getIfAbsent in interface MapIterable<K,V>
    • getIfAbsentValue

      public V getIfAbsentValue(K key, V value)
      Description copied from interface: MapIterable
      Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return value.
      Specified by:
      getIfAbsentValue in interface MapIterable<K,V>
    • getIfAbsentWith

      public <P> V getIfAbsentWith(K key, Function<? super P,? extends V> function, P parameter)
      Description copied from interface: MapIterable
      Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified function and parameter.
      Specified by:
      getIfAbsentWith in interface MapIterable<K,V>
    • ifPresentApply

      public <A> A ifPresentApply(K key, Function<? super V,? extends A> function)
      Description copied from interface: MapIterable
      If there is a value in the Map that corresponds to the specified key return the result of applying the specified Function on the value, otherwise return null.
      Specified by:
      ifPresentApply in interface MapIterable<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
      Specified by:
      containsKey in interface MapIterable<K,V>
      See Also:
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
      Specified by:
      containsValue in interface MapIterable<K,V>
      See Also:
    • forEachValue

      public void forEachValue(Procedure<? super V> procedure)
      Description copied from interface: MapIterable
      Calls the procedure with each value of the map.
           Set<String> result = UnifiedSet.newSet();
           MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three", 4, "Four");
           map.forEachValue(new CollectionAddProcedure<String>(result));
           Verify.assertSetsEqual(UnifiedSet.newSetWith("One", "Two", "Three", "Four"), result);
       
      Specified by:
      forEachValue in interface MapIterable<K,V>
    • forEachKey

      public void forEachKey(Procedure<? super K> procedure)
      Description copied from interface: MapIterable
      Calls the procedure with each key of the map.
           final Collection<Integer> result = new ArrayList<Integer>();
           MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
           map.forEachKey(new CollectionAddProcedure<Integer>(result));
           Verify.assertContainsAll(result, 1, 2, 3);
       
      Specified by:
      forEachKey in interface MapIterable<K,V>
    • forEachKeyValue

      public void forEachKeyValue(Procedure2<? super K,? super V> procedure2)
      Description copied from interface: MapIterable
      Calls the procedure with each key-value pair of the map.
           final Collection<String> collection = new ArrayList<String>();
           MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
           map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value));
           Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
       
      Specified by:
      forEachKeyValue in interface MapIterable<K,V>
    • detect

      public Pair<K,V> detect(Predicate2<? super K,? super V> predicate)
      Description copied from interface: MapIterable
      Return the first key and value of the map for which the predicate evaluates to true when they are given as arguments. The predicate will only be evaluated until such pair is found or until all of the keys and values of the map have been used as arguments. That is, there may be keys and values of the map that are never used as arguments to the predicate. The result is null if predicate does not evaluate to true for any key/value combination.
       Pair<City, Person> detected =
           peopleByCity.detect((City city, Person person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
       
      Specified by:
      detect in interface MapIterable<K,V>
    • detectOptional

      public Optional<Pair<K,V>> detectOptional(Predicate2<? super K,? super V> predicate)
      Description copied from interface: MapIterable
      Return the first key and value of the map as an Optional for which the predicate evaluates to true when they are given as arguments. The predicate will only be evaluated until such pair is found or until all of the keys and values of the map have been used as arguments. That is, there may be keys and values of the map that are never used as arguments to the predicate.
       Optional<Pair<City, Person>> detected =
           peopleByCity.detectOptional((city, person)
                -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
       
      Specified by:
      detectOptional in interface MapIterable<K,V>
    • getIfAbsentPut

      public V getIfAbsentPut(K key, Function0<? extends V> function)
      Description copied from interface: MutableMapIterable
      Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map at the key, return the result of evaluating the specified Function0, and put that value in the map at the specified key.
      Specified by:
      getIfAbsentPut in interface MutableMapIterable<K,V>
    • getIfAbsentPut

      public V getIfAbsentPut(K key, V value)
      Description copied from interface: MutableMapIterable
      Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map at the key, return the specified value, and put that value in the map at the specified key.
      Specified by:
      getIfAbsentPut in interface MutableMapIterable<K,V>
    • getIfAbsentPutWithKey

      public V getIfAbsentPutWithKey(K key, Function<? super K,? extends V> function)
      Description copied from interface: MutableMapIterable
      Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map for that key return the result of evaluating the specified Function using the specified key, and put that value in the map at the specified key.
      Specified by:
      getIfAbsentPutWithKey in interface MutableMapIterable<K,V>
    • getIfAbsentPutWith

      public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
      Description copied from interface: MutableMapIterable
      Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map for that key return the result of evaluating the specified Function using the specified parameter, and put that value in the map at the specified key.
      Specified by:
      getIfAbsentPutWith in interface MutableMapIterable<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • removeKey

      public V removeKey(K key)
      Description copied from interface: MutableMapIterable
      Remove an entry from the map at the specified key.
      Specified by:
      removeKey in interface MutableMapIterable<K,V>
      Returns:
      The value removed from entry at key, or null if not found.
      See Also:
    • removeAllKeys

      public boolean removeAllKeys(Set<? extends K> keys)
      Description copied from interface: MutableMapIterable
      Remove entries from the map at the specified keys.
      Specified by:
      removeAllKeys in interface MutableMapIterable<K,V>
      Returns:
      true if this map changed as a result of the call
    • removeIf

      public boolean removeIf(Predicate2<? super K,? super V> predicate)
      Description copied from interface: MutableMapIterable
      Remove an entry from the map if the predicate evaluates to true.
      Specified by:
      removeIf in interface MutableMapIterable<K,V>
      Returns:
      true if any entry is removed.
    • putAll

      public void putAll(Map<? extends K,? extends V> map)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • putPair

      public V putPair(Pair<? extends K,? extends V> keyValuePair)
      Description copied from interface: MutableMapIterable
      This method allows mutable map the ability to add an element in the form of Pair<? extends K, ? extends V>.
      Specified by:
      putPair in interface MutableMapIterable<K,V>
      See Also:
    • add

      public V add(Pair<? extends K,? extends V> keyValuePair)
      Description copied from interface: MutableMapIterable
      This method allows mutable map the ability to add an element in the form of Pair<? extends K, ? extends V>.
      Specified by:
      add in interface MutableMapIterable<K,V>
      Returns:
      previous value in the map for the key, or null if no value exists for the key.
      See Also:
    • updateValue

      public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
      Description copied from interface: MutableMapIterable
      Looks up the value associated with key, applies the function to it, and replaces the value. If there is no value associated with key, starts it off with a value supplied by factory.
      Specified by:
      updateValue in interface MutableMapIterable<K,V>
    • updateValueWith

      public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)
      Description copied from interface: MutableMapIterable
      Same as MutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is passed to the function.
      Specified by:
      updateValueWith in interface MutableMapIterable<K,V>
    • groupByUniqueKey

      public <VV> MutableMapIterable<VV,V> groupByUniqueKey(Function<? super V,? extends VV> function)
      Description copied from interface: RichIterable
      For each element of the iterable, the function is evaluated and he 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.
      Specified by:
      groupByUniqueKey in interface MutableMapIterable<K,V>
      Specified by:
      groupByUniqueKey in interface RichIterable<K>
      Overrides:
      groupByUniqueKey in class AbstractSynchronizedRichIterable<V>
      See Also:
    • aggregateInPlaceBy

      public <KK, VV> MutableMap<KK,VV> aggregateInPlaceBy(Function<? super V,? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Procedure2<? super VV,? super V> mutatingAggregator)
      Description copied from interface: RichIterable
      Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function. Aggregate results are required to be mutable as they will be changed in place by the procedure. A second function specifies the initial "zero" aggregate value to work with (i.e. new AtomicInteger(0)).
      Specified by:
      aggregateInPlaceBy in interface MutableMapIterable<K,V>
      Specified by:
      aggregateInPlaceBy in interface RichIterable<K>
      Overrides:
      aggregateInPlaceBy in class AbstractSynchronizedRichIterable<V>
    • aggregateBy

      public <KK, VV> MutableMapIterable<KK,VV> aggregateBy(Function<? super V,? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Function2<? super VV,? super V,? extends VV> nonMutatingAggregator)
      Description copied from interface: RichIterable
      Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function. Aggregate results are allowed to be immutable as they will be replaced in place in the map. A second function specifies the initial "zero" aggregate value to work with (i.e. Integer.valueOf(0)).
      Specified by:
      aggregateBy in interface MutableMapIterable<K,V>
      Specified by:
      aggregateBy in interface RichIterable<K>
      Overrides:
      aggregateBy in class AbstractSynchronizedRichIterable<V>
    • aggregateBy

      public <K1, V1, V2> MutableMapIterable<K1,V2> aggregateBy(Function<? super K,? extends K1> keyFunction, Function<? super V,? extends V1> valueFunction, Function0<? extends V2> zeroValueFactory, Function2<? super V2,? super V1,? extends V2> nonMutatingAggregator)
      Description copied from interface: MapIterable
      Applies an aggregate function over the map grouping results into a map based on the specific key and value groupBy functions. Aggregate results are allowed to be immutable as they will be replaced in place in the map. A second function specifies the initial "zero" aggregate value to work with.
       MapIterable<String, Interval> map = Maps.mutable.with("oneToFive", Interval.fromTo(1, 5), "sixToNine", Interval.fromTo(6, 9));
      
       MapIterable<String, Long> result = map.aggregateBy(
               eachKey -> {
                   return eachKey.equals("oneToFive")  ? "lessThanSix" : "greaterOrEqualsToSix";
               },
               each -> each.sumOfInt(Integer::intValue),
               () -> 0L,
               (argument1, argument2) -> argument1 + argument2);
      
       MapIterable<String, Long> expected =
               Maps.mutable.with("lessThanSix", Interval.fromTo(1, 5).sumOfInt(Integer::intValue),
                       "greaterOrEqualsToSix", Interval.fromTo(6, 9).sumOfInt(Integer::intValue));
       Assert.assertEquals(expected, result);
       
      Specified by:
      aggregateBy in interface MapIterable<K,V>
      Specified by:
      aggregateBy in interface MutableMapIterable<K,V>
    • keyValuesView

      public RichIterable<Pair<K,V>> keyValuesView()
      Description copied from interface: MapIterable
      Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.
      Specified by:
      keyValuesView in interface MapIterable<K,V>
    • sumByInt

      public <V1> MutableObjectLongMap<V1> sumByInt(Function<? super V,? extends V1> groupBy, IntFunction<? super V> function)
      Description copied from interface: RichIterable
      Groups and sums the values using the two specified functions.
      Specified by:
      sumByInt in interface MutableMapIterable<K,V>
      Specified by:
      sumByInt in interface RichIterable<K>
      Overrides:
      sumByInt in class AbstractSynchronizedRichIterable<V>
    • sumByFloat

      public <V1> MutableObjectDoubleMap<V1> sumByFloat(Function<? super V,? extends V1> groupBy, FloatFunction<? super V> function)
      Description copied from interface: RichIterable
      Groups and sums the values using the two specified functions.
      Specified by:
      sumByFloat in interface MutableMapIterable<K,V>
      Specified by:
      sumByFloat in interface RichIterable<K>
      Overrides:
      sumByFloat in class AbstractSynchronizedRichIterable<V>
    • sumByLong

      public <V1> MutableObjectLongMap<V1> sumByLong(Function<? super V,? extends V1> groupBy, LongFunction<? super V> function)
      Description copied from interface: RichIterable
      Groups and sums the values using the two specified functions.
      Specified by:
      sumByLong in interface MutableMapIterable<K,V>
      Specified by:
      sumByLong in interface RichIterable<K>
      Overrides:
      sumByLong in class AbstractSynchronizedRichIterable<V>
    • sumByDouble

      public <V1> MutableObjectDoubleMap<V1> sumByDouble(Function<? super V,? extends V1> groupBy, DoubleFunction<? super V> function)
      Description copied from interface: RichIterable
      Groups and sums the values using the two specified functions.
      Specified by:
      sumByDouble in interface MutableMapIterable<K,V>
      Specified by:
      sumByDouble in interface RichIterable<K>
      Overrides:
      sumByDouble in class AbstractSynchronizedRichIterable<V>
    • groupBy

      public <V1> MutableMultimap<V1,V> groupBy(Function<? super V,? extends V1> function)
      Description copied from interface: RichIterable
      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);
       

      Example using an anonymous inner class:

       Multimap<String, Person> peopleByLastName =
           people.groupBy(new Function<Person, String>()
           {
               public String valueOf(Person person)
               {
                   return person.getLastName();
               }
           });
       
      Specified by:
      groupBy in interface MutableMapIterable<K,V>
      Specified by:
      groupBy in interface RichIterable<K>
      Overrides:
      groupBy in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • groupByEach

      public <V1> MutableMultimap<V1,V> groupByEach(Function<? super V,? extends Iterable<V1>> function)
      Description copied from interface: RichIterable
      Similar to RichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.
      Specified by:
      groupByEach in interface MutableMapIterable<K,V>
      Specified by:
      groupByEach in interface RichIterable<K>
      Overrides:
      groupByEach in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • zip

      public <S> MutableCollection<Pair<V,S>> zip(Iterable<S> that)
      Description copied from interface: RichIterable
      Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs. If one of the two RichIterables is longer than the other, its remaining elements are ignored.
      Specified by:
      zip in interface MutableMapIterable<K,V>
      Specified by:
      zip in interface RichIterable<K>
      Overrides:
      zip in class AbstractSynchronizedRichIterable<V>
      Type Parameters:
      S - the type of the second half of the returned pairs
      Parameters:
      that - The RichIterable providing the second half of each result pair
      Returns:
      A new RichIterable containing pairs consisting of corresponding elements of this RichIterable and that. The length of the returned RichIterable is the minimum of the lengths of this RichIterable and that.
      Since:
      9.0
    • zipWithIndex

      public MutableCollection<Pair<V,Integer>> zipWithIndex()
      Description copied from interface: RichIterable
      Zips this RichIterable with its indices.
      Specified by:
      zipWithIndex in interface MutableMapIterable<K,V>
      Specified by:
      zipWithIndex in interface RichIterable<K>
      Overrides:
      zipWithIndex in class AbstractSynchronizedRichIterable<V>
      Returns:
      A new RichIterable containing pairs consisting of all elements of this RichIterable paired with their index. Indices start at 0.
      Since:
      9.0
      See Also:
    • select

      public MutableCollection<V> select(Predicate<? super V> predicate)
      Description copied from interface: RichIterable
      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"));
       

      Example using an anonymous inner class:

       RichIterable<Person> selected =
           people.select(new Predicate<Person>()
           {
               public boolean accept(Person person)
               {
                   return person.getAddress().getCity().equals("London");
               }
           });
       
      Specified by:
      select in interface MutableMapIterable<K,V>
      Specified by:
      select in interface RichIterable<K>
      Overrides:
      select in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • selectInstancesOf

      public <S> MutableCollection<S> selectInstancesOf(Class<S> clazz)
      Description copied from interface: RichIterable
      Returns all elements of the source collection that are instances of the Class clazz.
       RichIterable<Integer> integers =
           List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
       
      Specified by:
      selectInstancesOf in interface MutableMapIterable<K,V>
      Specified by:
      selectInstancesOf in interface RichIterable<K>
      Overrides:
      selectInstancesOf in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • selectWith

      public <P> MutableCollection<V> selectWith(Predicate2<? super V,? super P> predicate, P parameter)
      Description copied from interface: RichIterable
      Similar to RichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

      E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

      Example using a Java 8 lambda expression:

       RichIterable<Person> selected =
           people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
       

      Example using an anonymous inner class:

       RichIterable<Person> selected =
           people.selectWith(new Predicate2<Person, Integer>()
           {
               public boolean accept(Person person, Integer age)
               {
                   return person.getAge()>= age;
               }
           }, Integer.valueOf(18));
       
      Specified by:
      selectWith in interface MutableMapIterable<K,V>
      Specified by:
      selectWith in interface RichIterable<K>
      Overrides:
      selectWith in class AbstractSynchronizedRichIterable<V>
      Parameters:
      predicate - a Predicate2 to use as the select criteria
      parameter - a parameter to pass in for evaluation of the second argument P in predicate
      Since:
      9.0
      See Also:
    • rejectWith

      public <P> MutableCollection<V> rejectWith(Predicate2<? super V,? super P> predicate, P parameter)
      Description copied from interface: RichIterable
      Similar to RichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

      E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

      Example using a Java 8 lambda expression:

       RichIterable<Person> rejected =
           people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
       

      Example using an anonymous inner class:

       MutableList<Person> rejected =
           people.rejectWith(new Predicate2<Person, Integer>()
           {
               public boolean accept(Person person, Integer age)
               {
                   return person.getAge() < age;
               }
           }, Integer.valueOf(18));
       
      Specified by:
      rejectWith in interface MutableMapIterable<K,V>
      Specified by:
      rejectWith in interface RichIterable<K>
      Overrides:
      rejectWith in class AbstractSynchronizedRichIterable<V>
      Parameters:
      predicate - a Predicate2 to use as the select criteria
      parameter - a parameter to pass in for evaluation of the second argument P in predicate
      Since:
      9.0
      See Also:
    • partition

      public PartitionMutableCollection<V> partition(Predicate<? super V> predicate)
      Description copied from interface: RichIterable
      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"));
       

      Example using an anonymous inner class:

       PartitionIterable<Person> newYorkersAndNonNewYorkers =
           people.partition(new Predicate<Person>()
           {
               public boolean accept(Person person)
               {
                   return person.getAddress().getState().getName().equals("New York");
               }
           });
       
      Specified by:
      partition in interface MutableMapIterable<K,V>
      Specified by:
      partition in interface RichIterable<K>
      Overrides:
      partition in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • countBy

      public <V1> MutableBag<V1> countBy(Function<? super V,? extends V1> function)
      Description copied from interface: RichIterable
      This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
      Specified by:
      countBy in interface MutableMapIterable<K,V>
      Specified by:
      countBy in interface RichIterable<K>
      Overrides:
      countBy in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • countByWith

      public <V1, P> MutableBag<V1> countByWith(Function2<? super V,? super P,? extends V1> function, P parameter)
      Description copied from interface: RichIterable
      This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.
      Specified by:
      countByWith in interface MutableMapIterable<K,V>
      Specified by:
      countByWith in interface RichIterable<K>
      Overrides:
      countByWith in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
    • countByEach

      public <V1> MutableBag<V1> countByEach(Function<? super V,? extends Iterable<V1>> function)
      Description copied from interface: RichIterable
      This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
      Specified by:
      countByEach in interface MutableMapIterable<K,V>
      Specified by:
      countByEach in interface RichIterable<K>
      Overrides:
      countByEach in class AbstractSynchronizedRichIterable<V>
      Since:
      10.0.0
    • reject

      public MutableCollection<V> reject(Predicate<? super V> predicate)
      Description copied from interface: RichIterable
      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"));
       

      Example using an anonymous inner class:

       RichIterable<Person> rejected =
           people.reject(new Predicate<Person>()
           {
               public boolean accept(Person person)
               {
                   return person.person.getLastName().equals("Smith");
               }
           });
       
      Specified by:
      reject in interface MutableMapIterable<K,V>
      Specified by:
      reject in interface RichIterable<K>
      Overrides:
      reject in class AbstractSynchronizedRichIterable<V>
      Parameters:
      predicate - a Predicate to use as the reject criteria
      Returns:
      a RichIterable that contains elements that cause Predicate.accept(Object) method to evaluate to false
      Since:
      9.0
    • tap

      public MutableMapIterable<K,V> tap(Procedure<? super V> procedure)
      Description copied from interface: RichIterable
      Executes the Procedure for each element in the iterable and returns this.

      Example using a Java 8 lambda expression:

       RichIterable<Person> tapped =
           people.tap(person -> LOGGER.info(person.getName()));
       

      Example using an anonymous inner class:

       RichIterable<Person> tapped =
           people.tap(new Procedure<Person>()
           {
               public void value(Person person)
               {
                   LOGGER.info(person.getName());
               }
           });
       
      Specified by:
      tap in interface MapIterable<K,V>
      Specified by:
      tap in interface MutableMapIterable<K,V>
      Specified by:
      tap in interface RichIterable<K>
      Overrides:
      tap in class AbstractSynchronizedRichIterable<V>
      Since:
      9.0
      See Also: