Comparing branches by using difference helper classes
One of the two difference item strategies is to compare two arbitrary branches by using the policy period difference plugin compareBranches method.
In the reference implementation of this plugin, the compareBranches method compares policies by using helper classes that examine details for each line of business. The base configuration includes a separate difference helper class for each line of business. The class name of the helper class includes the line of business name.
For example, for each line of business, the reference implementation of the plugin calls the
createPolicyLineDiffHelper method applicable to that policy line. The
createPolicyLineDiffHelper method is responsible for returning the correct difference helper
class, which is a subclass of DiffHelper. For example, for personal auto business line, the
method instantiates an object of class PADiffHelper.
Next, the Gosu code calls the addDiffItems and filterDiffItems methods on
that helper class.
// Add diffs by line of business
for (line1 in p1.Lines) {
var line2 = p2.Lines.firstWhere(\ l -> l.Subtype == line1.Subtype)
if (line2 != null) {
diffHelper = line1.createPolicyLineDiffHelper(reason, line2)
if (diffHelper != null) {
diffItems = diffHelper.addDiffItems(diffItems) as ArrayList<DiffItem>
diffItems = diffHelper.filterDiffItems(diffItems) as ArrayList<DiffItem>
}
}
}
If you make new lines of business in PolicyCenter, create new helper classes named with the line of business as a
prefix. Your helper class encapsulates your difference logic for that line of business. Your helper class must
extend the built-in DiffHelper class. Your subclass must encapsulate the line-specific logic
and call methods on other classes such as DiffUtils as necessary.
