propose for an empty query

This commit is contained in:
2017-04-16 10:39:17 +02:00
parent 44f30aafee
commit f6a9fc2394
7 changed files with 134 additions and 36 deletions

View File

@@ -33,7 +33,7 @@ public class CollectionUtils {
return Stream.of(input).map(mapper).collect(Collectors.toList());
}
public static <T, V> Map<T, V> toMap(final Iterable<V> iterable, final Function<V, T> keyMapper) {
public static <T, V> Map<T, V> createMapFromValues(final Iterable<V> iterable, final Function<V, T> keyMapper) {
final Map<T, V> result = new HashMap<>();
for (final V value : iterable) {
@@ -45,6 +45,19 @@ public class CollectionUtils {
return result;
}
public static <KEY, VALUE> Map<KEY, VALUE> createMapFromKeys(final Iterable<KEY> iterable,
final Function<KEY, VALUE> valueMapper) {
final Map<KEY, VALUE> result = new HashMap<>();
for (final KEY key : iterable) {
final VALUE value = valueMapper.apply(key);
result.put(key, value);
}
return result;
}
public static <T> List<T> filter(final Collection<T> collection, final Predicate<T> predicate) {
return collection.stream().filter(predicate).collect(Collectors.toList());
}