Skip to content
Snippets Groups Projects
Commit 8f92ade8 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

refs 3203
parent 56c27b68
No related branches found
No related tags found
No related merge requests found
LambdaUtils.java 6f78c95e41b99c905396aea1d62ff6a9d211a19f GREEN
LambdaUtils.java 4bd5016212e8d0b596a13ac7262cef1548e9b077 YELLOW
......@@ -244,6 +244,22 @@ public class LambdaUtils {
return (Optional<T>)filterStream(collection, filter).findFirst();
}
/**
* Returns the first element from the given Collection.
* <p>
* Use with care! This method is intended to avoid long lambda expressions or ugly conversions
* to list from standard collections if only a single element is guaranteed to exist in the
* collection.
* </p>
*
* @param collection
* Collection to return the first element from.
* @return First element of the given collection.
*/
public static <T> Optional<T> getFirst(Collection<T> collection) {
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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment