Package com.palantir.ptoss.cinch.core
Class BindingContext
- java.lang.Object
-
- com.palantir.ptoss.cinch.core.BindingContext
-
public class BindingContext extends java.lang.ObjectA
BindingContextholds 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.ObjectevalOnObject(java.lang.String on, BindableModel model)ObjectFieldMethodfindGetter(java.lang.String property)static java.util.List<java.lang.Class<?>>findModelUpdateClass(BindableModel modelClass)Returns the list ofModelUpdatetypes in this binding context.static ModelUpdatefindOnObject(java.lang.String on, BindableModel model)Resolves a string reference, as specified in theonparameter of aBoundannotation to an Enum object in this runtime.ObjectFieldMethodfindSetter(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.ObjectgetBindableConstant(java.lang.String key)Gets a constant from the binding context.ObjectFieldMethodgetBindableMethod(java.lang.String key)Looks up anObjectFieldMethodtuple by its key.BindableModelgetBindableModel(java.lang.String key)ObjectFieldMethodgetBindableModelMethod(java.lang.String key)Looks up anObjectFieldMethodtuple by its key.java.util.Set<BindableModel>getBindableModels()<T> TgetFieldObject(java.lang.reflect.Field field, java.lang.Class<T> klass)Returns the value of the specified Field on the object bound by thisBindingContextstatic 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 aBindingExceptionif 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.IllegalArgumentExceptionReturns the value of the specified Field on the object bound by thisBindingContext- Parameters:
field-Fieldto pull the value fromklass- return type of value in theField- Returns:
- value of type
klassfrom fieldfieldon bound object. - Throws:
java.lang.IllegalArgumentException- if the passedFieldis not a field on the object bound by thisBindingContext
-
getBindableMethod
public ObjectFieldMethod getBindableMethod(java.lang.String key)
Looks up anObjectFieldMethodtuple 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 anObjectFieldMethodtuple 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 ofModelUpdatetypes in this binding context.- Returns:
- the of
Classes that implementModelUpdatein this binding context.
-
findOnObject
public static ModelUpdate findOnObject(java.lang.String on, BindableModel model)
Resolves a string reference, as specified in theonparameter of aBoundannotation to an Enum object in this runtime.- Parameters:
on-onparameter from aBoundannotation.- 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)
-
-