Class PolicyAttribute

    • Constructor Detail

    • Method Detail

      • getSuperAttribute

        public PolicyAttribute getSuperAttribute()
        Description copied from class: Attribute
        Returns the attribute that is overridden by this attribute if this attribute overrides another one. Otherwise returns null.
        Overrides:
        getSuperAttribute in class Attribute
        Returns:
        The attribute that is overridden by this attribute.
        See Also:
        Attribute.isOverriding()
      • getValue

        public abstract java.lang.Object getValue​(IModelObject modelObject)
        Returns the value of the given model object's attribute identified by this model type attribute.
        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
        Throws:
        java.lang.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

        public abstract void setValue​(IModelObject modelObject,
                                      java.lang.Object value)
        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 the Type this attribute belongs to
        value - an object of this model type attribute's datatype
        Throws:
        java.lang.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.
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
      • removeValue

        public abstract void removeValue​(IModelObject modelObject)
        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.
        Parameters:
        modelObject - a model object corresponding to the Type this attribute belongs to
        Throws:
        java.lang.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.
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
        Since:
        21.6
      • isEmpty

        public boolean isEmpty​(IModelObject modelObject)
        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:

        • null
        • NullObject
        • empty/blank String
        Returns:
        true if empty
        Since:
        21.6
      • isValuePresent

        public boolean isValuePresent​(IModelObject modelObject)
        Checks whether this attribute has a non-empty value on the given model object.
        Since:
        21.6
        See Also:
        isEmpty(IModelObject)
      • getDefaultValue

        public java.lang.Object getDefaultValue​(IConfigurableModelObject modelObject)
        Returns the (product configured) default value of the attribute identified by this configurable 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.
        Parameters:
        modelObject - the configurable model object from which product component and (if necessary) effective date can be retrieved
        Throws:
        java.lang.IllegalStateException - if the model object has no default value constant or the product has no getter method for this attribute's default value.
        java.lang.IllegalArgumentException - if the invocation of the method that should get the default value for this attribute fails for any reason
        See Also:
        getDefaultValue(IProductComponent, Calendar), getDefaultValue(IModelObject)
        API Note:
        this method is supplanted by the more general getDefaultValue(IModelObject) but remains here for compile time compatibility with older versions.
      • getDefaultValue

        public abstract java.lang.Object getDefaultValue​(IModelObject modelObject)
        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.
        Parameters:
        modelObject - the configurable model object from which product component and (if necessary) effective date can be retrieved
        Throws:
        java.lang.IllegalStateException - if the model object has no default value constant or the product has no getter method for this attribute's default value.
        java.lang.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(IProductComponent, Calendar)
      • getDefaultValue

        public abstract java.lang.Object getDefaultValue​(IProductComponent source,
                                                         java.util.Calendar effectiveDate)
        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. If null the latest generation is used. Is ignored if the attribute's configuration is not changing over time.
        Throws:
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
        java.lang.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.
        java.lang.IllegalArgumentException - if the invocation of the method that should get the default value for this attribute fails for any reason
      • setDefaultValue

        public abstract void setDefaultValue​(IConfigurableModelObject modelObject,
                                             java.lang.Object defaultValue)
        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 retrieved
        defaultValue - the new default value
        Throws:
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
        java.lang.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.
        java.lang.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,
                                             java.util.Calendar effectiveDate,
                                             java.lang.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 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
        Throws:
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
        java.lang.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.
        java.lang.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 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.

        Parameters:
        modelObject - a model object
        Throws:
        java.lang.IllegalStateException - if the method that should return a value set for this attribute has too many arguments
        java.lang.IllegalArgumentException - 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​(IModelObject modelObject)
        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.

        This method uses a default IValidationContext.
        Parameters:
        modelObject - a model object
        Throws:
        java.lang.IllegalStateException - if the method that should return a value set for this attribute has too many arguments
        java.lang.IllegalArgumentException - 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,
                                                                       java.util.Calendar effectiveDate,
                                                                       IValidationContext context)
        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.
        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.
        Throws:
        java.lang.IllegalStateException - if the method that should return a value set for this attribute has too many arguments
        java.lang.IllegalArgumentException - 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,
                                                              java.util.Calendar effectiveDate)
        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.

        This method uses a default IValidationContext.

        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.
        Throws:
        java.lang.IllegalStateException - if the method that should return a value set for this attribute has too many arguments
        java.lang.IllegalArgumentException - 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 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.

        Parameters:
        modelObject - the configurable model object from which product component and (if necessary) effective date can be retrieved
        valueSet - the new value set
        Throws:
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
        java.lang.ClassCastException - if the type of value set does not match the property's configuration
        java.lang.IllegalStateException - 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.
        java.lang.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,
                                         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.

        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.

        Parameters:
        target - 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
        Throws:
        java.lang.UnsupportedOperationException - if invoked on a AttributeKind.CONSTANT attribute.
        java.lang.ClassCastException - if the type of value set does not match the property's configuration
        java.lang.IllegalStateException - 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.
        java.lang.IllegalArgumentException - if the invocation of the method that should set the value set for this attribute fails for any reason
        Since:
        20.6