Over a million developers have joined DZone.

New Interfaces For MultiMap and MultiSet in Apache Commons Collections 4.1

DZone 's Guide to

New Interfaces For MultiMap and MultiSet in Apache Commons Collections 4.1

Apache Commons Collections is a project for the development and maintenance of collection classes extending the JDK collection framework. Version 4.1 just arrived.

· Java Zone ·
Free Resource

The Apache Commons Collections project just released version 4.1, which has a few interesting new features despite being labelled a minor security release.  Let's take a look at the major new features since 4.0:

  • Added new interfaces "MultiValuedMap", "ListValuedMap" and "SetValuedMap" as a replacement for "MultiMap". Decorators and implementations reside in the "multimap" package and a "MultiMapUtils" class has been added. The existing interface "MultiMap" as well as the concrete implementation "MultiValueMap" has been deprecated. Fixes COLLECTIONS-508.

  • Added new MultiSet interface which is intended to be a replacement for the Bag interface. The main difference is that a MultiSet is fully compatible to the Collection contract. Fixes COLLECTIONS-567.

  • Added new class "FluentIterable" to support a fluent API for manipulating Iterable instances. Additionally various supporting methods have been added to "IterableUtils" and "IteratorUtils". Fixes COLLECTIONS-464,COLLECTIONS-442.

There's also a full list of the changes here.  4.x is also the first line to require Java 6+. The source and binary are compatible with the  4.0 release of Commons Collections with the exception that some classes in the functor package do not implement the Serializable interface anymore. This is because serialization support for unsafe classes in the functor package "has been removed completely as this can be exploited for remote code execution attacks. Classes considered to be unsafe are: CloneTransformer, ForClosure, InstantiateFactory, InstantiateTransformer, InvokerTransformer, PrototypeCloneFactory, PrototypeSerializationFactory, WhileClosure."

If you use Commons Collections, the security fix is probably the biggest reason to upgrade.

java ,apache commons

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}