Class DefaultFieldSetBuilder

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addToFieldSet​(java.util.Set<java.lang.String> fieldSet, java.lang.String fullFieldName, FieldSetBuilderContext context)  
      protected java.util.Map<java.lang.String,​java.lang.Class> buildTypeVariableMap​(java.lang.Class clazz)
      Creates a map of PARAMETER_NAME -> CLASS to help resolving parameterized super class definition
      java.util.Set<java.lang.String> createFieldSet​(java.lang.Class clazz, java.lang.String fieldPrefix, java.lang.String configuration)
      Method converts configuration string to set of field names
      java.util.Set<java.lang.String> createFieldSet​(java.lang.Class clazz, java.lang.String fieldPrefix, java.lang.String configuration, FieldSetBuilderContext context)
      Method converts configuration string to set of fully qualified field names eg.
      protected java.util.Set<java.lang.String> createFieldSetForLevel​(java.lang.Class clazz, java.lang.String prefix, java.lang.String levelName, FieldSetBuilderContext context)
      Method returns set of fully qualified field names defined in level.
      protected java.util.Set<java.lang.String> createFieldSetInternal​(java.lang.Class clazz, java.lang.String fieldPrefix, java.lang.String configuration, FieldSetBuilderContext context)
      Method converts configuration string to set of fully qualified field names eg.
      protected java.lang.String createFullFieldName​(java.lang.String basePrefix, java.lang.String fieldName)
      Method create fully qualified field name
      protected static int findElementEnd​(int startIndex, java.lang.String configuration)  
      protected static int findMatchingCloseBracket​(java.lang.String configuration, int openPos)  
      protected java.lang.Class getClassForType​(java.lang.reflect.Type fieldType)  
      int getDefaultMaxFieldSetSize()  
      int getDefaultRecurrencyLevel()  
      protected java.lang.String getElementName​(int startIndex, java.lang.String configuration)  
      FieldSetLevelHelper getFieldSetLevelHelper()  
      protected java.lang.reflect.Type getFieldType​(java.lang.String fieldName, java.lang.Class objectClass)
      Method returns field type
      java.util.Set<java.lang.Class> getSimpleClassSet()  
      SubclassRegistry getSubclassRegistry()  
      protected boolean isSimpleClass​(java.lang.Class clazz)
      Method check if class should be considered as simple.
      protected int omitBracket​(int startIndex, java.lang.String configuration)  
      protected int omitComma​(int startIndex, java.lang.String configuration)  
      protected static int omitSpace​(int startIndex, java.lang.String configuration)  
      protected int parseComplexField​(java.lang.String configuration, int currentPos, java.lang.String fullFieldName, java.lang.reflect.Type fieldType, java.util.Set<java.lang.String> fieldSet, FieldSetBuilderContext context)
      Methods add fully qualified field name to fieldSet.
      protected int parseField​(java.lang.String configuration, int currentPos, java.lang.String fullFieldName, java.lang.reflect.Type fieldType, java.util.Set<java.lang.String> fieldSet, FieldSetBuilderContext context)
      Methods add fully qualified field name to fieldSet.
      protected int parseMapField​(java.lang.String configuration, int currentPos, java.lang.String fieldName, java.lang.reflect.ParameterizedType fieldType, java.util.Set<java.lang.String> fieldSet, FieldSetBuilderContext context)
      Methods add fully qualified field name for map and it's key and value.
      protected int parseParametrizedTypeField​(java.lang.String configuration, int currentPos, java.lang.String fullFieldName, java.lang.reflect.Type fieldType, java.util.Set<java.lang.String> fieldSet, FieldSetBuilderContext context)
      Methods add fully qualified field name to fieldSet.
      protected int parseTypeVariableField​(java.lang.String configuration, int currentPos, java.lang.String fullFieldName, java.lang.reflect.Type fieldType, java.util.Set<java.lang.String> fieldSet, FieldSetBuilderContext context)
      Methods add fully qualified field name to fieldSet.
      protected int parseWildcardTypeField​(java.lang.String configuration, int currentPos, java.lang.String fullFieldName, java.lang.reflect.Type fieldType, java.util.Set<java.lang.String> fieldSet, FieldSetBuilderContext context)
      Methods add fully qualified field name to fieldSet.
      protected java.lang.reflect.Type searchFieldTypeInSubclasses​(java.lang.String fieldName, java.lang.Class objectClass)  
      void setDefaultMaxFieldSetSize​(int defaultMaxFieldSetSize)  
      void setDefaultRecurrencyLevel​(int defaultRecurrencyLevel)  
      void setFieldSetLevelHelper​(FieldSetLevelHelper fieldSetLevelHelper)  
      void setSimpleClassSet​(java.util.Set<java.lang.Class> simpleTypeSet)  
      void setSubclassRegistry​(SubclassRegistry subclassRegistry)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultFieldSetBuilder

        public DefaultFieldSetBuilder()
    • Method Detail

      • createFieldSet

        @Cacheable(value="fieldSetCache",
                   key="{#clazz,#fieldPrefix,#configuration}")
        public java.util.Set<java.lang.String> createFieldSet​(java.lang.Class clazz,
                                                              java.lang.String fieldPrefix,
                                                              java.lang.String configuration)
        Description copied from interface: FieldSetBuilder
        Method converts configuration string to set of field names
        Specified by:
        createFieldSet in interface FieldSetBuilder
        Parameters:
        clazz - - class of object for which field set is created
        fieldPrefix - - prefix which should be added to field name
        configuration - - string describing properties which should be added to the set
        Returns:
        set of fully qualified field names
      • createFieldSet

        @Cacheable(value="fieldSetCache",
                   key="{#clazz,#fieldPrefix,#configuration,#context}")
        public java.util.Set<java.lang.String> createFieldSet​(java.lang.Class clazz,
                                                              java.lang.String fieldPrefix,
                                                              java.lang.String configuration,
                                                              FieldSetBuilderContext context)
        Method converts configuration string to set of fully qualified field names eg. address.country.name, address.country.isocode.
        For example :
        - createFieldSet(AddressData.class,"address","firstName, lastName") will return set {address.firstName,address.lastName}
        - createFieldSet(AddressData.class,"address","BASIC,town") when definition for BASIC level ="firstName, lastName" will return {address.firstName,address.lastName,address.town}
        Specified by:
        createFieldSet in interface FieldSetBuilder
        Parameters:
        clazz - - class of object for which field set is created
        fieldPrefix - - prefix which should be added to field name
        configuration - - string describing properties which should be added to the set
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        set of fully qualified field names
      • buildTypeVariableMap

        protected java.util.Map<java.lang.String,​java.lang.Class> buildTypeVariableMap​(java.lang.Class clazz)
        Creates a map of PARAMETER_NAME -> CLASS to help resolving parameterized super class definition

        e.g. MyClass extents List will produce map ["E" : String.class]

      • createFieldSetInternal

        protected java.util.Set<java.lang.String> createFieldSetInternal​(java.lang.Class clazz,
                                                                         java.lang.String fieldPrefix,
                                                                         java.lang.String configuration,
                                                                         FieldSetBuilderContext context)
        Method converts configuration string to set of fully qualified field names eg. address.country.name, address.country.isocode.
        For example :
        - createFieldSetInternal(AddressData.class,"address","firstName, lastName") will return set {address.firstName,address.lastName}
        - createFieldSetInternal(AddressData.class,"address","BASIC,town") when definition for BASIC level = "firstName, lastName" will return {address.firstName,address.lastName,address.town}
        Parameters:
        clazz - - class of object for which field set is created
        fieldPrefix - - prefix which should be added to field name
        configuration - - string describing properties which should be added to the set
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        set of fully qualified field names
      • getElementName

        protected java.lang.String getElementName​(int startIndex,
                                                  java.lang.String configuration)
      • findElementEnd

        protected static int findElementEnd​(int startIndex,
                                            java.lang.String configuration)
      • createFieldSetForLevel

        protected java.util.Set<java.lang.String> createFieldSetForLevel​(java.lang.Class clazz,
                                                                         java.lang.String prefix,
                                                                         java.lang.String levelName,
                                                                         FieldSetBuilderContext context)
        Method returns set of fully qualified field names defined in level. For example if BASIC='firstName,lastName' and prefix='address' we will get set with values : address.firstName and address.lastName
        Parameters:
        clazz - - class of object. It is needed to find level definition
        prefix - - prefix, which should be added to parameter name
        levelName - - level name e.g. BASIC
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        set of fully qualified field names
      • parseComplexField

        protected int parseComplexField​(java.lang.String configuration,
                                        int currentPos,
                                        java.lang.String fullFieldName,
                                        java.lang.reflect.Type fieldType,
                                        java.util.Set<java.lang.String> fieldSet,
                                        FieldSetBuilderContext context)
        Methods add fully qualified field name to fieldSet. If field is complex class, it also add fully qualified names for it's fields. Method also handle Collections (like Map, List), WildcardType, TypeVariable
        Parameters:
        configuration - - string describing properties which should be added to the set
        currentPos - - position in configuration string
        fullFieldName - - fully qualified field name
        fieldType - - field type
        fieldSet - - set where fully qualified field name should be added
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        current position in configuration string
      • parseTypeVariableField

        protected int parseTypeVariableField​(java.lang.String configuration,
                                             int currentPos,
                                             java.lang.String fullFieldName,
                                             java.lang.reflect.Type fieldType,
                                             java.util.Set<java.lang.String> fieldSet,
                                             FieldSetBuilderContext context)
        Methods add fully qualified field name to fieldSet. If field is complex class, it also add fully qualified names for it's fields. Method handles TypeVariable fields.
        Parameters:
        configuration - - string describing properties which should be added to the set
        currentPos - - position in configuration string
        fullFieldName - - fully qualified field name
        fieldType - - field type
        fieldSet - - set where fully qualified field name should be added
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        current position in configuration string
      • parseWildcardTypeField

        protected int parseWildcardTypeField​(java.lang.String configuration,
                                             int currentPos,
                                             java.lang.String fullFieldName,
                                             java.lang.reflect.Type fieldType,
                                             java.util.Set<java.lang.String> fieldSet,
                                             FieldSetBuilderContext context)
        Methods add fully qualified field name to fieldSet. If field is complex class, it also add fully qualified names for it's fields. Method handles WildcardType fields.
        Parameters:
        configuration - - string describing properties which should be added to the set
        currentPos - - position in configuration string
        fullFieldName - - fully qualified field name
        fieldType - - field type
        fieldSet - - set where fully qualified field name should be added
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        current position in configuration string
      • parseParametrizedTypeField

        protected int parseParametrizedTypeField​(java.lang.String configuration,
                                                 int currentPos,
                                                 java.lang.String fullFieldName,
                                                 java.lang.reflect.Type fieldType,
                                                 java.util.Set<java.lang.String> fieldSet,
                                                 FieldSetBuilderContext context)
        Methods add fully qualified field name to fieldSet. If field is complex class, it also add fully qualified names for it's fields. Method handles ParameterizedType fields.
        Parameters:
        configuration - - string describing properties which should be added to the set
        currentPos - - position in configuration string
        fullFieldName - - fully qualified field name
        fieldType - - field type
        fieldSet - - set where fully qualified field name should be added
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        current position in configuration string
      • parseField

        protected int parseField​(java.lang.String configuration,
                                 int currentPos,
                                 java.lang.String fullFieldName,
                                 java.lang.reflect.Type fieldType,
                                 java.util.Set<java.lang.String> fieldSet,
                                 FieldSetBuilderContext context)
        Methods add fully qualified field name to fieldSet. If field is complex class, it also add fully qualified names for it's fields.
        Parameters:
        configuration - - string describing properties which should be added to the set
        currentPos - - position in configuration string
        fullFieldName - - fully qualified field name
        fieldType - - field type
        fieldSet - - set where fully qualified field name should be added
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        current position in configuration string
      • addToFieldSet

        protected void addToFieldSet​(java.util.Set<java.lang.String> fieldSet,
                                     java.lang.String fullFieldName,
                                     FieldSetBuilderContext context)
      • getClassForType

        protected java.lang.Class getClassForType​(java.lang.reflect.Type fieldType)
      • parseMapField

        protected int parseMapField​(java.lang.String configuration,
                                    int currentPos,
                                    java.lang.String fieldName,
                                    java.lang.reflect.ParameterizedType fieldType,
                                    java.util.Set<java.lang.String> fieldSet,
                                    FieldSetBuilderContext context)
        Methods add fully qualified field name for map and it's key and value.
        Parameters:
        configuration - - string describing properties which should be added to the set
        currentPos - - position in configuration string
        fieldName - - map field name
        fieldType - - field type
        fieldSet - - set where fully qualified field name should be added
        context - - object storing additional information like :
        typeVariableMap - map containing information about types used in generic class
        e.g. if we have type class like ProductSearchPageData we should give map like {STATE=SearchStateData.class, RESULT=ProductData.class}
        recurrencyLevel - define how many recurrency level builder should support (it is case when object have it's own type field e.g. VariantMatrixElementData have elements which are also VariantMatrixElementData type)
        recurrencyMap - map for controlling recurrency level
        Returns:
        current position in configuration string
      • getFieldType

        protected java.lang.reflect.Type getFieldType​(java.lang.String fieldName,
                                                      java.lang.Class objectClass)
        Method returns field type
        Parameters:
        fieldName - - field name
        objectClass - - object class
        Returns:
        field type
      • searchFieldTypeInSubclasses

        protected java.lang.reflect.Type searchFieldTypeInSubclasses​(java.lang.String fieldName,
                                                                     java.lang.Class objectClass)
      • createFullFieldName

        protected java.lang.String createFullFieldName​(java.lang.String basePrefix,
                                                       java.lang.String fieldName)
        Method create fully qualified field name
        Parameters:
        basePrefix - - prefix
        fieldName - - field name
        Returns:
        fully qualified field name
      • isSimpleClass

        protected boolean isSimpleClass​(java.lang.Class clazz)
        Method check if class should be considered as simple. Simple class cannot have configuration. So if class of field1 is simple we cannot use : field1(field11,field12)
        Parameters:
        clazz - - field class
        Returns:
        true - if field type is simple
        false - if field type is complex
      • findMatchingCloseBracket

        protected static int findMatchingCloseBracket​(java.lang.String configuration,
                                                      int openPos)
      • omitSpace

        protected static int omitSpace​(int startIndex,
                                       java.lang.String configuration)
      • omitComma

        protected int omitComma​(int startIndex,
                                java.lang.String configuration)
      • omitBracket

        protected int omitBracket​(int startIndex,
                                  java.lang.String configuration)
      • getSimpleClassSet

        public java.util.Set<java.lang.Class> getSimpleClassSet()
      • setSimpleClassSet

        public void setSimpleClassSet​(java.util.Set<java.lang.Class> simpleTypeSet)
      • getDefaultRecurrencyLevel

        public int getDefaultRecurrencyLevel()
      • setDefaultRecurrencyLevel

        public void setDefaultRecurrencyLevel​(int defaultRecurrencyLevel)
      • setFieldSetLevelHelper

        public void setFieldSetLevelHelper​(FieldSetLevelHelper fieldSetLevelHelper)
      • getDefaultMaxFieldSetSize

        public int getDefaultMaxFieldSetSize()
      • setDefaultMaxFieldSetSize

        public void setDefaultMaxFieldSetSize​(int defaultMaxFieldSetSize)
      • setSubclassRegistry

        public void setSubclassRegistry​(SubclassRegistry subclassRegistry)