private FacetedMethod findActionMethodPeer(final MethodScope methodScope, final RecognisedHelpersStrategy recognisedHelpersStrategy, final Method actionMethod) { if (!representsAction(actionMethod, methodScope, recognisedHelpersStrategy)) { return null; } // build action return createActionFacetedMethod(actionMethod); }
/** * Returns a {@link List} of {@link FacetedMethod}s representing object * actions, lazily creating them first if required. */ public List<FacetedMethod> getAssociationFacetedMethods() { if (associationFacetMethods == null) { associationFacetMethods = createAssociationFacetedMethods(); } return associationFacetMethods; }
/** * Since the value properties and collections have already been processed, * this will pick up the remaining reference properties. */ private void findAndRemovePropertyAccessorsAndCreateCorrespondingFacetedMethods(final List<FacetedMethod> fields) { final List<Method> propertyAccessors = Lists.newArrayList(); getFacetProcessor().findAndRemovePropertyAccessors(methodRemover, propertyAccessors); findAndRemovePrefixedNonVoidMethods(MethodScope.OBJECT, GET_PREFIX, Object.class, 0, propertyAccessors); findAndRemovePrefixedNonVoidMethods(MethodScope.OBJECT, IS_PREFIX, Boolean.class, 0, propertyAccessors); createPropertyFacetedMethodsFromAccessors(propertyAccessors, fields); }
private List<FacetedMethod> createAssociationFacetedMethods() { if (LOG.isDebugEnabled()) { LOG.debug("introspecting " + getClassName() + ": properties and collections"); } final Set<Method> associationCandidateMethods = getFacetProcessor().findAssociationCandidateAccessors(methods, new HashSet<Method>()); // Ensure all return types are known final List<Class<?>> typesToLoad = Lists.newArrayList(); for (final Method method : associationCandidateMethods) { getSpecificationTraverser().traverseTypes(method, typesToLoad); } getSpecificationLoader().loadSpecifications(typesToLoad, introspectedClass); // now create FacetedMethods for collections and for properties final List<FacetedMethod> associationFacetedMethods = Lists.newArrayList(); findAndRemoveCollectionAccessorsAndCreateCorrespondingFacetedMethods(associationFacetedMethods); findAndRemovePropertyAccessorsAndCreateCorrespondingFacetedMethods(associationFacetedMethods); return Collections.unmodifiableList(associationFacetedMethods); }
private void findAndRemoveCollectionAccessorsAndCreateCorrespondingFacetedMethods(final List<FacetedMethod> associationPeers) { final List<Method> collectionAccessors = Lists.newArrayList(); getFacetProcessor().findAndRemoveCollectionAccessors(methodRemover, collectionAccessors); createCollectionFacetedMethodsFromAccessors(collectionAccessors, associationPeers); }
/** * REVIEW: I'm not sure why we do two passes here. * * <p> * Perhaps it's important to skip helpers first. I doubt it, though. */ private List<FacetedMethod> findActionFacetedMethods(final MethodScope methodScope) { if (LOG.isDebugEnabled()) { LOG.debug("introspecting " + getClassName() + ": actions"); } final List<FacetedMethod> actionFacetedMethods1 = findActionFacetedMethods(methodScope, RecognisedHelpersStrategy.SKIP); final List<FacetedMethod> actionFacetedMethods2 = findActionFacetedMethods(methodScope, RecognisedHelpersStrategy.DONT_SKIP); return ListUtils.combine(actionFacetedMethods1, actionFacetedMethods2); }
/** * Returns a {@link List} of {@link FacetedMethod}s representing object * actions, lazily creating them first if required. */ public List<FacetedMethod> getActionFacetedMethods() { if (actionFacetedMethods == null) { actionFacetedMethods = findActionFacetedMethods(MethodScope.OBJECT); } return actionFacetedMethods; }
/** * As per * {@link #findAndRemovePrefixedNonVoidMethods(boolean, String, Class, int)} * , but appends to provided {@link List} (collecting parameter pattern). */ private void findAndRemovePrefixedNonVoidMethods(final MethodScope methodScope, final String prefix, final Class<?> returnType, final int paramCount, final List<Method> methodListToAppendTo) { final List<Method> matchingMethods = findAndRemovePrefixedMethods(methodScope, prefix, returnType, false, paramCount); methodListToAppendTo.addAll(matchingMethods); }
public ObjectSpecificationDefault(final Class<?> correspondingClass, final FacetedMethodsBuilderContext facetedMethodsBuilderContext, final IntrospectionContext introspectionContext, final SpecificationContext specContext, final ObjectMemberContext objectMemberContext, final CreateObjectContext createObjectContext) { super(correspondingClass, determineShortName(correspondingClass), specContext); this.facetedMethodsBuilder = new FacetedMethodsBuilder(this, facetedMethodsBuilderContext); this.introspectionContext = introspectionContext; this.createObjectContext = createObjectContext; this.objectMemberContext = objectMemberContext; }
private List<FacetedMethod> findActionFacetedMethods(final MethodScope methodScope, final RecognisedHelpersStrategy recognisedHelpersStrategy) { if (LOG.isDebugEnabled()) { LOG.debug(" looking for action methods"); } final List<FacetedMethod> actionFacetedMethods = Lists.newArrayList(); for (int i = 0; i < methods.size(); i++) { final Method method = methods.get(i); if (method == null) { continue; } final FacetedMethod actionPeer = findActionMethodPeer(methodScope, recognisedHelpersStrategy, method); if (actionPeer != null) { methods.set(i, null); actionFacetedMethods.add(actionPeer); } } return actionFacetedMethods; }