XMLCompositeObjectMapping indirectionPolicyMapping = new XMLCompositeObjectMapping();
indirectionPolicyMapping.setReferenceClass(IndirectionPolicy.class);
// Handle translation of NoIndirectionPolicy -> null.
indirectionPolicyMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
IndirectionPolicy policy = ((AbstractTransformationMapping)object).getIndirectionPolicy();
if (policy instanceof NoIndirectionPolicy) {
return null;
}
return policy;
}
public void setAttributeValueInObject(Object object, Object value) {
IndirectionPolicy policy = (IndirectionPolicy)value;
if (value == null) {
policy = new NoIndirectionPolicy();
}
((AbstractTransformationMapping)object).setIndirectionPolicy(policy);
}