package Replay;

import Constants.BitmaskEnum;
import Constants.KeyStroke;

import java.util.*;

public final class Action {
    private final long sincePrevActionMillis;
    private final float xPos;
    private final float yPos;
    private final EnumSet<KeyStroke> keys;

    public Action(long sincePrevActionMillis, float xPos, float yPos, EnumSet<KeyStroke> keys) {
        this.sincePrevActionMillis = sincePrevActionMillis;
        this.xPos = xPos;
        this.yPos = yPos;
        this.keys = keys;
    }

    public long getMillisSincePrevAction() {
        return sincePrevActionMillis;
    }

    public float getX() {
        return xPos;
    }

    public float getY() {
        return yPos;
    }

    public EnumSet<KeyStroke> getKeyPresses() {
        return keys;
    }

    public static List<Action> parseActions(String input) {
        List<Action> actions = new ArrayList<Action>();
        try (Scanner scanner = new Scanner(input).useDelimiter(",") ){
            while (scanner.hasNext()) {
                actions.add(parseSingleAction(scanner.next()));
            }
            return actions;
        }
    }

    public static Action parseSingleAction(String input) {
        try (Scanner scanner = new Scanner(input).useDelimiter("[|]")) {
            long millis = scanner.nextLong();
            float x = scanner.nextFloat();
            float y = scanner.nextFloat();
            EnumSet<KeyStroke> keys = BitmaskEnum.fromMask(KeyStroke.class, scanner.nextInt());

            return new Action(millis, x, y, keys);
        }
    }
}

@@ -68,16 +68,109 @@
 Stroke;%0A
+import com.google.common.collect.ImmutableList;%0A%0Aimport javax.management.ImmutableDescriptor;
 %0Aimport 
@@ -949,52 +949,69 @@
     
-List%3CAction%3E actions = new ArrayList%3CAction%3E
+ImmutableList.Builder%3CAction%3E builder = ImmutableList.builder
 ();%0A
@@ -1081,10 +1081,10 @@
 %22,%22)
- 
 )
+ 
 %7B%0A  
@@ -1137,23 +1137,23 @@
         
-actions
+builder
 .add(par
@@ -1222,15 +1222,23 @@
 urn 
-actions
+builder.build()
 ;%0A  

Use immutable list in Actions