Class DefaultPolicyAttribute


public class DefaultPolicyAttribute extends PolicyAttribute
  • Field Details

  • Constructor Details

    • DefaultPolicyAttribute

      public DefaultPolicyAttribute(PolicyCmptType policyCmptType, Method getter, Method setter, boolean changingOverTime)
  • Method Details

    • 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
    • getValue

      public Object getValue(IModelObject modelObject)
      Description copied from class: PolicyAttribute
      Returns the value of the given model object's attribute identified by this model type attribute.
      Specified by:
      getValue in class PolicyAttribute
      Parameters:
      modelObject - a model object corresponding to the Type this 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, Object value)
      Description copied from class: PolicyAttribute
      Sets the given model object's attribute identified by this model type attribute to the given value. This only works for changeable attributes.
      Specified by:
      setValue in class PolicyAttribute
      Parameters:
      modelObject - a model object corresponding to the Type this attribute belongs to
      value - an object of this model type attribute's datatype
    • getDefaultValue

      public Object getDefaultValue(IModelObject modelObject)
      Description copied from class: PolicyAttribute
      Returns the (product configured) default value of the attribute identified by this model type attribute. Throws an IllegalStateException if the model object has no default value constant or the product has no getDefaultValue~() method for this attribute.
      Specified by:
      getDefaultValue in class PolicyAttribute
      Parameters:
      modelObject - the configurable model object from which product component and (if necessary) effective date can be retrieved
      See Also:
    • getDefaultValue

      public Object getDefaultValue(IProductComponent source, Calendar effectiveDate)
      Description copied from class: PolicyAttribute
      Returns the product configured default value of the attribute identified by this model type attribute.
      Specified by:
      getDefaultValue in class PolicyAttribute
      Parameters:
      source - the product component to read the attribute default value from.
      effectiveDate - the date to determine the product component generation. If null the latest generation is used. Is ignored if the attribute's configuration is not changing over time.
    • setDefaultValue

      public void setDefaultValue(IConfigurableModelObject modelObject, Object defaultValue)
      Description copied from class: PolicyAttribute
      Sets the product configured default value of the attribute identified by this model type attribute.
      Specified by:
      setDefaultValue in class PolicyAttribute
      Parameters:
      modelObject - the configurable model object from which product component and (if necessary) effective date can be retrieved
      defaultValue - the new default value
    • setDefaultValue

      public void setDefaultValue(IProductComponent source, Calendar effectiveDate, Object defaultValue)
      Description copied from class: PolicyAttribute
      Sets the product configured default value of the attribute identified by this model type attribute.
      Specified by:
      setDefaultValue in class PolicyAttribute
      Parameters:
      source - the product component to write the attribute default value to
      effectiveDate - the date to determine the product component generation. If null the latest generation is used. Is ignored if the attribute's configuration is not changing over time.
      defaultValue - the new default value
    • setDefaultValue

      public void setDefaultValue(IProductComponentGeneration generation, Object defaultValue)
      Description copied from class: PolicyAttribute
      Sets the product configured default value of the attribute identified by this model type attribute.
      Specified by:
      setDefaultValue in class PolicyAttribute
      Parameters:
      generation - the product component generation
      defaultValue - the new default value
    • getValueSet

      public org.faktorips.valueset.ValueSet<?> getValueSet(IModelObject modelObject, IValidationContext context)
      Description copied from class: PolicyAttribute
      Returns the value set of the given model object's attribute identified by this model type attribute.

      Note: If the PolicyCmptType this PolicyAttribute belongs to defines an UnrestrictedValueSet including null, no method is generated by Faktor-IPS. Therefore, a value set method in a subclass is not found even if the IModelObject passed to this method is an instance of that subclass. To make sure to get the correct value set, always use IpsModel.getPolicyCmptType(IModelObject) on the actual IModelObject instead of IpsModel.getPolicyCmptType(Class) on the super class.

      Specified by:
      getValueSet in class PolicyAttribute
      Parameters:
      modelObject - a model object
    • getValueSet

      public org.faktorips.valueset.ValueSet<?> getValueSet(IProductComponent source, Calendar effectiveDate, IValidationContext context)
      Description copied from class: PolicyAttribute
      Returns the value set of the given model object's attribute identified by this model type attribute. Returns an UnrestrictedValueSet if there is no method that returns a value set for this attribute.
      Specified by:
      getValueSet in class PolicyAttribute
      Parameters:
      source - the product component to read an attribute value set from. Must correspond to the Type this attribute belongs to.
      effectiveDate - the date to determine the product component generation. If null the latest generation is used. Is ignored if the attribute's configuration is not changing over time.
    • createOverwritingAttributeFor

      public DefaultPolicyAttribute 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
    • setValueSet

      public void setValueSet(IConfigurableModelObject modelObject, org.faktorips.valueset.ValueSet<?> valueSet)
      Description copied from class: PolicyAttribute
      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 ValueSet of a mismatched type with this method, for example an OrderedValueSet<String> for an attribute with Attribute.getDatatype() Integer, which will result in a ClassCastException on later method calls.

      Specified by:
      setValueSet in class PolicyAttribute
      Parameters:
      modelObject - the configurable model object from which product component and (if necessary) effective date can be retrieved
      valueSet - the new value set
    • setValueSet

      public void setValueSet(IProductComponent source, Calendar effectiveDate, org.faktorips.valueset.ValueSet<?> valueSet)
      Description copied from class: PolicyAttribute
      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 ValueSet of a mismatched type with this method, for example an OrderedValueSet<String> for an attribute with Attribute.getDatatype() Integer, which will result in a ClassCastException on later method calls.

      Specified by:
      setValueSet in class PolicyAttribute
      Parameters:
      source - the product component to write the attribute value set to. Must correspond to the Type this attribute belongs to.
      effectiveDate - the date to determine the product component generation. If null the 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(IProductComponentGeneration generation, org.faktorips.valueset.ValueSet<?> valueSet)
      Description copied from class: PolicyAttribute
      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 ValueSet of a mismatched type with this method, for example an OrderedValueSet<String> for an attribute with Attribute.getDatatype() Integer, which will result in a ClassCastException on later method calls.

      Specified by:
      setValueSet in class PolicyAttribute
      Parameters:
      generation - the product component generation, which will be used to write the attribute value set to the corresponding product component to.
      valueSet - the new value set
    • removeValue

      public void removeValue(IModelObject modelObject)
      Description copied from class: PolicyAttribute
      Sets the given model object's attribute identified by this model type attribute to its null-value (null for most datatypes, a NullObject for the NullObjectSupport-datatypes Decimal and Money, and an empty string for the datatype String) This only works for changeable attributes.
      Specified by:
      removeValue in class PolicyAttribute
      Parameters:
      modelObject - a model object corresponding to the Type this attribute belongs to
    • 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
    • getResourceBundleName

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