Class ProductAttribute


public class ProductAttribute extends Attribute
Represents an attribute in a ProductCmptType.
  • Field Details

  • Constructor Details

    • ProductAttribute

      public ProductAttribute(Type type, boolean changingOverTime, Method getter, Method setter)
  • Method Details

    • getType

      public ProductCmptType getType()
      Returns the ProductCmptType this attribute belongs to.
      Overrides:
      getType in class TypePart
    • getModelType

      @Deprecated public ProductCmptType getModelType()
      Deprecated.
      Returns the parent Type
      Overrides:
      getModelType in class TypePart
    • isProductRelevant

      public boolean isProductRelevant()
      Description copied from class: Attribute
      Returns true if this attribute is configured by the product. Product attributes are always product relevant.
      Specified by:
      isProductRelevant in class Attribute
      Returns:
      true if this attribute is configured by the product, false if not
    • createOverwritingAttributeFor

      public Attribute createOverwritingAttributeFor(Type subType)
      Description copied from class: Attribute
      Creates an attribute model for a sub type in which this attribute is overwritten. This is necessary to retrieve information contained in the class annotation such as labels if no getter is generated for the overwritten attribute in the sub class.
      Specified by:
      createOverwritingAttributeFor in class Attribute
      Parameters:
      subType - a model type representing a sub type of this attribute's model type
      Returns:
      a Attribute for the given sub model type
    • getValue

      public <T> T getValue(IProductComponent productComponent, Calendar effectiveDate)
      Returns the value of this attribute in the given product component (or its generation identified by the effectiveDate, if the attribute is changeable over time).

      It is safe to cast the returned object to the class returned by Attribute.getDatatype(), except when the attribute is a multi-value attribute - then a List is returned (and it's contents can be cast to the class returned by Attribute.getDatatype()).

      Parameters:
      productComponent - a product component based on the product component type this attribute belongs to.
      effectiveDate - (optional) the date to use for selecting the product component's generation, if this attribute Attribute.isChangingOverTime()
    • setValue

      public void setValue(IProductComponent productComponent, Calendar effectiveDate, Object value)
      Sets the value of this attribute in the given product component (or its generation identified by the effectiveDate, if the attribute is changeable over time).
      Parameters:
      productComponent - a product component based on the product component type this attribute belongs to.
      effectiveDate - (optional) the date to use for selecting the product component's generation, if this attribute Attribute.isChangingOverTime()
      value - the new value
      Since:
      24.1
    • setValue

      public void setValue(IProductComponentGeneration generation, Object value)
      Sets the value of this attribute using a product component generation.

      If the attribute is not changing over time, the underlying product component is used directly; otherwise, the provided generation is used.

      Parameters:
      generation - the product component generation to base the value update on
      value - the new value
      Since:
      25.1
    • isMultiValue

      public boolean isMultiValue()
      Whether this attribute has just one value or multiple values. If the attribute has multiple values, Attribute.getDatatype() will still return the class of a single value, but getValue(IProductComponent, Calendar) will return a List.
    • validate

      public void validate(MessageList list, IValidationContext context, IProductComponent product, Calendar effectiveDate)
      Description copied from class: Attribute
      Validates this attribute's configuration in the given product against the model.
      Overrides:
      validate in class Attribute
      Parameters:
      list - a MessageList, to which validation messages may be added
      context - the IValidationContext, needed to determine the Locale in which to create Messages
      product - the IProductComponent to validate
      effectiveDate - the date that determines which IProductComponentGeneration is to be validated, if the IProductComponent has any
    • getDefaultValueFromModel

      public <T> T getDefaultValueFromModel()
      Description copied from class: Attribute
      Returns the default value defined in the model for this attribute.
      Overrides:
      getDefaultValueFromModel in class Attribute
    • getResourceBundleName

      protected String getResourceBundleName()
      Specified by:
      getResourceBundleName in class Attribute