public final class AttributeDefinitionBuilder extends Base implements Builder<AttributeDefinition>
For AttributeType
s use the Javadoc page of AttributeType
s.
brief example:
final AttributeDefinition isbn = AttributeDefinitionBuilder .of(ISBN_ATTR_NAME, en("ISBN"), StringAttributeType.of()) .build(); final ProductTypeDraft productTypeDraft = ProductTypeDraft.of(randomKey(), BOOK_PRODUCT_TYPE_NAME, "books", asList(isbn)); final ProductType productType = client().executeBlocking(ProductTypeCreateCommand.of(productTypeDraft));
See the test code.
long example:
final LocalizedEnumValue green = LocalizedEnumValue.of("green", LocalizedString.of(ENGLISH, "green").plus(GERMAN, "grün")); final LocalizedEnumValue red = LocalizedEnumValue.of("red", LocalizedString.of(ENGLISH, "red").plus(GERMAN, "rot")); final AttributeDefinition color = AttributeDefinitionBuilder .of(COLOR_ATTR_NAME, en("color"), LocalizedEnumAttributeType.of(red, green)) .required(true) .build(); final EnumValue s = EnumValue.of("S", "S"); final EnumValue m = EnumValue.of("M", "M"); final EnumValue x = EnumValue.of("X", "X"); final AttributeDefinition size = AttributeDefinitionBuilder .of(SIZE_ATTR_NAME, en("size"), EnumAttributeType.of(s, m, x)) .required(true) .build(); final LocalizedEnumValue cold = LocalizedEnumValue.of("cold", LocalizedString.of(ENGLISH, "Wash at or below 30°C ").plus(GERMAN, "30°C")); final LocalizedEnumValue hot = LocalizedEnumValue.of("hot", LocalizedString.of(ENGLISH, "Wash at or below 60°C ").plus(GERMAN, "60°C")); final LocalizedEnumValue tumbleDrying = LocalizedEnumValue.of("tumbleDrying", LocalizedString.of(ENGLISH, "tumble drying").plus(GERMAN, "Trommeltrocknen")); final LocalizedEnumValue noTumbleDrying = LocalizedEnumValue.of("noTumbleDrying", LocalizedString.of(ENGLISH, "no tumble drying").plus(GERMAN, "Nicht im Trommeltrockner trocknen")); final SetAttributeType laundryLabelType = SetAttributeType.of(LocalizedEnumAttributeType.of(cold, hot, tumbleDrying, noTumbleDrying)); final AttributeDefinition laundrySymbols = AttributeDefinitionBuilder .of(LAUNDRY_SYMBOLS_ATTR_NAME, en("washing labels"), laundryLabelType) .build(); final AttributeDefinition matchingProducts = AttributeDefinitionBuilder .of(MATCHING_PRODUCTS_ATTR_NAME, en("matching products"), SetAttributeType.of(ReferenceAttributeType.ofProduct())) .build(); final AttributeDefinition rrp = AttributeDefinitionBuilder .of(RRP_ATTR_NAME, en("recommended retail price"), MoneyAttributeType.of()) .build(); final AttributeDefinition availableSince = AttributeDefinitionBuilder .of(AVAILABLE_SINCE_ATTR_NAME, en("available since"), DateAttributeType.of()) .build(); final List<AttributeDefinition> attributes = asList(color, size, laundrySymbols, matchingProducts, rrp, availableSince); final ProductTypeDraft productTypeDraft = ProductTypeDraft.of(randomKey(), PRODUCT_TYPE_NAME, "a 'T' shaped cloth", attributes); final ProductType productType = client().executeBlocking(ProductTypeCreateCommand.of(productTypeDraft));
See the test code.
public AttributeDefinitionBuilder attributeConstraint(AttributeConstraint attributeConstraint)
public AttributeDefinitionBuilder inputHint(TextInputHint inputHint)
public AttributeDefinitionBuilder label(LocalizedString label)
public AttributeDefinitionBuilder name(String name)
public AttributeDefinitionBuilder inputTip(LocalizedString inputTip)
public AttributeDefinitionBuilder required(boolean isRequired)
public AttributeDefinitionBuilder isRequired(boolean isRequired)
public AttributeDefinitionBuilder searchable(boolean isSearchable)
public AttributeDefinitionBuilder isSearchable(boolean isSearchable)
public AttributeDefinition build()
Builder
build
in interface Builder<AttributeDefinition>
public static AttributeDefinitionBuilder of(String name, LocalizedString label, AttributeType attributeType)
public AttributeConstraint getAttributeConstraint()
public AttributeType getAttributeType()
public TextInputHint getInputHint()
@Nullable public LocalizedString getInputTip()
public Boolean isRequired()
public Boolean isSearchable()
public LocalizedString getLabel()
public String getName()