|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.objectify.impl.TypeUtils
public class TypeUtils
Nested Class Summary | |
---|---|
static class |
TypeUtils.FieldMetadata
Simple container that groups the names associated with fields. |
static class |
TypeUtils.MethodMetadata
Simple container that groups the names associated with @AlsoLoad methods. |
Constructor Summary | |
---|---|
TypeUtils()
|
Method Summary | ||
---|---|---|
static java.lang.reflect.Type |
climbTypeHierarchy(java.lang.Class<?> here,
java.lang.Class<?> parentClass)
Climb the type hierarchy in the direction of parentClass. |
|
static java.util.Collection<java.lang.Object> |
createCollection(java.lang.Class<?> type,
int size)
Create a collection of the appropriate type. |
|
static java.lang.String |
extendPropertyPath(java.lang.String prefix,
java.lang.String name)
Extend a property path, adding a '.' separator but also checking for the first element. |
|
static java.lang.Object |
field_get(java.lang.reflect.Field field,
java.lang.Object obj)
Checked exceptions are LAME. |
|
static void |
field_set(java.lang.reflect.Field field,
java.lang.Object obj,
java.lang.Object value)
Checked exceptions are LAME. |
|
static java.util.List<TypeUtils.MethodMetadata> |
getAlsoLoadMethods(java.lang.Class<?> clazz)
Get all the methods that are appropriate for saving into on this class and all superclasses. |
|
static java.lang.Class<?> |
getClass(java.lang.reflect.Type type)
Get the underlying class for a type, or null if the type is a variable type. |
|
static java.lang.Class<?> |
getComponentType(java.lang.Class<?> type,
java.lang.reflect.Type genericType)
If getType() is an array or Collection, returns the component type - otherwise null |
|
static
|
getConstructor(java.lang.Class<T> clazz,
java.lang.Class<?>... args)
Gets a constructor that has the specified types of arguments. |
|
static java.lang.reflect.Field |
getDeclaredField(java.lang.Class<?> clazz,
java.lang.String fieldName)
A recursive version of Class.getDeclaredField, goes up the hierarchy looking |
|
static java.lang.Class<?> |
getMapValueType(java.lang.reflect.Type genericType)
Returns the value type, i.e. |
|
static
|
getNoArgConstructor(java.lang.Class<T> clazz)
Throw an IllegalStateException if the class does not have a no-arg constructor. |
|
static java.util.Set<java.lang.Integer> |
getNullIndexes(com.google.appengine.api.datastore.Entity entity,
java.lang.String pathBase)
Gets the embedded null indexes property in an entity. |
|
static java.lang.String |
getNullIndexPath(Path pathBase)
|
|
static java.lang.String |
getNullIndexPath(java.lang.String pathBase)
|
|
static java.util.List<TypeUtils.FieldMetadata> |
getPesistentFields(java.lang.Class<?> clazz,
boolean embedded)
Get all the persistent fields on a class, checking the superclasses as well. |
|
static
|
getTypeArguments(java.lang.Class<T> baseClass,
java.lang.Class<? extends T> childClass)
Get the actual type arguments a child class has used to extend a generic base class. |
|
static boolean |
isArrayOrCollection(java.lang.Class<?> clazz)
|
|
static boolean |
isAssignableFrom(java.lang.Class<?> to,
java.lang.Class<?> from)
Just like Class.isAssignableFrom(), but does the right thing when considering autoboxing. |
|
static java.lang.Boolean |
isClassIndexed(java.lang.Class<?> clazz)
Inspects a specific class and determines if there is a default indexed state; @Indexed = true, @Unindexed = false, nothing specified = null. |
|
static boolean |
isEmbedded(java.lang.reflect.Field field)
Determines if the field is embedded or not. |
|
static boolean |
isSaveable(java.lang.reflect.Field field)
|
|
static
|
newInstance(java.lang.Class<T> clazz)
Checked exceptions are LAME. |
|
static
|
newInstance(java.lang.reflect.Constructor<T> ctor,
java.lang.Object... params)
Checked exceptions are LAME. |
|
static java.util.Collection<java.lang.Object> |
prepareCollection(java.lang.Object onPojo,
Wrapper collectionField,
int size)
Prepare a collection of the appropriate type and place it on the pojo's field. |
|
static void |
setNullIndexes(com.google.appengine.api.datastore.Entity entity,
Path subPath,
java.util.Collection<java.lang.Integer> value)
Sets the embedded null indexes property in an entity, which tracks which elements of a collection are null. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeUtils()
Method Detail |
---|
public static <T> java.lang.reflect.Constructor<T> getNoArgConstructor(java.lang.Class<T> clazz)
public static <T> java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<T> clazz, java.lang.Class<?>... args)
public static boolean isSaveable(java.lang.reflect.Field field)
public static java.lang.Class<?> getComponentType(java.lang.Class<?> type, java.lang.reflect.Type genericType)
public static java.lang.Class<?> getMapValueType(java.lang.reflect.Type genericType)
T
for a generic Map<String, T>
.
public static java.lang.String extendPropertyPath(java.lang.String prefix, java.lang.String name)
public static java.util.Collection<java.lang.Object> prepareCollection(java.lang.Object onPojo, Wrapper collectionField, int size)
Prepare a collection of the appropriate type and place it on the pojo's field. The rules are described in createCollection(), with the addition that any collection already found in the object's field will be returned as-is; a new collection will not be created.
collectionField
- is a Collection-derived field on the pojo.onPojo
- is the object whose field should be setpublic static java.util.Collection<java.lang.Object> createCollection(java.lang.Class<?> type, int size)
Create a collection of the appropriate type. The rules are thus:
type
- is a Collection-derived typepublic static void setNullIndexes(com.google.appengine.api.datastore.Entity entity, Path subPath, java.util.Collection<java.lang.Integer> value)
Sets the embedded null indexes property in an entity, which tracks which elements of a collection are null. For a base of "foo.bar", the state property will be "foo.bar^null". The value, if present, will be a list of indexes in an embedded collection which are null.
If there are no nulls, this property does not need to be set.
public static java.util.Set<java.lang.Integer> getNullIndexes(com.google.appengine.api.datastore.Entity entity, java.lang.String pathBase)
Gets the embedded null indexes property in an entity.
setNullIndexes(Entity, Path, Collection)
public static java.lang.String getNullIndexPath(Path pathBase)
public static java.lang.String getNullIndexPath(java.lang.String pathBase)
public static boolean isArrayOrCollection(java.lang.Class<?> clazz)
public static boolean isEmbedded(java.lang.reflect.Field field)
public static <T> T newInstance(java.lang.Class<T> clazz)
public static <T> T newInstance(java.lang.reflect.Constructor<T> ctor, java.lang.Object... params)
public static java.lang.Object field_get(java.lang.reflect.Field field, java.lang.Object obj)
public static void field_set(java.lang.reflect.Field field, java.lang.Object obj, java.lang.Object value)
public static java.util.List<TypeUtils.FieldMetadata> getPesistentFields(java.lang.Class<?> clazz, boolean embedded)
embedded
- will add fields marked with @Id and @Parent to the persistent fields.
You only do this when you are embedding entities within other entities.
public static java.util.List<TypeUtils.MethodMetadata> getAlsoLoadMethods(java.lang.Class<?> clazz)
public static java.lang.reflect.Field getDeclaredField(java.lang.Class<?> clazz, java.lang.String fieldName) throws java.lang.NoSuchFieldException
java.lang.NoSuchFieldException
public static java.lang.Class<?> getClass(java.lang.reflect.Type type)
public static <T> java.util.List<java.lang.Class<?>> getTypeArguments(java.lang.Class<T> baseClass, java.lang.Class<? extends T> childClass)
baseClass
- the base class (or interface)childClass
- the child class
public static java.lang.reflect.Type climbTypeHierarchy(java.lang.Class<?> here, java.lang.Class<?> parentClass)
public static boolean isAssignableFrom(java.lang.Class<?> to, java.lang.Class<?> from)
public static java.lang.Boolean isClassIndexed(java.lang.Class<?> clazz)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |