/** * Get best binding component for class. Finds the component based on a fully qualified class * name. If a specific component for the actual class is not found (either in this or a containing * level) this returns the most specific superclass component. * * @param clas information for target class * @return binding component definition for class, or <code>null</code> if none found */ public ElementBase getMostSpecificComponent(IClass clas) { ElementBase comp = getSpecificComponent(clas.getName()); while (comp == null) { IClass sclas = clas.getSuperClass(); if (sclas == null) { break; } clas = sclas; comp = getSpecificComponent(clas.getName()); } return comp; }
/** * Add typed component to set defined at this level. This associated the component with the type * for class hierarchy-based lookups. * * @param type type name to be associated with component * @param comp definition component to be added * @param vctx validation context in use */ public void addTypedComponent(IClass clas, ElementBase comp, ValidationContext vctx) { String type = clas.getName(); if (m_typeToComponentMap.put(type, comp) == null) { // new type, add all interfaces and supertypes to compatible set String[] interfaces = clas.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { m_compatibleTypeSet.add(interfaces[i]); } IClass sclas = clas; do { m_compatibleTypeSet.add(sclas.getName()); } while ((sclas = sclas.getSuperClass()) != null); } else { vctx.addError("Duplicate conversion defined for type " + type, comp); } }