K - public final class MapKeys<K> extends Object
MapKeys is used to construct maps in a fluid manner. They can be
created using Expressive.mapKeys(Object...) and
Expressive.mapKeys(List).
A map is created by invoking to(List) or to(Object...),
which will create a map by pairing the ordered list of keys supplied at
construction time against the ordered set of values passed to the 'to'
method.
The map created will have as many entries as keys. That is if more keys were added than values, those keys without a value pairing will be mapped to null. If more values are supplied than keys, these values will not be present in the resulting map.
When both keys and values are added they are added as an ordered collection, not as a set. This means that it is possible to add keys which are duplicates as considered by their hashcode and equals methods. If this happens, the resulting map will contain the key/value pair that was added last. for example the map created by:
map = Expressive.mapKeys(1, 2, 3, 1).to("a", "b", "c", "d");
will have three entries, 1 -> "d", 2 -> "b", 3 -> "c"
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
int |
size() |
<V> Map<K,V> |
to(List<V> values)
A map is created by invoking
to(List) or to(Object...),
which will create a map by pairing the ordered list of keys supplied at
construction time against the ordered set of values passed to the 'to'
method. |
<V> Map<K,V> |
to(V... values)
A map is created by invoking
to(List) or to(Object...),
which will create a map by pairing the ordered list of keys supplied at
construction time against the ordered set of values passed to the 'to'
method. |
String |
toString() |
public <V> Map<K,V> to(List<V> values)
A map is created by invoking to(List) or to(Object...),
which will create a map by pairing the ordered list of keys supplied at
construction time against the ordered set of values passed to the 'to'
method.
The map created will have as many entries as keys. That is if more keys were added than values, those keys without a value pairing will be mapped to null. If more values are supplied than keys, these values will not be present in the resulting map.
When both keys and values are added they are added as an ordered collection, not as a set. This means that it is possible to add keys which are duplicates as considered by their hashcode and equals methods. If this happens, the resulting map will contain the key/value pair that was added last. for example the map created by:
map = Expressive.mapKeys(1, 2, 3, 1).to("a", "b", "c", "d");
will have three entries, 1 -> "d", 2 -> "b", 3 -> "c"
V - values - public <V> Map<K,V> to(V... values)
A map is created by invoking to(List) or to(Object...),
which will create a map by pairing the ordered list of keys supplied at
construction time against the ordered set of values passed to the 'to'
method.
The map created will have as many entries as keys. That is if more keys were added than values, those keys without a value pairing will be mapped to null. If more values are supplied than keys, these values will not be present in the resulting map.
When both keys and values are added they are added as an ordered collection, not as a set. This means that it is possible to add keys which are duplicates as considered by their hashcode and equals methods. If this happens, the resulting map will contain the key/value pair that was added last. for example the map created by:
map = Expressive.mapKeys(1, 2, 3, 1).to("a", "b", "c", "d");
will have three entries, 1 -> "d", 2 -> "b", 3 -> "c"
V - values - public int size()
MapKeysCopyright © 2013 Atomic Leopard. All Rights Reserved.