Added equals

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2018-10-27 14:01:53 -04:00
parent ea4164fbfb
commit 0e422a81ce

View File

@ -77,7 +77,7 @@ public class ConstantString implements StringProvider {
/** Create a provider for a string.
*
* @param string the string */
public ConstantString(String string) {
public ConstantString(final String string) {
this.string = string;
}
@ -87,4 +87,38 @@ public class ConstantString implements StringProvider {
public String apply() {
return string;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode() */
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((string == null) ? 0 : string.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object) */
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ConstantString other = (ConstantString) obj;
if (string == null) {
if (other.string != null) {
return false;
}
} else if (!string.equals(other.string)) {
return false;
}
return true;
}
}