@Test public void getRandomItemFromCollection () { assertNull(CollectionUtils.getRandomItemFromCollection(Collections.emptySet())); assertThat(CollectionUtils.getRandomItemFromCollection(Set.of("abc", "123")), anyOf(is("abc"), is("123"))); assertThat(CollectionUtils.getRandomItemFromCollection(List.of("abc", "123")), anyOf(is("abc"), is("123"))); try { CollectionUtils.getRandomItemFromCollection(null); fail("Null Pointer expected"); } catch (NullPointerException ignored) { } }
public static <T> T getRandomItemFromCollection (@NotNull Collection<T> collection) { return getRandomItemFromList(collection instanceof List ? (List<T>) collection : List.copyOf(collection)); }
CollectionUtils { public static <T> T getRandomItemFromCollection (@NotNull Collection<T> collection) { return getRandomItemFromList(collection instanceof List ? (List<T>) collection : List.copyOf(collection)); } }
CollectionUtils { public static <T> T getRandomItemFromCollection (@NotNull Collection<T> collection) { return getRandomItemFromList(collection instanceof List ? (List<T>) collection : List.copyOf(collection)); } private  CollectionUtils(); }
CollectionUtils { public static <T> T getRandomItemFromCollection (@NotNull Collection<T> collection) { return getRandomItemFromList(collection instanceof List ? (List<T>) collection : List.copyOf(collection)); } private  CollectionUtils(); static T getRandomItemFromCollection(@NotNull Collection<T> collection); }
CollectionUtils { public static <T> T getRandomItemFromCollection (@NotNull Collection<T> collection) { return getRandomItemFromList(collection instanceof List ? (List<T>) collection : List.copyOf(collection)); } private  CollectionUtils(); static T getRandomItemFromCollection(@NotNull Collection<T> collection);  }