Class Locator<T,I>
- java.lang.Object
-
- com.google.web.bindery.requestfactory.shared.Locator<T,I>
-
- Type Parameters:
T- the type of domain object the Locator will operate onI- the type of object the Locator expects to use as an id for the domain object
- Direct Known Subclasses:
ValueLocator
public abstract class Locator<T,I> extends java.lang.ObjectA Locator allows entity types that do not conform to the RequestFactory entity protocol to be used. Instead of attempting to use afindFoo(),getId(), andgetVersion()declared in the domain entity type, an instance of a Locator will be created to provide implementations of these methods.Locator subtypes must be default instantiable (i.e. public static types with a no-arg constructor). Instances of Locators may be retained and reused by the RequestFactory service layer.
- See Also:
ProxyFor.locator()
-
-
Constructor Summary
Constructors Constructor Description Locator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Tcreate(java.lang.Class<? extends T> clazz)Create a new instance of the requested type.abstract Tfind(java.lang.Class<? extends T> clazz, I id)Retrieve an object.abstract java.lang.Class<T>getDomainType()Returns theTtype.abstract IgetId(T domainObject)Returns a domain object to be used as the id for the given object.abstract java.lang.Class<I>getIdType()Returns theItype.abstract java.lang.ObjectgetVersion(T domainObject)Returns a domain object to be used as the version for the given object.booleanisLive(T domainObject)Returns a value indicating if the domain object should no longer be considered accessible.
-
-
-
Method Detail
-
create
public abstract T create(java.lang.Class<? extends T> clazz)
Create a new instance of the requested type.- Parameters:
clazz- the type of object to create- Returns:
- the new instance of the domain type
-
find
public abstract T find(java.lang.Class<? extends T> clazz, I id)
Retrieve an object. May returnnullto indicate that the requested object could not be found.- Parameters:
clazz- the type of object to retrieveid- an id previously returned fromgetId(Object)- Returns:
- the requested object or
nullif it could not be found
-
getDomainType
public abstract java.lang.Class<T> getDomainType()
Returns theTtype.
-
getId
public abstract I getId(T domainObject)
Returns a domain object to be used as the id for the given object. This method may returnnullif the object has not been persisted or should be treated as irretrievable.- Parameters:
domainObject- the object to obtain an id for- Returns:
- the object's id or
null
-
getIdType
public abstract java.lang.Class<I> getIdType()
Returns theItype.
-
getVersion
public abstract java.lang.Object getVersion(T domainObject)
Returns a domain object to be used as the version for the given object. This method may returnnullif the object has not been persisted or should be treated as irretrievable.- Parameters:
domainObject- the object to obtain an id for- Returns:
- the object's version or
null
-
isLive
public boolean isLive(T domainObject)
Returns a value indicating if the domain object should no longer be considered accessible. This method might return false if the record underlying the domain object had been deleted as a side-effect of processing a request.The default implementation of this method uses
getId(Object)andfind(Class, Object)to determine if an object can be retrieved.
-
-