diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-02-07 14:24:12 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-02-07 14:25:06 +0100 |
commit | d701848461f719eba635917199725b3b228fa7bc (patch) | |
tree | e606eecca3707b80e1349af1e0d18c615e66986a /controller-server | |
parent | aecea8e8755fd6d367a6d7df57b341314a583864 (diff) |
Convert to records
Diffstat (limited to 'controller-server')
2 files changed, 26 insertions, 69 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java index 8a6243a7224..5e36d6d6499 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java @@ -9,32 +9,13 @@ import java.util.Objects; * * @author enygaard */ -public class FormattedNotification { - private final String prettyType; - private final String messagePrefix; - private final URI uri; - private final Notification notification; +public record FormattedNotification(Notification notification, String prettyType, String messagePrefix, URI uri) { - public FormattedNotification(Notification notification, String prettyType, String messagePrefix, URI uri) { - this.prettyType = Objects.requireNonNull(prettyType); - this.messagePrefix = Objects.requireNonNull(messagePrefix); - this.uri = Objects.requireNonNull(uri); - this.notification = Objects.requireNonNull(notification); + public FormattedNotification { + Objects.requireNonNull(prettyType); + Objects.requireNonNull(messagePrefix); + Objects.requireNonNull(uri); + Objects.requireNonNull(notification); } - public String prettyType() { - return prettyType; - } - - public String messagePrefix() { - return messagePrefix; - } - - public URI uri() { - return uri; - } - - public Notification notification() { - return notification; - } -}
\ No newline at end of file +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java index da423995b7e..53450783c8e 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java @@ -13,12 +13,7 @@ import java.util.Objects; * * @author freva */ -public class Notification { - private final Instant at; - private final Type type; - private final Level level; - private final NotificationSource source; - private final List<String> messages; +public record Notification(Instant at, com.yahoo.vespa.hosted.controller.notification.Notification.Type type, com.yahoo.vespa.hosted.controller.notification.Notification.Level level, NotificationSource source, List<String> messages) { public Notification(Instant at, Type type, Level level, NotificationSource source, List<String> messages) { this.at = Objects.requireNonNull(at, "at cannot be null"); @@ -29,37 +24,6 @@ public class Notification { if (messages.size() < 1) throw new IllegalArgumentException("messages cannot be empty"); } - public Instant at() { return at; } - public Type type() { return type; } - public Level level() { return level; } - public NotificationSource source() { return source; } - public List<String> messages() { return messages; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Notification that = (Notification) o; - return at.equals(that.at) && type == that.type && level == that.level && - source.equals(that.source) && messages.equals(that.messages); - } - - @Override - public int hashCode() { - return Objects.hash(at, type, level, source, messages); - } - - @Override - public String toString() { - return "Notification{" + - "at=" + at + - ", type=" + type + - ", level=" + level + - ", source=" + source + - ", messages=" + messages + - '}'; - } - public enum Level { // Must be ordered in order of importance info, warning, error @@ -67,22 +31,34 @@ public class Notification { public enum Type { - /** Related to contents of application package, e.g., usage of deprecated features/syntax */ + /** + * Related to contents of application package, e.g., usage of deprecated features/syntax + */ applicationPackage, - /** Related to contents of application package detectable by the controller on submission */ + /** + * Related to contents of application package detectable by the controller on submission + */ submission, - /** Related to contents of application test package, e.g., mismatch between deployment spec and provided tests */ + /** + * Related to contents of application test package, e.g., mismatch between deployment spec and provided tests + */ testPackage, - /** Related to deployment of application, e.g., system test failure, node allocation failure, internal errors, etc. */ + /** + * Related to deployment of application, e.g., system test failure, node allocation failure, internal errors, etc. + */ deployment, - /** Application cluster is (near) external feed blocked */ + /** + * Application cluster is (near) external feed blocked + */ feedBlock, - /** Application cluster is reindexing document(s) */ + /** + * Application cluster is reindexing document(s) + */ reindex } |