All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pocketknife.internal.codegen.KeySpec Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package pocketknife.internal.codegen;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public class KeySpec implements Comparable {
    private String name;
    private String value;

    public KeySpec(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        KeySpec keySpec = (KeySpec) o;

        return new EqualsBuilder()
                .append(name, keySpec.name)
                .append(value, keySpec.value)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(name)
                .append(value)
                .toHashCode();
    }

    @Override
    public int compareTo(KeySpec o) {
        int i;
        if (name == null) {
            if (o.name != null) {
                i = -1;
            } else {
                i = 0;
            }
        } else if (o.name == null) {
            i = 1;
        } else {
            i = name.compareTo(o.name);
        }
        if (i == 0) {
            return value.compareTo(o.value);
        }
        return i;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy