Comparing issue values
The values associated with underwriting issues (UWIssue objects) can be either numeric or non-numeric, as needed to describe level of risk or authority related to a specific issue type. The ValueComparator is used to determine if:
- The value of an issue is within the limits set on the existing approval
- The value of an issue is within the user’s authority to approve
- A requested approval is within the user’s authority to authorize
Additionally, the value itself is not strongly typed; its type is inferred from the ValueComparator assigned to the issue type.
The ValueComparator typelist contains the list of possible comparisons, such as at least and at most. The UWIssueValueComparatorWrapper class defines how to compare issue values. That class uses the UWIssueValueType class to define what the underlying value type is. The UWIssueValueType class defines how to convert the value that gets stored in the Value field on UWIssue or the ReferenceValue field on UWHistory. This class also defines how to validate raw string values. More than one comparator can use the same underlying value type.
The UWIssueValueType class has three methods: deserialize, serialize, and validate. This class defines two primary value types, represented as constants on the UWIssueValueType interface. The two value types are BIG_DECIMAL type, and STATE_SET type. The BIG_DECIMAL type converts and validates to and from a big decimal number. The STATE_SET is a comma-separated list of codes for jurisdictions. The STATE_SET type can either be an inclusive or exclusive set. If the list is preceded by not, a jurisdiction is part of the set if it is not in the list.
You can use STATE_SET as an example for writing comparators for other types of sets.
You can create comparators for other types of numeric values such as dates. Dates would need a greater than or equal comparator that operates on dates instead of numbers. The UWIssueValueComparatorWrapper is bound to a particular UWIssueValueType. The comparator wrapper implements a compare(String, String) method, which indicates whether or not the given issue value is within the bounds of the given grant value. The wrapper also implements a calculateDefaultApprovalValue method. The wrapper ties together an issue type to its underlying value type (if any). Every key in the ValueComparator typelist must have an associated subclass of UWIssueValueComparatorWrapper.
See also
