/** * Check if the interface type or any of its super-interfaces matches the given name pattern. * * @param interfaceType * Type to check. * @param namePattern * Pattern to test FQN with. * @return <code>true</code> if interface or any of the super-interface match the name pattern. */ private boolean checkInterfaceAndSuperInterfacesForName(ImmutableInterfaceType interfaceType, IMatchPattern namePattern) { if (namePattern.match(interfaceType.getFQN())) { return true; } for (ImmutableInterfaceType superInterfaceType : interfaceType.getImmutableSuperInterfaces()) { if (checkInterfaceAndSuperInterfacesForName(superInterfaceType, namePattern)) { return true; } } return false; }
/** * Checks if the given {@link ImmutableClassType} or any of it's super classes implement an * interface that matches given annotation pattern. * * @param classType * Type to check. * @param pattern * Pattern to test interface FQNs with. * @return <code>true</code> if class or any super-classes implements interface that matches the * pattern. */ private boolean checkClassAndSuperClassForInterface(ImmutableClassType classType, IMatchPattern pattern) { // match any interface for (ImmutableAbstractInterfaceType interfaceType : classType.getImmutableRealizedInterfaces()) { if (interfaceType.isInterface() && checkInterfaceAndSuperInterfacesForName(interfaceType.castToInterface(), pattern)) { return true; } } for (ImmutableClassType superClassType : classType.getImmutableSuperClasses()) { if (checkClassAndSuperClassForInterface(superClassType, pattern)) { return true; } } return false; }