+++ /dev/null
-/**\r
-* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)\r
-*\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*/\r
-\r
-package org.openo.msb.wrapper.consul.model.catalog;\r
-\r
-import com.fasterxml.jackson.annotation.JsonCreator;\r
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;\r
-import com.google.common.base.MoreObjects;\r
-import com.google.common.base.Preconditions;\r
-import com.google.common.collect.ImmutableList;\r
-import com.google.common.collect.Lists;\r
-import java.util.List;\r
-import javax.annotation.Generated;\r
-\r
-/**\r
- * Immutable implementation of {@link CatalogService}.\r
- * <p>\r
- * Use the builder to create immutable instances:\r
- * {@code ImmutableCatalogService.builder()}.\r
- */\r
-@SuppressWarnings("all")\r
-@Generated({"Immutables.generator", "CatalogService"})\r
-@JsonIgnoreProperties(ignoreUnknown = true)\r
-public final class ImmutableCatalogService extends CatalogService {\r
- private final String node;\r
- private final String address;\r
- private final String serviceName;\r
- private final String serviceId;\r
- private final String serviceAddress;\r
- private final int servicePort;\r
- private final ImmutableList<String> serviceTags;\r
-\r
- private ImmutableCatalogService(\r
- String node,\r
- String address,\r
- String serviceName,\r
- String serviceId,\r
- String serviceAddress,\r
- int servicePort,\r
- ImmutableList<String> serviceTags) {\r
- this.node = node;\r
- this.address = address;\r
- this.serviceName = serviceName;\r
- this.serviceId = serviceId;\r
- this.serviceAddress = serviceAddress;\r
- this.servicePort = servicePort;\r
- this.serviceTags = serviceTags;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code node} attribute\r
- */\r
- @JsonProperty(value = "Node")\r
- @Override\r
- public String getNode() {\r
- return node;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code address} attribute\r
- */\r
- @JsonProperty(value = "Address")\r
- @Override\r
- public String getAddress() {\r
- return address;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code serviceName} attribute\r
- */\r
- @JsonProperty(value = "ServiceName")\r
- @Override\r
- public String getServiceName() {\r
- return serviceName;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code serviceId} attribute\r
- */\r
- @JsonProperty(value = "ServiceID")\r
- @Override\r
- public String getServiceId() {\r
- return serviceId;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code serviceAddress} attribute\r
- */\r
- @JsonProperty(value = "ServiceAddress")\r
- @Override\r
- public String getServiceAddress() {\r
- return serviceAddress;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code servicePort} attribute\r
- */\r
- @JsonProperty(value = "ServicePort")\r
- @Override\r
- public int getServicePort() {\r
- return servicePort;\r
- }\r
-\r
- /**\r
- * @return The value of the {@code serviceTags} attribute\r
- */\r
- @JsonProperty(value = "ServiceTags")\r
- @Override\r
- public ImmutableList<String> getServiceTags() {\r
- return serviceTags;\r
- }\r
-\r
- /**\r
- * Copy the current immutable object by setting a value for the {@link CatalogService#getNode() node} attribute.\r
- * An equals check used to prevent copying of the same value by returning {@code this}.\r
- * @param value A new value for node\r
- * @return A modified copy of the {@code this} object\r
- */\r
- public final ImmutableCatalogService withNode(String value) {\r
- if (this.node.equals(value)) return this;\r
- return new ImmutableCatalogService(\r
- Preconditions.checkNotNull(value, "node"),\r
- this.address,\r
- this.serviceName,\r
- this.serviceId,\r
- this.serviceAddress,\r
- this.servicePort,\r
- this.serviceTags);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object by setting a value for the {@link CatalogService#getAddress() address} attribute.\r
- * An equals check used to prevent copying of the same value by returning {@code this}.\r
- * @param value A new value for address\r
- * @return A modified copy of the {@code this} object\r
- */\r
- public final ImmutableCatalogService withAddress(String value) {\r
- if (this.address.equals(value)) return this;\r
- return new ImmutableCatalogService(\r
- this.node,\r
- Preconditions.checkNotNull(value, "address"),\r
- this.serviceName,\r
- this.serviceId,\r
- this.serviceAddress,\r
- this.servicePort,\r
- this.serviceTags);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object by setting a value for the {@link CatalogService#getServiceName() serviceName} attribute.\r
- * An equals check used to prevent copying of the same value by returning {@code this}.\r
- * @param value A new value for serviceName\r
- * @return A modified copy of the {@code this} object\r
- */\r
- public final ImmutableCatalogService withServiceName(String value) {\r
- if (this.serviceName.equals(value)) return this;\r
- return new ImmutableCatalogService(\r
- this.node,\r
- this.address,\r
- Preconditions.checkNotNull(value, "serviceName"),\r
- this.serviceId,\r
- this.serviceAddress,\r
- this.servicePort,\r
- this.serviceTags);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object by setting a value for the {@link CatalogService#getServiceId() serviceId} attribute.\r
- * An equals check used to prevent copying of the same value by returning {@code this}.\r
- * @param value A new value for serviceId\r
- * @return A modified copy of the {@code this} object\r
- */\r
- public final ImmutableCatalogService withServiceId(String value) {\r
- if (this.serviceId.equals(value)) return this;\r
- return new ImmutableCatalogService(\r
- this.node,\r
- this.address,\r
- this.serviceName,\r
- Preconditions.checkNotNull(value, "serviceId"),\r
- this.serviceAddress,\r
- this.servicePort,\r
- this.serviceTags);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object by setting a value for the {@link CatalogService#getServiceAddress() serviceAddress} attribute.\r
- * An equals check used to prevent copying of the same value by returning {@code this}.\r
- * @param value A new value for serviceAddress\r
- * @return A modified copy of the {@code this} object\r
- */\r
- public final ImmutableCatalogService withServiceAddress(String value) {\r
- if (this.serviceAddress.equals(value)) return this;\r
- return new ImmutableCatalogService(\r
- this.node,\r
- this.address,\r
- this.serviceName,\r
- this.serviceId,\r
- Preconditions.checkNotNull(value, "serviceAddress"),\r
- this.servicePort,\r
- this.serviceTags);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object by setting a value for the {@link CatalogService#getServicePort() servicePort} attribute.\r
- * A value equality check is used to prevent copying of the same value by returning {@code this}.\r
- * @param value A new value for servicePort\r
- * @return A modified copy of the {@code this} object\r
- */\r
- public final ImmutableCatalogService withServicePort(int value) {\r
- if (this.servicePort == value) return this;\r
- return new ImmutableCatalogService(\r
- this.node,\r
- this.address,\r
- this.serviceName,\r
- this.serviceId,\r
- this.serviceAddress,\r
- value,\r
- this.serviceTags);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object with elements that replace the content of {@link CatalogService#getServiceTags() serviceTags}.\r
- * @param elements The elements to set\r
- * @return A modified copy of {@code this} object\r
- */\r
- public final ImmutableCatalogService withServiceTags(String... elements) {\r
- ImmutableList<String> newValue = ImmutableList.copyOf(elements);\r
- return new ImmutableCatalogService(\r
- this.node,\r
- this.address,\r
- this.serviceName,\r
- this.serviceId,\r
- this.serviceAddress,\r
- this.servicePort,\r
- newValue);\r
- }\r
-\r
- /**\r
- * Copy the current immutable object with elements that replace the content of {@link CatalogService#getServiceTags() serviceTags}.\r
- * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.\r
- * @param elements An iterable of serviceTags elements to set\r
- * @return A modified copy of {@code this} object\r
- */\r
- public final ImmutableCatalogService withServiceTags(Iterable<String> elements) {\r
- if (this.serviceTags == elements) return this;\r
- ImmutableList<String> newValue = ImmutableList.copyOf(elements);\r
- return new ImmutableCatalogService(\r
- this.node,\r
- this.address,\r
- this.serviceName,\r
- this.serviceId,\r
- this.serviceAddress,\r
- this.servicePort,\r
- newValue);\r
- }\r
-\r
- /**\r
- * This instance is equal to all instances of {@code ImmutableCatalogService} that have equal attribute values.\r
- * @return {@code true} if {@code this} is equal to {@code another} instance\r
- */\r
- @Override\r
- public boolean equals(Object another) {\r
- if (this == another) return true;\r
- return another instanceof ImmutableCatalogService\r
- && equalTo((ImmutableCatalogService) another);\r
- }\r
-\r
- private boolean equalTo(ImmutableCatalogService another) {\r
- return node.equals(another.node)\r
- && address.equals(another.address)\r
- && serviceName.equals(another.serviceName)\r
- && serviceId.equals(another.serviceId)\r
- && serviceAddress.equals(another.serviceAddress)\r
- && servicePort == another.servicePort\r
- && serviceTags.equals(another.serviceTags);\r
- }\r
-\r
- /**\r
- * Computes a hash code from attributes: {@code node}, {@code address}, {@code serviceName}, {@code serviceId}, {@code serviceAddress}, {@code servicePort}, {@code serviceTags}.\r
- * @return hashCode value\r
- */\r
- @Override\r
- public int hashCode() {\r
- int h = 31;\r
- h = h * 17 + node.hashCode();\r
- h = h * 17 + address.hashCode();\r
- h = h * 17 + serviceName.hashCode();\r
- h = h * 17 + serviceId.hashCode();\r
- h = h * 17 + serviceAddress.hashCode();\r
- h = h * 17 + servicePort;\r
- h = h * 17 + serviceTags.hashCode();\r
- return h;\r
- }\r
-\r
- /**\r
- * Prints the immutable value {@code CatalogService...} with all non-generated\r
- * and non-auxiliary attribute values.\r
- * @return A string representation of the value\r
- */\r
- @Override\r
- public String toString() {\r
- return MoreObjects.toStringHelper("CatalogService")\r
- .add("node", node)\r
- .add("address", address)\r
- .add("serviceName", serviceName)\r
- .add("serviceId", serviceId)\r
- .add("serviceAddress", serviceAddress)\r
- .add("servicePort", servicePort)\r
- .add("serviceTags", serviceTags)\r
- .toString();\r
- }\r
-\r
- /**\r
- * Utility type used to correctly read immutable object from JSON representation.\r
- * @deprecated Do not use this type directly, it exists only for the <em>Jackson</em>-binding infrastructure\r
- */\r
- @Deprecated\r
- @JsonDeserialize\r
- static final class Json extends CatalogService {\r
- String node;\r
- String address;\r
- String serviceName;\r
- String serviceId;\r
- String serviceAddress;\r
- Integer servicePort;\r
- List<String> serviceTags = ImmutableList.of();\r
- @JsonProperty(value = "Node")\r
- public void setNode(String node) {\r
- this.node = node;\r
- }\r
- @JsonProperty(value = "Address")\r
- public void setAddress(String address) {\r
- this.address = address;\r
- }\r
- @JsonProperty(value = "ServiceName")\r
- public void setServiceName(String serviceName) {\r
- this.serviceName = serviceName;\r
- }\r
- @JsonProperty(value = "ServiceID")\r
- public void setServiceId(String serviceId) {\r
- this.serviceId = serviceId;\r
- }\r
- @JsonProperty(value = "ServiceAddress")\r
- public void setServiceAddress(String serviceAddress) {\r
- this.serviceAddress = serviceAddress;\r
- }\r
- @JsonProperty(value = "ServicePort")\r
- public void setServicePort(int servicePort) {\r
- this.servicePort = servicePort;\r
- }\r
- @JsonProperty(value = "ServiceTags")\r
- public void setServiceTags(List<String> serviceTags) {\r
- this.serviceTags = serviceTags;\r
- }\r
- @Override\r
- public String getNode() { throw new UnsupportedOperationException(); }\r
- @Override\r
- public String getAddress() { throw new UnsupportedOperationException(); }\r
- @Override\r
- public String getServiceName() { throw new UnsupportedOperationException(); }\r
- @Override\r
- public String getServiceId() { throw new UnsupportedOperationException(); }\r
- @Override\r
- public String getServiceAddress() { throw new UnsupportedOperationException(); }\r
- @Override\r
- public int getServicePort() { throw new UnsupportedOperationException(); }\r
- @Override\r
- public List<String> getServiceTags() { throw new UnsupportedOperationException(); }\r
- }\r
-\r
- /**\r
- * @param json A JSON-bindable data structure\r
- * @return An immutable value type\r
- * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure\r
- */\r
- @Deprecated\r
- @JsonCreator\r
- static ImmutableCatalogService fromJson(Json json) {\r
- ImmutableCatalogService.Builder builder = ImmutableCatalogService.builder();\r
- if (json.node != null) {\r
- builder.node(json.node);\r
- }\r
- if (json.address != null) {\r
- builder.address(json.address);\r
- }\r
- if (json.serviceName != null) {\r
- builder.serviceName(json.serviceName);\r
- }\r
- if (json.serviceId != null) {\r
- builder.serviceId(json.serviceId);\r
- }\r
- if (json.serviceAddress != null) {\r
- builder.serviceAddress(json.serviceAddress);\r
- }\r
- if (json.servicePort != null) {\r
- builder.servicePort(json.servicePort);\r
- }\r
- if (json.serviceTags != null) {\r
- builder.addAllServiceTags(json.serviceTags);\r
- }\r
- return builder.build();\r
- }\r
-\r
- /**\r
- * Creates an immutable copy of a {@link CatalogService} value.\r
- * Uses accessors to get values to initialize the new immutable instance.\r
- * If an instance is already immutable, it is returned as is.\r
- * @param instance The instance to copy\r
- * @return A copied immutable CatalogService instance\r
- */\r
- public static ImmutableCatalogService copyOf(CatalogService instance) {\r
- if (instance instanceof ImmutableCatalogService) {\r
- return (ImmutableCatalogService) instance;\r
- }\r
- return ImmutableCatalogService.builder()\r
- .from(instance)\r
- .build();\r
- }\r
-\r
- /**\r
- * Creates a builder for {@link ImmutableCatalogService ImmutableCatalogService}.\r
- * @return A new ImmutableCatalogService builder\r
- */\r
- public static ImmutableCatalogService.Builder builder() {\r
- return new ImmutableCatalogService.Builder();\r
- }\r
-\r
- /**\r
- * Builds instances of type {@link ImmutableCatalogService ImmutableCatalogService}.\r
- * Initialize attributes and then invoke the {@link #build()} method to create an\r
- * immutable instance.\r
- * <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection,\r
- * but instead used immediately to create instances.</em>\r
- */\r
- public static final class Builder {\r
- private static final long INIT_BIT_NODE = 0x1L;\r
- private static final long INIT_BIT_ADDRESS = 0x2L;\r
- private static final long INIT_BIT_SERVICE_NAME = 0x4L;\r
- private static final long INIT_BIT_SERVICE_ID = 0x8L;\r
- private static final long INIT_BIT_SERVICE_ADDRESS = 0x10L;\r
- private static final long INIT_BIT_SERVICE_PORT = 0x20L;\r
- private long initBits = 0x3f;\r
-\r
- private String node;\r
- private String address;\r
- private String serviceName;\r
- private String serviceId;\r
- private String serviceAddress;\r
- private int servicePort;\r
- private ImmutableList.Builder<String> serviceTagsBuilder = ImmutableList.builder();\r
-\r
- private Builder() {\r
- }\r
-\r
- /**\r
- * Fill a builder with attribute values from the provided {@code CatalogService} instance.\r
- * Regular attribute values will be replaced with those from the given instance.\r
- * Absent optional values will not replace present values.\r
- * Collection elements and entries will be added, not replaced.\r
- * @param instance The instance from which to copy values\r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder from(CatalogService instance) {\r
- Preconditions.checkNotNull(instance, "instance");\r
- node(instance.getNode());\r
- address(instance.getAddress());\r
- serviceName(instance.getServiceName());\r
- serviceId(instance.getServiceId());\r
- serviceAddress(instance.getServiceAddress());\r
- servicePort(instance.getServicePort());\r
- addAllServiceTags(instance.getServiceTags());\r
- return this;\r
- }\r
-\r
- /**\r
- * Initializes the value for the {@link CatalogService#getNode() node} attribute.\r
- * @param node The value for node \r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder node(String node) {\r
- this.node = Preconditions.checkNotNull(node, "node");\r
- initBits &= ~INIT_BIT_NODE;\r
- return this;\r
- }\r
-\r
- /**\r
- * Initializes the value for the {@link CatalogService#getAddress() address} attribute.\r
- * @param address The value for address \r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder address(String address) {\r
- this.address = Preconditions.checkNotNull(address, "address");\r
- initBits &= ~INIT_BIT_ADDRESS;\r
- return this;\r
- }\r
-\r
- /**\r
- * Initializes the value for the {@link CatalogService#getServiceName() serviceName} attribute.\r
- * @param serviceName The value for serviceName \r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder serviceName(String serviceName) {\r
- this.serviceName = Preconditions.checkNotNull(serviceName, "serviceName");\r
- initBits &= ~INIT_BIT_SERVICE_NAME;\r
- return this;\r
- }\r
-\r
- /**\r
- * Initializes the value for the {@link CatalogService#getServiceId() serviceId} attribute.\r
- * @param serviceId The value for serviceId \r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder serviceId(String serviceId) {\r
- this.serviceId = Preconditions.checkNotNull(serviceId, "serviceId");\r
- initBits &= ~INIT_BIT_SERVICE_ID;\r
- return this;\r
- }\r
-\r
- /**\r
- * Initializes the value for the {@link CatalogService#getServiceAddress() serviceAddress} attribute.\r
- * @param serviceAddress The value for serviceAddress \r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder serviceAddress(String serviceAddress) {\r
- this.serviceAddress = Preconditions.checkNotNull(serviceAddress, "serviceAddress");\r
- initBits &= ~INIT_BIT_SERVICE_ADDRESS;\r
- return this;\r
- }\r
-\r
- /**\r
- * Initializes the value for the {@link CatalogService#getServicePort() servicePort} attribute.\r
- * @param servicePort The value for servicePort \r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder servicePort(int servicePort) {\r
- this.servicePort = servicePort;\r
- initBits &= ~INIT_BIT_SERVICE_PORT;\r
- return this;\r
- }\r
-\r
- /**\r
- * Adds one element to {@link CatalogService#getServiceTags() serviceTags} list.\r
- * @param element A serviceTags element\r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder addServiceTags(String element) {\r
- serviceTagsBuilder.add(element);\r
- return this;\r
- }\r
-\r
- /**\r
- * Adds elements to {@link CatalogService#getServiceTags() serviceTags} list.\r
- * @param elements An array of serviceTags elements\r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder addServiceTags(String... elements) {\r
- serviceTagsBuilder.add(elements);\r
- return this;\r
- }\r
-\r
- /**\r
- * Sets or replaces all elements for {@link CatalogService#getServiceTags() serviceTags} list.\r
- * @param elements An iterable of serviceTags elements\r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder serviceTags(Iterable<String> elements) {\r
- serviceTagsBuilder = ImmutableList.builder();\r
- return addAllServiceTags(elements);\r
- }\r
-\r
- /**\r
- * Adds elements to {@link CatalogService#getServiceTags() serviceTags} list.\r
- * @param elements An iterable of serviceTags elements\r
- * @return {@code this} builder for use in a chained invocation\r
- */\r
- public final Builder addAllServiceTags(Iterable<String> elements) {\r
- serviceTagsBuilder.addAll(elements);\r
- return this;\r
- }\r
-\r
- /**\r
- * Builds a new {@link ImmutableCatalogService ImmutableCatalogService}.\r
- * @return An immutable instance of CatalogService\r
- * @throws java.lang.IllegalStateException if any required attributes are missing\r
- */\r
- public ImmutableCatalogService build() throws IllegalStateException {\r
- if (initBits != 0) {\r
- throw new IllegalStateException(formatRequiredAttributesMessage());\r
- }\r
- return new ImmutableCatalogService(\r
- node,\r
- address,\r
- serviceName,\r
- serviceId,\r
- serviceAddress,\r
- servicePort,\r
- serviceTagsBuilder.build());\r
- }\r
-\r
- private String formatRequiredAttributesMessage() {\r
- List<String> attributes = Lists.newArrayList();\r
- if ((initBits & INIT_BIT_NODE) != 0) attributes.add("node");\r
- if ((initBits & INIT_BIT_ADDRESS) != 0) attributes.add("address");\r
- if ((initBits & INIT_BIT_SERVICE_NAME) != 0) attributes.add("serviceName");\r
- if ((initBits & INIT_BIT_SERVICE_ID) != 0) attributes.add("serviceId");\r
- if ((initBits & INIT_BIT_SERVICE_ADDRESS) != 0) attributes.add("serviceAddress");\r
- if ((initBits & INIT_BIT_SERVICE_PORT) != 0) attributes.add("servicePort");\r
- return "Cannot build CatalogService, some of required attributes are not set " + attributes;\r
- }\r
- }\r
-}\r