Class 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 Detail

      • BindingContext

        public BindingContext​(java.lang.Object object)
        Create a BindingContext for the given, non-null object. Throws a BindingException 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 this BindingContext
        Parameters:
        field - Field to pull the value from
        klass - return type of value in the Field
        Returns:
        value of type klass from field field on bound object.
        Throws:
        java.lang.IllegalArgumentException - if the passed Field is not a field on the object bound by this BindingContext
      • getBindableMethod

        public ObjectFieldMethod getBindableMethod​(java.lang.String key)
        Looks up an ObjectFieldMethod tuple by its key.
        Parameters:
        key - - generated by OnChange.call()
        Returns:
        the tuple for this key (or null, if it doesn't exist)
      • getBindableModelMethod

        public ObjectFieldMethod getBindableModelMethod​(java.lang.String key)
        Looks up an ObjectFieldMethod tuple by its key.
        Parameters:
        key - - generated by OnChange.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 of ModelUpdate types in this binding context.
        Returns:
        the of Classes that implement ModelUpdate in this binding context.
      • findOnObject

        public static ModelUpdate findOnObject​(java.lang.String on,
                                               BindableModel model)
        Resolves a string reference, as specified in the on parameter of a Bound annotation to an Enum object in this runtime.
        Parameters:
        on - on parameter from a Bound annotation.
        Returns:
        the resolved object
        Throws:
        java.lang.IllegalArgumentException - if the referenced object can't be found.
      • 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)