Last active
August 27, 2019 15:30
-
-
Save yavuztas/eadfab4de65ade413615689f78d9d85d to your computer and use it in GitHub Desktop.
Created with Copy to Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> List<T> toList(Collection<T> collection) { | |
return collection.stream().collect(Collectors.toList()); | |
} | |
public static <T> Set<T> toSet(Collection<T> collection) { | |
return UtilsForCollections.toSet(collection, false); | |
} | |
public static <T> Set<T> toSet(Collection<T> collection, boolean preserveOrder) { | |
if (preserveOrder) { | |
return collection.stream() | |
.collect(Collectors.toCollection(LinkedHashSet::new)); | |
} | |
return collection.stream().collect(Collectors.toSet()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment