Class DefaultFieldSetBuilder

java.lang.Object
de.hybris.platform.webservicescommons.mapping.impl.DefaultFieldSetBuilder
All Implemented Interfaces:
FieldSetBuilder

public class DefaultFieldSetBuilder extends Object implements FieldSetBuilder
Default implementation of FieldSetBuilder
  • Constructor Details

    • DefaultFieldSetBuilder

      public DefaultFieldSetBuilder()
  • Method Details

    • createFieldSet

      @Cacheable(value="fieldSetCache", key="{#clazz,#fieldPrefix,#configuration}") public Set<String> createFieldSet(Class clazz, String fieldPrefix, 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 Set<String> createFieldSet(Class clazz, String fieldPrefix, 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<STATE, RESULT> 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 Map<String,Class> buildTypeVariableMap(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 Set<String> createFieldSetInternal(Class clazz, String fieldPrefix, 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<STATE, RESULT> 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 String getElementName(int startIndex, String configuration)
    • findElementEnd

      protected static int findElementEnd(int startIndex, String configuration)
    • createFieldSetForLevel

      protected Set<String> createFieldSetForLevel(Class clazz, String prefix, 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<STATE, RESULT> 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(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<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<STATE, RESULT> 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(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<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<STATE, RESULT> 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(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<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<STATE, RESULT> 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(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<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<STATE, RESULT> 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(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<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<STATE, RESULT> 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(Set<String> fieldSet, String fullFieldName, FieldSetBuilderContext context)
    • getClassForType

      protected Class getClassForType(Type fieldType)
    • parseMapField

      protected int parseMapField(String configuration, int currentPos, String fieldName, ParameterizedType fieldType, Set<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<STATE, RESULT> 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 Type getFieldType(String fieldName, Class objectClass)
      Method returns field type
      Parameters:
      fieldName - - field name
      objectClass - - object class
      Returns:
      field type
    • searchFieldTypeInSubclasses

      protected Type searchFieldTypeInSubclasses(String fieldName, Class objectClass)
    • createFullFieldName

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

      protected boolean isSimpleClass(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(String configuration, int openPos)
    • omitSpace

      protected static int omitSpace(int startIndex, String configuration)
    • omitComma

      protected int omitComma(int startIndex, String configuration)
    • omitBracket

      protected int omitBracket(int startIndex, String configuration)
    • getSimpleClassSet

      public Set<Class> getSimpleClassSet()
    • setSimpleClassSet

      public void setSimpleClassSet(Set<Class> simpleTypeSet)
    • getDefaultRecurrencyLevel

      public int getDefaultRecurrencyLevel()
    • setDefaultRecurrencyLevel

      public void setDefaultRecurrencyLevel(int defaultRecurrencyLevel)
    • getFieldSetLevelHelper

      public FieldSetLevelHelper getFieldSetLevelHelper()
    • setFieldSetLevelHelper

      public void setFieldSetLevelHelper(FieldSetLevelHelper fieldSetLevelHelper)
    • getDefaultMaxFieldSetSize

      public int getDefaultMaxFieldSetSize()
    • setDefaultMaxFieldSetSize

      public void setDefaultMaxFieldSetSize(int defaultMaxFieldSetSize)
    • getSubclassRegistry

      public SubclassRegistry getSubclassRegistry()
    • setSubclassRegistry

      public void setSubclassRegistry(SubclassRegistry subclassRegistry)