Module net.morimekta.collect
Utils : Collect
This package contains a number of unmodifiable collection classes largely inspired of the immutable collections in guava. Note that there are some important differences:
- All classes are made as simple as possible, only one implementation per type (e.g. no special 1-entry set implementation).
-
Builder classes for map and set accepts duplicate values / duplicate
keys, and will handle them as a normal
Map
orSet
would. - The unmodifiable collections are not serializable, and if forcefully serialized will always end up empty, and as new instances. PS: The whole concept of serializable should be ditched in my opinion.
- Note that since the classes were more or less written from scratch, I have taken the liberty of taking the general copyright of the implementations, though lots of kudos to the Guava team for making them in the first place, and more or less standardizing the interface for immutable collections. Even Java uses these now...
- The list sets and maps still require all values to be non-null.
-
The
UnmodifiableSet
andUnmodifiableMap
classes will always preserve input order when iterating. - Constructors will try to reuse the same instance and backing instances as much as possible, with the limitations of local knowledge.
UnmodifiableCollection.asList()
and
UnmodifiableMapBase.orderedBy(java.util.Comparator)
.-
-
Packages
Exports Package Description net.morimekta.collect This package contains a number of unmodifiable collection classes largely inspired of the immutable collections in guava.net.morimekta.collect.util Package with collect related utilities.
-