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:
java.io.Serializable,java.lang.Cloneable
public class TypedFeature<T> extends Feature<T>
Class for holding values for typed features. These features are must be backed by a existingClassAttributeAssignment. This way the feature type, its localization status and its number format is configured automatically.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTypedFeature.FeatureTypeThe enum for easier feature type handling.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONVERT_TO_FEATUREUNITSession context option to switch off automatic number conversion when callinggetValuesDirect(SessionContext).
-
Constructor Summary
Constructors Modifier Constructor Description protectedTypedFeature(FeatureContainer parent, ClassAttributeAssignment assignment)Creates a new typed feature object.protectedTypedFeature(TypedFeature<T> src)Clone constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassureSelectableValue(ClassificationAttributeValue value)TypedFeature<T>clone()FeatureValue<T>createValue(SessionContext ctx, int index, java.lang.Object value)Overridden to create a new value for this feature according to the configured value type.FeatureValue<T>createValue(SessionContext ctx, int index, java.lang.Object value, boolean typeSafe)Overridden to create a new value for this feature according to the configured value type.ClassAttributeAssignmentgetClassAttributeAssignment()Returns the assignment which backs this feature.ClassificationAttributegetClassificationAttribute()Returns the classification attribute of the assignment which backs this feature.ClassificationClassgetClassificationClass()Returns the classification class of the assignment which backs this feature.java.lang.StringgetCode()Returns the classification attribute code of the associatedClassificationAttribute.java.text.DateFormatgetDateFormat(SessionContext ctx)Overridden to provide the date format defined byClassAttributeAssignment.getDateFormat(SessionContext).TypedFeature.FeatureTypegetFeatureType()Returns the feature type enum instead of the actualEnumerationValuereturned byGeneratedClassAttributeAssignment.getAttributeType(SessionContext).java.lang.StringgetName(SessionContext ctx)OverridesFeature.getName(SessionContext)to return the localized attribute name.java.text.NumberFormatgetNumberFormat(SessionContext ctx)Overridden to provide the number format defined byClassAttributeAssignment.getNumberFormat(SessionContext).ClassificationAttributeValuegetSelectableValue(java.lang.String code)Convenience method to pick one selectable value for this feature using its code.java.util.Collection<ClassificationAttributeValue>getSelectableValues()Returns all assignable values for this feature.protected java.lang.StringgetUniqueKey()ClassificationAttributeUnitgetUnit()Returns the configured classification attribute unit of the assignment which backs this feature.java.util.List<T>getValuesDirect(SessionContext ctx)OverridesFeature.getValuesDirect(SessionContext)by converting all number values into the feature'sClassificationAttributeUnit.java.lang.StringgetValuesFormatted(SessionContext ctx)Overridden to format range features specially.FeatureValue<T>setSelectableValue(SessionContext ctx, java.lang.String code)Convenience method for setting enumeration values without fetching them viagetSelectableValue(String).FeatureValue<T>setSelectableValue(java.lang.String code)Convenience method for setting enumeration values without fetching them viagetSelectableValue(String).java.util.List<FeatureValue<T>>setSelectableValues(SessionContext ctx, java.lang.String... codes)Stores a list ofclassification enum valuesby specifying their code.java.util.List<FeatureValue<T>>setSelectableValues(SessionContext ctx, java.util.List<java.lang.String> codes)Stores a list ofclassification enum valuesby specifying their code.java.util.List<FeatureValue<T>>setSelectableValues(java.lang.String... codes)Stores a list ofclassification enum valuesby specifying their code.java.util.List<FeatureValue<T>>setSelectableValues(java.util.List<java.lang.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 Detail
-
CONVERT_TO_FEATUREUNIT
public static final java.lang.String 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:
- Constant Field Values
-
-
Constructor Detail
-
TypedFeature
protected TypedFeature(FeatureContainer parent, ClassAttributeAssignment assignment)
Creates a new typed feature object.- Parameters:
parent- the container which this feature belongs toassignment- the assignment which backs this feature
-
TypedFeature
protected TypedFeature(TypedFeature<T> src) throws java.lang.CloneNotSupportedException
Clone constructor. Don't use directly!- Parameters:
src- the source feature- Throws:
java.lang.CloneNotSupportedException
-
-
Method Detail
-
clone
public TypedFeature<T> clone() throws java.lang.CloneNotSupportedException
-
getName
public java.lang.String getName(SessionContext ctx)
OverridesFeature.getName(SessionContext)to return the localized attribute name.
-
getCode
public java.lang.String getCode()
Returns the classification attribute code of the associatedClassificationAttribute.
-
getClassAttributeAssignment
public ClassAttributeAssignment getClassAttributeAssignment()
Returns the assignment which backs this feature.
-
getClassificationAttribute
public ClassificationAttribute getClassificationAttribute()
Returns the classification attribute of the assignment which backs this feature.
-
getClassificationClass
public ClassificationClass getClassificationClass()
Returns the classification class of the assignment which backs this feature.
-
getUnit
public ClassificationAttributeUnit getUnit()
Returns the configured classification attribute unit of the assignment which backs this feature.
-
getSelectableValue
public ClassificationAttributeValue getSelectableValue(java.lang.String code)
Convenience method to pick one selectable value for this feature using its code.- Parameters:
code- the code of theClassificationAttributeValueto pick
-
getSelectableValues
public java.util.Collection<ClassificationAttributeValue> getSelectableValues()
Returns all assignable values for this feature.
-
setSelectableValue
public FeatureValue<T> setSelectableValue(java.lang.String code)
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
public FeatureValue<T> setSelectableValue(SessionContext ctx, java.lang.String code)
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
public java.util.List<FeatureValue<T>> setSelectableValues(java.lang.String... codes)
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
public java.util.List<FeatureValue<T>> setSelectableValues(java.util.List<java.lang.String> codes)
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
public java.util.List<FeatureValue<T>> setSelectableValues(SessionContext ctx, java.lang.String... codes)
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
public java.util.List<FeatureValue<T>> setSelectableValues(SessionContext ctx, java.util.List<java.lang.String> codes)
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
public TypedFeature.FeatureType getFeatureType()
Returns the feature type enum instead of the actualEnumerationValuereturned byGeneratedClassAttributeAssignment.getAttributeType(SessionContext).
-
getUniqueKey
protected java.lang.String getUniqueKey()
- Specified by:
getUniqueKeyin classFeature<T>
-
createValue
public FeatureValue<T> createValue(SessionContext ctx, int index, java.lang.Object value)
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
public FeatureValue<T> createValue(SessionContext ctx, int index, java.lang.Object value, boolean typeSafe)
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
public java.lang.String getValuesFormatted(SessionContext ctx)
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
public java.util.List<T> getValuesDirect(SessionContext ctx)
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
public java.text.NumberFormat getNumberFormat(SessionContext ctx)
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
public java.text.DateFormat getDateFormat(SessionContext ctx)
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
-
-