android.databinding.tool.reflection
Class ModelClass

java.lang.Object
  extended by android.databinding.tool.reflection.ModelClass

public abstract class ModelClass
extends java.lang.Object


Constructor Summary
ModelClass()
           
 
Method Summary
abstract  ModelClass box()
          When this is a primitive type, such as boolean, this will return the boxed value, such as Boolean.
abstract  ModelClass erasure()
          Returns this class type without any generic type arguments.
 boolean extendsViewStub()
           
 Callable findGetterOrField(java.lang.String name, boolean staticOnly)
          Returns the getter method or field that the name refers to.
 ModelMethod findInstanceGetter(java.lang.String name)
           
 java.util.List<ModelMethod> findMethods(java.lang.String name, boolean staticOnly)
          Finds public methods that matches the given name exactly.
 java.util.List<ModelMethod> getAbstractMethods()
          Returns a list of all abstract methods in the type.
 java.lang.String getCanonicalName()
           
abstract  ModelClass getComponentType()
          For arrays, lists, and maps, this returns the contained value.
protected abstract  ModelField[] getDeclaredFields()
           
protected abstract  ModelMethod[] getDeclaredMethods()
           
abstract  java.lang.String getJniDescription()
          Returns the JNI description of the method which can be used to lookup it in SDK.
 ModelMethod getMethod(java.lang.String name, java.util.List<ModelClass> args, boolean staticOnly)
          Returns the public method with the name name with the parameters that best match args.
 ModelMethod[] getMethods(java.lang.String name, int numParameters)
          Returns all public instance methods with the given name and number of parameters.
 ModelMethod[] getMethods(java.lang.String name, java.util.List<ModelClass> args, boolean staticOnly)
          Returns an array containing all public methods on the type represented by this ModelClass with the name name and can take the passed-in types as arguments.
 int getMinApi()
          Since when this class is available.
 java.lang.String getSimpleName()
           
abstract  ModelClass getSuperclass()
          If this represents a class, the super class that it extends is returned.
abstract  java.util.List<ModelClass> getTypeArguments()
           
abstract  boolean isArray()
           
abstract  boolean isAssignableFrom(ModelClass that)
          Returns whether or not the type associated with that can be assigned to the type associated with this ModelClass.
abstract  boolean isBoolean()
           
abstract  boolean isByte()
           
abstract  boolean isChar()
           
abstract  boolean isDouble()
           
abstract  boolean isFloat()
           
abstract  boolean isGeneric()
           
 boolean isIncomplete()
           
abstract  boolean isInt()
           
abstract  boolean isInterface()
           
 boolean isList()
           
abstract  boolean isLong()
           
 boolean isMap()
           
abstract  boolean isNullable()
           
 boolean isObject()
           
 boolean isObservable()
           
 boolean isObservableField()
           
abstract  boolean isPrimitive()
           
abstract  boolean isShort()
           
 boolean isString()
           
abstract  boolean isTypeVar()
           
 boolean isViewDataBinding()
           
abstract  boolean isVoid()
           
abstract  boolean isWildcard()
           
abstract  java.lang.String toJavaCode()
           
abstract  ModelClass unbox()
          When this is a boxed type, such as Integer, this will return the unboxed value, such as int.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelClass

public ModelClass()
Method Detail

toJavaCode

public abstract java.lang.String toJavaCode()

isArray

public abstract boolean isArray()
Returns:
whether this ModelClass represents an array.

getComponentType

public abstract ModelClass getComponentType()
For arrays, lists, and maps, this returns the contained value. For other types, null is returned.

Returns:
The component type for arrays, the value type for maps, and the element type for lists.

isList

public boolean isList()
Returns:
Whether or not this ModelClass can be treated as a List. This means it is a java.util.List, or one of the Sparse*Array classes.

isMap

public boolean isMap()
Returns:
whether or not this ModelClass can be considered a Map or not.

isString

public boolean isString()
Returns:
whether or not this ModelClass is a java.lang.String.

isNullable

public abstract boolean isNullable()
Returns:
whether or not this ModelClass represents a Reference type.

isPrimitive

public abstract boolean isPrimitive()
Returns:
whether or not this ModelClass represents a primitive type.

isBoolean

public abstract boolean isBoolean()
Returns:
whether or not this ModelClass represents a Java boolean

isChar

public abstract boolean isChar()
Returns:
whether or not this ModelClass represents a Java char

isByte

public abstract boolean isByte()
Returns:
whether or not this ModelClass represents a Java byte

isShort

public abstract boolean isShort()
Returns:
whether or not this ModelClass represents a Java short

isInt

public abstract boolean isInt()
Returns:
whether or not this ModelClass represents a Java int

isLong

public abstract boolean isLong()
Returns:
whether or not this ModelClass represents a Java long

isFloat

public abstract boolean isFloat()
Returns:
whether or not this ModelClass represents a Java float

isDouble

public abstract boolean isDouble()
Returns:
whether or not this ModelClass represents a Java double

isGeneric

public abstract boolean isGeneric()
Returns:
whether or not this has type parameters

getTypeArguments

public abstract java.util.List<ModelClass> getTypeArguments()
Returns:
a list of Generic type paramters for the class. For example, if the class is List<T>, then the return value will be a list containing T. null is returned if this is not a generic type

