package net.ttddyy.dsproxy.proxy;

/**
 * @author Tadaya Tsuyukubo
 * @since 1.4
 */
public class ParameterKey {

    public enum ParameterKeyType {
        BY_INDEX, BY_NAME
    }

    private int index;
    private String name;
    private ParameterKeyType type;

    public ParameterKey(int index) {
        this.index = index;
        this.type = ParameterKeyType.BY_INDEX;
    }

    public ParameterKey(String name) {
        this.name = name;
        this.type = ParameterKeyType.BY_NAME;
    }

    public int getIndex() {
        return index;
    }

    public String getName() {
        return name;
    }

    public ParameterKeyType getType() {
        return type;
    }

    public boolean isByIndex() {
        return this.type == ParameterKeyType.BY_INDEX;
    }

    public boolean isByName() {
        return this.type == ParameterKeyType.BY_NAME;
    }

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

        ParameterKey that = (ParameterKey) o;

        if (index != that.index) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        return type == that.type;

    }

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

    @Override
    public String toString() {
        return "ParameterKey[" +
                "type=" + type +
                ", index=" + index +
                ", name='" + name + '\'' +
                ']';
    }
}

@@ -103,16 +103,52 @@
 meterKey
+ implements Comparable%3CParameterKey%3E
  %7B%0A%0A    
@@ -895,32 +895,314 @@
 BY_NAME;%0A    %7D%0A%0A
+    public String getKeyAsString() %7B%0A        return this.type == ParameterKeyType.BY_INDEX ? Integer.toString(this.index) : this.name;%0A    %7D%0A%0A    @Override%0A    public int compareTo(ParameterKey other) %7B%0A        return this.getKeyAsString().compareTo(other.getKeyAsString());%0A    %7D%0A%0A
     @Override%0A  

make ParameterKey implement Comparable<ParameterKey>