aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeType.java12
1 files changed, 10 insertions, 2 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 25ec7485c24..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
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
import java.util.List;
@@ -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");
}
}