/***
 * Excerpted from "Domain-Driven Design Using Naked Objects",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/dhnako for more book information.
***/
public class IconMethodFacetFactory 
        extends MethodPrefixBasedFacetFactoryAbstract {
    private static final String ICON_NAME_PREFIX = "iconName";
    private static final String[] PREFIXES = { ICON_NAME_PREFIX, };
    public IconMethodFacetFactory() {
        super(PREFIXES, NakedObjectFeatureType.OBJECTS_ONLY);
    }
    @Override
    public boolean process(
            final Class<?> cls, final MethodRemover methodRemover, 
            final FacetHolder facetHolder) {
        final Method method = 
            findMethod(cls, OBJECT, ICON_NAME_PREFIX, 
                       String.class, NO_PARAMETERS_TYPES);
        if (method == null) {
            return false;
        }
        methodRemover.removeMethod(method);
        return FacetUtil.addFacet(
                new IconFacetViaMethod(method, facetHolder));
    }
}
