package com.leandog.gametel.driver.commands;

import java.util.Arrays;

import com.leandog.gametel.util.Objects;

public class Command {
    
    private final String name;
    private final Object[] arguments;
    private Target target;
    
    public enum Target {
        LastResultOrRobotium,
        Robotium,
    }
    
    public Command() {
        name = null;
        arguments = new Object[0];
        target = Target.LastResultOrRobotium;
    }

    public Command(final String name) {
        this.name = name;
        arguments = new Object[0];
        target = Target.LastResultOrRobotium;
    }

    public Command(final String name, final Object... arguments) {
        this.name = name;
        this.arguments = arguments;
        target = Target.LastResultOrRobotium;
    }

    public Command(final String name, final Target target,  final Object... arguments) {
        this.name = name;
        this.arguments = arguments;
        this.target = Target.LastResultOrRobotium;
        if( target != null ) {
            this.target = target;
        }
    }

    public String getName() {
        return name;
    }

    public Object[] getArguments() {
        return arguments;
    }

    public Target getTarget() {
        return target;
    }
    
    @Override
    public int hashCode() {
        return name.hashCode() + Arrays.hashCode(arguments);
    }
    
    @Override
    public boolean equals(Object other) {
        if( null == other || !(other instanceof Command)) {
            return false;
        }
        
        final Command otherCommand = (Command)other;
        return Objects.equal(name, otherCommand.getName()) &&
               Arrays.equals(arguments, otherCommand.getArguments());
    }
}
@@ -147,22 +147,16 @@
 private 
-final 
 String n
@@ -172,22 +172,16 @@
 private 
-final 
 Object%5B%5D
@@ -476,24 +476,40 @@
 ing name) %7B%0A
+        this();%0A
         this
@@ -526,89 +526,8 @@
 me;%0A
-        arguments = new Object%5B0%5D;%0A        target = Target.LastResultOrRobotium;%0A
     
@@ -588,32 +588,48 @@
 .. arguments) %7B%0A
+        this();%0A
         this.nam
@@ -678,54 +678,8 @@
 ts;%0A
-        target = Target.LastResultOrRobotium;%0A
     
@@ -762,32 +762,48 @@
 .. arguments) %7B%0A
+        this();%0A
         this.nam
@@ -804,32 +804,32 @@
 is.name = name;%0A
+
         this.arg
@@ -852,59 +852,8 @@
 ts;%0A
-        this.target = Target.LastResultOrRobotium;%0A
     

clean up Command constructors a bit