public static Intent getIntent(final ObjectMember member, final Method method) { final List<Facet> allFacets = member.getFacets(Filters.anyOfType(Facet.class)); final List<ImperativeFacet> imperativeFacets = Lists.newArrayList(); for (final Facet facet : allFacets) { final ImperativeFacet imperativeFacet = ImperativeFacet.Util.getImperativeFacet(facet); if (imperativeFacet == null) { continue; } final List<Method> methods = imperativeFacet.getMethods(); if (!methods.contains(method)) { continue; } imperativeFacets.add(imperativeFacet); } switch (imperativeFacets.size()) { case 0: break; case 1: return imperativeFacets.get(0).getIntent(method); default: Intent intentToReturn = null; for (ImperativeFacet imperativeFacet : imperativeFacets) { Intent intent = imperativeFacet.getIntent(method); if (intentToReturn == null) { intentToReturn = intent; } else if (intentToReturn != intent) { throw new IllegalArgumentException( member.getIdentifier().toClassAndNameIdentityString() + ": more than one ImperativeFacet for method " + method.getName() + " , with inconsistent intents: " + imperativeFacets.toString()); } } return intentToReturn; } throw new IllegalArgumentException( member.getIdentifier().toClassAndNameIdentityString() + ": unable to determine intent of " + method.getName()); }
@Override public final LinkBuilder memberBuilder( final Rel rel, final MemberType memberType, final ObjectMember objectMember, final RepresentationType representationType, final String... parts) { final StringBuilder buf = linkRef(new StringBuilder()); buf.append("/").append(memberType.getUrlPart()).append(objectMember.getId()); for (final String part : parts) { if (part == null) { continue; } buf.append("/").append(part); } final String url = buf.toString(); return LinkBuilder.newBuilder(rendererContext, rel.getName(), representationType, url); }
private String interpret(final Class<? extends Facet> cls) { return interpretFacet(member.getFacet(cls)); }
private String interpretRowAndFacet(Class<? extends Facet> facetClass) { final Facet facet = member.getFacet(facetClass); return interpretFacet(facet); }
public String getMemberName() { return member.getId(); }