/** * Construct a new instance. * * @param key the map key * @param value the map value * @param <K> the key type * @param <V> the value type * @return the entry */ public static <K, V> MapEntry<K, V> entry(K key, V value) { return new MapEntry<K, V>(key, value); }
/** * Compare this entry with another. * * @param obj the other entry * @return {@code true} if this object equals the other {@code MapEntry} instance, {@code false} otherwise */ public boolean equals(final Object obj) { return obj instanceof MapEntry && equals((MapEntry<?, ?>) obj); }
/** * Add entries to a map. * * @param map the map to add to * @param entries the entries to add * @param <K> the key type * @param <V> the value type * @return the map */ public static <K, V> Map<K, V> addTo(Map<K, V> map, MapEntry<? extends K, ? extends V>... entries) { for (MapEntry<? extends K, ? extends V> pair : entries) { map.put(pair.getKey(), pair.getValue()); } return map; } }
/** * Construct a new instance. * * @param key the key * @param value the value * @param <K> the key type * @param <V> the value type * @return the new entry value */ public static <K, V> Value<MapEntry<K, V>> of(Value<K> key, Value<V> value) { return new MapEntryValue<K, V>(MapEntry.entry(key, value)); } }
/** * Construct a new instance. * * @param key the key * @param value the value * @param <K> the key type * @param <V> the value type * @return the new entry value */ public static <K, V> Value<MapEntry<K, V>> of(Value<K> key, Value<V> value) { return new MapEntryValue<K, V>(MapEntry.entry(key, value)); } }
/** * Add entries to a map. * * @param map the map to add to * @param entries the entries to add * @param <K> the key type * @param <V> the value type * @return the map */ public static <K, V> Map<K, V> addTo(Map<K, V> map, MapEntry<? extends K, ? extends V>... entries) { for (MapEntry<? extends K, ? extends V> pair : entries) { map.put(pair.getKey(), pair.getValue()); } return map; } }
/** * Construct a new instance. * * @param key the map key * @param value the map value * @param <K> the key type * @param <V> the value type * @return the entry */ public static <K, V> MapEntry<K, V> entry(K key, V value) { return new MapEntry<K, V>(key, value); }
/** * Compare this entry with another. * * @param obj the other entry * @return {@code true} if this object equals the other {@code MapEntry} instance, {@code false} otherwise */ public boolean equals(final Object obj) { return obj instanceof MapEntry && equals((MapEntry<?, ?>) obj); }
/** {@inheritDoc} */ public Map<K, V> getValue() throws IllegalStateException { final List<MapEntry<? extends Value<? extends K>, ? extends Value<? extends V>>> values = this.values; final Map<K, V> map = mapValue.getValue(); for (MapEntry<? extends Value<? extends K>, ? extends Value<? extends V>> pair : values) { map.put(pair.getKey().getValue(), pair.getValue().getValue()); } return map; } }
/** {@inheritDoc} */ public Map<K, V> getValue() throws IllegalStateException { final List<MapEntry<? extends Value<? extends K>, ? extends Value<? extends V>>> values = this.values; final Map<K, V> map = mapValue.getValue(); for (MapEntry<? extends Value<? extends K>, ? extends Value<? extends V>> pair : values) { map.put(pair.getKey().getValue(), pair.getValue().getValue()); } return map; } }