Class TypedFeature<T>
java.lang.Object
de.hybris.platform.catalog.jalo.classification.util.Feature<T>
de.hybris.platform.catalog.jalo.classification.util.TypedFeature<T>
- All Implemented Interfaces:
Serializable,Cloneable
Class for holding values for typed features. These features are must be backed by a existing
ClassAttributeAssignment. This way the feature type, its
localization status and its number format is configured automatically.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe enum for easier feature type handling. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSession context option to switch off automatic number conversion when callinggetValuesDirect(SessionContext). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypedFeature(FeatureContainer parent, ClassAttributeAssignment assignment) Creates a new typed feature object.protectedTypedFeature(TypedFeature<T> src) Clone constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclone()createValue(SessionContext ctx, int index, Object value) Overridden to create a new value for this feature according to the configured value type.createValue(SessionContext ctx, int index, Object value, boolean typeSafe) Overridden to create a new value for this feature according to the configured value type.Returns the assignment which backs this feature.Returns the classification attribute of the assignment which backs this feature.Returns the classification class of the assignment which backs this feature.getCode()Returns the classification attribute code of the associatedClassificationAttribute.Overridden to provide the date format defined byClassAttributeAssignment.getDateFormat(SessionContext).Returns the feature type enum instead of the actualEnumerationValuereturned byGeneratedClassAttributeAssignment.getAttributeType(SessionContext).getName(SessionContext ctx) OverridesFeature.getName(SessionContext)to return the localized attribute name.Overridden to provide the number format defined byClassAttributeAssignment.getNumberFormat(SessionContext).getSelectableValue(String code) Convenience method to pick one selectable value for this feature using its code.Returns all assignable values for this feature.protected StringgetUnit()Returns the configured classification attribute unit of the assignment which backs this feature.OverridesFeature.getValuesDirect(SessionContext)by converting all number values into the feature'sClassificationAttributeUnit.Overridden to format range features specially.setSelectableValue(SessionContext ctx, String code) Convenience method for setting enumeration values without fetching them viagetSelectableValue(String).setSelectableValue(String code) Convenience method for setting enumeration values without fetching them viagetSelectableValue(String).setSelectableValues(SessionContext ctx, String... codes) Stores a list ofclassification enum valuesby specifying their code.setSelectableValues(SessionContext ctx, List<String> codes) Stores a list ofclassification enum valuesby specifying their code.setSelectableValues(String... codes) Stores a list ofclassification enum valuesby specifying their code.setSelectableValues(List<String> codes) Stores a list ofclassification enum valuesby specifying their code.Methods inherited from class de.hybris.platform.catalog.jalo.classification.util.Feature
add, assureOwnValue, clear, clear, clearAll, createValue, createValue, createValue, createValues, createValues, createValues, createValues, equals, extractLanguage, getAllDescriptions, getAllDescriptions, getLanguageValues, getName, getParent, getValue, getValue, getValues, getValues, getValuesDirect, getValuesFormatted, hashCode, isEmpty, isEmpty, isEmptyIgnoringLanguage, isFallbackEnabled, isLocalized, loadTyped, loadTyped, loadValue, moveValue, moveValue, remove, remove, remove, removeValue, setLocalized, setValue, setValue, setValues, setValues, setValues, setValues, size, size, toString, writeToDatabase
-
Field Details
-
CONVERT_TO_FEATUREUNIT
Session context option to switch off automatic number conversion when callinggetValuesDirect(SessionContext).SessionContext ctx = jaloSession.createSessionContext(); ctx.setAttribute(TypedFeature.CONVERT_TO_FEATUREUNIT, false); List<Number> numbersNotConverted = feat.getValuesDirect(ctx);
- See Also:
-
-
Constructor Details
-
TypedFeature
Creates a new typed feature object.- Parameters:
parent- the container which this feature belongs toassignment- the assignment which backs this feature
-
TypedFeature
Clone constructor. Don't use directly!- Parameters:
src- the source feature- Throws:
CloneNotSupportedException
-
-
Method Details
-
clone
- Specified by:
clonein classFeature<T>- Throws:
CloneNotSupportedException
-
getName
OverridesFeature.getName(SessionContext)to return the localized attribute name. -
getCode
Returns the classification attribute code of the associatedClassificationAttribute. -
getClassAttributeAssignment
Returns the assignment which backs this feature. -
getClassificationAttribute
Returns the classification attribute of the assignment which backs this feature. -
getClassificationClass
Returns the classification class of the assignment which backs this feature. -
getUnit
Returns the configured classification attribute unit of the assignment which backs this feature. -
getSelectableValue
Convenience method to pick one selectable value for this feature using its code.- Parameters:
code- the code of theClassificationAttributeValueto pick
-
getSelectableValues
Returns all assignable values for this feature. -
setSelectableValue
Convenience method for setting enumeration values without fetching them viagetSelectableValue(String).- Parameters:
code- the code of the classification enumeration value to set as value- Returns:
- the new or updated feature value instance
- Throws:
JaloInvalidParameterException- if no such value exists for the underlying class attribute assignment
-
setSelectableValue
Convenience method for setting enumeration values without fetching them viagetSelectableValue(String).- Parameters:
ctx- the session context to perform this operation withincode- the code of the classification enumeration value to set as value- Returns:
- the new or updated feature value instance
- Throws:
JaloInvalidParameterException- if no such value exists for the underlying class attribute assignment
-
setSelectableValues
Stores a list ofclassification enum valuesby specifying their code. This is a convenience method to avoid fetching all enum values viagetSelectableValue(String)first.- Parameters:
codes- the list of enumeration value codes- Returns:
- the newly created or update feature values
- Throws:
JaloInvalidParameterException- if at least one value does not exists for the underlying class attribute assignment
-
setSelectableValues
Stores a list ofclassification enum valuesby specifying their code. This is a convenience method to avoid fetching all enum values viagetSelectableValue(String)first.- Parameters:
codes- the list of enumeration value codes- Returns:
- the newly created or update feature values
- Throws:
JaloInvalidParameterException- if at least one value does not exists for the underlying class attribute assignment
-
setSelectableValues
Stores a list ofclassification enum valuesby specifying their code. This is a convenience method to avoid fetching all enum values viagetSelectableValue(String)first.- Parameters:
ctx- the session context to perform this operation withincodes- the list of enumeration value codes- Returns:
- the newly created or update feature values
- Throws:
JaloInvalidParameterException- if at least one value does not exists for the underlying class attribute assignment
-
setSelectableValues
Stores a list ofclassification enum valuesby specifying their code. This is a convenience method to avoid fetching all enum values viagetSelectableValue(String)first.- Parameters:
ctx- the session context to perform this operation withincodes- the list of enumeration value codes- Returns:
- the newly created or update feature values
- Throws:
JaloInvalidParameterException- if at least one value does not exists for the underlying class attribute assignment
-
getFeatureType
Returns the feature type enum instead of the actualEnumerationValuereturned byGeneratedClassAttributeAssignment.getAttributeType(SessionContext). -
getUniqueKey
- Specified by:
getUniqueKeyin classFeature<T>
-
createValue
Overridden to create a new value for this feature according to the configured value type.- Specified by:
createValuein classFeature<T>- Parameters:
ctx- the session context to define session language ( if feature is localized )index- the value index to insert new value at;-1to append at the endvalue- the actual value to wrap inside the feature value object- Returns:
- the new feature value object
-
createValue
Overridden to create a new value for this feature according to the configured value type.- Parameters:
ctx- the session context to define session language ( if feature is localized )index- the value index to insert new value at;-1to append at the endvalue- the actual value to wrap inside the feature value objecttypeSafe- if true throws an error if given Object is not of correct type, else creates an feature value of type String- Returns:
- the new feature value object
-
getValuesFormatted
Overridden to format range features specially.- Overrides:
getValuesFormattedin classFeature<T>- Parameters:
ctx- the session context which defines the language to choose the value for
-
getValuesDirect
OverridesFeature.getValuesDirect(SessionContext)by converting all number values into the feature'sClassificationAttributeUnit.This can be controlled by using the
CONVERT_TO_FEATUREUNITsession context attriute:SessionContext myCtx = jaloSession.createSessionContext(); // to switch off automatic conversion: myCtx.setAttribute(TypedFeature.CONVERT_TO_FEATUREUNIT, Boolean.FALSE); List<Number> numbers = typedfeature.getValuesDirect(myCtx);
- Overrides:
getValuesDirectin classFeature<T>- Parameters:
ctx- the session context defining the language to get values for
-
getNumberFormat
Overridden to provide the number format defined byClassAttributeAssignment.getNumberFormat(SessionContext).If no number format is stored there just
Feature.getNumberFormat(SessionContext)is called.- Overrides:
getNumberFormatin classFeature<T>
-
getDateFormat
Overridden to provide the date format defined byClassAttributeAssignment.getDateFormat(SessionContext).If no number format is stored there just
Feature.getDateFormat(SessionContext)is called.- Overrides:
getDateFormatin classFeature<T>
-
assureSelectableValue
protected void assureSelectableValue(ClassificationAttributeValue value) throws JaloInvalidParameterException - Throws:
JaloInvalidParameterException
-