Example usage for java.lang.reflect Method equals

List of usage examples for java.lang.reflect Method equals

Introduction

In this page you can find the example usage for java.lang.reflect Method equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this Method against the specified object.

Usage

From source file:org.topazproject.otm.mapping.java.ClassBinder.java

private static <T> Class<? extends T> createProxy(Class<T> clazz, final Method[] ignoreList) {
    MethodFilter mf = new MethodFilter() {
        public boolean isHandled(Method m) {
            if (m.getName().equals("finalize"))
                return false;

            for (Method ignore : ignoreList)
                if (m.equals(ignore))
                    return false;

            return true;
        }/* ww  w  .  java  2s  . c  o  m*/
    };

    ProxyFactory f = new ProxyFactory();
    f.setSuperclass(clazz);

    if (Serializable.class.isAssignableFrom(clazz))
        f.setInterfaces(new Class[] { WriteReplace.class, LazyLoaded.class });
    else
        f.setInterfaces(new Class[] { LazyLoaded.class });

    f.setFilter(mf);

    Class<? extends T> c = f.createClass();

    return c;
}

From source file:org.topazproject.otm.metadata.AnnotationClassMetaFactory.java

private void createMeta(ClassDefinition def, Class<?> clazz, String uriPrefix) throws OtmException {
    sf.addDefinition(def);//from ww  w . j a  v  a2  s .co m

    ClassBinding bin = sf.getClassBinding(def.getName());
    bin.bind(EntityMode.POJO, new ClassBinder(clazz));

    Map<String, PropertyDefFactory> factories = new HashMap<String, PropertyDefFactory>();

    for (Method method : clazz.getDeclaredMethods()) {
        if (!isAnnotated(method))
            continue;

        if (method.getAnnotation(SubClassResolver.class) != null) {
            registerSubClassResolver(def, method);
            continue;
        }

        Property property = Property.toProperty(method);

        if (property == null)
            throw new OtmException("'" + method.toGenericString() + "' is not a valid getter or setter");

        PropertyDefFactory pi = factories.get(property.getName());

        if (pi != null) {
            if (method.equals(pi.property.getReadMethod()) || method.equals(pi.property.getWriteMethod()))
                continue;

            throw new OtmException("Duplicate property " + property);
        }

        validate(property, def);
        factories.put(property.getName(), new PropertyDefFactory(def, property));
    }

    if (def instanceof EntityDefinition) {
        if (clazz.getGenericSuperclass() instanceof ParameterizedType)
            addGenericsSyntheticProps(def, clazz, (ParameterizedType) clazz.getGenericSuperclass(), factories);

        for (Type t : clazz.getGenericInterfaces())
            if (t instanceof ParameterizedType)
                addGenericsSyntheticProps(def, clazz, (ParameterizedType) t, factories);

        Map<String, Map<String, String>> supersedes = new HashMap<String, Map<String, String>>();
        buildSupersedes((EntityDefinition) def, supersedes);

        for (String name : supersedes.keySet()) {
            PropertyDefFactory pi = factories.get(name);
            if (pi != null)
                pi.setSupersedes(supersedes.get(name));
        }
    }

    for (PropertyDefFactory fi : factories.values()) {
        PropertyDefinition d = fi.getDefinition(sf, uriPrefix);
        if (d != null) {
            sf.addDefinition(d);
            bin.addBinderFactory(new PropertyBinderFactory(fi.name, fi.property));
        }

        SearchableDefinition sd = fi.getSearchableDefinition(sf, d instanceof BlobDefinition);
        if (sd != null)
            sf.addDefinition(sd);
    }
}