A comprehensive collections library for Java delivering productivity and performance through an expressive and efficient set of APIs and types.
npx @tessl/cli install tessl/maven-org-eclipse-collections--eclipse-collections@13.0.0Eclipse Collections is a comprehensive Java collections library providing mutable and immutable collections, primitive collections, and various container types. It delivers productivity and performance through an expressive and efficient set of APIs and types with over 200 methods for functional programming operations.
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>13.0.0</version>
</dependency>import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.factory.Sets;
import org.eclipse.collections.impl.factory.Maps;For primitive collections (generated interfaces):
import org.eclipse.collections.api.list.primitive.MutableIntList;
import org.eclipse.collections.api.set.primitive.MutableIntSet;
import org.eclipse.collections.impl.factory.primitive.IntLists;
import org.eclipse.collections.impl.factory.primitive.IntSets;Note: Primitive collection interfaces and factory classes are generated at build time to provide specialized implementations for all Java primitive types (boolean, byte, char, short, int, long, float, double).
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.impl.factory.Lists;
// Create collections using factory methods
MutableList<String> list = Lists.mutable.with("Alice", "Bob", "Charlie");
MutableSet<String> set = Sets.mutable.with("red", "green", "blue");
MutableMap<String, Integer> map = Maps.mutable.with("Alice", 25, "Bob", 30);
// Rich functional operations
MutableList<String> upperCaseNames = list
.select(name -> name.length() > 3)
.collect(String::toUpperCase);
// Primitive collections avoid boxing
MutableIntList numbers = IntLists.mutable.with(1, 2, 3, 4, 5);
int sum = numbers.sum();
MutableIntList doubled = numbers.collect(i -> i * 2);
// Immutable collections for safety
ImmutableList<String> immutableList = Lists.immutable.with("A", "B", "C");
ImmutableList<String> newList = immutableList.newWith("D");Eclipse Collections is built around several key design principles:
Lists, Sets, Maps, etc.) provide convenient entry pointsRichIterable<T> providing consistent functional programming capabilitiesStatic factory classes providing convenient creation of all collection types with mutable, immutable, and fixed-size variants.
// Main factory entry points
MutableList<T> Lists.mutable.empty();
MutableList<T> Lists.mutable.with(T... elements);
ImmutableList<T> Lists.immutable.of(T... elements);
FixedSizeList<T> Lists.fixedSize.with(T... elements);
MutableSet<T> Sets.mutable.with(T... elements);
ImmutableSet<T> Sets.immutable.of(T... elements);
MutableMap<K, V> Maps.mutable.empty();
MutableMap<K, V> Maps.mutable.with(K key, V value);Comprehensive collection interfaces providing rich functionality for all collection types, built around the RichIterable foundation.
interface RichIterable<T> extends InternalIterable<T> {
// Filtering
RichIterable<T> select(Predicate<? super T> predicate);
RichIterable<T> reject(Predicate<? super T> predicate);
// Transformation
<V> RichIterable<V> collect(Function<? super T, ? extends V> function);
<V> RichIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function);
// Aggregation
<IV> IV injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function);
T detect(Predicate<? super T> predicate);
// Testing
boolean anySatisfy(Predicate<? super T> predicate);
boolean allSatisfy(Predicate<? super T> predicate);
}Complete primitive collection APIs for all Java primitive types (boolean, byte, char, short, int, long, float, double) avoiding boxing overhead.
interface IntIterable extends PrimitiveIterable {
void forEach(IntProcedure procedure);
IntIterable select(IntPredicate predicate);
<V> RichIterable<V> collect(IntToObjectFunction<? extends V> function);
long sum();
int max();
int min();
double average();
}
interface MutableIntList extends IntIterable, MutableIntCollection {
boolean add(int element);
int get(int index);
int set(int index, int element);
MutableIntList with(int element);
}Rich functional programming support with Functions, Predicates, Procedures and factory classes for common operations.
// Core functional interfaces
interface Function<T, R> {
R valueOf(T argument);
}
interface Predicate<T> {
boolean accept(T object);
}
interface Procedure<T> {
void value(T object);
}
// Factory classes for common patterns
class Predicates {
static <T> Predicate<T> alwaysTrue();
static <T> Predicate<T> equal(Object expected);
static <T> Predicate<T> instanceOf(Class<?> clazz);
static <T> Predicate<T> and(Predicate<? super T>... predicates);
}Specialized collection types including Multimaps, BiMaps, Partitions, and utility APIs for advanced use cases.
interface Multimap<K, V> {
boolean put(K key, V value);
RichIterable<V> get(K key);
RichIterable<V> removeAll(Object key);
Multimap<V, K> flip();
}
interface BiMap<K, V> extends MapIterable<K, V> {
BiMap<V, K> inverse();
V put(K key, V value);
}
interface PartitionIterable<T> {
RichIterable<T> getSelected();
RichIterable<T> getRejected();
}interface InternalIterable<T> {
void forEach(Procedure<? super T> procedure);
void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter);
void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure);
}
interface RichIterable<T> extends InternalIterable<T> {
// Over 200 methods for functional operations
}
interface MutableCollection<T> extends Collection<T>, RichIterable<T> {
boolean add(T item);
boolean remove(Object item);
MutableCollection<T> with(T element);
MutableCollection<T> without(T element);
}
interface ImmutableCollection<T> extends RichIterable<T> {
ImmutableCollection<T> newWith(T element);
ImmutableCollection<T> newWithout(T element);
}// Lists
interface ListIterable<T> extends RichIterable<T>, OrderedIterable<T> {
T get(int index);
int indexOf(Object object);
int lastIndexOf(Object object);
}
interface MutableList<T> extends MutableCollection<T>, List<T>, ListIterable<T> {
void add(int index, T element);
T set(int index, T element);
T remove(int index);
MutableList<T> sortThis();
MutableList<T> reverseThis();
}
// Sets
interface SetIterable<T> extends RichIterable<T> {
SetIterable<T> union(SetIterable<? extends T> set);
SetIterable<T> intersect(SetIterable<? extends T> set);
SetIterable<T> difference(SetIterable<? extends T> subtrahend);
boolean isSubsetOf(SetIterable<? extends T> candidateSuperset);
}
interface MutableSet<T> extends MutableCollection<T>, Set<T>, SetIterable<T> {
}
// Maps
interface MapIterable<K, V> extends RichIterable<V> {
V get(Object key);
boolean containsKey(Object key);
V getIfAbsent(K key, Function0<? extends V> function);
RichIterable<K> keysView();
RichIterable<V> valuesView();
RichIterable<Pair<K, V>> keyValuesView();
}
interface MutableMap<K, V> extends MutableMapIterable<K, V>, Map<K, V> {
V put(K key, V value);
V getIfAbsentPut(K key, Function0<? extends V> function);
V updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function);
MutableMap<K, V> withKeyValue(K key, V value);
}