| Modifier and Type | Field and Description |
|---|---|
| private final K | |
| private final K | |
| private static final long | |
| private final V | |
| private final V |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public <K2, V2> ImmutableMap | collect(Function2<? super K, ? super V, Pair<K2, V2>> function)
Overrides org. Implements org. For each key and value of the map the function is evaluated. |
| public <R> ImmutableMap | collectValues(Function2<? super K, ? super V, ? extends R> function)
Overrides org. Implements org. For each key and value of the map the function is evaluated. |
| public boolean | containsKey(Object key)
Implements org. Returns |
| public boolean | containsValue(Object value)
Implements org. Returns |
| public Pair | detect(Predicate2<? super K, ? super V> predicate)
Overrides org. Implements org. Return the first key and value of the map for which the predicate evaluates to true when they are given as arguments. |
| public boolean | equals(Object other)
Overrides java. Implements org. Compares the specified object with this map for equality. |
| private ImmutableMap | |
| public ImmutableMap | flipUniqueValues()
Overrides org. Implements org. Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key. |
| public void | forEachKey(Procedure<? super K> procedure)
Overrides org. Implements org. Calls the |
| public void | forEachKeyValue(Procedure2<? super K, ? super V> procedure)
Implements org. Calls the |
| public void | forEachValue(Procedure<? super V> procedure)
Overrides org. Implements org. Calls the procedure with each value of the map. |
| public <P> void | forEachWith(Procedure2<? super V, ? super P> procedure, P parameter)
Overrides org. Implements org. The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument. |
| public void | forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)
Overrides org. Implements org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. |
| public V | get(Object key)
Implements org. Returns the value to which the specified key is mapped,
or |
| public V | getOnly()
Overrides org. Overrides default org. Returns the element if the iterable has exactly one element. |
| public int | hashCode()
Overrides java. Implements org. Returns the hash code value for this map. |
| public Set | |
| public RichIterable | keysView()
Implements org. Returns an unmodifiable lazy iterable wrapped around the keySet for the map. |
| public RichIterable | keyValuesView()
Implements org. Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map. |
| public ImmutableMap | reject(Predicate2<? super K, ? super V> predicate)
Overrides org. Implements org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map. |
| public ImmutableMap | select(Predicate2<? super K, ? super V> predicate)
Overrides org. Implements org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map. |
| public int | size()
Implements org. Returns the number of key-value mappings in this map. |
| public String | toString()
Overrides org. Implements org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. |
| public Collection | values()
Implements java. Returns a |
| public RichIterable | valuesView()
Implements org. Returns an unmodifiable lazy iterable wrapped around the values for the map. |
| private Object |
| key1 | back to summary |
|---|---|
| private final K key1 | |
| key2 | back to summary |
|---|---|
| private final K key2 | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| value1 | back to summary |
|---|---|
| private final V value1 | |
| value2 | back to summary |
|---|---|
| private final V value2 | |
| ImmutableDoubletonMap | back to summary |
|---|---|
| pack-priv ImmutableDoubletonMap(K key1, V value1, K key2, V value2) | |
| collect | back to summary |
|---|---|
| public <K2, V2> ImmutableMap Overrides org. Implements org. Doc from org. For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.
MapIterable<String, String> collected =
peopleByCity.collect((City city, Person person) -> Pair.of(city.getCountry(), person.getAddress().getCity()));
| |
| collectValues | back to summary |
|---|---|
| public <R> ImmutableMap Overrides org. Implements org. Doc from org. For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.
MapIterable<City, String> collected =
peopleByCity.collectValues((City city, Person person) -> person.getFirstName() + " " + person.getLastName());
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Implements org. Doc from java. Returns
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Implements org. Doc from java. Returns
| |
| detect | back to summary |
|---|---|
| public Pair Overrides org. Implements org. Doc from org. 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 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"));
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Implements org. Doc from java. Compares the specified object with this map for equality. Returns
| |
| filter | back to summary |
|---|---|
| private ImmutableMap | |
| flipUniqueValues | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org. Doc from org. Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key.
MapIterable<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
MapIterable<String, Integer> result = map.flipUniqueValues();
Assert.assertTrue(result.equals(UnifiedMap.newWithKeysValues("1", 1, "2", 2, "3", 3)));
| |
| forEachKey | back to summary |
|---|---|
| public void forEachKey(Procedure<? super K> procedure) Overrides org. Implements org. Doc from org. Calls the
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);
| |
| forEachKeyValue | back to summary |
|---|---|
| public void forEachKeyValue(Procedure2<? super K, ? super V> procedure) Implements org. Doc from org. Calls the
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");
| |
| forEachValue | back to summary |
|---|---|
| public void forEachValue(Procedure<? super V> procedure) Overrides org. Implements org. Doc from org. 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);
| |
| forEachWith | back to summary |
|---|---|
| public <P> void forEachWith(Procedure2<? super V, ? super P> procedure, P parameter) Overrides org. Implements org. Doc from org. The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument. Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) ->
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}, fred);
Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>()
{
public void value(Person person, Person other)
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}
}, fred);
| |
| forEachWithIndex | back to summary |
|---|---|
| public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) Overrides org. Implements org. Doc from org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>()
{
public void value(Person person, int index)
{
LOGGER.info("Index: " + index + " person: " + person.getName());
}
});
| |
| get | back to summary |
|---|---|
| public V get(Object key) Implements org. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| getOnly | back to summary |
|---|---|
| public V getOnly() Overrides org. Overrides default org. Doc from org. Returns the element if the iterable has exactly one element. Otherwise, throw
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from java. Returns the hash code value for this map. The hash code of a map is
defined to be the sum of the hash codes of each entry in the map's
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a
| |
| keysView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable wrapped around the keySet for the map.
| |
| keyValuesView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.
| |
| reject | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org. Doc from org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map.
MapIterable<City, Person> rejected =
peopleByCity.reject((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| select | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org. Doc from org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map.
MapIterable<City, Person> selected =
peopleByCity.select((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Implements org. Doc from 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}", Maps.mutable.with(1, 1, 2, 2, 3, 3).toString());
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Doc from java. Returns a
| |
| valuesView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable wrapped around the values for the map.
| |
| writeReplace | back to summary |
|---|---|
| private Object writeReplace() | |