Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java optional to collection

public static <T> List<T> toList(Optional<T> opt) {
    return opt
            .map(Collections::singletonList)
            .orElseGet(Collections::emptyList);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #optional #collection
ADD COMMENT
Topic
Name
2+8 =