Add ApplicationId to NodeIdentity
// 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.security;
+import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeType;
@@ -17,11 +18,13 @@ public class NodeIdentity {
private final NodeType nodeType;
private final String identityName;
private final HostName hostname;
+ private final ApplicationId applicationId;
- private NodeIdentity(NodeType nodeType, String identityName, HostName hostname) {
+ private NodeIdentity(NodeType nodeType, String identityName, HostName hostname, ApplicationId applicationId) {
this.nodeType = nodeType;
this.identityName = identityName;
this.hostname = hostname;
+ this.applicationId = applicationId;
}
public NodeType nodeType() {
@@ -37,6 +40,10 @@ public class NodeIdentity {
return Optional.ofNullable(hostname);
}
+ public Optional<ApplicationId> applicationId() {
+ return Optional.ofNullable(applicationId);
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -44,12 +51,13 @@ public class NodeIdentity {
NodeIdentity that = (NodeIdentity) o;
return nodeType == that.nodeType &&
Objects.equals(identityName, that.identityName) &&
- Objects.equals(hostname, that.hostname);
+ Objects.equals(hostname, that.hostname) &&
+ Objects.equals(applicationId, that.applicationId);
}
@Override
public int hashCode() {
- return Objects.hash(nodeType, identityName, hostname);
+ return Objects.hash(nodeType, identityName, hostname, applicationId);
}
@Override
@@ -58,6 +66,7 @@ public class NodeIdentity {
"nodeType=" + nodeType +
", identityName='" + identityName + '\'' +
", hostname=" + hostname +
+ ", applicationId=" + applicationId +
'}';
}
@@ -65,6 +74,7 @@ public class NodeIdentity {
private final NodeType nodeType;
private String identityName;
private HostName hostname;
+ private ApplicationId applicationId;
public Builder(NodeType nodeType) {
this.nodeType = nodeType;
@@ -80,8 +90,13 @@ public class NodeIdentity {
return this;
}
+ public Builder applicationId(ApplicationId applicationId) {
+ this.applicationId = applicationId;
+ return this;
+ }
+
public NodeIdentity build() {
- return new NodeIdentity(nodeType, identityName, hostname);
+ return new NodeIdentity(nodeType, identityName, hostname, applicationId);
}
}
}
