TheoBrd / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Create fluent interface for building immutable collections #59

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
By immutable I mean two things:
- you cannot modify resulting collection,
- source collection is not modified too.

Currently to operate on immutable data structures one have to write something 
like this:

public Set<Bills> howMuchIMustPayNextWeek(Set<Bill> myBills) {
  // I don't want to modify myBills, so I use clone()
  return with(myBills).clone().retain(dueInNextWeek);
}

As a collection API user (with functional programming background) I would like 
to have possibility to easily operate on immutable data structures like this:

public Set<Bills> howMuchIMustPayNextWeek(Set<Bill> myBills) {
  return from(myBills).filter(dueInNextWeek);
}

from(...) should return immutable collection

I am aware that support for immutable collections is a big task and I'll 
understand if you decide it is out of LambdaJ's scope, but it would be great to 
have decent immutable collections API in Java world...

Original issue reported on code.google.com by adamcze...@gmail.com on 9 Jan 2011 at 10:13

GoogleCodeExporter commented 8 years ago
Great suggestion! I will evaluate it for release 2.4

Original comment by mario.fu...@gmail.com on 9 Jan 2011 at 10:33

GoogleCodeExporter commented 8 years ago

Original comment by mario.fu...@gmail.com on 14 Jan 2011 at 8:22