public class DefaultProductAttributeFormatter extends ProductAttributeConverterBase<String> implements ProductAttributeConverter<String>
Constructor and Description |
---|
DefaultProductAttributeFormatter(Collection<ProductType> productTypes,
List<Locale> locales) |
DefaultProductAttributeFormatter(ProductTypeLocalRepository productTypes,
List<Locale> locales) |
Modifier and Type | Method and Description |
---|---|
String |
convert(Attribute attribute,
Referenceable<ProductType> productType)
Formats a product attribute as String.
|
protected String |
convertBoolean(Boolean booleanValue,
Attribute attribute,
ProductType productType) |
protected String |
convertBooleanSet(Set<Boolean> booleanSet,
Attribute attribute,
ProductType productType) |
protected String |
convertCategoryReference(Reference<Category> categoryReference,
Attribute attribute,
ProductType productType) |
protected String |
convertCategoryReferenceSet(Set<Reference<Category>> categoryReferenceSet,
Attribute attribute,
ProductType productType) |
protected String |
convertChannelReference(Reference<Channel> channelReference,
Attribute attribute,
ProductType productType) |
protected String |
convertChannelReferenceSet(Set<Reference<Channel>> channelReferenceSet,
Attribute attribute,
ProductType productType) |
protected String |
convertDate(LocalDate dateValue,
Attribute attribute,
ProductType productType) |
protected String |
convertDateSet(Set<LocalDate> dateSet,
Attribute attribute,
ProductType productType) |
protected String |
convertDateTime(ZonedDateTime dateTimeValue,
Attribute attribute,
ProductType productType) |
protected String |
convertDateTimeSet(Set<ZonedDateTime> zonedDateTimeSet,
Attribute attribute,
ProductType productType) |
protected String |
convertDouble(Double doubleValue,
Attribute attribute,
ProductType productType) |
protected String |
convertDoubleSet(Set<Double> doubleSet,
Attribute attribute,
ProductType productType) |
protected String |
convertEnumValue(EnumValue enumValue,
Attribute attribute,
ProductType productType) |
protected String |
convertEnumValueSet(Set<EnumValue> enumValueSet,
Attribute attribute,
ProductType productType) |
protected String |
convertInteger(Integer integer,
Attribute attribute,
ProductType productType) |
protected String |
convertIntegerSet(Set<Integer> integerSet,
Attribute attribute,
ProductType productType) |
protected String |
convertLocalizedEnumValue(LocalizedEnumValue localizedEnumValue,
Attribute attribute,
ProductType productType) |
protected String |
convertLocalizedEnumValueSet(Set<LocalizedEnumValue> localizedEnumValueSet,
Attribute attribute,
ProductType productType) |
protected String |
convertLocalizedString(LocalizedString localizedString,
Attribute attribute,
ProductType productType) |
protected String |
convertLocalizedStringSet(Set<LocalizedString> localizedStringSet,
Attribute attribute,
ProductType productType) |
protected String |
convertLong(Long longValue,
Attribute attribute,
ProductType productType) |
protected String |
convertLongSet(Set<Long> longSet,
Attribute attribute,
ProductType productType) |
protected String |
convertMoney(javax.money.MonetaryAmount moneyValue,
Attribute attribute,
ProductType productType) |
protected String |
convertMoneySet(Set<javax.money.MonetaryAmount> monetaryAmountSet,
Attribute attribute,
ProductType productType) |
protected String |
convertProductReference(Reference<Product> productReference,
Attribute attribute,
ProductType productType) |
protected String |
convertProductReferenceSet(Set<Reference<Product>> referenceSet,
Attribute attribute,
ProductType productType) |
protected String |
convertProductTypeReference(Reference<ProductType> productTypeReference,
Attribute attribute,
ProductType productType) |
protected String |
convertProductTypeReferenceSet(Set<Reference<ProductType>> productTypeReferenceSet,
Attribute attribute,
ProductType productType) |
protected <X> String |
convertReference(Reference<X> reference,
ProductType productType) |
protected <X> String |
convertReferenceSet(Set<Reference<X>> referenceSet,
ProductType productType) |
protected String |
convertString(String stringValue,
Attribute attribute,
ProductType productType) |
protected String |
convertStringSet(Set<String> stringSet,
Attribute attribute,
ProductType productType) |
protected String |
convertTime(LocalTime time,
Attribute attribute,
ProductType productType) |
protected String |
convertTimeSet(Set<LocalTime> timeSet,
Attribute attribute,
ProductType productType) |
Map.Entry<String,String> |
createAttributeEntry(Attribute attribute,
Referenceable<ProductType> productTypeRef)
Creates an entry for a single attribute with translated and formatted label and value by requiring a reference to the product type.
|
List<Map.Entry<String,String>> |
createAttributeEntryList(ProductVariant variant,
Reference<ProductType> productType,
List<String> attrNamesToShow)
Creates a list of attribute translated and formatted labels and values.
|
String |
format(Attribute attribute,
Referenceable<ProductType> productType)
Formats a product attribute as String, alias of
convert(Attribute, Referenceable) . |
protected List<Locale> |
getLocales() |
protected Locale |
locale() |
convertWithProductType, findProductType, integerAttributes, integerSetAttributes, isInteger, isIntegerSet, isLong, isLongSet, longAttributes, longSetAttributes
public DefaultProductAttributeFormatter(ProductTypeLocalRepository productTypes, List<Locale> locales)
public DefaultProductAttributeFormatter(Collection<ProductType> productTypes, List<Locale> locales)
@Nullable public String convert(Attribute attribute, Referenceable<ProductType> productType)
ProductLike.getProductType()
or
ProductLike.getProductType()
.convert
in interface ProductAttributeConverter<String>
convert
in class ProductAttributeConverterBase<String>
attribute
- the attribute which should be formattedproductType
- the reference of the product type of this attribute, it is not necessary to expand the reference@Nullable public String format(Attribute attribute, Referenceable<ProductType> productType)
convert(Attribute, Referenceable)
.
The product type reference is typically extracted using
ProductLike.getProductType()
or
ProductLike.getProductType()
.attribute
- the attribute which should be formattedproductType
- the reference of the product type of this attribute, it is not necessary to expand the referencepublic List<Map.Entry<String,String>> createAttributeEntryList(ProductVariant variant, Reference<ProductType> productType, List<String> attrNamesToShow)
variant
- the product variant which holds attributesproductType
- the product type belonging to the product variantattrNamesToShow
- a list containing the attribute names (the name is used as key) which clafies which attributes are allowed to displayed and also give an order to display them@Nullable public Map.Entry<String,String> createAttributeEntry(Attribute attribute, Referenceable<ProductType> productTypeRef)
attribute
- the attribute as data sourceproductTypeRef
- the product type belonging to product containing the attributesprotected Locale locale()
@Nullable protected <X> String convertReference(Reference<X> reference, ProductType productType)
@Nullable protected <X> String convertReferenceSet(Set<Reference<X>> referenceSet, ProductType productType)
protected String convertStringSet(Set<String> stringSet, Attribute attribute, ProductType productType)
convertStringSet
in class ProductAttributeConverterBase<String>
protected String convertProductTypeReferenceSet(Set<Reference<ProductType>> productTypeReferenceSet, Attribute attribute, ProductType productType)
convertProductTypeReferenceSet
in class ProductAttributeConverterBase<String>
protected String convertProductTypeReference(Reference<ProductType> productTypeReference, Attribute attribute, ProductType productType)
convertProductTypeReference
in class ProductAttributeConverterBase<String>
protected String convertProductReferenceSet(Set<Reference<Product>> referenceSet, Attribute attribute, ProductType productType)
convertProductReferenceSet
in class ProductAttributeConverterBase<String>
protected String convertProductReference(Reference<Product> productReference, Attribute attribute, ProductType productType)
convertProductReference
in class ProductAttributeConverterBase<String>
protected String convertMoneySet(Set<javax.money.MonetaryAmount> monetaryAmountSet, Attribute attribute, ProductType productType)
convertMoneySet
in class ProductAttributeConverterBase<String>
protected String convertLongSet(Set<Long> longSet, Attribute attribute, ProductType productType)
convertLongSet
in class ProductAttributeConverterBase<String>
protected String convertLong(Long longValue, Attribute attribute, ProductType productType)
convertLong
in class ProductAttributeConverterBase<String>
protected String convertTimeSet(Set<LocalTime> timeSet, Attribute attribute, ProductType productType)
convertTimeSet
in class ProductAttributeConverterBase<String>
protected String convertTime(LocalTime time, Attribute attribute, ProductType productType)
convertTime
in class ProductAttributeConverterBase<String>
protected String convertLocalizedStringSet(Set<LocalizedString> localizedStringSet, Attribute attribute, ProductType productType)
convertLocalizedStringSet
in class ProductAttributeConverterBase<String>
protected String convertLocalizedEnumValueSet(Set<LocalizedEnumValue> localizedEnumValueSet, Attribute attribute, ProductType productType)
convertLocalizedEnumValueSet
in class ProductAttributeConverterBase<String>
protected String convertIntegerSet(Set<Integer> integerSet, Attribute attribute, ProductType productType)
convertIntegerSet
in class ProductAttributeConverterBase<String>
protected String convertInteger(Integer integer, Attribute attribute, ProductType productType)
convertInteger
in class ProductAttributeConverterBase<String>
protected String convertEnumValueSet(Set<EnumValue> enumValueSet, Attribute attribute, ProductType productType)
convertEnumValueSet
in class ProductAttributeConverterBase<String>
protected String convertDoubleSet(Set<Double> doubleSet, Attribute attribute, ProductType productType)
convertDoubleSet
in class ProductAttributeConverterBase<String>
protected String convertDouble(Double doubleValue, Attribute attribute, ProductType productType)
convertDouble
in class ProductAttributeConverterBase<String>
protected String convertDateTimeSet(Set<ZonedDateTime> zonedDateTimeSet, Attribute attribute, ProductType productType)
convertDateTimeSet
in class ProductAttributeConverterBase<String>
protected String convertDateSet(Set<LocalDate> dateSet, Attribute attribute, ProductType productType)
convertDateSet
in class ProductAttributeConverterBase<String>
protected String convertChannelReferenceSet(Set<Reference<Channel>> channelReferenceSet, Attribute attribute, ProductType productType)
convertChannelReferenceSet
in class ProductAttributeConverterBase<String>
protected String convertChannelReference(Reference<Channel> channelReference, Attribute attribute, ProductType productType)
convertChannelReference
in class ProductAttributeConverterBase<String>
protected String convertCategoryReferenceSet(Set<Reference<Category>> categoryReferenceSet, Attribute attribute, ProductType productType)
convertCategoryReferenceSet
in class ProductAttributeConverterBase<String>
protected String convertCategoryReference(Reference<Category> categoryReference, Attribute attribute, ProductType productType)
convertCategoryReference
in class ProductAttributeConverterBase<String>
protected String convertBooleanSet(Set<Boolean> booleanSet, Attribute attribute, ProductType productType)
convertBooleanSet
in class ProductAttributeConverterBase<String>
protected String convertString(String stringValue, Attribute attribute, ProductType productType)
convertString
in class ProductAttributeConverterBase<String>
protected String convertMoney(javax.money.MonetaryAmount moneyValue, Attribute attribute, ProductType productType)
convertMoney
in class ProductAttributeConverterBase<String>
protected String convertLocalizedString(LocalizedString localizedString, Attribute attribute, ProductType productType)
convertLocalizedString
in class ProductAttributeConverterBase<String>
protected String convertLocalizedEnumValue(LocalizedEnumValue localizedEnumValue, Attribute attribute, ProductType productType)
convertLocalizedEnumValue
in class ProductAttributeConverterBase<String>
protected String convertEnumValue(EnumValue enumValue, Attribute attribute, ProductType productType)
convertEnumValue
in class ProductAttributeConverterBase<String>
protected String convertDateTime(ZonedDateTime dateTimeValue, Attribute attribute, ProductType productType)
convertDateTime
in class ProductAttributeConverterBase<String>
protected String convertDate(LocalDate dateValue, Attribute attribute, ProductType productType)
convertDate
in class ProductAttributeConverterBase<String>
protected String convertBoolean(Boolean booleanValue, Attribute attribute, ProductType productType)
convertBoolean
in class ProductAttributeConverterBase<String>