implement equals/hashCode/toString for SimpleConfigOrigin

This commit is contained in:
Havoc Pennington 2011-11-15 22:09:55 -05:00
parent aefdb58e04
commit 3bdaaabf02
2 changed files with 32 additions and 0 deletions

View File

@ -15,4 +15,23 @@ final class SimpleConfigOrigin implements ConfigOrigin {
return description;
}
@Override
public boolean equals(Object other) {
if (other instanceof SimpleConfigOrigin) {
return this.description
.equals(((SimpleConfigOrigin) other).description);
} else {
return false;
}
}
@Override
public int hashCode() {
return description.hashCode();
}
@Override
public String toString() {
return "ConfigOrigin(" + description + ")";
}
}

View File

@ -13,6 +13,17 @@ import com.typesafe.config.ConfigOrigin
class ConfigValueTest extends TestUtils {
@Test
def configOriginEquality() {
val a = new SimpleConfigOrigin("foo")
val sameAsA = new SimpleConfigOrigin("foo")
val b = new SimpleConfigOrigin("bar")
checkEqualObjects(a, a)
checkEqualObjects(a, sameAsA)
checkNotEqualObjects(a, b)
}
@Test
def configIntEquality() {
val a = intValue(42)
@ -152,6 +163,8 @@ class ConfigValueTest extends TestUtils {
dm.toString()
val dmo = new ConfigDelayedMergeObject(fakeOrigin(), List[AbstractConfigValue](emptyObj, subst("a"), subst("b")).asJava)
dmo.toString()
fakeOrigin().toString()
}
private def unsupported(body: => Unit) {