live.document.mavenplugin.rootmethod.RootMethodOperator Maven / Gradle / Ivy
package live.document.mavenplugin.rootmethod;
public class RootMethodOperator implements Comparable {
private String name;
private String operator;
public RootMethodOperator(String name, String operator) {
this.name = name;
this.operator = operator;
}
public String getName() {
return name;
}
public String getOperator() {
return operator;
}
public RootMethodOperator combine(RootMethodOperator another) {
if (another == null) {
return this;
}
if ("W".equalsIgnoreCase(operator)) {
return this;
}
if (name != null && name.equals(another.name)) {
if ("W".equalsIgnoreCase(another.operator)) {
this.operator = "W";
}
}
return this;
}
@Override
public int compareTo(RootMethodOperator o) {
if (o == null) {
return 1;
}
return this.name.compareTo(o.name);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RootMethodOperator that = (RootMethodOperator) o;
if (!name.equals(that.name)) return false;
return operator.equals(that.operator);
}
@Override
public int hashCode() {
int result = name.hashCode();
result = 31 * result + operator.hashCode();
return result;
}
@Override
public String toString() {
return name;
}
public String getClassName() {
int i = name.lastIndexOf(".");
if (i > 0) {
return name.substring(0, i);
} else {
return name;
}
}
}