isTypeVar

public abstract boolean isTypeVar()
Returns:
whether this is a type variable. For example, in List<T>, T is a type variable. However, List<String>, String is not a type variable.

isWildcard

public abstract boolean isWildcard()
Returns:
whether this is a wildcard type argument or not.

isObject

public boolean isObject()
Returns:
whether or not this ModelClass is java.lang.Object and not a primitive or subclass.

isInterface

public abstract boolean isInterface()
Returns:
whether or not this ModelClass is an interface

isViewDataBinding

public boolean isViewDataBinding()
Returns:
whether or not his is a ViewDataBinding subclass.

extendsViewStub

public boolean extendsViewStub()
Returns:
whether or not this ModelClass type extends ViewStub.

isObservable

public boolean isObservable()
Returns:
whether or not this is an Observable type such as ObservableMap, ObservableList, or Observable.

isObservableField

public boolean isObservableField()
Returns:
whether or not this is an ObservableField, or any of the primitive versions such as ObservableBoolean and ObservableInt

isVoid

public abstract boolean isVoid()
Returns:
whether or not this ModelClass represents a void

unbox

public abstract ModelClass unbox()
When this is a boxed type, such as Integer, this will return the unboxed value, such as int. If this is not a boxed type, this is returned.

Returns:
The unboxed type of the class that this ModelClass represents or this if it isn't a boxed type.

box

public abstract ModelClass box()
When this is a primitive type, such as boolean, this will return the boxed value, such as Boolean. If this is not a primitive type, this is returned.

Returns:
The boxed type of the class that this ModelClass represents or this if it isn't a primitive type.

isAssignableFrom

public abstract boolean isAssignableFrom(ModelClass that)
Returns whether or not the type associated with that can be assigned to the type associated with this ModelClass. If this and that only require boxing or unboxing then true is returned.

Parameters:
that - the ModelClass to compare.
Returns:
true if that requires only boxing or if that is an implementation of or subclass of this.

getMethods

public ModelMethod[] getMethods(java.lang.String name,
                                java.util.List<ModelClass> args,
                                boolean staticOnly)
Returns an array containing all public methods on the type represented by this ModelClass with the name name and can take the passed-in types as arguments. This will also work if the arguments match VarArgs parameter.

Parameters:
name - The name of the method to find.
args - The types that the method should accept.
staticOnly - Whether only static methods should be returned or both instance methods and static methods are valid.
Returns:
An array containing all public methods with the name name and taking args parameters.

getMethods

public ModelMethod[] getMethods(java.lang.String name,
                                int numParameters)
Returns all public instance methods with the given name and number of parameters.

Parameters:
name - The name of the method to find.
numParameters - The number of parameters that the method should take
Returns:
An array containing all public methods with the given name and number of parameters.

getMethod

public ModelMethod getMethod(java.lang.String name,
                             java.util.List<ModelClass> args,
                             boolean staticOnly)
Returns the public method with the name name with the parameters that best match args. staticOnly governs whether a static or instance method will be returned. If no matching method was found, null is returned.

Parameters:
name - The method name to find
args - The arguments that the method should accept
staticOnly - true if the returned method must be static or false if it does not matter.

getSuperclass

public abstract ModelClass getSuperclass()
If this represents a class, the super class that it extends is returned. If this represents an interface, the interface that this extends is returned. null is returned if this is not a class or interface, such as an int, or if it is java.lang.Object or an interface that does not extend any other type.

Returns:
The class or interface that this ModelClass extends or null.

getCanonicalName

public java.lang.String getCanonicalName()
Returns:
A String representation of the class or interface that this represents, not including any type arguments.

getSimpleName

public java.lang.String getSimpleName()
Returns:
The class or interface name of this type or the primitive type if it isn't a reference type.

erasure

public abstract ModelClass erasure()
Returns this class type without any generic type arguments.

Returns:
this class type without any generic type arguments.

getMinApi

public int getMinApi()
Since when this class is available. Important for Binding expressions so that we don't call non-existing APIs when setting UI.

Returns:
The SDK_INT where this method was added. If it is not a framework method, should return 1.

getJniDescription

public abstract java.lang.String getJniDescription()
Returns the JNI description of the method which can be used to lookup it in SDK.

See Also:
TypeUtil

getAbstractMethods

@NotNull
public java.util.List<ModelMethod> getAbstractMethods()
Returns a list of all abstract methods in the type.


findGetterOrField

public Callable findGetterOrField(java.lang.String name,
                                  boolean staticOnly)
Returns the getter method or field that the name refers to.

Parameters:
name - The name of the field or the body of the method name -- can be name(), getName(), or isName().
staticOnly - Whether this should look for static methods and fields or instance versions
Returns:
the getter method or field that the name refers to or null if none can be found.

findInstanceGetter

public ModelMethod findInstanceGetter(java.lang.String name)

findMethods

@NotNull
public java.util.List<ModelMethod> findMethods(java.lang.String name,
                                                       boolean staticOnly)
Finds public methods that matches the given name exactly. These may be resolved into listener methods during Expr.resolveListeners.


isIncomplete

public boolean isIncomplete()

getDeclaredFields

protected abstract ModelField[] getDeclaredFields()

getDeclaredMethods

protected abstract ModelMethod[] getDeclaredMethods()