Class ConstantPolicyAttribute
- 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.PolicyAttribute
-
- org.faktorips.runtime.model.type.ConstantPolicyAttribute
-
public class ConstantPolicyAttribute extends PolicyAttribute
An PolicyCmptType'sCONSTANTattribute.
-
-
Constructor Summary
Constructors Constructor Description ConstantPolicyAttribute(Type type, java.lang.reflect.Field field, boolean changingOverTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstantPolicyAttributecreateOverwritingAttributeFor(Type subType)Creates an attribute model for a sub type in which this attribute is overwritten.java.lang.ObjectgetDefaultValue(IConfigurableModelObject modelObject)Returns the product configured default value of the attribute identified by this model type attribute.java.lang.ObjectgetDefaultValue(IProductComponent source, java.util.Calendar effectiveDate)Returns the product configured default value of the attribute identified by this model type attribute.java.lang.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, 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, java.util.Calendar effectiveDate, IValidationContext context)Returns the value set of the given model object's attribute identified by this model type attribute.booleanisProductRelevant()Returns true if this attribute is configured by the product.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.voidsetDefaultValue(IConfigurableModelObject modelObject, java.lang.Object defaultValue)Sets the product configured default value of the attribute identified by this model type attribute.voidsetDefaultValue(IProductComponent source, java.util.Calendar effectiveDate, java.lang.Object defaultValue)Sets the product configured default value of the attribute identified by this model type attribute.voidsetValue(IModelObject modelObject, java.lang.Object value)Sets the given model object's attribute identified by this model type attribute to the given value.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.voidsetValueSet(IProductComponent source, java.util.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.PolicyAttribute
getModelType, getSuperAttribute, getType, getValueSet, getValueSet, isEmpty, isValuePresent
-
Methods inherited from class org.faktorips.runtime.model.type.Attribute
findSuperAttribute, getAttributeKind, getDatatype, getRelevantProductObject, getValueSetKind, isChangingOverTime, isOverriding, toString
-
Methods inherited from class org.faktorips.runtime.model.type.TypePart
getMessageHelper, getMessageKey, getTypeName
-
Methods inherited from class org.faktorips.runtime.model.type.ModelElement
createMessageHelper, getDescription, getDocumentation, getExtensionPropertyIds, getExtensionPropertyValue, getLabel, getName, getRelevantProductObject, invokeField, invokeMethod
-
-
-
-
Constructor Detail
-
ConstantPolicyAttribute
public ConstantPolicyAttribute(Type type, java.lang.reflect.Field field, boolean changingOverTime)
-
-
Method Detail
-
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
-
getValue
public java.lang.Object getValue(IModelObject modelObject)
Description copied from class:PolicyAttributeReturns the value of the given model object's attribute identified by this model type attribute.- Specified by:
getValuein classPolicyAttribute- 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
-
setValue
public void setValue(IModelObject modelObject, java.lang.Object value)
Description copied from class:PolicyAttributeSets the given model object's attribute identified by this model type attribute to the given value. This only works for changeable attributes.- Specified by:
setValuein classPolicyAttribute- Parameters:
modelObject- a model object corresponding to theTypethis attribute belongs tovalue- an object of this model type attribute's datatype
-
removeValue
public void removeValue(IModelObject modelObject)
Description copied from class:PolicyAttributeSets 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.- Specified by:
removeValuein classPolicyAttribute- Parameters:
modelObject- a model object corresponding to theTypethis attribute belongs to
-
createOverwritingAttributeFor
public ConstantPolicyAttribute createOverwritingAttributeFor(Type subType)
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
-
getDefaultValue
public java.lang.Object getDefaultValue(IConfigurableModelObject modelObject)
Description copied from class:PolicyAttributeReturns the product configured default value of the attribute identified by this model type attribute. Throws anIllegalStateExceptionif the model object has no getDefaultValue() method for this attribute. This also occurs if the corresponding policy class is not configured by a product class.- Specified by:
getDefaultValuein classPolicyAttribute- Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrieved- See Also:
PolicyAttribute.getDefaultValue(IProductComponent, Calendar)
-
getDefaultValue
public java.lang.Object getDefaultValue(IProductComponent source, java.util.Calendar effectiveDate)
Description copied from class:PolicyAttributeReturns the product configured default value of the attribute identified by this model type attribute.- Specified by:
getDefaultValuein classPolicyAttribute- 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.
-
setDefaultValue
public void setDefaultValue(IConfigurableModelObject modelObject, java.lang.Object defaultValue)
Description copied from class:PolicyAttributeSets the product configured default value of the attribute identified by this model type attribute.- Specified by:
setDefaultValuein classPolicyAttribute- Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrieveddefaultValue- the new default value
-
setDefaultValue
public void setDefaultValue(IProductComponent source, java.util.Calendar effectiveDate, java.lang.Object defaultValue)
Description copied from class:PolicyAttributeSets the product configured default value of the attribute identified by this model type attribute.- Specified by:
setDefaultValuein classPolicyAttribute- Parameters:
source- 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
-
getValueSet
public org.faktorips.valueset.ValueSet<?> getValueSet(IModelObject modelObject, IValidationContext context)
Description copied from class:PolicyAttributeReturns 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.- Specified by:
getValueSetin classPolicyAttribute- Parameters:
modelObject- a model object
-
getValueSet
public org.faktorips.valueset.ValueSet<?> getValueSet(IProductComponent source, java.util.Calendar effectiveDate, IValidationContext context)
Description copied from class:PolicyAttributeReturns 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.- Specified by:
getValueSetin classPolicyAttribute- 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.
-
setValueSet
public void setValueSet(IProductComponent source, java.util.Calendar effectiveDate, org.faktorips.valueset.ValueSet<?> valueSet)
Description copied from class:PolicyAttributeSets 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.- Specified by:
setValueSetin classPolicyAttribute- Parameters:
source- 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
-
setValueSet
public void setValueSet(IConfigurableModelObject modelObject, org.faktorips.valueset.ValueSet<?> valueSet)
Description copied from class:PolicyAttributeSets 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.- Specified by:
setValueSetin classPolicyAttribute- Parameters:
modelObject- the configurable model object from which product component and (if necessary) effective date can be retrievedvalueSet- the new value set
-
-