package com.transloadit.sdk;

import java.util.HashMap;
import java.util.Map;

/**
 * Holds all the steps that would be added to a given assembly
 */
public class Steps {
    private Map<String, Step> all;

    public Steps(){
        all = new HashMap<>();
    }

    /**
     * This class represents a single step that may be added to an assembly.
     */
    public class Step {
        public String name;
        public String robot;
        public Map<String, Object> options;

        /**
         *
         * @param name Name of the step.
         * @param robot The name of the robot ot use with the step
         * @param options
         */
        public Step(String name, String robot, Map<String, Object> options){
            this.name = name;
            this.robot = robot;
            this.options = options;
        }

        /**
         *
         * @return Map representation of the Step
         */
        public Map<String, Object> asHash() {
            Map<String, Object> options = new HashMap<>(this.options);
            options.put("robot", this.robot);
            return options;
        }
    }

    /**
     * Adds a new step to the list of steps.
     *
     * @param name Name of the step to add
     * @param robot The name of the robot ot use with the step
     * @param options
     */
    public void addStep(String name, String robot, Map<String, Object> options) {
        all.put(name, new Step(name, robot, options));
    }

    /**
     *
     * @param name The name of the step to return.
     * @return an instance of ({@link Step ) with the specified name.
     */
    public Step getStep(String name) {
        return all.get(name);
    }

    /**
     *
     * @return Steps as a HashMap ready to be used by an assembly.
     */
    public Map<String, Map> asHash(){
        Map<String, Map> hash = new HashMap<>();
        all.forEach((name, step)-> hash.put(name, step.asHash()));
        return  hash;
    }
}

@@ -138,16 +138,17 @@
 assembly
+.
 %0A */%0Apub
@@ -604,24 +604,25 @@
 ith the step
+.
 %0A         * 
@@ -631,24 +631,61 @@
 aram options
+ extra options required for the step.
 %0A         */
@@ -943,16 +943,17 @@
 the Step
+.
 %0A       
@@ -992,22 +992,21 @@
 Object%3E 
-asHash
+toMap
 () %7B%0A   
@@ -1266,16 +1266,17 @@
 p to add
+.
 %0A     * 
@@ -1330,16 +1330,17 @@
 the step
+.
 %0A     * 
@@ -1353,16 +1353,53 @@
  options
+ extra options required for the step.
 %0A     */
@@ -1881,22 +1881,21 @@
 g, Map%3E 
-asHash
+toMap
 ()%7B%0A    
@@ -1951,66 +1951,152 @@
     
-all.forEach((name, step)-%3E hash.put(name, step.asHash()));
+for (Map.Entry%3CString, Step%3E entry :%0A                all.entrySet()) %7B%0A            hash.put(entry.getKey(), entry.getValue().toMap());%0A        %7D
 %0A   

rename steps methods and docs