Package com.oracle.coherence.common.base
Class NaturalAssociator
- java.lang.Object
-
- com.oracle.coherence.common.base.NaturalAssociator
-
- All Implemented Interfaces:
Associator
- Direct Known Subclasses:
DefaultKeyAssociator
public class NaturalAssociator extends Object implements Associator
NaturalAssociator provides an Associator implementation for objects that implement theAssociated
interface.- Author:
- gg 2012.03.11
-
-
Constructor Summary
Constructors Constructor Description NaturalAssociator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getAssociatedKey(Object o)
Determine the host key (or base) object to which the specified object is associated.protected Object
validateAssociated(Associated assoc)
Check if given Associated object generates a circular association.
-
-
-
Method Detail
-
getAssociatedKey
public Object getAssociatedKey(Object o)
Determine the host key (or base) object to which the specified object is associated.Note: It's expected that the returned object is suitable to be used as an immutable identity (e.g. a key in a Map).
Note 2: Circular associations are not permitted.- Specified by:
getAssociatedKey
in interfaceAssociator
- Parameters:
o
- the object to obtain an association for- Returns:
- the host key that for this object, or null if this object has no association
-
validateAssociated
protected Object validateAssociated(Associated assoc)
Check if given Associated object generates a circular association.- Parameters:
assoc
- an Associated object to check- Returns:
- the key object that is associated with the specified object, or null if there is no association
- Throws:
RuntimeException
- if there is a circular key association chain, or if the maximum association depth has been reached
-
-