Class DefaultFieldSetBuilder
java.lang.Object
de.hybris.platform.webservicescommons.mapping.impl.DefaultFieldSetBuilder
- All Implemented Interfaces:
FieldSetBuilder
Default implementation of
FieldSetBuilder-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddToFieldSet(Set<String> fieldSet, String fullFieldName, FieldSetBuilderContext context) buildTypeVariableMap(Class clazz) Creates a map of PARAMETER_NAME -> CLASS to help resolving parameterized super class definitioncreateFieldSet(Class clazz, String fieldPrefix, String configuration) Method converts configuration string to set of field namescreateFieldSet(Class clazz, String fieldPrefix, String configuration, FieldSetBuilderContext context) Method converts configuration string to set of fully qualified field names eg.createFieldSetForLevel(Class clazz, String prefix, String levelName, FieldSetBuilderContext context) Method returns set of fully qualified field names defined in level.createFieldSetInternal(Class clazz, String fieldPrefix, String configuration, FieldSetBuilderContext context) Method converts configuration string to set of fully qualified field names eg.protected StringcreateFullFieldName(String basePrefix, String fieldName) Method create fully qualified field nameprotected static intfindElementEnd(int startIndex, String configuration) protected static intfindMatchingCloseBracket(String configuration, int openPos) protected ClassgetClassForType(Type fieldType) intintprotected StringgetElementName(int startIndex, String configuration) protected TypegetFieldType(String fieldName, Class objectClass) Method returns field typeprotected booleanisSimpleClass(Class clazz) Method check if class should be considered as simple.protected intomitBracket(int startIndex, String configuration) protected intprotected static intprotected intparseComplexField(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<String> fieldSet, FieldSetBuilderContext context) Methods add fully qualified field name to fieldSet.protected intparseField(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<String> fieldSet, FieldSetBuilderContext context) Methods add fully qualified field name to fieldSet.protected intparseMapField(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.protected intparseParametrizedTypeField(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<String> fieldSet, FieldSetBuilderContext context) Methods add fully qualified field name to fieldSet.protected intparseTypeVariableField(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<String> fieldSet, FieldSetBuilderContext context) Methods add fully qualified field name to fieldSet.protected intparseWildcardTypeField(String configuration, int currentPos, String fullFieldName, Type fieldType, Set<String> fieldSet, FieldSetBuilderContext context) Methods add fully qualified field name to fieldSet.protected TypesearchFieldTypeInSubclasses(String fieldName, Class objectClass) voidsetDefaultMaxFieldSetSize(int defaultMaxFieldSetSize) voidsetDefaultRecurrencyLevel(int defaultRecurrencyLevel) voidsetFieldSetLevelHelper(FieldSetLevelHelper fieldSetLevelHelper) voidsetSimpleClassSet(Set<Class> simpleTypeSet) voidsetSubclassRegistry(SubclassRegistry subclassRegistry)
-
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:FieldSetBuilderMethod converts configuration string to set of field names- Specified by:
createFieldSetin interfaceFieldSetBuilder- Parameters:
clazz- - class of object for which field set is createdfieldPrefix- - prefix which should be added to field nameconfiguration- - 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:
createFieldSetin interfaceFieldSetBuilder- Parameters:
clazz- - class of object for which field set is createdfieldPrefix- - prefix which should be added to field nameconfiguration- - string describing properties which should be added to the setcontext- - 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
Creates a map of PARAMETER_NAME -> CLASS to help resolving parameterized super class definitione.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 createdfieldPrefix- - prefix which should be added to field nameconfiguration- - string describing properties which should be added to the setcontext- - 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
-
findElementEnd
-
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 definitionprefix- - prefix, which should be added to parameter namelevelName- - level name e.g. BASICcontext- - 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 setcurrentPos- - position in configuration stringfullFieldName- - fully qualified field namefieldType- - field typefieldSet- - set where fully qualified field name should be addedcontext- - 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 setcurrentPos- - position in configuration stringfullFieldName- - fully qualified field namefieldType- - field typefieldSet- - set where fully qualified field name should be addedcontext- - 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 setcurrentPos- - position in configuration stringfullFieldName- - fully qualified field namefieldType- - field typefieldSet- - set where fully qualified field name should be addedcontext- - 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 setcurrentPos- - position in configuration stringfullFieldName- - fully qualified field namefieldType- - field typefieldSet- - set where fully qualified field name should be addedcontext- - 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 setcurrentPos- - position in configuration stringfullFieldName- - fully qualified field namefieldType- - field typefieldSet- - set where fully qualified field name should be addedcontext- - 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
-
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 setcurrentPos- - position in configuration stringfieldName- - map field namefieldType- - field typefieldSet- - set where fully qualified field name should be addedcontext- - 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
Method returns field type- Parameters:
fieldName- - field nameobjectClass- - object class- Returns:
- field type
-
searchFieldTypeInSubclasses
-
createFullFieldName
Method create fully qualified field name- Parameters:
basePrefix- - prefixfieldName- - field name- Returns:
- fully qualified field name
-
isSimpleClass
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
-
omitSpace
-
omitComma
-
omitBracket
-
getSimpleClassSet
-
setSimpleClassSet
-
getDefaultRecurrencyLevel
public int getDefaultRecurrencyLevel() -
setDefaultRecurrencyLevel
public void setDefaultRecurrencyLevel(int defaultRecurrencyLevel) -
getFieldSetLevelHelper
-
setFieldSetLevelHelper
-
getDefaultMaxFieldSetSize
public int getDefaultMaxFieldSetSize() -
setDefaultMaxFieldSetSize
public void setDefaultMaxFieldSetSize(int defaultMaxFieldSetSize) -
getSubclassRegistry
-
setSubclassRegistry
-