Interface PluginAdapter

  • All Known Implementing Classes:
    PluginAdapterImpl

    public interface PluginAdapter
    Utility for creating Descriptions from Plugin class annotations and setting property values for annotated property fields.
    • Method Detail

      • canBuildDescription

        boolean canBuildDescription​(java.lang.Object object)
        Parameters:
        object - potential plugin object annotated with Plugin
        Returns:
        true if the object has a valid Plugin annotation
      • buildDescription

        Description buildDescription​(java.lang.Object object,
                                     DescriptionBuilder builder)
        Parameters:
        object - the object
        builder - builder
        Returns:
        Create a Description using a builder by analyzing the annotations on a plugin object, and including annotations on fields as DescriptionProperties.
      • buildDescription

        Description buildDescription​(java.lang.Class<?> type,
                                     DescriptionBuilder builder)
        Parameters:
        type - the type
        builder - builder
        Returns:
        Create a Description using a builder by analyzing the annotations on a plugin type, and including annotations on fields as DescriptionProperties.
      • buildDescription

        Description buildDescription​(java.lang.Object object,
                                     DescriptionBuilder builder,
                                     boolean includeAnnotatedFieldProperties)
        Parameters:
        object - the object
        builder - builder
        includeAnnotatedFieldProperties - if true, add DescriptionProperties to the Description based on annotations of fields in the class of the instance
        Returns:
        Create a Description using a builder by analyzing the annotations on a plugin object.
      • buildDescription

        Description buildDescription​(java.lang.Class<?> type,
                                     DescriptionBuilder builder,
                                     boolean includeAnnotatedFieldProperties)
        Parameters:
        builder - builder
        includeAnnotatedFieldProperties - if true, add DescriptionProperties to the Description based on annotations of fields in the class of the instance
        Returns:
        Create a Description using a builder by analyzing the annotations on a plugin object.
      • getPluginNameAnnotation

        java.lang.String getPluginNameAnnotation​(java.lang.Class<?> aClass)
      • loadPluginMetadata

        java.util.Map<java.lang.String,​java.lang.String> loadPluginMetadata​(java.lang.Class<?> clazz)
      • buildFieldProperties

        java.util.List<Property> buildFieldProperties​(java.lang.Object object)
        Return the list of properties by introspecting the annotated fields for PluginProperty
        Parameters:
        object - object
        Returns:
        list of properties, may be empty
      • buildFieldProperties

        java.util.List<Property> buildFieldProperties​(java.lang.Class<?> aClass)
        Return the list of properties by introspecting the annotated fields for PluginProperty
        Parameters:
        aClass - class
        Returns:
        list of properties, may be empty
      • buildFieldProperties

        void buildFieldProperties​(java.lang.Object object,
                                  DescriptionBuilder builder)
        Add properties based on introspection of the object
        Parameters:
        object - object
        builder - builder
      • buildFieldProperties

        void buildFieldProperties​(java.lang.Class<?> aClass,
                                  DescriptionBuilder builder)
        Add properties based on introspection of a class
        Parameters:
        aClass - class
        builder - builder
      • fieldForPropertyName

        java.lang.reflect.Field fieldForPropertyName​(java.lang.String name,
                                                     java.lang.Object object)
      • collectFields

        java.util.Collection<java.lang.reflect.Field> collectFields​(java.lang.Object object)
      • collectClassFields

        java.util.Collection<java.lang.reflect.Field> collectClassFields​(java.lang.Class<?> aClass)
      • propertyTypeFromFieldType

        Property.Type propertyTypeFromFieldType​(java.lang.Class clazz)
      • propertyFromField

        Property propertyFromField​(java.lang.reflect.Field field,
                                   PluginProperty annotation)
      • extractSelectLabels

        void extractSelectLabels​(PropertyBuilder pbuild,
                                 java.lang.String[] values,
                                 SelectLabels labelsAnnotation)
      • notBlank

        boolean notBlank​(java.lang.String string)
      • configureProperties

        java.util.Map<java.lang.String,​java.lang.Object> configureProperties​(PropertyResolver resolver,
                                                                                   java.lang.Object object)
        Set field values on a plugin object by using annotated field values to create a Description, and setting field values to resolved property values. Any resolved properties that are not mapped to a field will be included in the return result.
        Parameters:
        resolver - property resolver
        object - plugin object
        Returns:
        Map of resolved properties that were not configured in the object's fields
      • configureProperties

        java.util.Map<java.lang.String,​java.lang.Object> configureProperties​(PropertyResolver resolver,
                                                                                   Description description,
                                                                                   java.lang.Object object,
                                                                                   PropertyScope defaultScope)
        Set field values on a plugin object by using a Description, and setting field values to resolved property values. Any resolved properties that are not mapped to a field will be included in the return result.
        Parameters:
        resolver - the property resolver
        description - the property descriptions
        object - the target object, which can implement Configurable, otherwise introspection will be used
        defaultScope - a default property scope to assume for unspecified properties
        Returns:
        Map of resolved properties that were not configured in the object's fields
      • configureObjectFieldsWithProperties

        java.util.Map<java.lang.String,​java.lang.Object> configureObjectFieldsWithProperties​(java.lang.Object object,
                                                                                                   java.util.Map<java.lang.String,​java.lang.Object> inputConfig)
        Set field values on an object using introspection and input values for those properties
        Parameters:
        object - object
        inputConfig - input
        Returns:
        Map of resolved properties that were not configured in the object's fields
      • configureObjectFieldsWithProperties

        java.util.Map<java.lang.String,​java.lang.Object> configureObjectFieldsWithProperties​(java.lang.Object object,
                                                                                                   java.util.List<Property> properties,
                                                                                                   java.util.Map<java.lang.String,​java.lang.Object> inputConfig)
        Set field values on an object given a list of properties and input values for those properties
        Parameters:
        object - object
        properties - properties
        inputConfig - input
        Returns:
        Map of resolved properties that were not configured in the object's fields
      • mapDescribedProperties

        java.util.Map<java.lang.String,​java.lang.Object> mapDescribedProperties​(PropertyResolver resolver,
                                                                                      Description description)
        Retrieve the Description's Properties mapped to resolved values given the resolver, using InsanceOnly default scope.
        Parameters:
        resolver - property resolver
        description - plugin description
        Returns:
        All mapped properties by name and value.
      • mapDescribedProperties

        java.util.Map<java.lang.String,​java.lang.Object> mapDescribedProperties​(PropertyResolver resolver,
                                                                                      Description description,
                                                                                      PropertyScope defaultPropertyScope)
        Retrieve the Description's Properties mapped to resolved values given the resolver, with a default property scope
        Parameters:
        resolver - property resolver
        description - plugin description
        defaultPropertyScope - default scope for unspecified property scopes
        Returns:
        All mapped properties by name and value.
      • mapProperties

        java.util.Map<java.lang.String,​java.lang.Object> mapProperties​(PropertyResolver resolver,
                                                                             java.util.List<Property> properties,
                                                                             PropertyScope defaultPropertyScope)
        Retrieve the Properties mapped to resolved values given the resolver, with a default property scope
        Parameters:
        resolver - property resolver
        properties - properties
        defaultPropertyScope - default scope for unspecified property scopes
        Returns:
        All mapped properties by name and value.
      • setConfig

        void setConfig​(java.lang.Object object,
                       java.lang.Object config)
        Set config on fields annotated with PluginConfig PluginCustomConfig
        Parameters:
        object -
        config -
      • getCustomConfigAnnotation

        PluginCustomConfig getCustomConfigAnnotation​(java.lang.Object providerInstance)