Package com.palantir.ptoss.cinch.core
Class BindingContext
- java.lang.Object
-
- com.palantir.ptoss.cinch.core.BindingContext
-
public class BindingContext extends java.lang.Object
A
BindingContext
holds information about how to bind various parts of a Java Object.Binding Constants - TODO
Visibility - TODO
Subclassing - TODO
Bindable models - have to be final
-
-
Constructor Summary
Constructors Constructor Description BindingContext(java.lang.Object object)
Create a BindingContext for the given, non-null object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
evalOnObject(java.lang.String on, BindableModel model)
ObjectFieldMethod
findGetter(java.lang.String property)
static java.util.List<java.lang.Class<?>>
findModelUpdateClass(BindableModel modelClass)
Returns the list ofModelUpdate
types in this binding context.static ModelUpdate
findOnObject(java.lang.String on, BindableModel model)
Resolves a string reference, as specified in theon
parameter of aBound
annotation to an Enum object in this runtime.ObjectFieldMethod
findSetter(java.lang.String property)
java.util.List<java.lang.reflect.Field>
getAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> klass)
java.util.List<ObjectFieldMethod>
getAnnotatedParameterlessMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
java.lang.Object
getBindableConstant(java.lang.String key)
Gets a constant from the binding context.ObjectFieldMethod
getBindableMethod(java.lang.String key)
Looks up anObjectFieldMethod
tuple by its key.BindableModel
getBindableModel(java.lang.String key)
ObjectFieldMethod
getBindableModelMethod(java.lang.String key)
Looks up anObjectFieldMethod
tuple by its key.java.util.Set<BindableModel>
getBindableModels()
<T> T
getFieldObject(java.lang.reflect.Field field, java.lang.Class<T> klass)
Returns the value of the specified Field on the object bound by thisBindingContext
static java.util.List<java.lang.Object>
getOnObjects(java.lang.String[] ons, BindableModel model)
static <T extends java.lang.Enum<?> & ModelUpdate>
booleanisOn(java.lang.Object onObject, T... changed)
static <T extends java.lang.Enum<?> & ModelUpdate>
booleanisOn(java.util.Collection<java.lang.Object> ons, T... changed)
-
-
-
Constructor Detail
-
BindingContext
public BindingContext(java.lang.Object object)
Create a BindingContext for the given, non-null object. Throws aBindingException
if there is a problem.- Parameters:
object
- the object - cannot be null
-
-
Method Detail
-
getBindableConstant
public java.lang.Object getBindableConstant(java.lang.String key)
Gets a constant from the binding context. Constants are static, final fields of the bound object.- Parameters:
key
- the name of the field- Returns:
- the value of the field
-
getFieldObject
public <T> T getFieldObject(java.lang.reflect.Field field, java.lang.Class<T> klass) throws java.lang.IllegalArgumentException
Returns the value of the specified Field on the object bound by thisBindingContext
- Parameters:
field
-Field
to pull the value fromklass
- return type of value in theField
- Returns:
- value of type
klass
from fieldfield
on bound object. - Throws:
java.lang.IllegalArgumentException
- if the passedField
is not a field on the object bound by thisBindingContext
-
getBindableMethod
public ObjectFieldMethod getBindableMethod(java.lang.String key)
Looks up anObjectFieldMethod
tuple by its key.- Parameters:
key
- - generated byOnChange.call()
- Returns:
- the tuple for this key (or null, if it doesn't exist)
-
getBindableModelMethod
public ObjectFieldMethod getBindableModelMethod(java.lang.String key)
Looks up anObjectFieldMethod
tuple by its key.- Parameters:
key
- - generated byOnChange.call()
- Returns:
- the tuple for this key (or null, if it doesn't exist)
-
getBindableModel
public BindableModel getBindableModel(java.lang.String key)
-
evalOnObject
public java.lang.Object evalOnObject(java.lang.String on, BindableModel model)
-
findModelUpdateClass
public static java.util.List<java.lang.Class<?>> findModelUpdateClass(BindableModel modelClass)
Returns the list ofModelUpdate
types in this binding context.- Returns:
- the of
Class
es that implementModelUpdate
in this binding context.
-
findOnObject
public static ModelUpdate findOnObject(java.lang.String on, BindableModel model)
Resolves a string reference, as specified in theon
parameter of aBound
annotation to an Enum object in this runtime.- Parameters:
on
-on
parameter from aBound
annotation.- Returns:
- the resolved object
- Throws:
java.lang.IllegalArgumentException
- if the referenced object can't be found.
-
findGetter
public ObjectFieldMethod findGetter(java.lang.String property)
-
findSetter
public ObjectFieldMethod findSetter(java.lang.String property)
-
getBindableModels
public java.util.Set<BindableModel> getBindableModels()
-
getAnnotatedFields
public java.util.List<java.lang.reflect.Field> getAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> klass)
-
getAnnotatedParameterlessMethods
public java.util.List<ObjectFieldMethod> getAnnotatedParameterlessMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
-
isOn
public static <T extends java.lang.Enum<?> & ModelUpdate> boolean isOn(java.lang.Object onObject, T... changed)
-
isOn
public static <T extends java.lang.Enum<?> & ModelUpdate> boolean isOn(java.util.Collection<java.lang.Object> ons, T... changed)
-
getOnObjects
public static java.util.List<java.lang.Object> getOnObjects(java.lang.String[] ons, BindableModel model)
-
-