package com.yheriatovych.reductor;

import java.util.Arrays;

/**
 * Minimal representation of change to be performed on state
 */
public class Action {
    public final String type;
    public final Object[] values;

    /**
     * Create Action object with specified type and value
     *
     * @param type  String type of action, will be used by {@link Reducer} for dispatch
     * @param value any payload to be included with this value
     */
    public Action(String type, Object[] values) {
        this.type = type;
        this.values = values;
    }

    /**
     * Create Action with defined type and null value
     *
     * @param type String type of action, will be used by {@link Reducer} for dispatch
     */
    public Action(String type) {
        this(type, new Object[0]);
    }

    public static Action create(String type, Object... values) {
        return new Action(type, values);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Action action = (Action) o;

        if (type != null ? !type.equals(action.type) : action.type != null) return false;
        // Probably incorrect - comparing Object[] arrays with Arrays.equals
        return Arrays.equals(values, action.values);

    }

    @Override
    public int hashCode() {
        int result = type != null ? type.hashCode() : 0;
        result = 31 * result + Arrays.hashCode(values);
        return result;
    }

    @Override
    public String toString() {
        return "Action{" +
                "type='" + type + '\'' +
                ", values=" + Arrays.toString(values) +
                '}';
    }
}

@@ -272,24 +272,25 @@
 pe and value
+s
 %0A     *%0A    
@@ -305,16 +305,17 @@
 m type  
+ 
 String t
@@ -397,51 +397,88 @@
 alue
+s
  any 
-payload to be included with this value
+number of arbitrary objects that can be attached as payload to this action
 %0A   
@@ -646,22 +646,36 @@
 ype 
-and null value
+without any attached payload
 %0A   
@@ -856,108 +856,663 @@
     
-public static Action create(String type, Object... values) %7B%0A        return new Action(type, values)
+/**%0A     * Factory method to create action with defined type and any number of attached values as payload%0A     *%0A     * @param type   String type of action, will be used by %7B@link Reducer%7D for dispatch%0A     * @param values any number of arbitrary objects that can be attached as payload to this action%0A     * @return created Action%0A     */%0A    public static Action create(String type, Object... values) %7B%0A        return new Action(type, values);%0A    %7D%0A%0A    /**%0A     * Returns action value at given position%0A     * @param position value position%0A     * @return Object value%0A     */%0A    public Object getValue(int position) %7B%0A        return values%5Bposition%5D
 ;%0A  

add javadocs and getValue method to Action