I'm trying to do partial update on collection items based on a condition. Here's the Java code snippet:

```
public class Point {
    public int x = 0;
    public int y = 0;

    public Point(int a, int b) {
        x = a;
        y = b;
    }

    public String toString() {
      return this.x + ":" + this.y;
    }
}

public class HelloWorld
{

  public static void main(String[] args)
  {
    Point p1 = new Point(1, 1);
    Point p2 = new Point(2, 2);

    Collection<Point> arr = new ArrayList<Point>();
    arr.add(p1);
    arr.add(p2);

    arr.stream().map(el -> el.x == 2 ? el.y : 20);

    System.out.println(Arrays.toString(arr.toArray()));
  }
}

```

As you can see this function returns: [1:1, 2:2], but what I want is: [1:1, 2:20]

I believe the collection is immutable and that's why I cannot modify the object in place. My actual code is a painless script in ElasticSearch:

```
ctx._source.points = ctx._source.points
    .stream()
    .map(point -> point.x == 2 ? point.y : 20);
    .collect(Collectors.toList())

```

Which I believe translates to above Java code.

I don't have much experience in Java. That's why I cannot figure out what data structure would allow me to mutate list elements in Java that I can use in ElasticSearch painless scripting language.