ImmutableMap
| Modifier and Type | Field and Description |
|---|---|
| private final UnifiedMapWithHashingStrategy | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ImmutableUnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K, V>... pairs)
|
| delegate | back to summary |
|---|---|
| private final UnifiedMapWithHashingStrategy<K, V> delegate | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ImmutableUnifiedMapWithHashingStrategy | back to summary |
|---|---|
| public ImmutableUnifiedMapWithHashingStrategy(UnifiedMapWithHashingStrategy<K, V> delegate) | |
| ImmutableUnifiedMapWithHashingStrategy | back to summary |
|---|---|
| public ImmutableUnifiedMapWithHashingStrategy(HashingStrategy<? super K> hashingStrategy, Pair<K, V>... pairs) | |
| batchForEach | back to summary |
|---|---|
| public void batchForEach(Procedure<? super V> procedure, int sectionIndex, int sectionCount) Implements org.
| |
| 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
| |
| entrySet | back to summary |
|---|---|
| public Set Overrides org. Implements java. Doc from java. Returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements org. Doc from java. Compares the specified object with this map for equality. Returns
| |
| 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
| |
| getBatchCount | back to summary |
|---|---|
| public int getBatchCount(int batchSize) Implements org.
| |
| 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.
| |
| newWithAllKeyValueArguments | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| newWithAllKeyValues | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| newWithKeyValue | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| newWithMap | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| newWithMapIterable | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| newWithoutAllKeys | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| newWithoutKey | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org.
| |
| 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 |
|---|---|
| protected Object writeReplace() | |