A library with a java unmodifiable list implementation and a method like createAndAdd?

55 Views Asked by At

I would like to do something like:

final unmodifiableList1 = staticMethodForUnmodifiableList(1,2,3,4);
final unmodifiableList2 = unmodifiableList1.createAndAdd(5);

System.out.println(unmodifiableList1); // prints 1, 2, 3, 4
System.out.println(unmodifiableList2); // prints 1, 2, 3, 4, 5

I have implemented my own solution, but now I realize I would like to have this class in other companies, where I can't reuse my own solution and now I'm thinking if this exist's in any Open Source Library that I could use.

Same would be nice to have for methods like subList and for other collections like unmodifiable Maps, Sets etc.

Best Regards

1

There are 1 best solutions below

0
henry86 On

For someone interested - I've switched to kotlin language, which solved these problems because kotlin has this methods included (and much more) and is fully compatible with the java source code (and binaries of course)