diff --git a/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/.ratings b/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/.ratings index 5c036a37e9699d60e24fb387b24eb17160a430c6..f558f34c53aad1951c1720f43d9e677cb32af37e 100644 --- a/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/.ratings +++ b/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/.ratings @@ -1 +1 @@ -LambdaUtils.java 6a7260eca3f4c0f44e97a26cfeacb8801d00bf6c GREEN +LambdaUtils.java 6fed9bb62eba3f7af6ebd7821fb22df6fcc507f8 YELLOW diff --git a/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/LambdaUtils.java b/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/LambdaUtils.java index 6a7260eca3f4c0f44e97a26cfeacb8801d00bf6c..6fed9bb62eba3f7af6ebd7821fb22df6fcc507f8 100644 --- a/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/LambdaUtils.java +++ b/org.fortiss.tooling.common/src/org/fortiss/tooling/common/util/LambdaUtils.java @@ -300,6 +300,20 @@ public class LambdaUtils { return collection.stream().findFirst(); } + /** + * Checks whether the given object inherits from any of the given Classes, i.e. the check + * {@link Class#isAssignableFrom(Class)} is performed for each given class on the given Object. + * + * @param types + * collection of classes to check inheritance. + * @param testType + * type to check whether it inherits from any of the given classes. + * @return see above. + */ + public static boolean isAssignableFromAny(Collection<Class<?>> types, Class<?> testType) { + return types.stream().anyMatch(t -> t.isAssignableFrom(testType)); + } + /** * Checks whether the given object inherits from any of the given Classes, i.e. the check * {@link Class#isAssignableFrom(Class)} is performed for each given class on the given Object. @@ -311,7 +325,7 @@ public class LambdaUtils { * @return see above. */ public static boolean isAssignableFromAny(Collection<Class<?>> types, Object element) { - return types.stream().anyMatch(t -> t.isAssignableFrom(element.getClass())); + return isAssignableFromAny(types, element.getClass()); } /**