@Test public void testToSet() { assertThat(CollectionHelper.toSet((Set<Long>) null)).isNull(); Set<Long> set = new HashSet<>(); set.add(33L); set.add(44L); assertThat(CollectionHelper.toSet(set)).isInstanceOf(Set.class).containsOnly(33L, 44L); assertThat(CollectionHelper.toSet(Arrays.asList(1L))).isInstanceOf(Set.class) .containsExactly(1L); assertThat(CollectionHelper.toSet(Arrays.asList(1L, 2L, 3L))) .isInstanceOf(Set.class).containsExactly(1L, 2L, 3L); }
@Nullable public static Set<Long> toSet(@Nullable Collection<Long> collection) { if (collection != null) { if (collection instanceof Set) { return (Set<Long>) collection; } return new HashSet<>(collection); } return null; }
CollectionHelper { @Nullable public static Set<Long> toSet(@Nullable Collection<Long> collection) { if (collection != null) { if (collection instanceof Set) { return (Set<Long>) collection; } return new HashSet<>(collection); } return null; } }
CollectionHelper { @Nullable public static Set<Long> toSet(@Nullable Collection<Long> collection) { if (collection != null) { if (collection instanceof Set) { return (Set<Long>) collection; } return new HashSet<>(collection); } return null; }  }
CollectionHelper { @Nullable public static Set<Long> toSet(@Nullable Collection<Long> collection) { if (collection != null) { if (collection instanceof Set) { return (Set<Long>) collection; } return new HashSet<>(collection); } return null; }  @SafeVarargs @Nullable static List<T> toList(@Nullable T... arguments); @SuppressWarnings("unchecked") @Nullable static List<Object> toList(@Nullable Collection<T> collection); @Nullable static Set<Long> toSet(@Nullable Collection<Long> collection); }
CollectionHelper { @Nullable public static Set<Long> toSet(@Nullable Collection<Long> collection) { if (collection != null) { if (collection instanceof Set) { return (Set<Long>) collection; } return new HashSet<>(collection); } return null; }  @SafeVarargs @Nullable static List<T> toList(@Nullable T... arguments); @SuppressWarnings("unchecked") @Nullable static List<Object> toList(@Nullable Collection<T> collection); @Nullable static Set<Long> toSet(@Nullable Collection<Long> collection);  }