package com.netopyr.reduxfx.updater;

import javaslang.collection.Array;
import javaslang.collection.Seq;
import org.apache.commons.lang3.builder.ToStringBuilder;

public final class Update<STATE> {

    public static <T> Update<T> of(T state, Command... commands) {
        return Update.of(state, Array.of(commands));
    }

    public static <T> Update<T> of(T state, Seq<? extends Command> commands) {
        return new Update<>(state, commands);
    }

    private final STATE state;
    private final Seq<? extends Command> commands;

    private Update(STATE state, Seq<? extends Command> commands) {
        this.state = state;
        this.commands = commands;
    }

    public STATE getState() {
        return state;
    }

    public Seq<? extends Command> getCommands() {
        return commands;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("state", state)
                .append("commands", commands)
                .toString();
    }
}

@@ -157,16 +157,42 @@
 ilder;%0A%0A
+import java.util.Arrays;%0A%0A
 public f
@@ -219,16 +219,105 @@
 ATE%3E %7B%0A%0A
+    public static %3CT%3E Update%3CT%3E of(T state) %7B%0A        return new Update%3C%3E(state);%0A    %7D%0A%0A
     publ
@@ -394,17 +394,20 @@
 urn 
+new 
 Update
-.of
+%3C%3E
 (sta
@@ -430,32 +430,49 @@
 mands));%0A    %7D%0A%0A
+    @SafeVarargs%0A
     public stati
@@ -503,34 +503,24 @@
 te, Seq%3C
-? extends 
 Command%3E
  command
@@ -503,32 +503,35 @@
 te, Seq%3CCommand%3E
+...
  commands) %7B%0A   
@@ -629,34 +629,24 @@
 e final Seq%3C
-? extends 
 Command%3E com
@@ -653,16 +653,33 @@
 mands;%0A%0A
+    @SafeVarargs%0A
     priv
@@ -706,34 +706,24 @@
 te, Seq%3C
-? extends 
 Command%3E
  command
@@ -706,32 +706,35 @@
 te, Seq%3CCommand%3E
+...
  commands) %7B%0A   
@@ -782,24 +782,77 @@
 mands = 
-commands
+Arrays.stream(commands).reduce(Array.empty(), Seq::appendAll)
 ;%0A    %7D%0A
@@ -930,18 +930,8 @@
 Seq%3C
-? extends 
 Comm

Improve Update interface