Added equals
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
ea4164fbfb
commit
0e422a81ce
@ -77,7 +77,7 @@ public class ConstantString implements StringProvider {
|
|||||||
/** Create a provider for a string.
|
/** Create a provider for a string.
|
||||||
*
|
*
|
||||||
* @param string the string */
|
* @param string the string */
|
||||||
public ConstantString(String string) {
|
public ConstantString(final String string) {
|
||||||
this.string = string;
|
this.string = string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,4 +87,38 @@ public class ConstantString implements StringProvider {
|
|||||||
public String apply() {
|
public String apply() {
|
||||||
return string;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user