Class PolicyAttribute
- Direct Known Subclasses:
ConstantPolicyAttribute,DefaultPolicyAttribute
PolicyCmptType.-
Constructor Summary
ConstructorsConstructorDescriptionPolicyAttribute(Type type, IpsAttribute attributeAnnotation, IpsExtensionProperties extensionProperties, Class<?> datatype, boolean changingOverTime, Optional<Deprecation> deprecation) -
Method Summary
Modifier and TypeMethodDescriptiongetDefaultValue(IConfigurableModelObject modelObject) Returns the (product configured) default value of the attribute identified by this configurable model type attribute.abstract ObjectgetDefaultValue(IModelObject modelObject) Returns the (product configured) default value of the attribute identified by this model type attribute.abstract ObjectgetDefaultValue(IProductComponent source, Calendar effectiveDate) Returns the product configured default value of the attribute identified by this model type attribute.Deprecated.Returns the attribute that is overridden by this attribute if this attribute overrides another one.getType()Returns thePolicyCmptTypethis attribute belongs to.abstract ObjectgetValue(IModelObject modelObject) Returns the value of the given model object's attribute identified by this model type attribute.org.faktorips.valueset.ValueSet<?>getValueSet(IModelObject modelObject) Returns the value set of the given model object's attribute identified by this model type attribute.abstract org.faktorips.valueset.ValueSet<?>getValueSet(IModelObject modelObject, IValidationContext context) Returns the value set of the given model object's attribute identified by this model type attribute.org.faktorips.valueset.ValueSet<?>getValueSet(IProductComponent source, Calendar effectiveDate) Returns the value set of the given model object's attribute identified by this model type attribute.abstract org.faktorips.valueset.ValueSet<?>getValueSet(IProductComponent source, Calendar effectiveDate, IValidationContext context) Returns the value set of the given model object's attribute identified by this model type attribute.booleanisEmpty(IModelObject modelObject) Checks whether this attribute is empty on the given model object.booleanisValuePresent(IModelObject modelObject) Checks whether this attribute has a non-empty value on the given model object.abstract voidremoveValue(IModelObject modelObject) Sets the given model object's attribute identified by this model type attribute to its null-value (nullfor most datatypes, aNullObjectfor theNullObjectSupport-datatypesDecimalandMoney, and an empty string for the datatypeString) This only works for changeable attributes.abstract voidsetDefaultValue(IConfigurableModelObject modelObject, Object defaultValue) Sets the product configured default value of the attribute identified by this model type attribute.abstract voidsetDefaultValue(IProductComponent target, Calendar effectiveDate, Object defaultValue) Sets the product configured default value of the attribute identified by this model type attribute.abstract voidsetValue(IModelObject modelObject, Object value) Sets the given model object's attribute identified by this model type attribute to the given value.abstract voidsetValueSet(IConfigurableModelObject modelObject, org.faktorips.valueset.ValueSet<?> valueSet) Sets the product configured set of allowed values of the attribute identified by this model type attribute.abstract voidsetValueSet(IProductComponent target, Calendar effectiveDate, org.faktorips.valueset.ValueSet<?> valueSet) Sets the product configured set of allowed values of the attribute identified by this model type attribute.Methods inherited from class org.faktorips.runtime.model.type.Attribute
createOverwritingAttributeFor, findSuperAttribute, getAttributeKind, getDatatype, getDocumentation, getRelevantProductObject, getValueSetKind, isChangingOverTime, isOverriding, isProductRelevant, toStringMethods 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, invokeField, invokeMethod, isDeprecated
-
Constructor Details
-
PolicyAttribute
public PolicyAttribute(Type type, IpsAttribute attributeAnnotation, IpsExtensionProperties extensionProperties, Class<?> datatype, boolean changingOverTime, Optional<Deprecation> deprecation)
-
-
Method Details
-
getType
Returns thePolicyCmptTypethis attribute belongs to. -
getModelType
Deprecated.UsegetType()Returns the parentType- Overrides:
getModelTypein classTypePart
-
getSuperAttribute
Description copied from class:AttributeReturns the attribute that is overridden by this attribute if this attribute overrides another one. Otherwise returnsnull.- Overrides:
getSuperAttributein classAttribute- Returns:
- The attribute that is overridden by this attribute.
- See Also:
-
getValue
Returns the value of the given model object's attribute identified by this model type attribute.- Parameters:
modelObject- a model object corresponding to theTypethis attribute belongs to- Returns:
- the value of the given model object's attribute identified by this model type attribute
- Throws:
IllegalArgumentException- if the model object does not have an attribute fitting this model type attribute or that attribute is not accessible for any reason
-
setValue
Sets the given model object's attribute identified by this model type attribute to the given value. This only works for changeable attributes.- Parameters:
modelObject- a model object corresponding to theTypethis attribute belongs tovalue- an object of this model type attribute's datatype- Throws:
IllegalArgumentException- if the model object does not have a changeable attribute fitting this model type attribute or that attribute is not accessible for any reason or the value does not fit the attribute's datatype.UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.
-
removeValue
Sets the given model object's attribute identified by this model type attribute to its null-value (nullfor most datatypes, aNullObjectfor theNullObjectSupport-datatypesDecimalandMoney, and an empty string for the datatypeString) This only works for changeable attributes.- Parameters:
modelObject- a model object corresponding to theTypethis attribute belongs to- Throws:
IllegalArgumentException- if the model object does not have a changeable attribute fitting this model type attribute or that attribute is not accessible for any reason.UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.- Since:
- 21.6
-
isEmpty
Checks whether this attribute is empty on the given model object.An attribute is considered empty if its value is one of the following cases:
nullNullObject- empty/blank
String
- Returns:
trueif empty- Since:
- 21.6
-
isValuePresent
Checks whether this attribute has a non-empty value on the given model object.- Since:
- 21.6
- See Also:
-
getDefaultValue
Returns the (product configured) default value of the attribute identified by this configurable model type attribute. Throws anIllegalStateExceptionif the model object has no default value constant or the product has no getDefaultValue~() method for this attribute.- API Note:
- this method is supplanted by the more general
getDefaultValue(IModelObject)but remains here for compile time compatibility with older versions. - Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrieved- Throws:
IllegalStateException- if the model object has no default value constant or the product has no getter method for this attribute's default value.IllegalArgumentException- if the invocation of the method that should get the default value for this attribute fails for any reason- See Also:
-
getDefaultValue
Returns the (product configured) default value of the attribute identified by this model type attribute. Throws anIllegalStateExceptionif the model object has no default value constant or the product has no getDefaultValue~() method for this attribute.- Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrieved- Throws:
IllegalStateException- if the model object has no default value constant or the product has no getter method for this attribute's default value.IllegalArgumentException- if the invocation of the method that should get the default value for this attribute fails for any reason- Since:
- 22.6
- See Also:
-
getDefaultValue
Returns the product configured default value of the attribute identified by this model type attribute.- Parameters:
source- the product component to read the attribute default value from.effectiveDate- the date to determine the product component generation. Ifnullthe latest generation is used. Is ignored if the attribute's configuration is not changing over time.- Throws:
UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.IllegalStateException- if the model object has no getter method for this attribute's default value. This also occurs if the corresponding policy class is not configured by a product class.IllegalArgumentException- if the invocation of the method that should get the default value for this attribute fails for any reason
-
setDefaultValue
Sets the product configured default value of the attribute identified by this model type attribute.- Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrieveddefaultValue- the new default value- Throws:
UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.IllegalStateException- if the model object has no setter method for this attribute's default value. This also occurs if the corresponding policy class is not configured by a product class.IllegalArgumentException- if the invocation of the method that should set the default value for this attribute fails for any reason- Since:
- 20.6
-
setDefaultValue
public abstract void setDefaultValue(IProductComponent target, Calendar effectiveDate, Object defaultValue) Sets the product configured default value of the attribute identified by this model type attribute.- Parameters:
target- the product component to write the attribute default value toeffectiveDate- the date to determine the product component generation. Ifnullthe latest generation is used. Is ignored if the attribute's configuration is not changing over time.defaultValue- the new default value- Throws:
UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.IllegalStateException- if the model object has no setter method for this attribute's default value. This also occurs if the corresponding policy class is not configured by a product class.IllegalArgumentException- if the invocation of the method that should set the default value for this attribute fails for any reason- Since:
- 20.6
-
getValueSet
public abstract org.faktorips.valueset.ValueSet<?> getValueSet(IModelObject modelObject, IValidationContext context) Returns the value set of the given model object's attribute identified by this model type attribute.Note: If the
PolicyCmptTypethisPolicyAttributebelongs to defines anUnrestrictedValueSetincludingnull, no method is generated by Faktor-IPS. Therefore, a value set method in a subclass is not found even if theIModelObjectpassed to this method is an instance of that subclass. To make sure to get the correct value set, always useIpsModel.getPolicyCmptType(IModelObject)on the actualIModelObjectinstead ofIpsModel.getPolicyCmptType(Class)on the super class.- Parameters:
modelObject- a model object- Throws:
IllegalStateException- if the method that should return a value set for this attribute has too many argumentsIllegalArgumentException- if the invocation of the method that should return a value set for this attribute fails for any reason
-
getValueSet
Returns the value set of the given model object's attribute identified by this model type attribute.Note: If the
This method uses a defaultPolicyCmptTypethisPolicyAttributebelongs to defines anUnrestrictedValueSetincludingnull, no method is generated by Faktor-IPS. Therefore, a value set method in a subclass is not found even if theIModelObjectpassed to this method is an instance of that subclass. To make sure to get the correct value set, always useIpsModel.getPolicyCmptType(IModelObject)on the actualIModelObjectinstead ofIpsModel.getPolicyCmptType(Class)on the super class.IValidationContext.- Parameters:
modelObject- a model object- Throws:
IllegalStateException- if the method that should return a value set for this attribute has too many argumentsIllegalArgumentException- if the invocation of the method that should return a value set for this attribute fails for any reason
-
getValueSet
public abstract org.faktorips.valueset.ValueSet<?> getValueSet(IProductComponent source, Calendar effectiveDate, IValidationContext context) Returns the value set of the given model object's attribute identified by this model type attribute. Returns anUnrestrictedValueSetif there is no method that returns a value set for this attribute.- Parameters:
source- the product component to read an attribute value set from. Must correspond to theTypethis attribute belongs to.effectiveDate- the date to determine the product component generation. Ifnullthe latest generation is used. Is ignored if the attribute's configuration is not changing over time.- Throws:
IllegalStateException- if the method that should return a value set for this attribute has too many argumentsIllegalArgumentException- if the invocation of the method that should return a value set for this attribute fails for any reason
-
getValueSet
public org.faktorips.valueset.ValueSet<?> getValueSet(IProductComponent source, Calendar effectiveDate) Returns the value set of the given model object's attribute identified by this model type attribute. Returns anUnrestrictedValueSetif there is no method that returns a value set for this attribute.This method uses a default
IValidationContext.- Parameters:
source- the product component to read an attribute value set from. Must correspond to theTypethis attribute belongs to.effectiveDate- the date to determine the product component generation. Ifnullthe latest generation is used. Is ignored if the attribute's configuration is not changing over time.- Throws:
IllegalStateException- if the method that should return a value set for this attribute has too many argumentsIllegalArgumentException- if the invocation of the method that should return a value set for this attribute fails for any reason
-
setValueSet
public abstract void setValueSet(IConfigurableModelObject modelObject, org.faktorips.valueset.ValueSet<?> valueSet) Sets the product configured set of allowed values of the attribute identified by this model type attribute.Caution: as generics are erased at runtime, it is possible to set a
ValueSetof a mismatched type with this method, for example anOrderedValueSet<String>for an attribute withAttribute.getDatatype()Integer, which will result in aClassCastExceptionon later method calls.- Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrievedvalueSet- the new value set- Throws:
UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.ClassCastException- if the type of value set does not match the property's configurationIllegalStateException- if the model object has no setter method for this attribute's value set. This also occurs if the corresponding policy class is not configured by a product class.IllegalArgumentException- if the invocation of the method that should set the value set for this attribute fails for any reason- Since:
- 20.6
-
setValueSet
public abstract void setValueSet(IProductComponent target, Calendar effectiveDate, org.faktorips.valueset.ValueSet<?> valueSet) Sets the product configured set of allowed values of the attribute identified by this model type attribute.Caution: as generics are erased at runtime, it is possible to set a
ValueSetof a mismatched type with this method, for example anOrderedValueSet<String>for an attribute withAttribute.getDatatype()Integer, which will result in aClassCastExceptionon later method calls.- Parameters:
target- the product component to write the attribute value set to. Must correspond to theTypethis attribute belongs to.effectiveDate- the date to determine the product component generation. Ifnullthe latest generation is used. Is ignored if the attribute's configuration is not changing over time.valueSet- the new value set- Throws:
UnsupportedOperationException- if invoked on aAttributeKind.CONSTANTattribute.ClassCastException- if the type of value set does not match the property's configurationIllegalStateException- if the model object has no setter method for this attribute's value set. This also occurs if the corresponding policy class is not configured by a product class.IllegalArgumentException- if the invocation of the method that should set the value set for this attribute fails for any reason- Since:
- 20.6
-
getType()