Override equals(), hashCode() and toString() in DefaultRequest and DefaultRequestContext.
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.cloud.client.loadbalancer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* A default implementation of {@link Request}.
|
||||
*
|
||||
@@ -43,4 +47,28 @@ public class DefaultRequest<T> implements Request<T> {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringCreator to = new ToStringCreator(this);
|
||||
to.append("context", context);
|
||||
return to.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof DefaultRequest)) {
|
||||
return false;
|
||||
}
|
||||
DefaultRequest<?> that = (DefaultRequest<?>) o;
|
||||
return Objects.equals(context, that.context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.cloud.client.loadbalancer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* Contains information relevant to the request.
|
||||
*
|
||||
@@ -44,4 +48,28 @@ public class DefaultRequestContext {
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringCreator to = new ToStringCreator(this);
|
||||
to.append("hint", hint);
|
||||
return to.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof DefaultRequestContext)) {
|
||||
return false;
|
||||
}
|
||||
DefaultRequestContext that = (DefaultRequestContext) o;
|
||||
return Objects.equals(hint, that.hint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(hint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user