/** * Match class pattern only * * @param classMetaData the class meta-data * @return boolean */ public boolean match(final ClassMetaData classMetaData) { boolean matchesClassPattern = false; if (m_isHierarchical) { if (matchSuperClasses(classMetaData)) { matchesClassPattern = true; } } else { matchesClassPattern = m_classPattern.matches(classMetaData.getName()); } return matchesClassPattern; }
/** * Tries to finds a match at some superclass in the hierarchy. * * <p>Only checks for a class match to allow early filtering. * * <p>Recursive. * * @param classMetaData the class meta-data * @return boolean */ protected boolean matchSuperClasses(final ClassMetaData classMetaData) { if (classMetaData == null) { return false; } // match the class/super class if (m_classPattern.matches(classMetaData.getName())) { return true; } else { // match the interfaces for the class if (matchInterfaces(classMetaData.getInterfaces(), classMetaData)) { return true; } // no match; get the next superclass return matchSuperClasses(classMetaData.getSuperClass()); } }
/** * Tries to finds a match at some interface in the hierarchy. * * <p>Only checks for a class match to allow early filtering. * * <p>Recursive. * * @param interfaces the interfaces * @param classMetaData the class meta-data * @return boolean */ protected boolean matchInterfaces(final List interfaces, final ClassMetaData classMetaData) { if (interfaces.isEmpty()) { return false; } for (Iterator it = interfaces.iterator(); it.hasNext(); ) { InterfaceMetaData interfaceMD = (InterfaceMetaData) it.next(); if (m_classPattern.matches(interfaceMD.getName())) { return true; } else { if (matchInterfaces(interfaceMD.getInterfaces(), classMetaData)) { return true; } else { continue; } } } return false; }