diff options
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java index 266ede04800..0eac568ec45 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java @@ -88,6 +88,14 @@ public enum NodeType { return childNodeTypes.contains(type); } + /** Returns the parent host type. */ + public NodeType parentNodeType() { + for (var type : values()) { + if (type.childNodeTypes.contains(this)) return type; + } + throw new IllegalStateException(this + " has no parent"); + } + /** Returns the host type of this */ public NodeType hostType() { if (isHost()) return this; @@ -97,7 +105,7 @@ public enum NodeType { return nodeType; } } - throw new IllegalArgumentException("No host of " + this + " exists"); + throw new IllegalStateException("No host of " + this + " exists"); } } |