public abstract class Ref<T> extends Object implements Serializable, Comparable<Ref<T>>
Ref> is a Key> which allows the entity value to be fetched directly.
Note that the methods might or might not throw runtime exceptions related to datastore operations; ConcurrentModificationException, DatastoreTimeoutException, DatastoreFailureException, and DatastoreNeedIndexException. Some Refs hide datastore operations that could throw these exceptions.
Modifier and Type | Field and Description |
---|---|
protected Key<T> |
key
The key associated with this ref
|
Modifier | Constructor and Description |
---|---|
protected |
Ref()
For GWT serialization
|
protected |
Ref(Key<T> key)
Create a Ref based on the key, with the specified session
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Ref<T> o)
Comparison is based on key
|
static <T> Ref<T> |
create(Key<T> key)
Key.create(Blah.class, id) is easier to type than new Key
|
static <T> Ref<T> |
create(T value)
Creates a Ref from a registered pojo entity
|
boolean |
equals(Object obj)
Equality comparison is based on key equivalence
|
boolean |
equivalent(Key<T> other)
Type safe comparison for key equivalence
|
boolean |
equivalent(Ref<T> other)
Type-safe comparison for key equivalence
|
abstract T |
get()
Obtain the entity value associated with the key.
|
Key<T> |
getKey()
Same as key() but conforms to JavaBeans conventions in case this is being processed by a JSON
converter or expression language.
|
T |
getValue()
This method exists to facilitate serialization via javabeans conventions.
|
int |
hashCode()
Hash code is simply that of key
|
abstract boolean |
isLoaded()
If an entity has been loaded into the session or is otherwise available, this will return true.
|
Key<T> |
key() |
T |
safe()
Obtain the entity value, throwing an exception if the entity was not found.
|
String |
toString()
Renders some info about the key
|
public static <T> Ref<T> create(Key<T> key)
public static <T> Ref<T> create(T value)
public abstract T get()
public abstract boolean isLoaded()
public final T getValue()
public final Key<T> getKey()
public final T safe() throws NotFoundException
NotFoundException
- if the specified entity was not foundpublic int compareTo(Ref<T> o)
compareTo
in interface Comparable<Ref<T>>
public boolean equals(Object obj)
Copyright © 2016. All rights reserved.