aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@vespa.ai>2023-10-27 12:35:13 +0200
committerBjørn Christian Seime <bjorncs@vespa.ai>2023-10-27 12:35:13 +0200
commit3e9a01e465e65e2130c6b4c4b8b7f9e490e777f1 (patch)
tree6aac818f0bc66f933274b1c646d00df4e61f87db /controller-api/src/main/java/com
parent1dd0634447a9ee626e3cad02762ab628d4dd1d6d (diff)
Split `TaxId` into type and code
Diffstat (limited to 'controller-api/src/main/java/com')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TaxId.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TaxId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TaxId.java
index bd7a9402033..99c2400c58c 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TaxId.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TaxId.java
@@ -8,14 +8,34 @@ import static ai.vespa.validation.Validation.requireLength;
/**
* @author olaa
*/
-public class TaxId extends StringWrapper<TaxId> {
+public record TaxId(Type type, Code code) {
- public TaxId(String value) {
- super(value);
- requireLength(value, "tax code length", 0, 64);
+ public TaxId(String type, String code) { this(new Type(type), new Code(code)); }
+
+ public static TaxId empty() { return new TaxId(Type.empty(), Code.empty()); }
+ public boolean isEmpty() { return type.isEmpty() && code.isEmpty(); }
+
+ // TODO(bjorncs) Remove legacy once no longer present in ZK
+ public static TaxId legacy(String code) { return new TaxId(Type.empty(), new Code(code)); }
+ public boolean isLegacy() { return type.isEmpty() && !code.isEmpty(); }
+
+ public static class Type extends StringWrapper<Type> {
+ public Type(String value) {
+ super(value);
+ requireLength(value, "tax code type length", 0, 16);
+ }
+
+ public static Type empty() { return new Type(""); }
+ public boolean isEmpty() { return value().isEmpty(); }
}
- public static TaxId empty() {
- return new TaxId("");
+ public static class Code extends StringWrapper<Code> {
+ public Code(String value) {
+ super(value);
+ requireLength(value, "tax code value length", 0, 64);
+ }
+
+ public static Code empty() { return new Code(""); }
+ public boolean isEmpty() { return value().isEmpty(); }
}
}