diff --git a/org.fortiss.tooling.common/trunk/src/org/fortiss/tooling/common/util/LambdaUtils.java b/org.fortiss.tooling.common/trunk/src/org/fortiss/tooling/common/util/LambdaUtils.java index 8c8006e9a3ae9d4c79cc49e7dabed2328fcf07d2..7c3e3be7d04d62a8829b67bba78c10503bb4d2be 100644 --- a/org.fortiss.tooling.common/trunk/src/org/fortiss/tooling/common/util/LambdaUtils.java +++ b/org.fortiss.tooling.common/trunk/src/org/fortiss/tooling/common/util/LambdaUtils.java @@ -237,6 +237,20 @@ public class LambdaUtils { return outCol; } + /** + * Returns the first element of the given {@code inCol} collection that is assignable from the + * given type. + * + * @param inCol + * Collection to be filtered. + * @param typeFilter + * Type for which the elements shall be filtered. + * @return Optional of the first found element of the given type. + */ + public static <S, T> Optional<T> firstOfType(Collection<S> inCol, Class<T> typeFilter) { + return getFirst(filterType(inCol, typeFilter)); + } + /** * Applies the given {@code action} to each element of the given {@code inputCollection}. *