@Override public boolean containsDoOpFacet(final Class<? extends Facet> facetType) { return getFacetedMethod().containsDoOpFacet(facetType); }
private static void attachDefaultFacetForParametersIfDefaultsNumMethodIsFound(final ProcessMethodContext processMethodContext, final List<FacetedMethodParameter> parameters) { if (parameters.isEmpty()) { return; } final Class<?> cls = processMethodContext.getCls(); final Method actionMethod = processMethodContext.getMethod(); final Class<?>[] paramTypes = actionMethod.getParameterTypes(); final String capitalizedName = NameUtils.capitalizeName(actionMethod.getName()); for (int i = 0; i < paramTypes.length; i++) { final Method defaultMethod = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.DEFAULT_PREFIX + i + capitalizedName, paramTypes[i], new Class[0]); if (defaultMethod == null) { continue; } processMethodContext.removeMethod(defaultMethod); final FacetedMethod facetedMethod = processMethodContext.getFacetHolder(); if (facetedMethod.containsDoOpFacet(ActionDefaultsFacet.class)) { throw new MetaModelException(cls + " uses both old and new default syntax for " + actionMethod.getName() + "(...) - must use one or other"); } // add facets directly to parameters, not to actions final FacetedMethodParameter paramAsHolder = parameters.get(i); FacetUtil.addFacet(new ActionParameterDefaultsFacetViaMethod(defaultMethod, paramAsHolder)); } }
private void attachChoicesFacetForParametersIfChoicesNumMethodIsFound(final ProcessMethodContext processMethodContext, final List<FacetedMethodParameter> parameters) { if (parameters.isEmpty()) { return; } final Method actionMethod = processMethodContext.getMethod(); final Class<?>[] params = actionMethod.getParameterTypes(); for (int i = 0; i < params.length; i++) { final Class<?> arrayOfParamType = (Array.newInstance(params[i], 0)).getClass(); Method choicesMethod = findChoicesNumMethodReturning(processMethodContext, i, arrayOfParamType); if (choicesMethod == null) { choicesMethod = findChoicesNumMethodReturning(processMethodContext, i, List.class); } if (choicesMethod == null) { continue; } processMethodContext.removeMethod(choicesMethod); final FacetedMethod facetedMethod = processMethodContext.getFacetHolder(); if (facetedMethod.containsDoOpFacet(ActionChoicesFacet.class)) { final Class<?> cls = processMethodContext.getCls(); throw new MetaModelException(cls + " uses both old and new choices syntax - must use one or other"); } // add facets directly to parameters, not to actions final FacetedMethodParameter paramAsHolder = parameters.get(i); FacetUtil.addFacet(new ActionParameterChoicesFacetViaMethod(choicesMethod, arrayOfParamType, paramAsHolder, getSpecificationLookup(), getAdapterMap())); } }