Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public Class Relation<K, V>

extends Object
implements Freezable<Relation<K, V>>
Class Inheritance
All Implemented Interfaces
com.ibm.icu.util.Freezable, java.lang.Cloneable
Imports
java.lang.reflect.Constructor, java.util.Arrays, .Collection, .Collections, .Comparator, .HashMap, .LinkedHashSet, .Map, .Map.Entry, .Set, com.ibm.icu.util.Freezable

A Relation is a set of mappings from keys to values. Unlike Map, there is not guaranteed to be a single value per key. The Map-like APIs return collections for values.
Author
medavis

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private Map<K, Set<V>>
pack-priv volatile boolean
pack-priv Object[]
pack-priv Constructor<? extends Set<V>>

Constructor Summary

AccessConstructor and Description
public
Relation(Map<K, Set<V>> map, Class<?> setCreator)

public
Relation(Map<K, Set<V>> map, Class<?> setCreator, Comparator<V> setComparator)

Method Summary

Modifier and TypeMethod and Description
public Relation<K, V>
addAllInverted(Relation<V, K> source)

public Relation<K, V>
addAllInverted(Map<V, K> source)

public void
public Relation<K, V>
cloneAsThawed()

Implements com.ibm.icu.util.Freezable.cloneAsThawed.

Provides for the clone operation.
public boolean
public boolean
public final Set<Map.Entry<K, V>>
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Relation<K, V>
freeze()

Implements com.ibm.icu.util.Freezable.freeze.

Freezes the object.
public Set<V>
get(Object key)

public Set<V>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
public boolean
isFrozen()

Implements com.ibm.icu.util.Freezable.isFrozen.

Determines whether the object has been frozen or not.
public Set<K>
public Set<Map.Entry<K, V>>
public Set<Map.Entry<K, Set<V>>>
private Set<V>
public static <K, V> Relation<K, V>
of(Map<K, Set<V>> map, Class<?> setCreator)

public static <K, V> Relation<K, V>
of(Map<K, Set<V>> map, Class<?> setCreator, Comparator<V> setComparator)

public V
put(K key, V value)

public V
putAll(K key, Collection<? extends V> values)

public V
putAll(Collection<K> keys, V value)

public void
putAll(Map<? extends K, ? extends V> t)

public void
putAll(Relation<? extends K, ? extends V> t)

public boolean
remove(K key, V value)

public Set<V>
removeAll(K key)

public boolean
removeAll(Relation<K, V> toBeRemoved)

public final Set<V>
removeAll(K... keys)

public boolean
removeAll(K key, Iterable<V> toBeRemoved)

public Set<V>
removeAll(Collection<K> toBeRemoved)

public int
size()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Set<V>
public <C extends Collection<V>> C
values(C result)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

databack to summary
private Map<K, Set<V>> data
frozenback to summary
pack-priv volatile boolean frozen
setComparatorParamback to summary
pack-priv Object[] setComparatorParam
setCreatorback to summary
pack-priv Constructor<? extends Set<V>> setCreator

Constructor Detail

Relationback to summary
public Relation(Map<K, Set<V>> map, Class<?> setCreator)
Relationback to summary
public Relation(Map<K, Set<V>> map, Class<?> setCreator, Comparator<V> setComparator)
Annotations
@SuppressWarnings:unchecked

Method Detail

addAllInvertedback to summary
public Relation<K, V> addAllInverted(Relation<V, K> source)
addAllInvertedback to summary
public Relation<K, V> addAllInverted(Map<V, K> source)
clearback to summary
public void clear()
cloneAsThawedback to summary
public Relation<K, V> cloneAsThawed()

Implements com.ibm.icu.util.Freezable.cloneAsThawed.

Doc from com.ibm.icu.util.Freezable.cloneAsThawed.

Provides for the clone operation. Any clone is initially unfrozen.

