Package com.palantir.ptoss.cinch.core
Class BindingContext
java.lang.Object
com.palantir.ptoss.cinch.core.BindingContext
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
ConstructorsConstructorDescriptionBindingContext
(Object object) Create a BindingContext for the given, non-null object. -
Method Summary
Modifier and TypeMethodDescriptionevalOnObject
(String on, BindableModel model) findGetter
(String property) findModelUpdateClass
(BindableModel modelClass) Returns the list ofModelUpdate
types in this binding context.static ModelUpdate
findOnObject
(String on, BindableModel model) Resolves a string reference, as specified in theon
parameter of aBound
annotation to an Enum object in this runtime.findSetter
(String property) getAnnotatedFields
(Class<? extends Annotation> klass) getAnnotatedParameterlessMethods
(Class<? extends Annotation> annotation) Gets a constant from the binding context.getBindableMethod
(String key) Looks up anObjectFieldMethod
tuple by its key.getBindableModel
(String key) Looks up anObjectFieldMethod
tuple by its key.<T> T
getFieldObject
(Field field, Class<T> klass) Returns the value of the specified Field on the object bound by thisBindingContext
getOnObjects
(String[] ons, BindableModel model) static <T extends Enum<?> & ModelUpdate>
booleanstatic <T extends Enum<?> & ModelUpdate>
booleanisOn
(Collection<Object> ons, T... changed)
-
Constructor Details
-
BindingContext
Create a BindingContext for the given, non-null object. Throws aBindingException
if there is a problem.- Parameters:
object
- the object - cannot be null
-
-
Method Details
-
getBindableConstant
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
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:
IllegalArgumentException
- if the passedField
is not a field on the object bound by thisBindingContext
-
getBindableMethod
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
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
-
evalOnObject
-
findModelUpdateClass
Returns the list ofModelUpdate
types in this binding context.- Returns:
- the of
Class
es that implementModelUpdate
in this binding context.
-
findOnObject
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:
IllegalArgumentException
- if the referenced object can't be found.
-
findGetter
-
findSetter
-
getBindableModels
-
getAnnotatedFields
-
getAnnotatedParameterlessMethods
public List<ObjectFieldMethod> getAnnotatedParameterlessMethods(Class<? extends Annotation> annotation) -
isOn
-
isOn
-
getOnObjects
-