Create a JSON value resolver for the custom risk unit
A value resolver is a class used in updaters to return the resource that a foreign key property points to. Within the context of a foreign key property:
- The root (or the root resource) is the resource that has the foreign key property.
- The resolved value is the resource that the foreign key points to.
For general information on value resolvers, see Adding foreign keys.
In the "no damageable" data model design, the incident entity has a foreign key to the risk unit entity. Therefore, the incident updater has a foreign key property that uses a value resolver whose resolved value is the risk unit.
For custom entities, you must declare a custom value resolver. If
the custom entity must provide support for reference by
policySystemId
, then the value resolver must extend the
PolicyDescendantJsonValueResolver
class.
Syntax for a custom risk unit value resolver
Guidewire recommends declaring the custom risk unit value resolver in the
gw.rest.ext.cc.claim.v1.claims.policy
package in a sub-package
whose name is the custom risk unit.
This is the syntax for a custom risk unit value resolver. Values that are not literal and must be replaced by the custom risk unit name appear in bold italic between a < and >. For example, <CustomRiskUnit>.
package gw.rest.ext.cc.claim.v1.claims.policy.<customriskunit>
uses gw.rest.core.cc.claim.v1.claims.policy.PolicyDescendantJsonValueResolver
uses org.jetbrains.annotations.NotNull
class <CustomRiskUnit>JsonValueResolver extends
PolicyDescendantJsonValueResolver<<CustomRiskUnit>, Policy> {
@NotNull
protected override property get ResolvedValueType() : Class<<CustomRiskUnit>> {
return <CustomRiskUnit>
}
@NotNull
protected override property get AncestorType() : Class<Policy> {
return Policy
}
protected override function getPossibleResolvedValues(ancestor : Policy) :
<CustomRiskUnit>[] {
return ancestor.RiskUnits.cast(<CustomRiskUnit>)
}
}
Example custom risk unit value resolver
MobilePhoneRU_Ext
.package gw.rest.ext.cc.claim.v1.claims.policy.mobilephoneruext
uses gw.rest.core.cc.claim.v1.claims.policy.PolicyDescendantJsonValueResolver
uses org.jetbrains.annotations.NotNull
class MobilePhoneRUExtJsonValueResolver extends
PolicyDescendantJsonValueResolver<MobilePhoneRU_Ext, Policy> {
@NotNull
protected override property get ResolvedValueType() : Class<MobilePhoneRU_Ext> {
return MobilePhoneRU_Ext
}
@NotNull
protected override property get AncestorType() : Class<Policy> {
return Policy
}
protected override function getPossibleResolvedValues(ancestor : Policy) :
MobilePhoneRU_Ext[] {
return ancestor.RiskUnits.cast(MobilePhoneRU_Ext)
}
}