public abstract class

Locator

extends Object
java.lang.Object
   ↳ com.google.gwt.requestfactory.shared.Locator<T, I>

Class Overview

A Locator allows entity types that do not conform to the RequestFactory entity protocol to be used. Instead of attempting to use a findFoo(), getId(), and getVersion() 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()

Summary

Public Constructors
Locator()
Public Methods
abstract T create(Class<? extends T> clazz)
Create a new instance of the requested type.
abstract T find(Class<? extends T> clazz, I id)
Retrieve an object.
abstract Class<T> getDomainType()
Returns the T type.
abstract I getId(T domainObject)
Returns a domain object to be used as the id for the given object.
abstract Class<I> getIdType()
Returns the I type.
abstract Object getVersion(T domainObject)
Returns a domain object to be used as the version for the given object.
boolean isLive(T domainObject)
Returns a value indicating if the domain object should no longer be considered accessible.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Locator ()

Public Methods

public abstract T create (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

public abstract T find (Class<? extends T> clazz, I id)

Retrieve an object. May return null to indicate that the requested object could not be found.

Parameters
clazz the type of object to retrieve
id an id previously returned from getId(Object)
Returns
  • the requested object or null if it could not be found

public abstract Class<T> getDomainType ()

Returns the T type.

public abstract I getId (T domainObject)

Returns a domain object to be used as the id for the given object. This method may return null if 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

public abstract Class<I> getIdType ()

Returns the I type.

public abstract Object getVersion (T domainObject)

Returns a domain object to be used as the version for the given object. This method may return null if 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

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) and find(Class, Object) to determine if an object can be retrieved.