Skip to content

Commit

Permalink
Merge pull request #29371 from vespa-engine/hakonhall/add-links-to-co…
Browse files Browse the repository at this point in the history
…re-dump-tickets

Methods to get InfrastructureApplication and NodeType from names
  • Loading branch information
hakonhall authored Nov 21, 2023
2 parents 8f9be37 + 885d166 commit ccc4d65
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.yahoo.config.provision.NodeType;

import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -37,6 +38,16 @@ public static InfrastructureApplication withNodeType(NodeType nodeType) {
.orElseThrow(() -> new IllegalArgumentException("No application associated with " + nodeType));
}

public static Optional<InfrastructureApplication> ofOptional(ApplicationId applicationId) {
for (var application : values()) {
if (application.id.equals(applicationId)) {
return Optional.of(application);
}
}

return Optional.empty();
}

InfrastructureApplication(String name, NodeType nodeType) {
this.id = ApplicationId.from(TenantId.HOSTED_VESPA.value(), name, "default");
this.nodeType = nodeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package com.yahoo.config.provision;

import java.util.List;
import java.util.Optional;

/**
* The possible types of nodes in the node repository
Expand Down Expand Up @@ -37,6 +38,13 @@ public enum NodeType {
private final String description;
private final List<NodeType> childNodeTypes;

public static Optional<NodeType> ofOptional(String name) {
for (var type : values()) {
if (type.name().equals(name)) return Optional.of(type);
}
return Optional.empty();
}

NodeType(String description, NodeType... childNodeTypes) {
this.childNodeTypes = List.of(childNodeTypes);
this.description = description;
Expand Down

0 comments on commit ccc4d65

Please sign in to comment.