mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
implement equals/hashCode/toString for SimpleConfigOrigin
This commit is contained in:
parent
aefdb58e04
commit
3bdaaabf02
@ -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 + ")";
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user