Implemented equals for CommandContext and ParsedArgument
This commit is contained in:
@@ -38,4 +38,26 @@ public class CommandContext<T> {
|
||||
throw new IllegalArgumentException("Argument '" + name + "' is defined as " + argument.getResult().getClass().getSimpleName() + ", not " + clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof CommandContext)) return false;
|
||||
|
||||
CommandContext that = (CommandContext) o;
|
||||
|
||||
if (!arguments.equals(that.arguments)) return false;
|
||||
if (command != null ? !command.equals(that.command) : that.command != null) return false;
|
||||
if (!source.equals(that.source)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = source.hashCode();
|
||||
result = 31 * result + arguments.hashCode();
|
||||
result = 31 * result + (command != null ? command.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,24 @@ public class ParsedArgument<T> {
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ParsedArgument)) return false;
|
||||
|
||||
ParsedArgument that = (ParsedArgument) o;
|
||||
|
||||
if (!raw.equals(that.raw)) return false;
|
||||
if (!result.equals(that.result)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result1 = raw.hashCode();
|
||||
result1 = 31 * result1 + result.hashCode();
|
||||
return result1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user