|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.errai.jpa.client.local.Key<X,T>
X
- The entity's Java typeT
- The entity's identity typepublic class Key<X,T>
Holder class for a storage key: a tuple of type and identity value.
Instances of this class are immutable.
Constructor Summary | |
---|---|
Key(ErraiManagedType<X> entityType,
T id)
Creates a key that uniquely identifies an entity of a particular type (the entity with this identity does not necessarily exist, but if it did, this would be its identity). |
Method Summary | ||
---|---|---|
boolean |
equals(Object obj)
|
|
static Key<?,?> |
fromJson(ErraiEntityManager em,
String key,
boolean failIfNotFound)
Returns a Key instance based on the given JSON string. |
|
static Key<?,?> |
fromJsonObject(ErraiEntityManager em,
com.google.gwt.json.client.JSONObject key,
boolean failIfNotFound)
Returns a Key instance based on the given JSON object. |
|
static
|
get(ErraiEntityManager em,
Class<X> entityClass,
T id)
Returns a Key instance for the entity type of the given class. |
|
ErraiManagedType<X> |
getEntityType()
Returns the managed type this key refers to. |
|
T |
getId()
Returns the ID value for this key. |
|
int |
hashCode()
|
|
String |
toJson()
Returns a JSON string representation of this key which can be turned back into a Key instance via fromJson(ErraiEntityManager, String, boolean) . |
|
com.google.gwt.json.client.JSONObject |
toJsonObject()
Returns a JSONObject representation of this key which can be turned back into a Key instance via fromJsonObject(ErraiEntityManager, JSONObject, boolean) . |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Key(ErraiManagedType<X> entityType, T id)
entityType
- The type of the entity. Must not be null.id
- The ID of the entity. Must not be null.
NullPointerException
- if either argument is null.Method Detail |
---|
public static <X,T> Key<X,T> get(ErraiEntityManager em, Class<X> entityClass, T id)
em
- The entity manager (required for looking up the EntityType for the
given class). Must not be null.entityClass
- The class of the entity for the key. Must not be null.id
- The ID value for the entity. Must not be null.
NullPointerException
- if any argument is null.
IllegalArgumentException
- if entityClass
is not a known JPA entity type.public ErraiManagedType<X> getEntityType()
public T getId()
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
public String toJson()
fromJson(ErraiEntityManager, String, boolean)
.
toJsonObject()
public com.google.gwt.json.client.JSONObject toJsonObject()
fromJsonObject(ErraiEntityManager, JSONObject, boolean)
.
toJson()
public static Key<?,?> fromJson(ErraiEntityManager em, String key, boolean failIfNotFound)
em
- The entity manager that can be used to look up the entity type
corresponding with the key.key
- The key to parse.failIfNotFound
- If true, and the entity type given in key
is not known to
em
, an IllegalArgumentException will be thrown.
public static Key<?,?> fromJsonObject(ErraiEntityManager em, com.google.gwt.json.client.JSONObject key, boolean failIfNotFound)
em
- The entity manager that can be used to look up the entity type
corresponding with the key.key
- The properties of the key to create.failIfNotFound
- If true, and the entity type given in key
is not known to
em
, an IllegalArgumentException will be thrown.
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |