Getting cost entity instances for this cost data object
There are several related cost data APIs for getting (and optionally creating) corresponding cost entity instances for this cost data object.
To simply get a reference to the corresponding
Cost entity instance,
call the cost data object method getExistingCost.
This method takes the PolicyLine
to search. This method does not modify the effective window of the returned
cost. It merely finds the matching cost object, if any, that is effective
as of the effective date of this cost data object. If there is no existing
cost, this method returns null.
Internally, this method calls the getVersionedCosts method, which each cost data must override.
var c = getExistingCost(myPolicyLine)In some cases, you might want
to actually create a new Cost
row or modify an existing one. This choice depends on whether there is
an existing Cost instance
that corresponds to this cost data with the appropriate effective dates.
The cost data object method getPopulatedCost
implements this logic.
There are several possibly outcomes of
getOrCreateCost.
- If there is an existing
Costat the effective date of this cost data object, this method returns it. - If there is an existing
Costbut none at the effective date of this cost data object, this method creates a new cost entity cloned from an existing cost. If there are multiple to choose from, the rating engine chooses the one with earliest effective date. Among other properties cloned, the fixed ID value for the new cost entity is always the same as cloned cost. This is important to remember. The fixed IDs must be the same because both costs represent the cost for a specific thing, just at different effective dates. The method returns the new cost object. - If there is no existing
Cost, even at other dates, the method creates a new cost entity. The new cost object has an entirely new auto-generated fixed ID. The method returns the new cost object.
Unlike the getExistingCost
method, the getOrCreateCost
method never returns null.
var c = getOrCreateCost(myPolicyLine)Finally, there is another
method called getPopulatedCost.
It performs the following operations.
- Calls the public method getOrCreateCost to get the matching cost object, or creates a new one. See the earlier description of this method in this section.
- Calls an internal method populateCostEntity that populates the entity with the core cost properties from this cost data object.
- Calls the public method setSpecificFieldsOnCost, which
each cost data class implements to copy all the non-core (line-specific)
cost properties from the cost data object to the Cost entity instance.
var c = getPopulatedCost(myPolicyLine)