Annotations
@Override
containsKeyback to summary
public boolean containsKey(Object key)
containsValueback to summary
public boolean containsValue(Object value)
entrySetback to summary
public final Set<Map.Entry<K, V>> entrySet()
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
freezeback to summary
public Relation<K, V> freeze()

Implements com.ibm.icu.util.Freezable.freeze.

Doc from com.ibm.icu.util.Freezable.freeze.

Freezes the object.

Returns:Relation<K, V>

the object itself.

Annotations
@Override
getback to summary
public Set<V> get(Object key)
getAllback to summary
public Set<V> getAll(Object key)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()
isFrozenback to summary
public boolean isFrozen()

Implements com.ibm.icu.util.Freezable.isFrozen.

Doc from com.ibm.icu.util.Freezable.isFrozen.

Determines whether the object has been frozen or not.

Annotations
@Override
keySetback to summary
public Set<K> keySet()
keyValueSetback to summary
public Set<Map.Entry<K, V>> keyValueSet()
keyValuesSetback to summary
public Set<Map.Entry<K, Set<V>>> keyValuesSet()
newSetback to summary
private Set<V> newSet()
ofback to summary
public static <K, V> Relation<K, V> of(Map<K, Set<V>> map, Class<?> setCreator)
ofback to summary
public static <K, V> Relation<K, V> of(Map<K, Set<V>> map, Class<?> setCreator, Comparator<V> setComparator)
putback to summary
public V put(K key, V value)
putAllback to summary
public V putAll(K key, Collection<? extends V> values)
putAllback to summary
public V putAll(Collection<K> keys, V value)
putAllback to summary
public void putAll(Map<? extends K, ? extends V> t)
putAllback to summary
public void putAll(Relation<? extends K, ? extends V> t)
removeback to summary
public boolean remove(K key, V value)
removeAllback to summary
public Set<V> removeAll(K key)
removeAllback to summary
public boolean removeAll(Relation<K, V> toBeRemoved)
removeAllback to summary
public final Set<V> removeAll(K... keys)
Annotations
@SafeVarargs
@SuppressWarnings:varargs
removeAllback to summary
public boolean removeAll(K key, Iterable<V> toBeRemoved)
removeAllback to summary
public Set<V> removeAll(Collection<K> toBeRemoved)
sizeback to summary
public int size()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
valuesback to summary
public Set<V> values()
valuesback to summary
public <C extends Collection<V>> C values(C result)
com.ibm.icu.impl back to summary

pack-priv Class Relation.SimpleEntry<K, V>

extends Object
implements Map.Entry<K, V>
Class Inheritance
All Implemented Interfaces
java.util.Map.Entry

Field Summary

Modifier and TypeField and Description
pack-priv K
pack-priv V

Constructor Summary

AccessConstructor and Description
public
SimpleEntry(K key, V value)

public

Method Summary

Modifier and TypeMethod and Description
public K
getKey()

Implements java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.
public V
getValue()

Implements java.util.Map.Entry.getValue.

Returns the value corresponding to this entry.
public V
setValue(V
new value to be stored in this entry
value
)

Implements java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
pack-priv K key
valueback to summary
pack-priv V value

Constructor Detail

SimpleEntryback to summary
public SimpleEntry(K key, V value)
SimpleEntryback to summary
public SimpleEntry(Map.Entry<K, V> e)

Method Detail

getKeyback to summary
public K getKey()

Implements java.util.Map.Entry.getKey.

Doc from java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.

Returns:K

the key corresponding to this entry

Annotations
@Override
getValueback to summary
public V getValue()

Implements java.util.Map.Entry.getValue.

Doc from java.util.Map.Entry.getValue.

Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Returns:V

the value corresponding to this entry

Annotations
@Override
setValueback to summary
public V setValue(V value)

Implements java.util.Map.Entry.setValue.

Doc from java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Parameters
value:V

new value to be stored in this entry

Returns:V

old value corresponding to the entry

Annotations
@Override