Class DefaultBindingParameter<T>

java.lang.Object
com.inductiveautomation.vision.api.client.binding.DefaultBindingParameter<T>
All Implemented Interfaces:
BindingParameter<T>

public class DefaultBindingParameter<T> extends Object implements BindingParameter<T>
Default implementation of BindingParameter. Commonly a binding parameter will be a instance of this class or an anonymous subclass of this class to override various functions such as getOptionMap().
  • Field Details

    • parameterName

      protected String parameterName
    • titleKey

      protected String titleKey
    • parameterType

      protected Class<T> parameterType
    • defaultValue

      protected T defaultValue
  • Constructor Details

    • DefaultBindingParameter

      public DefaultBindingParameter(String parameterName, String titleKey, T defaultValue)
    • DefaultBindingParameter

      public DefaultBindingParameter(String parameterName, String titleKey, T defaultValue, Class<T> parameterType)
  • Method Details

    • createOrdinalBasedEnumOptions

      protected static List<StringPair> createOrdinalBasedEnumOptions(Class<? extends Enum> enumClass, boolean includeNone)
      Creates an option map out of an enum, where the ordinals (or getIntValue's) of the enum are the intended value.
      Parameters:
      includeNone - If true, a "None" option will be included whose value is empty string.
    • createNameBasedEnumOptions

      protected static List<StringPair> createNameBasedEnumOptions(Class<? extends Enum> enumClass, boolean includeNone)
      Creates an option map out of an enum, where the names of the enum are the intended value.
      Parameters:
      includeNone - If true, a "None" option will be included whose value is empty string.
    • createBasicOptionMap

      protected static List<StringPair> createBasicOptionMap(String... options)
      Creates a basic option map out of a list of Strings
    • createRPCOptionMap

      protected static List<StringPair> createRPCOptionMap(String rpcCall)
      Calls through to the gateway via RPC to the given function call. It is assumed that this function call returns a list of strings. For example, the rpc call "Alert.getStorageProfiles" would be an appropriate call, because it returns a list of strings. See also:
    • createModuleRPCOptionMap

      protected static List<StringPair> createModuleRPCOptionMap(String moduleId, String function)
      Just like createRPCOptionMap(String), but uses module-based rpc instead.
    • coerce

      public T coerce(String rawValue) throws ClassCastException
      Abstract implementation provides the following logic:
      1. If rawValue is null or blank, use the default value.
      2. else, use TypeUtilities.coerce(Object, Class) to coerce rawValue into T
      Specified by:
      coerce in interface BindingParameter<T>
      Throws:
      ClassCastException - If this is thrown, the binding will not be executed, instead the property will receive a poor data quality.
    • getDefaultValue

      public T getDefaultValue()
      Provide a default value to use for this parameter if the user left the parameter blank
      Specified by:
      getDefaultValue in interface BindingParameter<T>
    • getOptionMap

      public List<StringPair> getOptionMap()
      Default implementation returns null. Meant to be overridden.
      Specified by:
      getOptionMap in interface BindingParameter<T>
    • getBrowseHelper

      public BindingParameter.BrowseHelper getBrowseHelper()
      Default implementation returns null. Meant to be overridden.
      Specified by:
      getBrowseHelper in interface BindingParameter<T>
    • getParameterType

      public Class<T> getParameterType()
      Description copied from interface: BindingParameter
      The data type of the parameter. All parameters are treated as Strings during the design phase, but will be coerced to this type right before execution. Coersion is handled by the BindingParameter.coerce(String) function.
      Specified by:
      getParameterType in interface BindingParameter<T>
    • isBindingAllowed

      public boolean isBindingAllowed()
      Description copied from interface: BindingParameter
      If true, the user will be allowed to bind this parameter's runtime value to tags and/or properties
      Specified by:
      isBindingAllowed in interface BindingParameter<T>
    • getParameterName

      public String getParameterName()
      Description copied from interface: BindingParameter
      The name of this parameter. This is the string that will be used to identify this parameter's value when executing the binding. Must be unique amongst the list of binding parameters for a given binding type.
      Specified by:
      getParameterName in interface BindingParameter<T>
    • getTitleKey

      public String getTitleKey()
      Description copied from interface: BindingParameter
      A resource bundle key to use as the param's title for display purposes.
      Specified by:
      getTitleKey in interface BindingParameter<T>
    • getTooltipKey

      public String getTooltipKey()
      Description copied from interface: BindingParameter
      A resource bundle key to use for the GUI control's tooltip
      Specified by:
      getTooltipKey in interface BindingParameter<T>