Here is my solution. It's cleaned up a bit and uses subtypes. I think that this is probably the most straightforward way to do this.
trait RegionUpperBound
trait CountyUpperBound extends RegionUpperBound
trait DistrictUpperBound extends CountyUpperBound
trait TownUpperBound extends...
Here's one somewhat verbose solution I've found. Basically, the relationships of "administers" and "administeredBy" are captured in traits and then each type of organization incorporates the applicable traits. (This is Scala.) It's wordy, but it does ensure that only the correct relationships...
I have a set of objects that represent different levels in a hierarchical organizational structure, in this instance a statewide school system.
At the bottom of the hierarchy is the school. It is administered by a town, which is administered by a disctrict, and so forth, like this:
State...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.