switch to old google collections syntax to avoid conflict between guava and google collections

This commit is contained in:
Adrian Cole 2010-04-26 23:46:22 -07:00
parent 1af5fccb0c
commit e3a816e6cd
10 changed files with 235 additions and 221 deletions

View File

@ -116,7 +116,8 @@ public class EC2RestClientModule extends AbstractModule {
@Singleton @Singleton
@EC2 @EC2
Region provideCurrentRegion(@EC2 Map<Region, URI> regionMap, @EC2 URI currentUri) { Region provideCurrentRegion(@EC2 Map<Region, URI> regionMap, @EC2 URI currentUri) {
ImmutableBiMap<URI, Region> map = ImmutableBiMap.copyOf(regionMap).inverse(); ImmutableBiMap<URI, Region> map = ImmutableBiMap.<Region, URI> builder().putAll(regionMap)
.build().inverse();
Region region = map.get(currentUri); Region region = map.get(currentUri);
assert region != null : currentUri + " not in " + map; assert region != null : currentUri + " not in " + map;
return region; return region;

View File

@ -18,11 +18,13 @@
*/ */
package org.jclouds.aws.ec2.domain; package org.jclouds.aws.ec2.domain;
import com.google.common.collect.*;
import com.google.inject.internal.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.internal.Nullable;
/** /**
* Defines the mapping of volumes for * Defines the mapping of volumes for
* {@link org.jclouds.aws.ec2.services.InstanceClient#setBlockDeviceMappingForInstanceInRegion}. * {@link org.jclouds.aws.ec2.services.InstanceClient#setBlockDeviceMappingForInstanceInRegion}.
@ -31,8 +33,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public class BlockDeviceMapping { public class BlockDeviceMapping {
private final Multimap<String, RunningInstance.EbsBlockDevice> ebsBlockDevices = private final Multimap<String, RunningInstance.EbsBlockDevice> ebsBlockDevices = LinkedHashMultimap
LinkedHashMultimap.create(); .create();
public BlockDeviceMapping() { public BlockDeviceMapping() {
} }
@ -41,6 +43,7 @@ public class BlockDeviceMapping {
* Creates block device mapping from the list of {@link RunningInstance.EbsBlockDevice devices}. * Creates block device mapping from the list of {@link RunningInstance.EbsBlockDevice devices}.
* *
* This method copies the values of the list. * This method copies the values of the list.
*
* @param ebsBlockDevices * @param ebsBlockDevices
* devices to be changed for the volume. This cannot be null. * devices to be changed for the volume. This cannot be null.
*/ */
@ -51,18 +54,22 @@ public class BlockDeviceMapping {
/** /**
* Adds a {@link RunningInstance.EbsBlockDevice} to the mapping. * Adds a {@link RunningInstance.EbsBlockDevice} to the mapping.
* @param deviceName name of the device to apply the mapping. Can be null. *
* @param deviceName
* name of the device to apply the mapping. Can be null.
* @param ebsBlockDevice * @param ebsBlockDevice
* ebsBlockDevice to be added. This cannot be null. * ebsBlockDevice to be added. This cannot be null.
* @return the same instance for method chaining purposes * @return the same instance for method chaining purposes
*/ */
public BlockDeviceMapping addEbsBlockDevice(@Nullable String deviceName, RunningInstance.EbsBlockDevice ebsBlockDevice) { public BlockDeviceMapping addEbsBlockDevice(@Nullable String deviceName,
RunningInstance.EbsBlockDevice ebsBlockDevice) {
this.ebsBlockDevices.put(deviceName, checkNotNull(ebsBlockDevice, this.ebsBlockDevices.put(deviceName, checkNotNull(ebsBlockDevice,
/* or throw */"EbsBlockDevice can't be null")); /* or throw */"EbsBlockDevice can't be null"));
return this; return this;
} }
public Multimap<String, RunningInstance.EbsBlockDevice> getEbsBlockDevices() { public Multimap<String, RunningInstance.EbsBlockDevice> getEbsBlockDevices() {
return ImmutableMultimap.copyOf(ebsBlockDevices); return ImmutableMultimap.<String, RunningInstance.EbsBlockDevice> builder().putAll(
ebsBlockDevices).build();
} }
} }

View File

@ -128,7 +128,7 @@ public class S3RestClientModule extends AbstractModule {
@Singleton @Singleton
@S3 @S3
Region getDefaultRegion(@S3 URI uri, @S3 Map<Region, URI> map) { Region getDefaultRegion(@S3 URI uri, @S3 Map<Region, URI> map) {
return ImmutableBiMap.copyOf(map).inverse().get(uri); return ImmutableBiMap.<Region, URI> builder().putAll(map).build().inverse().get(uri);
} }
@Provides @Provides

View File

@ -110,7 +110,7 @@ public class SQSRestClientModule extends AbstractModule {
@Singleton @Singleton
@SQS @SQS
Region getDefaultRegion(@SQS URI uri, @SQS Map<Region, URI> map) { Region getDefaultRegion(@SQS URI uri, @SQS Map<Region, URI> map) {
return ImmutableBiMap.copyOf(map).inverse().get(uri); return ImmutableBiMap.<Region, URI> builder().putAll(map).build().inverse().get(uri);
} }
@Provides @Provides

View File

@ -49,7 +49,7 @@ public class QueueHandler extends ParseSax.HandlerWithResult<Queue> {
@Inject @Inject
QueueHandler(Provider<UriBuilder> uriBuilderProvider, @SQS Map<Region, URI> regionMap) { QueueHandler(Provider<UriBuilder> uriBuilderProvider, @SQS Map<Region, URI> regionMap) {
this.uriBuilderProvider = uriBuilderProvider; this.uriBuilderProvider = uriBuilderProvider;
this.regionBiMap = ImmutableBiMap.copyOf(regionMap); this.regionBiMap = ImmutableBiMap.<Region, URI> builder().putAll(regionMap).build();
} }
public Queue getResult() { public Queue getResult() {

View File

@ -46,7 +46,7 @@ public class BaseRegexQueueHandler {
@Inject @Inject
protected BaseRegexQueueHandler(Map<Region, URI> regionMap) { protected BaseRegexQueueHandler(Map<Region, URI> regionMap) {
this.uriToRegion = ImmutableBiMap.copyOf(regionMap).inverse(); this.uriToRegion = ImmutableBiMap.<Region, URI> builder().putAll(regionMap).build().inverse();
} }
public Set<Queue> parse(String in) { public Set<Queue> parse(String in) {

View File

@ -43,6 +43,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@SuppressWarnings("deprecation")
@Singleton @Singleton
public class SyncProxy implements InvocationHandler { public class SyncProxy implements InvocationHandler {
@ -60,7 +61,7 @@ public class SyncProxy implements InvocationHandler {
private final Map<Method, Method> methodMap; private final Map<Method, Method> methodMap;
private final Map<Method, Method> syncMethodMap; private final Map<Method, Method> syncMethodMap;
private final Map<Method, Long> timeoutMap; private final Map<Method, Long> timeoutMap;
private static final Set<Method> objectMethods = ImmutableSet.copyOf(Object.class.getMethods()); private static final Set<Method> objectMethods = ImmutableSet.of(Object.class.getMethods());
@Inject @Inject
public SyncProxy(Class<?> declaring, Object delegate) throws SecurityException, public SyncProxy(Class<?> declaring, Object delegate) throws SecurityException,

View File

@ -18,14 +18,14 @@
*/ */
package org.jclouds.gogrid.domain; package org.jclouds.gogrid.domain;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.primitives.Longs;
import com.google.gson.annotations.SerializedName;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import com.google.common.primitives.Longs;
import com.google.gson.annotations.SerializedName;
/** /**
* Represents any job in GoGrid system * Represents any job in GoGrid system
* (jobs include server creation, stopping, etc) * (jobs include server creation, stopping, etc)
@ -47,7 +47,7 @@ public class Job implements Comparable<Job> {
private JobState currentState; private JobState currentState;
private int attempts; private int attempts;
private String owner; private String owner;
private SortedSet<JobProperties> history; private Set<JobProperties> history;
@SerializedName("detail") /*NOTE: as of Feb 28, 10, @SerializedName("detail") /*NOTE: as of Feb 28, 10,
there is a contradiction b/w the name in there is a contradiction b/w the name in
documentation (details) and actual param documentation (details) and actual param
@ -108,8 +108,8 @@ public class Job implements Comparable<Job> {
return owner; return owner;
} }
public SortedSet<JobProperties> getHistory() { public Set<JobProperties> getHistory() {
return ImmutableSortedSet.copyOf(history); return history;
} }
public Map<String, String> getDetails() { public Map<String, String> getDetails() {

View File

@ -18,12 +18,11 @@
*/ */
package org.jclouds.gogrid.domain; package org.jclouds.gogrid.domain;
import com.google.common.collect.ImmutableSortedSet; import java.util.Set;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.SortedSet;
/** /**
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@ -35,7 +34,7 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
@SerializedName("virtualip") @SerializedName("virtualip")
private IpPortPair virtualIp; private IpPortPair virtualIp;
@SerializedName("realiplist") @SerializedName("realiplist")
private SortedSet<IpPortPair> realIpList; private Set<IpPortPair> realIpList;
private LoadBalancerType type; private LoadBalancerType type;
private LoadBalancerPersistenceType persistence; private LoadBalancerPersistenceType persistence;
private LoadBalancerOs os; private LoadBalancerOs os;
@ -48,7 +47,7 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
} }
public LoadBalancer(long id, String name, String description, public LoadBalancer(long id, String name, String description,
IpPortPair virtualIp, SortedSet<IpPortPair> realIpList, LoadBalancerType type, IpPortPair virtualIp, Set<IpPortPair> realIpList, LoadBalancerType type,
LoadBalancerPersistenceType persistence, LoadBalancerOs os, LoadBalancerPersistenceType persistence, LoadBalancerOs os,
LoadBalancerState state) { LoadBalancerState state) {
this.id = id; this.id = id;
@ -78,8 +77,8 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
return virtualIp; return virtualIp;
} }
public SortedSet<IpPortPair> getRealIpList() { public Set<IpPortPair> getRealIpList() {
return ImmutableSortedSet.copyOf(realIpList); return realIpList;
} }
public LoadBalancerType getType() { public LoadBalancerType getType() {

View File

@ -23,13 +23,12 @@
*/ */
package org.jclouds.gogrid.domain; package org.jclouds.gogrid.domain;
import com.google.common.collect.ImmutableSortedSet; import java.util.Date;
import java.util.Set;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.SortedSet;
/** /**
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@ -50,7 +49,7 @@ public class ServerImage implements Comparable<ServerImage> {
private Date createdTime; private Date createdTime;
private Date updatedTime; private Date updatedTime;
@SerializedName("billingtokens") @SerializedName("billingtokens")
private SortedSet<BillingToken> billingTokens; private Set<BillingToken> billingTokens;
private Customer owner; private Customer owner;
/** /**
@ -59,11 +58,10 @@ public class ServerImage implements Comparable<ServerImage> {
public ServerImage() { public ServerImage() {
} }
public ServerImage(long id, String name, String friendlyName, public ServerImage(long id, String name, String friendlyName, String description, Option os,
String description, Option os, Option architecture, Option architecture, ServerImageType type, ServerImageState state, double price,
ServerImageType type, ServerImageState state, double price, String location, String location, boolean active, boolean aPublic, Date createdTime, Date updatedTime,
boolean active, boolean aPublic, Date createdTime, Set<BillingToken> billingTokens, Customer owner) {
Date updatedTime, SortedSet<BillingToken> billingTokens, Customer owner) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.friendlyName = friendlyName; this.friendlyName = friendlyName;
@ -138,8 +136,8 @@ public class ServerImage implements Comparable<ServerImage> {
return updatedTime; return updatedTime;
} }
public SortedSet<BillingToken> getBillingTokens() { public Set<BillingToken> getBillingTokens() {
return ImmutableSortedSet.copyOf(billingTokens); return billingTokens;
} }
public Customer getOwner() { public Customer getOwner() {
@ -148,28 +146,48 @@ public class ServerImage implements Comparable<ServerImage> {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o)
if (o == null || getClass() != o.getClass()) return false; return true;
if (o == null || getClass() != o.getClass())
return false;
ServerImage that = (ServerImage) o; ServerImage that = (ServerImage) o;
if (id != that.id) return false; if (id != that.id)
if (isActive != that.isActive) return false; return false;
if (isPublic != that.isPublic) return false; if (isActive != that.isActive)
if (Double.compare(that.price, price) != 0) return false; return false;
if (architecture != null ? !architecture.equals(that.architecture) : that.architecture != null) return false; if (isPublic != that.isPublic)
if (billingTokens != null ? !billingTokens.equals(that.billingTokens) : that.billingTokens != null) return false;
if (Double.compare(that.price, price) != 0)
return false;
if (architecture != null ? !architecture.equals(that.architecture)
: that.architecture != null)
return false;
if (billingTokens != null ? !billingTokens.equals(that.billingTokens)
: that.billingTokens != null)
return false;
if (!createdTime.equals(that.createdTime))
return false;
if (description != null ? !description.equals(that.description) : that.description != null)
return false;
if (friendlyName != null ? !friendlyName.equals(that.friendlyName)
: that.friendlyName != null)
return false;
if (location != null ? !location.equals(that.location) : that.location != null)
return false;
if (!name.equals(that.name))
return false;
if (!os.equals(that.os))
return false;
if (owner != null ? !owner.equals(that.owner) : that.owner != null)
return false;
if (!state.equals(that.state))
return false;
if (!type.equals(that.type))
return false;
if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null)
return false; return false;
if (!createdTime.equals(that.createdTime)) return false;
if (description != null ? !description.equals(that.description) : that.description != null) return false;
if (friendlyName != null ? !friendlyName.equals(that.friendlyName) : that.friendlyName != null) return false;
if (location != null ? !location.equals(that.location) : that.location != null) return false;
if (!name.equals(that.name)) return false;
if (!os.equals(that.os)) return false;
if (owner != null ? !owner.equals(that.owner) : that.owner != null) return false;
if (!state.equals(that.state)) return false;
if (!type.equals(that.type)) return false;
if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) return false;
return true; return true;
} }
@ -204,23 +222,11 @@ public class ServerImage implements Comparable<ServerImage> {
@Override @Override
public String toString() { public String toString() {
return "ServerImage{" + return "ServerImage{" + "id=" + id + ", name='" + name + '\'' + ", friendlyName='"
"id=" + id + + friendlyName + '\'' + ", description='" + description + '\'' + ", os=" + os
", name='" + name + '\'' + + ", architecture=" + architecture + ", type=" + type + ", state=" + state
", friendlyName='" + friendlyName + '\'' + + ", price=" + price + ", location='" + location + '\'' + ", isActive=" + isActive
", description='" + description + '\'' + + ", isPublic=" + isPublic + ", createdTime=" + createdTime + ", updatedTime="
", os=" + os + + updatedTime + ", billingTokens=" + billingTokens + ", owner=" + owner + '}';
", architecture=" + architecture +
", type=" + type +
", state=" + state +
", price=" + price +
", location='" + location + '\'' +
", isActive=" + isActive +
", isPublic=" + isPublic +
", createdTime=" + createdTime +
", updatedTime=" + updatedTime +
", billingTokens=" + billingTokens +
", owner=" + owner +
'}';
} }
} }