if (isUnderlyingMethod(method)) {
return getDelegate();
}
final ObjectMember objectMember = locateAndCheckMember(method);
final List<Facet> imperativeFacets = getImperativeFacets(objectMember, method);
final String memberName = objectMember.getName();
if (instanceOf(imperativeFacets, DisableForContextFacetViaMethod.class, HideForContextFacetViaMethod.class)) {
throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'", memberName));
}
final String methodName = method.getName();
if (instanceOf(imperativeFacets, ActionDefaultsFacet.class, PropertyDefaultFacet.class, ActionChoicesFacet.class, ActionParameterChoicesFacet.class, PropertyChoicesFacet.class)) {
return method.invoke(getDelegate(), args);
}
// for all members, check visibility and usability
checkVisibility(getAuthenticationSession(), targetAdapter, objectMember);
if (objectMember.isOneToOneAssociation()) {
if (instanceOf(imperativeFacets, PropertyValidateFacetViaMethod.class, PropertySetterFacetViaModifyMethod.class, PropertyClearFacetViaClearMethod.class)) {
throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only property accessor/mutator", memberName));
}
final OneToOneAssociation otoa = (OneToOneAssociation) objectMember;
if (instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
return handleGetterMethodOnProperty(args, targetAdapter, otoa, methodName);
}
if (instanceOf(imperativeFacets, PropertySetterFacet.class, PropertyInitializationFacet.class)) {
checkUsability(getAuthenticationSession(), targetAdapter, objectMember);
return handleSetterMethodOnProperty(args, getAuthenticationSession(), targetAdapter, otoa, methodName);
}
}
if (objectMember.isOneToManyAssociation()) {
if (instanceOf(imperativeFacets, CollectionValidateAddToFacetViaMethod.class, CollectionValidateRemoveFromFacetViaMethod.class)) {
throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only collection accessor/mutator", memberName));
}