javadoc
Project: http://git-wip-us.apache.org/repos/asf/bval/repo Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/763f6114 Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/763f6114 Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/763f6114 Branch: refs/heads/bv2 Commit: 763f611453d22f88da6428823086f1cf077cdbb2 Parents: d9cb6a7 Author: Matt Benson <[email protected]> Authored: Thu Mar 22 14:00:40 2018 -0500 Committer: Matt Benson <[email protected]> Committed: Thu Mar 22 14:00:40 2018 -0500 ---------------------------------------------------------------------- .../apache/bval/jsr/util/ToUnmodifiable.java | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bval/blob/763f6114/bval-jsr/src/main/java/org/apache/bval/jsr/util/ToUnmodifiable.java ---------------------------------------------------------------------- diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/util/ToUnmodifiable.java b/bval-jsr/src/main/java/org/apache/bval/jsr/util/ToUnmodifiable.java index 6f6b021..e7a2f9b 100644 --- a/bval-jsr/src/main/java/org/apache/bval/jsr/util/ToUnmodifiable.java +++ b/bval-jsr/src/main/java/org/apache/bval/jsr/util/ToUnmodifiable.java @@ -31,20 +31,44 @@ import java.util.stream.Collectors; */ public class ToUnmodifiable { + /** + * Collector to unmodifiable {@link Set} with custom backing implementation. + * + * @param set + * {@link Supplier} + * @return {@link Collector} + */ public static <T> Collector<T, ?, Set<T>> set(Supplier<Set<T>> set) { return Collectors.collectingAndThen(Collectors.toCollection(set), t -> t.isEmpty() ? Collections.emptySet() : Collections.unmodifiableSet(t)); } + /** + * Collector to unmodifiable {@link Set} (maintains insertion order). + * + * @return {@link Collector} + */ public static <T> Collector<T, ?, Set<T>> set() { return set(LinkedHashSet::new); } + /** + * Collector to unmodifiable {@link List}. + * + * @return {@link Collector} + */ public static <T> Collector<T, ?, List<T>> list() { return Collectors.collectingAndThen(Collectors.toList(), t -> t.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(t)); } + /** + * Collector to unmodifiable {@link Map}. + * + * @param keyMapper + * @param valueMapper + * @return {@link Collector} + */ public static <T, K, U> Collector<T, ?, Map<K, U>> map(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) { return Collectors.collectingAndThen(Collectors.toMap(keyMapper, valueMapper),
