@Override public void process(final ProcessMethodContext processMethodContext) { final String fullMethodName = processMethodContext.getMethod().getName(); final String capitalizedName = fullMethodName.substring(0, 1).toUpperCase() + fullMethodName.substring(1); if (!capitalizedName.startsWith(LOCAL_PREFIX)) { return; } FacetUtil.addFacets(new Facet[] { new ExecutedFacetViaNamingConvention(ExecutedFacet.Where.LOCALLY, processMethodContext.getFacetHolder()), new NamedFacetInferred(capitalizedName.substring(5), processMethodContext.getFacetHolder()) }); }
private void addNamedFacetAndPluralFacetIfRequired() { NamedFacet namedFacet = getFacet(NamedFacet.class); if (namedFacet == null) { namedFacet = new NamedFacetInferred(NameUtils.naturalName(getShortIdentifier()), this); addFacet(namedFacet); } PluralFacet pluralFacet = getFacet(PluralFacet.class); if (pluralFacet == null) { pluralFacet = new PluralFacetInferred(NameUtils.pluralName(namedFacet.value()), this); addFacet(pluralFacet); } }
/** * Must be called after added the debug, exploration etc facets. * * <p> * TODO: remove this hack */ private void attachNamedFacetInferredFromMethodName(final ProcessMethodContext processMethodContext) { final Method method = processMethodContext.getMethod(); final String capitalizedName = NameUtils.capitalizeName(method.getName()); // this is nasty... String name = StringUtils.removePrefix(capitalizedName, ExecutedFacet.Where.LOCAL_PREFIX); name = StringUtils.removePrefix(name, ExecutedFacet.Where.REMOTE_PREFIX); name = StringUtils.removePrefix(name, DEBUG_PREFIX); name = StringUtils.removePrefix(name, EXPLORATION_PREFIX); name = StringUtils.removePrefix(name, ExecutedFacet.Where.LOCAL_PREFIX); name = StringUtils.removePrefix(name, ExecutedFacet.Where.REMOTE_PREFIX); name = NameUtils.naturalName(name); final FacetHolder facetedMethod = processMethodContext.getFacetHolder(); FacetUtil.addFacet(new NamedFacetInferred(name, facetedMethod)); }