Package org.faktorips.runtime.model.type
Class ProductAttribute
java.lang.Object
org.faktorips.runtime.model.type.ModelElement
org.faktorips.runtime.model.type.TypePart
org.faktorips.runtime.model.type.Attribute
org.faktorips.runtime.model.type.ProductAttribute
Represents an attribute in a
ProductCmptType.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProductAttribute(Type type, boolean changingOverTime, Method getter, Method setter) -
Method Summary
Modifier and TypeMethodDescriptioncreateOverwritingAttributeFor(Type subType) Creates an attribute model for a sub type in which this attribute is overwritten.<T> TReturns the default value defined in the model for this attribute.Deprecated.protected StringgetType()Returns theProductCmptTypethis attribute belongs to.<T> TgetValue(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).booleanWhether this attribute has just one value or multiple values.booleanReturns true if this attribute is configured by the product.voidsetValue(IProductComponentGeneration generation, Object value) Sets the value of this attribute using a product component generation.voidsetValue(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).voidvalidate(MessageList list, IValidationContext context, IProductComponent product, Calendar effectiveDate) Validates this attribute's configuration in the given product against the model.Methods inherited from class org.faktorips.runtime.model.type.Attribute
findSuperAttribute, getAttributeKind, getDatatype, getDocumentation, getRelevantProductObject, getRelevantProductObject, getSuperAttribute, getValueSetFromModel, getValueSetKind, isChangingOverTime, isOverriding, toString, validateMethods inherited from class org.faktorips.runtime.model.type.TypePart
getMessageHelper, getMessageKey, getTypeNameMethods inherited from class org.faktorips.runtime.model.type.ModelElement
createMessageHelper, getDeprecation, getDescription, getExtensionPropertyIds, getExtensionPropertyValue, getLabel, getName, getRelevantProductObject, getRelevantProductObject, invokeField, invokeMethod, isDeprecated
-
Field Details
-
MSGCODE_VALUE_NOT_IN_VALUE_SET
- See Also:
-
MSGKEY_VALUE_NOT_IN_VALUE_SET
- See Also:
-
MSGCODE_DUPLICATE_VALUE
- See Also:
-
MSGKEY_DUPLICATE_VALUE
- See Also:
-
PROPERTY_VALUE
- See Also:
-
-
Constructor Details
-
ProductAttribute
-
-
Method Details
-
getType
Returns theProductCmptTypethis attribute belongs to. -
getModelType
Deprecated.UsegetType()Returns the parentType- Overrides:
getModelTypein classTypePart
-
isProductRelevant
public boolean isProductRelevant()Description copied from class:AttributeReturns true if this attribute is configured by the product. Product attributes are always product relevant.- Specified by:
isProductRelevantin classAttribute- Returns:
trueif this attribute is configured by the product,falseif not
-
createOverwritingAttributeFor
Description copied from class:AttributeCreates 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:
createOverwritingAttributeForin classAttribute- Parameters:
subType- a model type representing a sub type of this attribute's model type- Returns:
- a
Attributefor the given sub model type
-
getValue
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 aListis returned (and it's contents can be cast to the class returned byAttribute.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 attributeAttribute.isChangingOverTime()
-
setValue
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 attributeAttribute.isChangingOverTime()value- the new value- Since:
- 24.1
-
setValue
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 onvalue- 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, butgetValue(IProductComponent, Calendar)will return aList. -
validate
public void validate(MessageList list, IValidationContext context, IProductComponent product, Calendar effectiveDate) Description copied from class:AttributeValidates this attribute's configuration in the given product against the model.- Overrides:
validatein classAttribute- Parameters:
list- aMessageList, to which validation messages may be addedcontext- theIValidationContext, needed to determine theLocalein which to createMessagesproduct- theIProductComponentto validateeffectiveDate- the date that determines whichIProductComponentGenerationis to be validated, if theIProductComponenthas any
-
getDefaultValueFromModel
public <T> T getDefaultValueFromModel()Description copied from class:AttributeReturns the default value defined in the model for this attribute.- Overrides:
getDefaultValueFromModelin classAttribute
-
getResourceBundleName
- Specified by:
getResourceBundleNamein classAttribute
-
getType()