aboutsummaryrefslogtreecommitdiffstats
path: root/config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java
Publish
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java')
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java87
1 files changed, 87 insertions, 0 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java
new file mode 100644
index 00000000000..6d72da7df6f
--- /dev/null
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ServiceInfo.java
@@ -0,0 +1,87 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.config.model.api;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Collection;
+
+/**
+ * Contains information about a service.
+ *
+ * @author lulf
+ * @since 5.37
+ */
+public class ServiceInfo {
+ private final String serviceName;
+ private final String serviceType;
+ private final Collection<PortInfo> ports;
+ private final Map<String, String> properties;
+ private final String configId;
+ private final String hostName;
+
+ public ServiceInfo(String serviceName, String serviceType, Collection<PortInfo> ports, Map<String, String> properties,
+ String configId, String hostName) {
+
+ Objects.requireNonNull(configId);
+
+ this.serviceName = serviceName;
+ this.serviceType = serviceType;
+ this.ports = ports;
+ this.properties = properties;
+ this.configId = configId;
+ this.hostName = hostName;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getConfigId() {
+ return configId;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public Optional<String> getProperty(String propertyName) {
+ return Optional.ofNullable(properties.get(propertyName));
+ }
+
+ public Collection<PortInfo> getPorts() {
+ return ports;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ServiceInfo that = (ServiceInfo) o;
+
+ if (ports != null ? !ports.equals(that.ports) : that.ports != null) return false;
+ if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
+ if (!serviceName.equals(that.serviceName)) return false;
+ if (!serviceType.equals(that.serviceType)) return false;
+ if (!configId.equals(that.configId)) return false;
+ if (!hostName.equals(that.hostName)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = serviceName.hashCode();
+ result = 31 * result + serviceType.hashCode();
+ result = 31 * result + (ports != null ? ports.hashCode() : 0);
+ result = 31 * result + (properties != null ? properties.hashCode() : 0);
+ result = 31 * result + configId.hashCode();
+ result = 31 * result + hostName.hashCode();
+ return result;
+ }
+}