All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.polyglotted.common.util.CollUtil Maven / Gradle / Ivy
package io.polyglotted.common.util;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static com.google.common.base.Predicates.not;
import static io.polyglotted.common.util.NullUtil.nonNull;
@SuppressWarnings({"unused", "unchecked", "Guava", "StaticPseudoFunctionalStyleMethod", "ConstantConditions", "WeakerAccess"})
public abstract class CollUtil {
public static Map filterKeys(Map map, final Predicate super K> predicate) { return Maps.filterKeys(map, predicate); }
public static Map filterKeysNeg(Map map, final Predicate super K> predicate) { return Maps.filterKeys(map, not(predicate)); }
public static Map filterValues(Map map, final Predicate super V> predicate) { return Maps.filterValues(map, predicate); }
public static Map filterValuesNeg(Map map, final Predicate super V> pred) { return Maps.filterValues(map, not(pred)); }
public static Map uniqueIndex(Iterable values, Function super V, K> function) { return Maps.uniqueIndex(values, function); }
public static Collection asColl(Object value, Collection defaulted) { return nonNull((Collection) value, defaulted); }
public static Collection filterColl(Collection coll, Predicate super E> predicate) { return Collections2.filter(coll, predicate); }
public static Collection filterCollNeg(Collection coll, Predicate super E> pred) { return Collections2.filter(coll, not(pred)); }
public static Collection transformColl(Collection coll, Function super F, T> fn) { return Collections2.transform(coll, fn); }
public static List transformList(List list, Function super F, ? extends T> fn) { return Lists.transform(list, fn); }
public static FluentIterable fluent(Iterable list) { return FluentIterable.from(list); }
public static FluentIterable transform(Iterable list, final Function super F, ? extends T> fn) {
return (FluentIterable) Iterables.transform(list, fn);
}
public static FluentIterable filter(Iterable list, Predicate super E> predicate) {
return (FluentIterable) Iterables.filter(list, predicate);
}
public static FluentIterable filterNeg(Iterable list, Predicate super E> predicate) {
return (FluentIterable) Iterables.filter(list, not(predicate));
}
public static FluentIterable concat(Iterable extends T>... inputs) { return FluentIterable.concat(inputs); }
public static FluentIterable concat(Iterable extends T> a, Iterable extends T> b) { return FluentIterable.concat(a, b); }
public static T[] toArray(Iterable extends T> iterable, Class type) { return Iterables.toArray(iterable, type); }
public static E firstOf(Iterable list) { return firstOf(list, null); }
public static E firstOf(Iterable list, E defaulted) { return Iterables.getFirst(list, defaulted); }
}