Example usage for java.lang Class getGenericInterfaces

List of usage examples for java.lang Class getGenericInterfaces

Introduction

In this page you can find the example usage for java.lang Class getGenericInterfaces.

Prototype

public Type[] getGenericInterfaces() 

Source Link

Document

Returns the Type s representing the interfaces directly implemented by the class or interface represented by this object.

Usage

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

private void createMeta(ClassDefinition def, Class<?> clazz, String uriPrefix) throws OtmException {
    sf.addDefinition(def);//from   w ww .jav  a2 s. c  om

    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);
    }
}