if (isWrappedMethod(method)) {
return getDelegate();
}
final ObjectMember objectMember = locateAndCheckMember(method);
final String memberName = objectMember.getName();
final Intent intent = ImperativeFacet.Util.getIntent(objectMember, method);
if(intent == Intent.CHECK_IF_HIDDEN || intent == Intent.CHECK_IF_DISABLED) {
throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'", memberName));
}
final String methodName = method.getName();
if (intent == Intent.DEFAULTS || intent == Intent.CHOICES_OR_AUTOCOMPLETE) {
return method.invoke(getDelegate(), args);
}
if (objectMember.isOneToOneAssociation()) {
if (intent == Intent.CHECK_IF_VALID || intent == Intent.MODIFY_PROPERTY_SUPPORTING) {
throw new UnsupportedOperationException(String.format("Cannot invoke supporting method for '%s'; use only property accessor/mutator", memberName));
}
final OneToOneAssociation otoa = (OneToOneAssociation) objectMember;
if (intent == Intent.ACCESSOR) {
return handleGetterMethodOnProperty(args, targetAdapter, otoa, methodName);
}
if (intent == Intent.MODIFY_PROPERTY || intent == Intent.INITIALIZATION) {
return handleSetterMethodOnProperty(args, getAuthenticationSession(), targetAdapter, otoa, methodName);
}
}
if (objectMember.isOneToManyAssociation()) {
if (intent == Intent.CHECK_IF_VALID) {
throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only collection accessor/mutator", memberName));
}