org.persvr.data
Class Identification<T>

java.lang.Object
  extended by org.persvr.data.Identification<T>
Type Parameters:
T - base type of objects that can be referred to
All Implemented Interfaces:
TargetRetriever<T>
Direct Known Subclasses:
JsonPath, LazyPropertyId, ObjectId, ObjectPath

public abstract class Identification<T>
extends java.lang.Object
implements TargetRetriever<T>

An Identification represents an id of object or a value. This allows objects or values to be reference without the actual object being loaded into the object graph yet. When the object or value is needed, the identification object can retrieve it (by calling getTarget)

Author:
Kris Zyp

Field Summary
 DataSource source
           
 java.lang.String subObjectId
           
 
Constructor Summary
Identification()
           
 
Method Summary
 DataSource getSource()
           
 java.lang.String getSubObjectId()
           
 T getTarget()
          Retrieves the value or object referred to by this identification
static Identification<? extends java.lang.Object> idForRelativeString(java.lang.String startingId, java.lang.String targetId)
           
static Identification<? extends java.lang.Object> idForString(java.lang.String value)
           
 boolean isForeign()
           
 boolean isLoaded()
           
protected  java.lang.String relativePath(java.lang.String originalPath, java.lang.String newPath)
           
protected abstract  T resolveTarget()
          Implementations should implement this to resolve a target when it has not been loaded yet
 java.lang.String toString()
           
 java.lang.String toString(DataSource relativeSource, java.lang.String relativeSubPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subObjectId

public java.lang.String subObjectId

source

public DataSource source
Constructor Detail

Identification

public Identification()
Method Detail

idForString

public static Identification<? extends java.lang.Object> idForString(java.lang.String value)

idForRelativeString

public static Identification<? extends java.lang.Object> idForRelativeString(java.lang.String startingId,
                                                                             java.lang.String targetId)

isLoaded

public boolean isLoaded()

isForeign

public boolean isForeign()

resolveTarget

protected abstract T resolveTarget()
Implementations should implement this to resolve a target when it has not been loaded yet

Returns:
object referred to by identification

getTarget

public T getTarget()
Retrieves the value or object referred to by this identification

Specified by:
getTarget in interface TargetRetriever<T>
Returns:
object referred to by identification

getSubObjectId

public java.lang.String getSubObjectId()

getSource

public DataSource getSource()

relativePath

protected java.lang.String relativePath(java.lang.String originalPath,
                                        java.lang.String newPath)

toString

public java.lang.String toString(DataSource relativeSource,
                                 java.lang.String relativeSubPath)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object