diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-02-04 09:29:37 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-02-04 09:29:37 +0100 |
commit | 143348b1f6fe210ec8a3a0d22eb07cac56a07825 (patch) | |
tree | 22aca47129d3b90fa3bf46c7edf82114c7ce037d /config-provisioning | |
parent | d810c82e9c3a8f57f53d6ba9ed0ea7cb51b77d75 (diff) |
Add support for rotations element
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/RotationName.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/RotationName.java b/config-provisioning/src/main/java/com/yahoo/config/provision/RotationName.java new file mode 100644 index 00000000000..5d9ac3699b3 --- /dev/null +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/RotationName.java @@ -0,0 +1,57 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.provision; + +import java.util.Objects; + +/** + * Represents a rotation name for a container cluster. Typically created from the rotation element in services.xml. + * + * @author mpolden + */ +public class RotationName implements Comparable<RotationName> { + + private final String name; + + private RotationName(String name) { + this.name = requireNonBlank(name, "name must be non-empty"); + } + + public String value() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RotationName that = (RotationName) o; + return name.equals(that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public int compareTo(RotationName o) { + return name.compareTo(o.name); + } + + @Override + public String toString() { + return "rotation '" + name + "'"; + } + + public static RotationName from(String name) { + return new RotationName(name); + } + + private static String requireNonBlank(String s, String message) { + if (s == null || s.isBlank()) { + throw new IllegalArgumentException(message); + } + return s; + } + +} |