Consider non-existent AttributeContainers empty

Given the prior faulty logic, no tree of `HierarchyAttributeContainer`s would ever report itself as empty (not even a 'tree' consisting of a single, attribute-less/empty HierarchyAttributeContainer), since every tree will have a root, which will lack a parent, and it considered the lack of existence of a parent to mean that that root container is not empty.
This commit is contained in:
Corey
2018-11-29 11:22:21 -05:00
committed by Sergey Igushkin
parent 8cec50e6e2
commit ae7cc8a133
@@ -30,7 +30,7 @@ class HierarchyAttributeContainer(val parent: AttributeContainer?) : AttributeCo
override fun <T : Any?> getAttribute(key: Attribute<T>?): T? =
attributesMap.get(key as Attribute<*>) as T? ?: parent?.getAttribute(key)
override fun isEmpty(): Boolean = attributesMap.isEmpty() && parent?.isEmpty ?: false
override fun isEmpty(): Boolean = attributesMap.isEmpty() && (parent?.isEmpty ?: true)
override fun keySet(): Set<Attribute<*>> = attributesMap.keys + parent?.keySet().orEmpty()
@@ -41,4 +41,4 @@ class HierarchyAttributeContainer(val parent: AttributeContainer?) : AttributeCo
}
override fun getAttributes(): AttributeContainer = this
}
}