Class DefaultFieldSetBuilder
- java.lang.Object
-
- de.hybris.platform.webservicescommons.mapping.impl.DefaultFieldSetBuilder
-
- All Implemented Interfaces:
FieldSetBuilder
public class DefaultFieldSetBuilder extends java.lang.Object implements FieldSetBuilder
Default implementation ofFieldSetBuilder
-
-
Constructor Summary
Constructors Constructor Description DefaultFieldSetBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddToFieldSet(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 definitionjava.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 namesjava.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.StringcreateFullFieldName(java.lang.String basePrefix, java.lang.String fieldName)Method create fully qualified field nameprotected static intfindElementEnd(int startIndex, java.lang.String configuration)protected static intfindMatchingCloseBracket(java.lang.String configuration, int openPos)protected java.lang.ClassgetClassForType(java.lang.reflect.Type fieldType)intgetDefaultMaxFieldSetSize()intgetDefaultRecurrencyLevel()protected java.lang.StringgetElementName(int startIndex, java.lang.String configuration)FieldSetLevelHelpergetFieldSetLevelHelper()protected java.lang.reflect.TypegetFieldType(java.lang.String fieldName, java.lang.Class objectClass)Method returns field typejava.util.Set<java.lang.Class>getSimpleClassSet()SubclassRegistrygetSubclassRegistry()protected booleanisSimpleClass(java.lang.Class clazz)Method check if class should be considered as simple.protected intomitBracket(int startIndex, java.lang.String configuration)protected intomitComma(int startIndex, java.lang.String configuration)protected static intomitSpace(int startIndex, java.lang.String configuration)protected intparseComplexField(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 intparseField(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 intparseMapField(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 intparseParametrizedTypeField(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 intparseTypeVariableField(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 intparseWildcardTypeField(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.TypesearchFieldTypeInSubclasses(java.lang.String fieldName, java.lang.Class objectClass)voidsetDefaultMaxFieldSetSize(int defaultMaxFieldSetSize)voidsetDefaultRecurrencyLevel(int defaultRecurrencyLevel)voidsetFieldSetLevelHelper(FieldSetLevelHelper fieldSetLevelHelper)voidsetSimpleClassSet(java.util.Set<java.lang.Class> simpleTypeSet)voidsetSubclassRegistry(SubclassRegistry subclassRegistry)
-
-
-
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: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 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:
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 ProductSearchPageDatawe 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 definitione.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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 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 ProductSearchPageDatawe 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 nameobjectClass- - 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- - prefixfieldName- - 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)
-
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)
-
-