Predicate<SdkTypeId> () { boolean hasNotSimple = false; Predicate<SdkTypeId> condition = notSimpleJavaSdkType(); for (SdkType it : SdkType.getAllTypeList()) { if (condition.test(it)) { if (it instanceof JavaSdkType && it.getDependencyType() == null && !((JavaSdkType)it).isDependent()) { hasNotSimple = true; break; } } } if (hasNotSimple) { //we found another JavaSdkType (e.g. JavaSdkImpl), there is no need for SimpleJavaSdkType return NOT_SIMPLE_JAVA_TYPE; } else { //there is only one JavaSdkType, so it is no need to filter anything return TRUE; } }