aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/flag/FlagId.java
blob: 1b798c14588270f7a335ada3f3c6bd81570725f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.flag;

import java.util.Arrays;

/**
 * Features of this node repository that can be toggled.
 *
 * @author mpolden
 */
public enum FlagId {

    /** Indicates whether a exclusive load balancer should be provisioned */
    exclusiveLoadBalancer("exclusive-load-balancer");

    private final String serializedValue;

    FlagId(String serializedValue) {
        this.serializedValue = serializedValue;
    }

    public String serializedValue() {
        return serializedValue;
    }

    public static FlagId fromSerializedForm(String value) {
        return Arrays.stream(FlagId.values())
                     .filter(f -> f.serializedValue().equals(value))
                     .findFirst()
                     .orElseThrow(() -> new IllegalArgumentException("Could not find flag ID by serialized value '" +
                                                                     value + "'"));
    }

}