예제 #1
0
 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());
 }
예제 #2
0
 @Override
 public boolean accept(final Facet facet) {
   return ImperativeFacet.Util.isImperativeFacet(facet);
 }