mirror of https://github.com/apache/jclouds.git
Guava toString, hashCode, and equals for domain objects. Removed unnecessary Objects.
This commit is contained in:
parent
7b1b897c21
commit
976b6ef4a0
|
@ -46,6 +46,7 @@ import com.google.inject.Module;
|
|||
*/
|
||||
public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static final TypeToken<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> CONTEXT_TOKEN =
|
||||
new TypeToken<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>>() {};
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.jclouds.rackspace.cloudloadbalancers;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Represents a Load Balancer endpoint
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Qualifier
|
||||
public @interface LoadBalancer {
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.jclouds.rackspace.cloudloadbalancers;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Represents a Node endpoint
|
||||
*
|
||||
* @author Dan Lo Bianco
|
||||
*
|
||||
*/
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Qualifier
|
||||
public @interface Node {
|
||||
|
||||
}
|
|
@ -355,7 +355,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
|||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("id", id).add("region", region).add("name", name).add("protocol", protocol).add("port", port)
|
||||
.add("algorithm", algorithm).add("status", status).add("virtualIPs", virtualIPs).add("nodeCount", getNodeCount())
|
||||
.add("nodes", nodes).add("sessionPersistenceType", sessionPersistenceType).add("created", created)
|
||||
|
|
|
@ -20,6 +20,9 @@ package org.jclouds.rackspace.cloudloadbalancers.domain;
|
|||
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -75,51 +78,30 @@ public class LoadBalancerAttributes {
|
|||
}
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("name", name).add("algorithm", algorithm).add("port", port).add("protocol", protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[algorithm=%s, name=%s, port=%s, protocol=%s]", algorithm, name, port, protocol);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((algorithm == null) ? 0 : algorithm.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((port == null) ? 0 : port.hashCode());
|
||||
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
|
||||
return result;
|
||||
return Objects.hashCode(name, algorithm, port, protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
LoadBalancerAttributes other = (LoadBalancerAttributes) obj;
|
||||
if (algorithm == null) {
|
||||
if (other.algorithm != null)
|
||||
return false;
|
||||
} else if (!algorithm.equals(other.algorithm))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (port == null) {
|
||||
if (other.port != null)
|
||||
return false;
|
||||
} else if (!port.equals(other.port))
|
||||
return false;
|
||||
if (protocol == null) {
|
||||
if (other.protocol != null)
|
||||
return false;
|
||||
} else if (!protocol.equals(other.protocol))
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
LoadBalancerAttributes that = LoadBalancerAttributes.class.cast(obj);
|
||||
return Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.algorithm, that.algorithm)
|
||||
&& Objects.equal(this.port, that.port)
|
||||
&& Objects.equal(this.protocol, that.protocol);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.Map;
|
|||
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -141,10 +143,14 @@ public class LoadBalancerRequest extends BaseLoadBalancer<NodeRequest, LoadBalan
|
|||
throw new IllegalArgumentException("virtualIPType or virtualIPId must be specified");
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("name", name).add("algorithm", algorithm).add("nodes", nodes).add("port", port)
|
||||
.add("protocol", protocol).add("virtualIps", virtualIps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[algorithm=%s, name=%s, nodes=%s, port=%s, protocol=%s, virtualIps=%s]", algorithm, name,
|
||||
nodes, port, protocol, virtualIps);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseNode;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The nodes defined by the load balancer are responsible for servicing the requests received
|
||||
* through the load balancer's virtual IP. By default, the load balancer employs a basic health
|
||||
|
@ -169,32 +172,28 @@ public class Node extends BaseNode<Node> {
|
|||
return status;
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("address", address).add("port", port).add("condition", condition)
|
||||
.add("weight", weight).add("status", status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[id=%s, address=%s, condition=%s, port=%s, weight=%s, status=%s]", id, address, condition,
|
||||
port, weight, status);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + id;
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Node other = (Node) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
Node that = Node.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.rackspace.cloudloadbalancers.domain;
|
|||
import org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseNode;
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseNode.Condition;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dan Lo Bianco
|
||||
|
@ -56,39 +59,28 @@ public class NodeAttributes {
|
|||
}
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("condition", condition).add("weight", weight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[condition=%s, weight=%s]", condition, weight);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((condition == null) ? 0 : condition.hashCode());
|
||||
result = prime * result + ((weight == null) ? 0 : weight.hashCode());
|
||||
return result;
|
||||
return Objects.hashCode(condition, weight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NodeAttributes other = (NodeAttributes) obj;
|
||||
if (condition == null) {
|
||||
if (other.condition != null)
|
||||
return false;
|
||||
} else if (!condition.equals(other.condition))
|
||||
return false;
|
||||
if (weight == null) {
|
||||
if (other.weight != null)
|
||||
return false;
|
||||
} else if (!weight.equals(other.weight))
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
NodeAttributes that = NodeAttributes.class.cast(obj);
|
||||
return Objects.equal(this.condition, that.condition)
|
||||
&& Objects.equal(this.weight, that.weight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ package org.jclouds.rackspace.cloudloadbalancers.domain;
|
|||
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.internal.BaseNode;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The nodes defined by the load balancer are responsible for servicing the requests received
|
||||
* through the load balancer's virtual IP. By default, the load balancer employs a basic health
|
||||
|
@ -106,4 +109,28 @@ public class NodeRequest extends BaseNode<NodeRequest> {
|
|||
super(address, port, condition, weight);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("address", address).add("port", port).add("condition", condition).add("weight", weight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(address, port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
NodeRequest that = NodeRequest.class.cast(obj);
|
||||
return Objects.equal(this.address, that.address)
|
||||
&& Objects.equal(this.port, that.port);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.rackspace.cloudloadbalancers.domain;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* A virtual IP (VIP) makes a load balancer accessible by clients. The load balancing service
|
||||
* supports either a public VIP, routable on the public Internet, or a ServiceNet address, routable
|
||||
|
@ -146,31 +149,27 @@ public class VirtualIP implements Comparable<VirtualIP> {
|
|||
return address.compareTo(arg0.address);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("id", id).add("address", address).add("ipVersion", ipVersion).add("type", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + id;
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VirtualIP other = (VirtualIP) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[address=%s, id=%s, ipVersion=%s, type=%s]", address, id, ipVersion, type);
|
||||
VirtualIP that = VirtualIP.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class BaseLoadBalancer<N extends BaseNode<N>, T extends BaseLoadBalancer<
|
|||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("name", name).add("protocol", protocol).add("port", port)
|
||||
.add("algorithm", algorithm).add("nodes", nodes);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.rackspace.cloudloadbalancers.domain.internal;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The nodes defined by the load balancer are responsible for servicing the requests received
|
||||
* through the load balancer's virtual IP. By default, the load balancer employs a basic health
|
||||
|
@ -168,43 +171,29 @@ public class BaseNode<T extends BaseNode<T>> implements Comparable<BaseNode<T>>
|
|||
return address.compareTo(arg0.address);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues()
|
||||
.add("address", address).add("port", port).add("condition", condition).add("weight", weight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((address == null) ? 0 : address.hashCode());
|
||||
result = prime * result + ((condition == null) ? 0 : condition.hashCode());
|
||||
result = prime * result + port;
|
||||
return result;
|
||||
return Objects.hashCode(address, port, condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BaseNode<?> other = (BaseNode<?>) obj;
|
||||
if (address == null) {
|
||||
if (other.address != null)
|
||||
return false;
|
||||
} else if (!address.equals(other.address))
|
||||
return false;
|
||||
if (condition == null) {
|
||||
if (other.condition != null)
|
||||
return false;
|
||||
} else if (!condition.equals(other.condition))
|
||||
return false;
|
||||
if (port != other.port)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[address=%s, condition=%s, port=%s, weight=%s]", address, condition, port, weight);
|
||||
BaseNode<?> that = BaseNode.class.cast(obj);
|
||||
return Objects.equal(this.address, that.address)
|
||||
&& Objects.equal(this.port, that.port)
|
||||
&& Objects.equal(this.condition, that.condition);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.jclouds.rackspace.cloudloadbalancers.domain.LoadBalancer;
|
|||
import org.jclouds.rackspace.cloudloadbalancers.domain.Node;
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.NodeAttributes;
|
||||
import org.jclouds.rackspace.cloudloadbalancers.domain.NodeRequest;
|
||||
import org.jclouds.rackspace.cloudloadbalancers.functions.ParseLoadBalancers;
|
||||
import org.jclouds.rackspace.cloudloadbalancers.functions.ParseNodes;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -49,7 +48,6 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
|||
import org.jclouds.rest.annotations.Transform;
|
||||
import org.jclouds.rest.annotations.WrapWith;
|
||||
import org.jclouds.rest.functions.ReturnEmptyPagedIterableOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.jclouds.rackspace.cloudloadbalancers.functions;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
|
||||
import org.jclouds.rackspace.cloudloadbalancers.reference.RackspaceConstants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
@Singleton
|
||||
public final class AppendAccountIdToURI implements Function<Supplier<URI>, Supplier<URI>> {
|
||||
|
||||
private final Supplier<String> accountID;
|
||||
private final javax.inject.Provider<UriBuilder> builders;
|
||||
|
||||
@Inject
|
||||
public AppendAccountIdToURI(javax.inject.Provider<UriBuilder> builders,
|
||||
@Named(RackspaceConstants.PROPERTY_ACCOUNT_ID) Supplier<String> accountID) {
|
||||
this.accountID = accountID;
|
||||
this.builders = builders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<URI> apply(final Supplier<URI> input) {
|
||||
return new Supplier<URI>() {
|
||||
|
||||
@Override
|
||||
public URI get() {
|
||||
return builders.get().uri(input.get()).path(accountID.get()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "appendAccountId()";
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.jclouds.rackspace.cloudloadbalancers.location;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.config.ValueOfConfigurationKeyOrNull;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.suppliers.fromconfig.RegionIdToURIFromConfigurationOrDefaultToProvider;
|
||||
import org.jclouds.rackspace.cloudloadbalancers.functions.AppendAccountIdToURI;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@Singleton
|
||||
public class RegionUrisFromPropertiesAndAccountIDPathSuffix extends RegionIdToURIFromConfigurationOrDefaultToProvider {
|
||||
|
||||
private AppendAccountIdToURI filter;
|
||||
|
||||
@Inject
|
||||
protected RegionUrisFromPropertiesAndAccountIDPathSuffix(ValueOfConfigurationKeyOrNull config,
|
||||
@Provider Supplier<URI> providerURI, @Region Supplier<Set<String>> regionIds, AppendAccountIdToURI filter) {
|
||||
super(config, providerURI, regionIds);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Supplier<URI>> get() {
|
||||
return Maps.transformValues(super.get(), filter);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.jclouds.rackspace.cloudloadbalancers.reference;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in rackspace connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface RackspaceConstants {
|
||||
public static final String PROPERTY_ACCOUNT_ID = "jclouds.rackspace.account-id";
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.jclouds.rackspace.cloudloadbalancers.reference;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The load balancing service is a regionalized service. It allows the caller to select a region
|
||||
* into which a load balancer is to be provisioned.
|
||||
* <p/>
|
||||
* If load balancing Cloud Servers, you can determine the appropriate region to select by viewing
|
||||
* your Cloud Servers list and creating a load balancer within the same region as the data center in
|
||||
* which your Cloud Server resides. When your resources reside in the same region as your load
|
||||
* balancer, devices are in close proximity to each other and can take advantage of ServiceNet
|
||||
* connectivity for free data transfer between services.
|
||||
* <p/>
|
||||
* If load balancing external servers, you can determine the appropriate region to select by
|
||||
* choosing the region that is geographically as close to your external servers as possible.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch03s02.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
||||
public interface Region {
|
||||
/**
|
||||
* Chicago (ORD) https://ord.loadbalancers.api.rackspacecloud.com/v1.0/1234/
|
||||
*/
|
||||
public static final String ORD = "ORD";
|
||||
|
||||
/**
|
||||
* Dallas/Ft. Worth (DFW) https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/
|
||||
*/
|
||||
public static final String DFW = "DFW";
|
||||
|
||||
/**
|
||||
* London/Slough (LON) https://lon.loadbalancers.api.rackspacecloud.com/v1.0/1234/
|
||||
*/
|
||||
public static final String LON = "LON";
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@ package org.jclouds.rackspace.cloudloadbalancers.uk;
|
|||
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||
import static org.jclouds.rackspace.cloudloadbalancers.reference.Region.LON;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
@ -63,7 +62,7 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata {
|
|||
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(PROPERTY_ZONES, LON);
|
||||
properties.setProperty(PROPERTY_ZONES, "LON");
|
||||
properties.setProperty(PROPERTY_ZONE + ".LON." + ISO3166_CODES, "GB-SLG");
|
||||
return properties;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue