diff options
Diffstat (limited to 'msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model')
11 files changed, 0 insertions, 2153 deletions
diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/ConsulResponse.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/ConsulResponse.java deleted file mode 100644 index b19f37c..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/ConsulResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.openo.msb.wrapper.consul.model; - -import com.google.common.base.Objects; - -import java.math.BigInteger; - -public class ConsulResponse<T> { - - private final T response; - private final long lastContact; - private final boolean knownLeader; - private final BigInteger index; - - public ConsulResponse(T response, long lastContact, boolean knownLeader, BigInteger index) { - this.response = response; - this.lastContact = lastContact; - this.knownLeader = knownLeader; - this.index = index; - } - - public T getResponse() { - return response; - } - - public long getLastContact() { - return lastContact; - } - - public boolean isKnownLeader() { - return knownLeader; - } - - public BigInteger getIndex() { - return index; - } - - @Override - public String toString() { - return "ConsulResponse{" + - "response=" + response + - ", lastContact=" + lastContact + - ", knownLeader=" + knownLeader + - ", index=" + index + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConsulResponse that = (ConsulResponse) o; - - return Objects.equal(this.response, that.response) && - Objects.equal(this.lastContact, that.lastContact) && - Objects.equal(this.knownLeader, that.knownLeader) && - Objects.equal(this.index, that.index); - } - - @Override - public int hashCode() { - return Objects.hashCode(response, lastContact, knownLeader, index); - } -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/CatalogNode.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/CatalogNode.java deleted file mode 100644 index 5ffc97b..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/CatalogNode.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.openo.msb.wrapper.consul.model.catalog; - -import java.util.Map; - -import org.openo.msb.wrapper.consul.model.health.Node; -import org.openo.msb.wrapper.consul.model.health.Service; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - - -@JsonSerialize(as = ImmutableCatalogNode.class) -@JsonDeserialize(as = ImmutableCatalogNode.class) -@JsonIgnoreProperties(ignoreUnknown = true) -public abstract class CatalogNode { - - @JsonProperty("Node") - public abstract Node getNode(); - - @JsonProperty("Services") - public abstract Map<String, Service> getServices(); - -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/CatalogService.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/CatalogService.java deleted file mode 100644 index 9d62f02..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/CatalogService.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.openo.msb.wrapper.consul.model.catalog; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - - -@JsonSerialize(as = ImmutableCatalogService.class) -@JsonDeserialize(as = ImmutableCatalogService.class) -@JsonIgnoreProperties(ignoreUnknown = true) -public abstract class CatalogService { - - @JsonProperty("Node") - public abstract String getNode(); - - @JsonProperty("Address") - public abstract String getAddress(); - - @JsonProperty("ServiceName") - public abstract String getServiceName(); - - @JsonProperty("ServiceID") - public abstract String getServiceId(); - - @JsonProperty("ServiceAddress") - public abstract String getServiceAddress(); - - @JsonProperty("ServicePort") - public abstract int getServicePort(); - - @JsonProperty("ServiceTags") - public abstract List<String> getServiceTags(); -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ImmutableCatalogNode.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ImmutableCatalogNode.java deleted file mode 100644 index 18830d5..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ImmutableCatalogNode.java +++ /dev/null @@ -1,305 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openo.msb.wrapper.consul.model.catalog; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; - -import java.util.List; -import java.util.Map; - -import javax.annotation.Generated; - -import org.openo.msb.wrapper.consul.model.health.Node; -import org.openo.msb.wrapper.consul.model.health.Service; - -/** - * Immutable implementation of {@link CatalogNode}. - * <p> - * Use the builder to create immutable instances: - * {@code ImmutableCatalogNode.builder()}. - */ -@SuppressWarnings("all") -@Generated({"Immutables.generator", "CatalogNode"}) -@JsonIgnoreProperties(ignoreUnknown = true) -public final class ImmutableCatalogNode extends CatalogNode { - private final Node node; - private final ImmutableMap<String, Service> services; - - private ImmutableCatalogNode( - Node node, - ImmutableMap<String, Service> services) { - this.node = node; - this.services = services; - } - - /** - * @return The value of the {@code node} attribute - */ - @JsonProperty(value = "Node") - @Override - public Node getNode() { - return node; - } - - /** - * @return The value of the {@code services} attribute - */ - @JsonProperty(value = "Services") - @Override - public ImmutableMap<String, Service> getServices() { - return services; - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogNode#getNode() node} attribute. - * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. - * @param value A new value for node - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogNode withNode(Node value) { - if (this.node == value) return this; - return new ImmutableCatalogNode(Preconditions.checkNotNull(value, "node"), this.services); - } - - /** - * Copy the current immutable object by replacing the {@link CatalogNode#getServices() services} map with the specified map. - * Nulls are not permitted as keys or values. - * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. - * @param entries The entries to be added to the services map - * @return A modified copy of {@code this} object - */ - public final ImmutableCatalogNode withServices(Map<String, ? extends Service> entries) { - if (this.services == entries) return this; - ImmutableMap<String, Service> value = ImmutableMap.copyOf(entries); - return new ImmutableCatalogNode(this.node, value); - } - - /** - * This instance is equal to all instances of {@code ImmutableCatalogNode} that have equal attribute values. - * @return {@code true} if {@code this} is equal to {@code another} instance - */ - @Override - public boolean equals(Object another) { - if (this == another) return true; - return another instanceof ImmutableCatalogNode - && equalTo((ImmutableCatalogNode) another); - } - - private boolean equalTo(ImmutableCatalogNode another) { - return node.equals(another.node) - && services.equals(another.services); - } - - /** - * Computes a hash code from attributes: {@code node}, {@code services}. - * @return hashCode value - */ - @Override - public int hashCode() { - int h = 31; - h = h * 17 + node.hashCode(); - h = h * 17 + services.hashCode(); - return h; - } - - /** - * Prints the immutable value {@code CatalogNode...} with all non-generated - * and non-auxiliary attribute values. - * @return A string representation of the value - */ - @Override - public String toString() { - return MoreObjects.toStringHelper("CatalogNode") - .add("node", node) - .add("services", services) - .toString(); - } - - /** - * Utility type used to correctly read immutable object from JSON representation. - * @deprecated Do not use this type directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonDeserialize - static final class Json extends CatalogNode { - Node node; - Map<String, Service> services; - @JsonProperty(value = "Node") - public void setNode(Node node) { - this.node = node; - } - @JsonProperty(value = "Services") - public void setServices(Map<String, Service> services) { - this.services = services; - } - @Override - public Node getNode() { throw new UnsupportedOperationException(); } - @Override - public Map<String, Service> getServices() { throw new UnsupportedOperationException(); } - } - - /** - * @param json A JSON-bindable data structure - * @return An immutable value type - * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonCreator - static ImmutableCatalogNode fromJson(Json json) { - ImmutableCatalogNode.Builder builder = ImmutableCatalogNode.builder(); - if (json.node != null) { - builder.node(json.node); - } - if (json.services != null) { - builder.putAllServices(json.services); - } - return builder.build(); - } - - /** - * Creates an immutable copy of a {@link CatalogNode} value. - * Uses accessors to get values to initialize the new immutable instance. - * If an instance is already immutable, it is returned as is. - * @param instance The instance to copy - * @return A copied immutable CatalogNode instance - */ - public static ImmutableCatalogNode copyOf(CatalogNode instance) { - if (instance instanceof ImmutableCatalogNode) { - return (ImmutableCatalogNode) instance; - } - return ImmutableCatalogNode.builder() - .from(instance) - .build(); - } - - /** - * Creates a builder for {@link ImmutableCatalogNode ImmutableCatalogNode}. - * @return A new ImmutableCatalogNode builder - */ - public static ImmutableCatalogNode.Builder builder() { - return new ImmutableCatalogNode.Builder(); - } - - /** - * Builds instances of type {@link ImmutableCatalogNode ImmutableCatalogNode}. - * Initialize attributes and then invoke the {@link #build()} method to create an - * immutable instance. - * <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection, - * but instead used immediately to create instances.</em> - */ - public static final class Builder { - private static final long INIT_BIT_NODE = 0x1L; - private long initBits = 0x1; - - private Node node; - private ImmutableMap.Builder<String, Service> servicesBuilder = ImmutableMap.builder(); - - private Builder() { - } - - /** - * Fill a builder with attribute values from the provided {@code CatalogNode} instance. - * Regular attribute values will be replaced with those from the given instance. - * Absent optional values will not replace present values. - * Collection elements and entries will be added, not replaced. - * @param instance The instance from which to copy values - * @return {@code this} builder for use in a chained invocation - */ - public final Builder from(CatalogNode instance) { - Preconditions.checkNotNull(instance, "instance"); - node(instance.getNode()); - putAllServices(instance.getServices()); - return this; - } - - /** - * Initializes the value for the {@link CatalogNode#getNode() node} attribute. - * @param node The value for node - * @return {@code this} builder for use in a chained invocation - */ - public final Builder node(Node node) { - this.node = Preconditions.checkNotNull(node, "node"); - initBits &= ~INIT_BIT_NODE; - return this; - } - - /** - * Put one entry to the {@link CatalogNode#getServices() services} map. - * @param key The key in the services map - * @param value The associated value in the services map - * @return {@code this} builder for use in a chained invocation - */ - public final Builder putServices(String key, Service value) { - servicesBuilder.put(key, value); - return this; - } - - /** - * Put one entry to the {@link CatalogNode#getServices() services} map. Nulls are not permitted - * @param entry The key and value entry - * @return {@code this} builder for use in a chained invocation - */ - public final Builder putServices(Map.Entry<String, ? extends Service> entry) { - servicesBuilder.put(entry); - return this; - } - - /** - * Sets or replaces all mappings from the specified map as entries for the {@link CatalogNode#getServices() services} map. Nulls are not permitted - * @param entries The entries that will be added to the services map - * @return {@code this} builder for use in a chained invocation - */ - public final Builder services(Map<String, ? extends Service> entries) { - servicesBuilder = ImmutableMap.builder(); - return putAllServices(entries); - } - - /** - * Put all mappings from the specified map as entries to {@link CatalogNode#getServices() services} map. Nulls are not permitted - * @param entries The entries that will be added to the services map - * @return {@code this} builder for use in a chained invocation - */ - public final Builder putAllServices(Map<String, ? extends Service> entries) { - servicesBuilder.putAll(entries); - return this; - } - - /** - * Builds a new {@link ImmutableCatalogNode ImmutableCatalogNode}. - * @return An immutable instance of CatalogNode - * @throws java.lang.IllegalStateException if any required attributes are missing - */ - public ImmutableCatalogNode build() throws IllegalStateException { - if (initBits != 0) { - throw new IllegalStateException(formatRequiredAttributesMessage()); - } - return new ImmutableCatalogNode(node, servicesBuilder.build()); - } - - private String formatRequiredAttributesMessage() { - List<String> attributes = Lists.newArrayList(); - if ((initBits & INIT_BIT_NODE) != 0) attributes.add("node"); - return "Cannot build CatalogNode, some of required attributes are not set " + attributes; - } - } -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ImmutableCatalogService.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ImmutableCatalogService.java deleted file mode 100644 index c16b94f..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ImmutableCatalogService.java +++ /dev/null @@ -1,625 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openo.msb.wrapper.consul.model.catalog; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import java.util.List; -import javax.annotation.Generated; - -/** - * Immutable implementation of {@link CatalogService}. - * <p> - * Use the builder to create immutable instances: - * {@code ImmutableCatalogService.builder()}. - */ -@SuppressWarnings("all") -@Generated({"Immutables.generator", "CatalogService"}) -@JsonIgnoreProperties(ignoreUnknown = true) -public final class ImmutableCatalogService extends CatalogService { - private final String node; - private final String address; - private final String serviceName; - private final String serviceId; - private final String serviceAddress; - private final int servicePort; - private final ImmutableList<String> serviceTags; - - private ImmutableCatalogService( - String node, - String address, - String serviceName, - String serviceId, - String serviceAddress, - int servicePort, - ImmutableList<String> serviceTags) { - this.node = node; - this.address = address; - this.serviceName = serviceName; - this.serviceId = serviceId; - this.serviceAddress = serviceAddress; - this.servicePort = servicePort; - this.serviceTags = serviceTags; - } - - /** - * @return The value of the {@code node} attribute - */ - @JsonProperty(value = "Node") - @Override - public String getNode() { - return node; - } - - /** - * @return The value of the {@code address} attribute - */ - @JsonProperty(value = "Address") - @Override - public String getAddress() { - return address; - } - - /** - * @return The value of the {@code serviceName} attribute - */ - @JsonProperty(value = "ServiceName") - @Override - public String getServiceName() { - return serviceName; - } - - /** - * @return The value of the {@code serviceId} attribute - */ - @JsonProperty(value = "ServiceID") - @Override - public String getServiceId() { - return serviceId; - } - - /** - * @return The value of the {@code serviceAddress} attribute - */ - @JsonProperty(value = "ServiceAddress") - @Override - public String getServiceAddress() { - return serviceAddress; - } - - /** - * @return The value of the {@code servicePort} attribute - */ - @JsonProperty(value = "ServicePort") - @Override - public int getServicePort() { - return servicePort; - } - - /** - * @return The value of the {@code serviceTags} attribute - */ - @JsonProperty(value = "ServiceTags") - @Override - public ImmutableList<String> getServiceTags() { - return serviceTags; - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogService#getNode() node} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for node - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogService withNode(String value) { - if (this.node.equals(value)) return this; - return new ImmutableCatalogService( - Preconditions.checkNotNull(value, "node"), - this.address, - this.serviceName, - this.serviceId, - this.serviceAddress, - this.servicePort, - this.serviceTags); - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogService#getAddress() address} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for address - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogService withAddress(String value) { - if (this.address.equals(value)) return this; - return new ImmutableCatalogService( - this.node, - Preconditions.checkNotNull(value, "address"), - this.serviceName, - this.serviceId, - this.serviceAddress, - this.servicePort, - this.serviceTags); - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogService#getServiceName() serviceName} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for serviceName - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogService withServiceName(String value) { - if (this.serviceName.equals(value)) return this; - return new ImmutableCatalogService( - this.node, - this.address, - Preconditions.checkNotNull(value, "serviceName"), - this.serviceId, - this.serviceAddress, - this.servicePort, - this.serviceTags); - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogService#getServiceId() serviceId} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for serviceId - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogService withServiceId(String value) { - if (this.serviceId.equals(value)) return this; - return new ImmutableCatalogService( - this.node, - this.address, - this.serviceName, - Preconditions.checkNotNull(value, "serviceId"), - this.serviceAddress, - this.servicePort, - this.serviceTags); - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogService#getServiceAddress() serviceAddress} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for serviceAddress - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogService withServiceAddress(String value) { - if (this.serviceAddress.equals(value)) return this; - return new ImmutableCatalogService( - this.node, - this.address, - this.serviceName, - this.serviceId, - Preconditions.checkNotNull(value, "serviceAddress"), - this.servicePort, - this.serviceTags); - } - - /** - * Copy the current immutable object by setting a value for the {@link CatalogService#getServicePort() servicePort} attribute. - * A value equality check is used to prevent copying of the same value by returning {@code this}. - * @param value A new value for servicePort - * @return A modified copy of the {@code this} object - */ - public final ImmutableCatalogService withServicePort(int value) { - if (this.servicePort == value) return this; - return new ImmutableCatalogService( - this.node, - this.address, - this.serviceName, - this.serviceId, - this.serviceAddress, - value, - this.serviceTags); - } - - /** - * Copy the current immutable object with elements that replace the content of {@link CatalogService#getServiceTags() serviceTags}. - * @param elements The elements to set - * @return A modified copy of {@code this} object - */ - public final ImmutableCatalogService withServiceTags(String... elements) { - ImmutableList<String> newValue = ImmutableList.copyOf(elements); - return new ImmutableCatalogService( - this.node, - this.address, - this.serviceName, - this.serviceId, - this.serviceAddress, - this.servicePort, - newValue); - } - - /** - * Copy the current immutable object with elements that replace the content of {@link CatalogService#getServiceTags() serviceTags}. - * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. - * @param elements An iterable of serviceTags elements to set - * @return A modified copy of {@code this} object - */ - public final ImmutableCatalogService withServiceTags(Iterable<String> elements) { - if (this.serviceTags == elements) return this; - ImmutableList<String> newValue = ImmutableList.copyOf(elements); - return new ImmutableCatalogService( - this.node, - this.address, - this.serviceName, - this.serviceId, - this.serviceAddress, - this.servicePort, - newValue); - } - - /** - * This instance is equal to all instances of {@code ImmutableCatalogService} that have equal attribute values. - * @return {@code true} if {@code this} is equal to {@code another} instance - */ - @Override - public boolean equals(Object another) { - if (this == another) return true; - return another instanceof ImmutableCatalogService - && equalTo((ImmutableCatalogService) another); - } - - private boolean equalTo(ImmutableCatalogService another) { - return node.equals(another.node) - && address.equals(another.address) - && serviceName.equals(another.serviceName) - && serviceId.equals(another.serviceId) - && serviceAddress.equals(another.serviceAddress) - && servicePort == another.servicePort - && serviceTags.equals(another.serviceTags); - } - - /** - * Computes a hash code from attributes: {@code node}, {@code address}, {@code serviceName}, {@code serviceId}, {@code serviceAddress}, {@code servicePort}, {@code serviceTags}. - * @return hashCode value - */ - @Override - public int hashCode() { - int h = 31; - h = h * 17 + node.hashCode(); - h = h * 17 + address.hashCode(); - h = h * 17 + serviceName.hashCode(); - h = h * 17 + serviceId.hashCode(); - h = h * 17 + serviceAddress.hashCode(); - h = h * 17 + servicePort; - h = h * 17 + serviceTags.hashCode(); - return h; - } - - /** - * Prints the immutable value {@code CatalogService...} with all non-generated - * and non-auxiliary attribute values. - * @return A string representation of the value - */ - @Override - public String toString() { - return MoreObjects.toStringHelper("CatalogService") - .add("node", node) - .add("address", address) - .add("serviceName", serviceName) - .add("serviceId", serviceId) - .add("serviceAddress", serviceAddress) - .add("servicePort", servicePort) - .add("serviceTags", serviceTags) - .toString(); - } - - /** - * Utility type used to correctly read immutable object from JSON representation. - * @deprecated Do not use this type directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonDeserialize - static final class Json extends CatalogService { - String node; - String address; - String serviceName; - String serviceId; - String serviceAddress; - Integer servicePort; - List<String> serviceTags = ImmutableList.of(); - @JsonProperty(value = "Node") - public void setNode(String node) { - this.node = node; - } - @JsonProperty(value = "Address") - public void setAddress(String address) { - this.address = address; - } - @JsonProperty(value = "ServiceName") - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - @JsonProperty(value = "ServiceID") - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - @JsonProperty(value = "ServiceAddress") - public void setServiceAddress(String serviceAddress) { - this.serviceAddress = serviceAddress; - } - @JsonProperty(value = "ServicePort") - public void setServicePort(int servicePort) { - this.servicePort = servicePort; - } - @JsonProperty(value = "ServiceTags") - public void setServiceTags(List<String> serviceTags) { - this.serviceTags = serviceTags; - } - @Override - public String getNode() { throw new UnsupportedOperationException(); } - @Override - public String getAddress() { throw new UnsupportedOperationException(); } - @Override - public String getServiceName() { throw new UnsupportedOperationException(); } - @Override - public String getServiceId() { throw new UnsupportedOperationException(); } - @Override - public String getServiceAddress() { throw new UnsupportedOperationException(); } - @Override - public int getServicePort() { throw new UnsupportedOperationException(); } - @Override - public List<String> getServiceTags() { throw new UnsupportedOperationException(); } - } - - /** - * @param json A JSON-bindable data structure - * @return An immutable value type - * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonCreator - static ImmutableCatalogService fromJson(Json json) { - ImmutableCatalogService.Builder builder = ImmutableCatalogService.builder(); - if (json.node != null) { - builder.node(json.node); - } - if (json.address != null) { - builder.address(json.address); - } - if (json.serviceName != null) { - builder.serviceName(json.serviceName); - } - if (json.serviceId != null) { - builder.serviceId(json.serviceId); - } - if (json.serviceAddress != null) { - builder.serviceAddress(json.serviceAddress); - } - if (json.servicePort != null) { - builder.servicePort(json.servicePort); - } - if (json.serviceTags != null) { - builder.addAllServiceTags(json.serviceTags); - } - return builder.build(); - } - - /** - * Creates an immutable copy of a {@link CatalogService} value. - * Uses accessors to get values to initialize the new immutable instance. - * If an instance is already immutable, it is returned as is. - * @param instance The instance to copy - * @return A copied immutable CatalogService instance - */ - public static ImmutableCatalogService copyOf(CatalogService instance) { - if (instance instanceof ImmutableCatalogService) { - return (ImmutableCatalogService) instance; - } - return ImmutableCatalogService.builder() - .from(instance) - .build(); - } - - /** - * Creates a builder for {@link ImmutableCatalogService ImmutableCatalogService}. - * @return A new ImmutableCatalogService builder - */ - public static ImmutableCatalogService.Builder builder() { - return new ImmutableCatalogService.Builder(); - } - - /** - * Builds instances of type {@link ImmutableCatalogService ImmutableCatalogService}. - * Initialize attributes and then invoke the {@link #build()} method to create an - * immutable instance. - * <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection, - * but instead used immediately to create instances.</em> - */ - public static final class Builder { - private static final long INIT_BIT_NODE = 0x1L; - private static final long INIT_BIT_ADDRESS = 0x2L; - private static final long INIT_BIT_SERVICE_NAME = 0x4L; - private static final long INIT_BIT_SERVICE_ID = 0x8L; - private static final long INIT_BIT_SERVICE_ADDRESS = 0x10L; - private static final long INIT_BIT_SERVICE_PORT = 0x20L; - private long initBits = 0x3f; - - private String node; - private String address; - private String serviceName; - private String serviceId; - private String serviceAddress; - private int servicePort; - private ImmutableList.Builder<String> serviceTagsBuilder = ImmutableList.builder(); - - private Builder() { - } - - /** - * Fill a builder with attribute values from the provided {@code CatalogService} instance. - * Regular attribute values will be replaced with those from the given instance. - * Absent optional values will not replace present values. - * Collection elements and entries will be added, not replaced. - * @param instance The instance from which to copy values - * @return {@code this} builder for use in a chained invocation - */ - public final Builder from(CatalogService instance) { - Preconditions.checkNotNull(instance, "instance"); - node(instance.getNode()); - address(instance.getAddress()); - serviceName(instance.getServiceName()); - serviceId(instance.getServiceId()); - serviceAddress(instance.getServiceAddress()); - servicePort(instance.getServicePort()); - addAllServiceTags(instance.getServiceTags()); - return this; - } - - /** - * Initializes the value for the {@link CatalogService#getNode() node} attribute. - * @param node The value for node - * @return {@code this} builder for use in a chained invocation - */ - public final Builder node(String node) { - this.node = Preconditions.checkNotNull(node, "node"); - initBits &= ~INIT_BIT_NODE; - return this; - } - - /** - * Initializes the value for the {@link CatalogService#getAddress() address} attribute. - * @param address The value for address - * @return {@code this} builder for use in a chained invocation - */ - public final Builder address(String address) { - this.address = Preconditions.checkNotNull(address, "address"); - initBits &= ~INIT_BIT_ADDRESS; - return this; - } - - /** - * Initializes the value for the {@link CatalogService#getServiceName() serviceName} attribute. - * @param serviceName The value for serviceName - * @return {@code this} builder for use in a chained invocation - */ - public final Builder serviceName(String serviceName) { - this.serviceName = Preconditions.checkNotNull(serviceName, "serviceName"); - initBits &= ~INIT_BIT_SERVICE_NAME; - return this; - } - - /** - * Initializes the value for the {@link CatalogService#getServiceId() serviceId} attribute. - * @param serviceId The value for serviceId - * @return {@code this} builder for use in a chained invocation - */ - public final Builder serviceId(String serviceId) { - this.serviceId = Preconditions.checkNotNull(serviceId, "serviceId"); - initBits &= ~INIT_BIT_SERVICE_ID; - return this; - } - - /** - * Initializes the value for the {@link CatalogService#getServiceAddress() serviceAddress} attribute. - * @param serviceAddress The value for serviceAddress - * @return {@code this} builder for use in a chained invocation - */ - public final Builder serviceAddress(String serviceAddress) { - this.serviceAddress = Preconditions.checkNotNull(serviceAddress, "serviceAddress"); - initBits &= ~INIT_BIT_SERVICE_ADDRESS; - return this; - } - - /** - * Initializes the value for the {@link CatalogService#getServicePort() servicePort} attribute. - * @param servicePort The value for servicePort - * @return {@code this} builder for use in a chained invocation - */ - public final Builder servicePort(int servicePort) { - this.servicePort = servicePort; - initBits &= ~INIT_BIT_SERVICE_PORT; - return this; - } - - /** - * Adds one element to {@link CatalogService#getServiceTags() serviceTags} list. - * @param element A serviceTags element - * @return {@code this} builder for use in a chained invocation - */ - public final Builder addServiceTags(String element) { - serviceTagsBuilder.add(element); - return this; - } - - /** - * Adds elements to {@link CatalogService#getServiceTags() serviceTags} list. - * @param elements An array of serviceTags elements - * @return {@code this} builder for use in a chained invocation - */ - public final Builder addServiceTags(String... elements) { - serviceTagsBuilder.add(elements); - return this; - } - - /** - * Sets or replaces all elements for {@link CatalogService#getServiceTags() serviceTags} list. - * @param elements An iterable of serviceTags elements - * @return {@code this} builder for use in a chained invocation - */ - public final Builder serviceTags(Iterable<String> elements) { - serviceTagsBuilder = ImmutableList.builder(); - return addAllServiceTags(elements); - } - - /** - * Adds elements to {@link CatalogService#getServiceTags() serviceTags} list. - * @param elements An iterable of serviceTags elements - * @return {@code this} builder for use in a chained invocation - */ - public final Builder addAllServiceTags(Iterable<String> elements) { - serviceTagsBuilder.addAll(elements); - return this; - } - - /** - * Builds a new {@link ImmutableCatalogService ImmutableCatalogService}. - * @return An immutable instance of CatalogService - * @throws java.lang.IllegalStateException if any required attributes are missing - */ - public ImmutableCatalogService build() throws IllegalStateException { - if (initBits != 0) { - throw new IllegalStateException(formatRequiredAttributesMessage()); - } - return new ImmutableCatalogService( - node, - address, - serviceName, - serviceId, - serviceAddress, - servicePort, - serviceTagsBuilder.build()); - } - - private String formatRequiredAttributesMessage() { - List<String> attributes = Lists.newArrayList(); - if ((initBits & INIT_BIT_NODE) != 0) attributes.add("node"); - if ((initBits & INIT_BIT_ADDRESS) != 0) attributes.add("address"); - if ((initBits & INIT_BIT_SERVICE_NAME) != 0) attributes.add("serviceName"); - if ((initBits & INIT_BIT_SERVICE_ID) != 0) attributes.add("serviceId"); - if ((initBits & INIT_BIT_SERVICE_ADDRESS) != 0) attributes.add("serviceAddress"); - if ((initBits & INIT_BIT_SERVICE_PORT) != 0) attributes.add("servicePort"); - return "Cannot build CatalogService, some of required attributes are not set " + attributes; - } - } -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ServiceInfo.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ServiceInfo.java deleted file mode 100644 index dcf67a2..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/catalog/ServiceInfo.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openo.msb.wrapper.consul.model.catalog; - -import com.google.common.base.Objects; - -public class ServiceInfo { - - private String serviceName; - - private String version=""; - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public boolean equals(Object other) - { - if(this == other) - return true; - if(other instanceof ServiceInfo) - { - ServiceInfo that = (ServiceInfo)other; - return Objects.equal(serviceName, that.serviceName) && Objects.equal(version, that.version); - } else - { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(serviceName, version); - } - -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ImmutableNode.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ImmutableNode.java deleted file mode 100644 index ed0340e..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ImmutableNode.java +++ /dev/null @@ -1,265 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openo.msb.wrapper.consul.model.health; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import java.util.List; -import javax.annotation.Generated; - -/** - * Immutable implementation of {@link Node}. - * <p> - * Use the builder to create immutable instances: - * {@code ImmutableNode.builder()}. - */ -@SuppressWarnings("all") -@Generated({"Immutables.generator", "Node"}) -@JsonIgnoreProperties(ignoreUnknown = true) -public final class ImmutableNode extends Node { - private final String node; - private final String address; - - private ImmutableNode(String node, String address) { - this.node = node; - this.address = address; - } - - /** - * @return The value of the {@code node} attribute - */ - @JsonProperty(value = "Node") - @Override - public String getNode() { - return node; - } - - /** - * @return The value of the {@code address} attribute - */ - @JsonProperty(value = "Address") - @Override - public String getAddress() { - return address; - } - - /** - * Copy the current immutable object by setting a value for the {@link Node#getNode() node} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for node - * @return A modified copy of the {@code this} object - */ - public final ImmutableNode withNode(String value) { - if (this.node.equals(value)) return this; - return new ImmutableNode(Preconditions.checkNotNull(value, "node"), this.address); - } - - /** - * Copy the current immutable object by setting a value for the {@link Node#getAddress() address} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for address - * @return A modified copy of the {@code this} object - */ - public final ImmutableNode withAddress(String value) { - if (this.address.equals(value)) return this; - return new ImmutableNode(this.node, Preconditions.checkNotNull(value, "address")); - } - - /** - * This instance is equal to all instances of {@code ImmutableNode} that have equal attribute values. - * @return {@code true} if {@code this} is equal to {@code another} instance - */ - @Override - public boolean equals(Object another) { - if (this == another) return true; - return another instanceof ImmutableNode - && equalTo((ImmutableNode) another); - } - - private boolean equalTo(ImmutableNode another) { - return node.equals(another.node) - && address.equals(another.address); - } - - /** - * Computes a hash code from attributes: {@code node}, {@code address}. - * @return hashCode value - */ - @Override - public int hashCode() { - int h = 31; - h = h * 17 + node.hashCode(); - h = h * 17 + address.hashCode(); - return h; - } - - /** - * Prints the immutable value {@code Node...} with all non-generated - * and non-auxiliary attribute values. - * @return A string representation of the value - */ - @Override - public String toString() { - return MoreObjects.toStringHelper("Node") - .add("node", node) - .add("address", address) - .toString(); - } - - /** - * Utility type used to correctly read immutable object from JSON representation. - * @deprecated Do not use this type directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonDeserialize - static final class Json extends Node { - String node; - String address; - @JsonProperty(value = "Node") - public void setNode(String node) { - this.node = node; - } - @JsonProperty(value = "Address") - public void setAddress(String address) { - this.address = address; - } - @Override - public String getNode() { throw new UnsupportedOperationException(); } - @Override - public String getAddress() { throw new UnsupportedOperationException(); } - } - - /** - * @param json A JSON-bindable data structure - * @return An immutable value type - * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonCreator - static ImmutableNode fromJson(Json json) { - ImmutableNode.Builder builder = ImmutableNode.builder(); - if (json.node != null) { - builder.node(json.node); - } - if (json.address != null) { - builder.address(json.address); - } - return builder.build(); - } - - /** - * Creates an immutable copy of a {@link Node} value. - * Uses accessors to get values to initialize the new immutable instance. - * If an instance is already immutable, it is returned as is. - * @param instance The instance to copy - * @return A copied immutable Node instance - */ - public static ImmutableNode copyOf(Node instance) { - if (instance instanceof ImmutableNode) { - return (ImmutableNode) instance; - } - return ImmutableNode.builder() - .from(instance) - .build(); - } - - /** - * Creates a builder for {@link ImmutableNode ImmutableNode}. - * @return A new ImmutableNode builder - */ - public static ImmutableNode.Builder builder() { - return new ImmutableNode.Builder(); - } - - /** - * Builds instances of type {@link ImmutableNode ImmutableNode}. - * Initialize attributes and then invoke the {@link #build()} method to create an - * immutable instance. - * <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection, - * but instead used immediately to create instances.</em> - */ - public static final class Builder { - private static final long INIT_BIT_NODE = 0x1L; - private static final long INIT_BIT_ADDRESS = 0x2L; - private long initBits = 0x3; - - private String node; - private String address; - - private Builder() { - } - - /** - * Fill a builder with attribute values from the provided {@code Node} instance. - * Regular attribute values will be replaced with those from the given instance. - * Absent optional values will not replace present values. - * @param instance The instance from which to copy values - * @return {@code this} builder for use in a chained invocation - */ - public final Builder from(Node instance) { - Preconditions.checkNotNull(instance, "instance"); - node(instance.getNode()); - address(instance.getAddress()); - return this; - } - - /** - * Initializes the value for the {@link Node#getNode() node} attribute. - * @param node The value for node - * @return {@code this} builder for use in a chained invocation - */ - public final Builder node(String node) { - this.node = Preconditions.checkNotNull(node, "node"); - initBits &= ~INIT_BIT_NODE; - return this; - } - - /** - * Initializes the value for the {@link Node#getAddress() address} attribute. - * @param address The value for address - * @return {@code this} builder for use in a chained invocation - */ - public final Builder address(String address) { - this.address = Preconditions.checkNotNull(address, "address"); - initBits &= ~INIT_BIT_ADDRESS; - return this; - } - - /** - * Builds a new {@link ImmutableNode ImmutableNode}. - * @return An immutable instance of Node - * @throws java.lang.IllegalStateException if any required attributes are missing - */ - public ImmutableNode build() throws IllegalStateException { - if (initBits != 0) { - throw new IllegalStateException(formatRequiredAttributesMessage()); - } - return new ImmutableNode(node, address); - } - - private String formatRequiredAttributesMessage() { - List<String> attributes = Lists.newArrayList(); - if ((initBits & INIT_BIT_NODE) != 0) attributes.add("node"); - if ((initBits & INIT_BIT_ADDRESS) != 0) attributes.add("address"); - return "Cannot build Node, some of required attributes are not set " + attributes; - } - } -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ImmutableService.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ImmutableService.java deleted file mode 100644 index ec8f2d3..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ImmutableService.java +++ /dev/null @@ -1,477 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openo.msb.wrapper.consul.model.health; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import java.util.List; -import javax.annotation.Generated; - -/** - * Immutable implementation of {@link Service}. - * <p> - * Use the builder to create immutable instances: - * {@code ImmutableService.builder()}. - */ -@SuppressWarnings("all") -@Generated({"Immutables.generator", "Service"}) -@JsonIgnoreProperties(ignoreUnknown = true) -public final class ImmutableService extends Service { - private final String id; - private final String service; - private final ImmutableList<String> tags; - private final String address; - private final int port; - - private ImmutableService( - String id, - String service, - ImmutableList<String> tags, - String address, - int port) { - this.id = id; - this.service = service; - this.tags = tags; - this.address = address; - this.port = port; - } - - /** - * @return The value of the {@code id} attribute - */ - @JsonProperty(value = "ID") - @Override - public String getId() { - return id; - } - - /** - * @return The value of the {@code service} attribute - */ - @JsonProperty(value = "Service") - @Override - public String getService() { - return service; - } - - /** - * @return The value of the {@code tags} attribute - */ - @JsonProperty(value = "Tags") - @JsonDeserialize(as = ImmutableList.class, contentAs = String.class) - @Override - public ImmutableList<String> getTags() { - return tags; - } - - /** - * @return The value of the {@code address} attribute - */ - @JsonProperty(value = "Address") - @Override - public String getAddress() { - return address; - } - - /** - * @return The value of the {@code port} attribute - */ - @JsonProperty(value = "Port") - @Override - public int getPort() { - return port; - } - - /** - * Copy the current immutable object by setting a value for the {@link Service#getId() id} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for id - * @return A modified copy of the {@code this} object - */ - public final ImmutableService withId(String value) { - if (this.id.equals(value)) return this; - return new ImmutableService( - Preconditions.checkNotNull(value, "id"), - this.service, - this.tags, - this.address, - this.port); - } - - /** - * Copy the current immutable object by setting a value for the {@link Service#getService() service} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for service - * @return A modified copy of the {@code this} object - */ - public final ImmutableService withService(String value) { - if (this.service.equals(value)) return this; - return new ImmutableService( - this.id, - Preconditions.checkNotNull(value, "service"), - this.tags, - this.address, - this.port); - } - - /** - * Copy the current immutable object with elements that replace the content of {@link Service#getTags() tags}. - * @param elements The elements to set - * @return A modified copy of {@code this} object - */ - public final ImmutableService withTags(String... elements) { - ImmutableList<String> newValue = ImmutableList.copyOf(elements); - return new ImmutableService(this.id, this.service, newValue, this.address, this.port); - } - - /** - * Copy the current immutable object with elements that replace the content of {@link Service#getTags() tags}. - * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. - * @param elements An iterable of tags elements to set - * @return A modified copy of {@code this} object - */ - public final ImmutableService withTags(Iterable<String> elements) { - if (this.tags == elements) return this; - ImmutableList<String> newValue = ImmutableList.copyOf(elements); - return new ImmutableService(this.id, this.service, newValue, this.address, this.port); - } - - /** - * Copy the current immutable object by setting a value for the {@link Service#getAddress() address} attribute. - * An equals check used to prevent copying of the same value by returning {@code this}. - * @param value A new value for address - * @return A modified copy of the {@code this} object - */ - public final ImmutableService withAddress(String value) { - if (this.address.equals(value)) return this; - return new ImmutableService( - this.id, - this.service, - this.tags, - Preconditions.checkNotNull(value, "address"), - this.port); - } - - /** - * Copy the current immutable object by setting a value for the {@link Service#getPort() port} attribute. - * A value equality check is used to prevent copying of the same value by returning {@code this}. - * @param value A new value for port - * @return A modified copy of the {@code this} object - */ - public final ImmutableService withPort(int value) { - if (this.port == value) return this; - return new ImmutableService(this.id, this.service, this.tags, this.address, value); - } - - /** - * This instance is equal to all instances of {@code ImmutableService} that have equal attribute values. - * @return {@code true} if {@code this} is equal to {@code another} instance - */ - @Override - public boolean equals(Object another) { - if (this == another) return true; - return another instanceof ImmutableService - && equalTo((ImmutableService) another); - } - - private boolean equalTo(ImmutableService another) { - return id.equals(another.id) - && service.equals(another.service) - && tags.equals(another.tags) - && address.equals(another.address) - && port == another.port; - } - - /** - * Computes a hash code from attributes: {@code id}, {@code service}, {@code tags}, {@code address}, {@code port}. - * @return hashCode value - */ - @Override - public int hashCode() { - int h = 31; - h = h * 17 + id.hashCode(); - h = h * 17 + service.hashCode(); - h = h * 17 + tags.hashCode(); - h = h * 17 + address.hashCode(); - h = h * 17 + port; - return h; - } - - /** - * Prints the immutable value {@code Service...} with all non-generated - * and non-auxiliary attribute values. - * @return A string representation of the value - */ - @Override - public String toString() { - return MoreObjects.toStringHelper("Service") - .add("id", id) - .add("service", service) - .add("tags", tags) - .add("address", address) - .add("port", port) - .toString(); - } - - /** - * Utility type used to correctly read immutable object from JSON representation. - * @deprecated Do not use this type directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonDeserialize - static final class Json extends Service { - String id; - String service; - List<String> tags = ImmutableList.of(); - String address; - Integer port; - @JsonProperty(value = "ID") - public void setId(String id) { - this.id = id; - } - @JsonProperty(value = "Service") - public void setService(String service) { - this.service = service; - } - @JsonProperty(value = "Tags") - @JsonDeserialize(as = ImmutableList.class, contentAs = String.class) - public void setTags(List<String> tags) { - this.tags = tags; - } - @JsonProperty(value = "Address") - public void setAddress(String address) { - this.address = address; - } - @JsonProperty(value = "Port") - public void setPort(int port) { - this.port = port; - } - @Override - public String getId() { throw new UnsupportedOperationException(); } - @Override - public String getService() { throw new UnsupportedOperationException(); } - @Override - public List<String> getTags() { throw new UnsupportedOperationException(); } - @Override - public String getAddress() { throw new UnsupportedOperationException(); } - @Override - public int getPort() { throw new UnsupportedOperationException(); } - } - - /** - * @param json A JSON-bindable data structure - * @return An immutable value type - * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure - */ - @Deprecated - @JsonCreator - static ImmutableService fromJson(Json json) { - ImmutableService.Builder builder = ImmutableService.builder(); - if (json.id != null) { - builder.id(json.id); - } - if (json.service != null) { - builder.service(json.service); - } - if (json.tags != null) { - builder.addAllTags(json.tags); - } - if (json.address != null) { - builder.address(json.address); - } - if (json.port != null) { - builder.port(json.port); - } - return builder.build(); - } - - /** - * Creates an immutable copy of a {@link Service} value. - * Uses accessors to get values to initialize the new immutable instance. - * If an instance is already immutable, it is returned as is. - * @param instance The instance to copy - * @return A copied immutable Service instance - */ - public static ImmutableService copyOf(Service instance) { - if (instance instanceof ImmutableService) { - return (ImmutableService) instance; - } - return ImmutableService.builder() - .from(instance) - .build(); - } - - /** - * Creates a builder for {@link ImmutableService ImmutableService}. - * @return A new ImmutableService builder - */ - public static ImmutableService.Builder builder() { - return new ImmutableService.Builder(); - } - - /** - * Builds instances of type {@link ImmutableService ImmutableService}. - * Initialize attributes and then invoke the {@link #build()} method to create an - * immutable instance. - * <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection, - * but instead used immediately to create instances.</em> - */ - public static final class Builder { - private static final long INIT_BIT_ID = 0x1L; - private static final long INIT_BIT_SERVICE = 0x2L; - private static final long INIT_BIT_ADDRESS = 0x4L; - private static final long INIT_BIT_PORT = 0x8L; - private long initBits = 0xf; - - private String id; - private String service; - private ImmutableList.Builder<String> tagsBuilder = ImmutableList.builder(); - private String address; - private int port; - - private Builder() { - } - - /** - * Fill a builder with attribute values from the provided {@code Service} instance. - * Regular attribute values will be replaced with those from the given instance. - * Absent optional values will not replace present values. - * Collection elements and entries will be added, not replaced. - * @param instance The instance from which to copy values - * @return {@code this} builder for use in a chained invocation - */ - public final Builder from(Service instance) { - Preconditions.checkNotNull(instance, "instance"); - id(instance.getId()); - service(instance.getService()); - addAllTags(instance.getTags()); - address(instance.getAddress()); - port(instance.getPort()); - return this; - } - - /** - * Initializes the value for the {@link Service#getId() id} attribute. - * @param id The value for id - * @return {@code this} builder for use in a chained invocation - */ - public final Builder id(String id) { - this.id = Preconditions.checkNotNull(id, "id"); - initBits &= ~INIT_BIT_ID; - return this; - } - - /** - * Initializes the value for the {@link Service#getService() service} attribute. - * @param service The value for service - * @return {@code this} builder for use in a chained invocation - */ - public final Builder service(String service) { - this.service = Preconditions.checkNotNull(service, "service"); - initBits &= ~INIT_BIT_SERVICE; - return this; - } - - /** - * Adds one element to {@link Service#getTags() tags} list. - * @param element A tags element - * @return {@code this} builder for use in a chained invocation - */ - public final Builder addTags(String element) { - tagsBuilder.add(element); - return this; - } - - /** - * Adds elements to {@link Service#getTags() tags} list. - * @param elements An array of tags elements - * @return {@code this} builder for use in a chained invocation - */ - public final Builder addTags(String... elements) { - tagsBuilder.add(elements); - return this; - } - - /** - * Sets or replaces all elements for {@link Service#getTags() tags} list. - * @param elements An iterable of tags elements - * @return {@code this} builder for use in a chained invocation - */ - public final Builder tags(Iterable<String> elements) { - tagsBuilder = ImmutableList.builder(); - return addAllTags(elements); - } - - /** - * Adds elements to {@link Service#getTags() tags} list. - * @param elements An iterable of tags elements - * @return {@code this} builder for use in a chained invocation - */ - public final Builder addAllTags(Iterable<String> elements) { - tagsBuilder.addAll(elements); - return this; - } - - /** - * Initializes the value for the {@link Service#getAddress() address} attribute. - * @param address The value for address - * @return {@code this} builder for use in a chained invocation - */ - public final Builder address(String address) { - this.address = Preconditions.checkNotNull(address, "address"); - initBits &= ~INIT_BIT_ADDRESS; - return this; - } - - /** - * Initializes the value for the {@link Service#getPort() port} attribute. - * @param port The value for port - * @return {@code this} builder for use in a chained invocation - */ - public final Builder port(int port) { - this.port = port; - initBits &= ~INIT_BIT_PORT; - return this; - } - - /** - * Builds a new {@link ImmutableService ImmutableService}. - * @return An immutable instance of Service - * @throws java.lang.IllegalStateException if any required attributes are missing - */ - public ImmutableService build() throws IllegalStateException { - if (initBits != 0) { - throw new IllegalStateException(formatRequiredAttributesMessage()); - } - return new ImmutableService(id, service, tagsBuilder.build(), address, port); - } - - private String formatRequiredAttributesMessage() { - List<String> attributes = Lists.newArrayList(); - if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); - if ((initBits & INIT_BIT_SERVICE) != 0) attributes.add("service"); - if ((initBits & INIT_BIT_ADDRESS) != 0) attributes.add("address"); - if ((initBits & INIT_BIT_PORT) != 0) attributes.add("port"); - return "Cannot build Service, some of required attributes are not set " + attributes; - } - } -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/Node.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/Node.java deleted file mode 100644 index 9f603c5..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/Node.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.openo.msb.wrapper.consul.model.health; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - - -@JsonSerialize(as = ImmutableNode.class) -@JsonDeserialize(as = ImmutableNode.class) -@JsonIgnoreProperties(ignoreUnknown = true) -public abstract class Node { - - @JsonProperty("Node") - public abstract String getNode(); - - @JsonProperty("Address") - public abstract String getAddress(); -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/Service.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/Service.java deleted file mode 100644 index 6ac3d4b..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/Service.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.openo.msb.wrapper.consul.model.health; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.collect.ImmutableList; - - -@JsonSerialize(as = ImmutableService.class) -@JsonDeserialize(as = ImmutableService.class) -@JsonIgnoreProperties(ignoreUnknown = true) -public abstract class Service { - - @JsonProperty("ID") - public abstract String getId(); - - @JsonProperty("Service") - public abstract String getService(); - - @JsonProperty("Tags") - @JsonDeserialize(as = ImmutableList.class, contentAs = String.class) - public abstract List<String> getTags(); - - @JsonProperty("Address") - public abstract String getAddress(); - - @JsonProperty("Port") - public abstract int getPort(); -} diff --git a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ServiceHealth.java b/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ServiceHealth.java deleted file mode 100644 index 4693256..0000000 --- a/msb-core/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/consul/model/health/ServiceHealth.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2016 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package org.openo.msb.wrapper.consul.model.health; - -import org.openo.msb.wrapper.consul.model.catalog.ServiceInfo; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Objects; - - -@JsonIgnoreProperties(ignoreUnknown = true) -public class ServiceHealth { - - @JsonProperty("Node") - public Node node; - - @JsonProperty("Service") - public Service service; - - public Node getNode() { - return node; - } - - public void setNode(Node node) { - this.node = node; - } - - public Service getService() { - return service; - } - - public void setService(Service service) { - this.service = service; - } - - @Override - public boolean equals(Object other) - { - if(this == other) - return true; - if(other instanceof ServiceHealth) - { - ServiceHealth that = (ServiceHealth)other; - return Objects.equal(node, that.node) && Objects.equal(service, that.service); - } else - { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(node, service); - } - - - -} |