Package org.faktorips.runtime.model.type
Class PolicyAssociation
java.lang.Object
org.faktorips.runtime.model.type.ModelElement
org.faktorips.runtime.model.type.TypePart
org.faktorips.runtime.model.type.Association
org.faktorips.runtime.model.type.PolicyAssociation
An association between two
PolicyCmptTypes.-
Field Summary
Fields inherited from class org.faktorips.runtime.model.type.Association
PROPERTY_MAX_CARDINALITY, PROPERTY_MIN_CARDINALITY -
Constructor Summary
ConstructorsConstructorDescriptionPolicyAssociation(Type type, Method getterMethod, Method addMethod, Method removeMethod) -
Method Summary
Modifier and TypeMethodDescription<S extends IModelObject>
SaddTargetObjects(S source, Collection<IModelObject> targets) Adds the target objects to this association in the source object.<S extends IModelObject>
SaddTargetObjects(S source, IModelObject... targets) Adds the target objects to this association in the source object.createOverwritingAssociationFor(Type subType) Returns the matching product component type association or anempty Optionalif no matching association is defined for this association.Returns the matching product component type association ornullif no matching association is defined for this association.Returns theProductCmptTypeidentified byAssociation.getMatchingAssociationSource()Deprecated.Returns the association that is overridden by this association if this association overrides another one.Returns the targetTypeof this association.getTargetObjects(IModelObject source) Returns a list of the target(s) of the given model object's association identified by this model type association.getType()Returns thePolicyCmptTypethis association belongs to.booleanAPolicyAssociationis never changing over time, but it's associatedProductAssociationmight be.booleanReturns whether this association is "qualified".<S extends IModelObject>
SremoveTargetObjects(S source, List<IModelObject> targetsToRemove) Removes the target object from this association in the source object.<S extends IModelObject>
SremoveTargetObjects(S source, IModelObject... targetsToRemove) Removes the target objects from this association in the source object.Methods inherited from class org.faktorips.runtime.model.type.Association
findSuperAssociation, getAnnotation, getAssociationKind, getDocumentation, getGetterMethod, getInverseAssociation, getLabelForPlural, getMatchingAssociationName, getMatchingAssociationSource, getMaxCardinality, getMinCardinality, getNamePlural, getResourceBundleName, getUsedName, isDerivedUnion, isMatchingAssociationPresent, isOverriding, isSubsetOfADerivedUnion, isToOneAssociation, toString, validate, validateMethods inherited from class org.faktorips.runtime.model.type.TypePart
getMessageHelper, getMessageKey, getTypeName, validateMethods inherited from class org.faktorips.runtime.model.type.ModelElement
createMessageHelper, getDeprecation, getDescription, getExtensionPropertyIds, getExtensionPropertyValue, getLabel, getName, getRelevantProductObject, getRelevantProductObject, invokeField, invokeMethod, isDeprecated
-
Constructor Details
-
PolicyAssociation
- Parameters:
type- the type the association belongs togetterMethod- the getter method for retrieving all associated instancesaddMethod- the method for associating new instances (add-method for ..N associations, set-method for ..1 associations)removeMethod- the method for removing instances from the association (nullin case of a ..1 association, as no method is generated)
-
-
Method Details
-
getType
Returns thePolicyCmptTypethis association belongs to. -
getModelType
Deprecated.UsegetType()Returns the model type this association belongs to.- Overrides:
getModelTypein classTypePart
-
createOverwritingAssociationFor
- Specified by:
createOverwritingAssociationForin classAssociation
-
getMatchingAssociationSourceType
Returns theProductCmptTypeidentified byAssociation.getMatchingAssociationSource()- Overrides:
getMatchingAssociationSourceTypein classAssociation- Returns:
- The model type object of the matching association source
- See Also:
-
getMatchingAssociation
Returns the matching product component type association ornullif no matching association is defined for this association.- Overrides:
getMatchingAssociationin classAssociation- Returns:
- The matching association
-
findMatchingAssociation
Returns the matching product component type association or anempty Optionalif no matching association is defined for this association.- Overrides:
findMatchingAssociationin classAssociation- Returns:
- The matching association
-
getTarget
Description copied from class:AssociationReturns the targetTypeof this association.- Overrides:
getTargetin classAssociation
-
getTargetObjects
Returns a list of the target(s) of the given model object's association identified by this model type association.- Parameters:
source- a model object corresponding to thePolicyCmptTypethis association belongs to- Returns:
- a list of the target(s) of the given model object's association identified by this model type association
- Throws:
IllegalArgumentException- if the model object does not have an association fitting this model type association or that association is not accessible for any reason
-
addTargetObjects
Adds the target objects to this association in the source object. If this is a ..1 ("to one") association, the target object is set (and thus the potentially existing object is overwritten).The return value is the updated source object. It could be used to directly create a tree of objects. For example with a model like:
You could write such code:Policy <>---- Contract <>---- Coveragecontracts.addTargetObjects(policy, coverages.addTargetObjects(contract, coverage1, coverage2));- Parameters:
source- the object to add a target object totargets- the objects to add to source- Returns:
- the changed source object
- Throws:
IllegalArgumentException- if there is no method annotated with@IpsAssociationAdder. This is the case if the associationis a derived union.IllegalArgumentException- if there are multiple target objects provided for a ..1 ("to one") association- Since:
- 3.22
-
addTargetObjects
Adds the target objects to this association in the source object. If this is a ..1 ("to one") association, the target object is set (and thus the potentially existing object is overwritten).The return value is the updated source object. It could be used to directly create a tree of objects. For example with a model like:
You could write such code:Policy <>---- Contract <>---- Coveragecontracts.addTargetObjects(policy, coverages.addTargetObjects(contract, coverage1, coverage2));- Parameters:
source- the object to add a target object totargets- the objects to add to source- Returns:
- the changed source object
- Throws:
IllegalArgumentException- if there is no method annotated with@IpsAssociationAdder. This is the case if the associationis a derived union.IllegalArgumentException- if there are multiple target objects provided for a ..1 ("to one") association- Since:
- 3.22
-
removeTargetObjects
Removes the target object from this association in the source object. Does nothing if the target object is not currently referenced (in this association). Sets tonullif this is a ..1 ("to one") association.The return value is the updated source object. It could be used to directly remove objects in a tree of objects. For example with a model like:
You could write such code:Policy <>---- Contract <>---- Coveragecontracts.removeTargetObjects(policy, coverages.removeTargetObjects(contract, coverage1, coverage2));- Parameters:
source- the object to remove a target object fromtargetsToRemove- the objects to remove from this association in source- Returns:
- the changed source object
- Throws:
IllegalArgumentException- if there is no method annotated with@IpsAssociationRemover(or@IpsAssociationAdderfor a ..1 association). This is the case if the associationis a derived union.IllegalArgumentException- if there are multiple or no target objects provided for a ..1 ("to one") association- Since:
- 3.22
-
getSuperAssociation
Description copied from class:AssociationReturns the association that is overridden by this association if this association overrides another one. Otherwise returnsnull.- Overrides:
getSuperAssociationin classAssociation- Returns:
- The association that is overridden by this attribute.
- See Also:
-
removeTargetObjects
Removes the target objects from this association in the source object. Does nothing if the target object is not currently referenced (in this association). Sets tonullif this is a ..1 ("to one") association.The return value is the updated source object. It could be used to directly remove objects in a tree of objects. For example with a model like:
You could write such code:Policy <>---- Contract <>---- Coveragecontracts.removeTargetObjects(policy, coverages.removeTargetObjects(contract, coverage1, coverage2));- Parameters:
source- the object to remove a target object fromtargetsToRemove- the objects to remove from this association in source- Returns:
- the changed source object
- Throws:
IllegalArgumentException- if there is no method annotated with@IpsAssociationRemover(or@IpsAssociationAdderfor a ..1 association). This is the case if the associationis a derived union.IllegalArgumentException- if there are multiple target objects provided for a ..1 ("to one") association- Since:
- 3.22
-
isQualified
public boolean isQualified()Returns whether this association is "qualified". A "qualified"PolicyAssociation's cardinalities are not defined for all targets but per target of the matchingProductAssociation.- Since:
- 22.6
-
isChangingOverTime
public boolean isChangingOverTime()APolicyAssociationis never changing over time, but it's associatedProductAssociationmight be.- Specified by:
isChangingOverTimein classTypePart- Returns:
- whether this association is changing over time
- Since:
- 25.1
-
getType()