diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java index 6dd03a491a..b2d1a11b8c 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/config/EC2RestClientModule.java @@ -116,7 +116,8 @@ public class EC2RestClientModule extends AbstractModule { @Singleton @EC2 Region provideCurrentRegion(@EC2 Map regionMap, @EC2 URI currentUri) { - ImmutableBiMap map = ImmutableBiMap.copyOf(regionMap).inverse(); + ImmutableBiMap map = ImmutableBiMap. builder().putAll(regionMap) + .build().inverse(); Region region = map.get(currentUri); assert region != null : currentUri + " not in " + map; return region; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/BlockDeviceMapping.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/BlockDeviceMapping.java index d2b1685c8d..31243fe88c 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/BlockDeviceMapping.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/BlockDeviceMapping.java @@ -18,51 +18,58 @@ */ 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 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 * {@link org.jclouds.aws.ec2.services.InstanceClient#setBlockDeviceMappingForInstanceInRegion}. - * + * * @author Oleksiy Yarmula */ public class BlockDeviceMapping { - private final Multimap ebsBlockDevices = - LinkedHashMultimap.create(); + private final Multimap ebsBlockDevices = LinkedHashMultimap + .create(); - public BlockDeviceMapping() { - } + public BlockDeviceMapping() { + } - /** - * Creates block device mapping from the list of {@link RunningInstance.EbsBlockDevice devices}. - * - * This method copies the values of the list. - * @param ebsBlockDevices - * devices to be changed for the volume. This cannot be null. - */ - public BlockDeviceMapping(Multimap ebsBlockDevices) { - this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, - /*or throw*/ "EbsBlockDevices can't be null")); - } + /** + * Creates block device mapping from the list of {@link RunningInstance.EbsBlockDevice devices}. + * + * This method copies the values of the list. + * + * @param ebsBlockDevices + * devices to be changed for the volume. This cannot be null. + */ + public BlockDeviceMapping(Multimap ebsBlockDevices) { + this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, + /* or throw */"EbsBlockDevices can't be null")); + } - /** - * Adds a {@link RunningInstance.EbsBlockDevice} to the mapping. - * @param deviceName name of the device to apply the mapping. Can be null. - * @param ebsBlockDevice - * ebsBlockDevice to be added. This cannot be null. - * @return the same instance for method chaining purposes - */ - public BlockDeviceMapping addEbsBlockDevice(@Nullable String deviceName, RunningInstance.EbsBlockDevice ebsBlockDevice) { - this.ebsBlockDevices.put(deviceName, checkNotNull(ebsBlockDevice, - /*or throw*/ "EbsBlockDevice can't be null")); - return this; - } + /** + * Adds a {@link RunningInstance.EbsBlockDevice} to the mapping. + * + * @param deviceName + * name of the device to apply the mapping. Can be null. + * @param ebsBlockDevice + * ebsBlockDevice to be added. This cannot be null. + * @return the same instance for method chaining purposes + */ + public BlockDeviceMapping addEbsBlockDevice(@Nullable String deviceName, + RunningInstance.EbsBlockDevice ebsBlockDevice) { + this.ebsBlockDevices.put(deviceName, checkNotNull(ebsBlockDevice, + /* or throw */"EbsBlockDevice can't be null")); + return this; + } - public Multimap getEbsBlockDevices() { - return ImmutableMultimap.copyOf(ebsBlockDevices); - } + public Multimap getEbsBlockDevices() { + return ImmutableMultimap. builder().putAll( + ebsBlockDevices).build(); + } } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/config/S3RestClientModule.java b/aws/core/src/main/java/org/jclouds/aws/s3/config/S3RestClientModule.java index 2d3b86b1c0..1b9e465163 100755 --- a/aws/core/src/main/java/org/jclouds/aws/s3/config/S3RestClientModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/config/S3RestClientModule.java @@ -128,7 +128,7 @@ public class S3RestClientModule extends AbstractModule { @Singleton @S3 Region getDefaultRegion(@S3 URI uri, @S3 Map map) { - return ImmutableBiMap.copyOf(map).inverse().get(uri); + return ImmutableBiMap. builder().putAll(map).build().inverse().get(uri); } @Provides diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSRestClientModule.java b/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSRestClientModule.java index 9e46f3ba42..e35d82037c 100755 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSRestClientModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSRestClientModule.java @@ -110,7 +110,7 @@ public class SQSRestClientModule extends AbstractModule { @Singleton @SQS Region getDefaultRegion(@SQS URI uri, @SQS Map map) { - return ImmutableBiMap.copyOf(map).inverse().get(uri); + return ImmutableBiMap. builder().putAll(map).build().inverse().get(uri); } @Provides diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/xml/QueueHandler.java b/aws/core/src/main/java/org/jclouds/aws/sqs/xml/QueueHandler.java index 3bd9a654a4..5a00c87db6 100644 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/xml/QueueHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/xml/QueueHandler.java @@ -49,7 +49,7 @@ public class QueueHandler extends ParseSax.HandlerWithResult { @Inject QueueHandler(Provider uriBuilderProvider, @SQS Map regionMap) { this.uriBuilderProvider = uriBuilderProvider; - this.regionBiMap = ImmutableBiMap.copyOf(regionMap); + this.regionBiMap = ImmutableBiMap. builder().putAll(regionMap).build(); } public Queue getResult() { diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/xml/internal/BaseRegexQueueHandler.java b/aws/core/src/main/java/org/jclouds/aws/sqs/xml/internal/BaseRegexQueueHandler.java index 95e11e755a..d55b1fd5f7 100644 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/xml/internal/BaseRegexQueueHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/xml/internal/BaseRegexQueueHandler.java @@ -46,7 +46,7 @@ public class BaseRegexQueueHandler { @Inject protected BaseRegexQueueHandler(Map regionMap) { - this.uriToRegion = ImmutableBiMap.copyOf(regionMap).inverse(); + this.uriToRegion = ImmutableBiMap. builder().putAll(regionMap).build().inverse(); } public Set parse(String in) { diff --git a/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java b/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java index 7c8c3237f7..08868d90e0 100644 --- a/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java +++ b/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java @@ -43,6 +43,7 @@ import com.google.common.util.concurrent.ListenableFuture; * * @author Adrian Cole */ +@SuppressWarnings("deprecation") @Singleton public class SyncProxy implements InvocationHandler { @@ -60,7 +61,7 @@ public class SyncProxy implements InvocationHandler { private final Map methodMap; private final Map syncMethodMap; private final Map timeoutMap; - private static final Set objectMethods = ImmutableSet.copyOf(Object.class.getMethods()); + private static final Set objectMethods = ImmutableSet.of(Object.class.getMethods()); @Inject public SyncProxy(Class declaring, Object delegate) throws SecurityException, diff --git a/gogrid/src/main/java/org/jclouds/gogrid/domain/Job.java b/gogrid/src/main/java/org/jclouds/gogrid/domain/Job.java index 0d252e17c9..a693fc8887 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/domain/Job.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/domain/Job.java @@ -18,14 +18,14 @@ */ 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.Map; +import java.util.Set; import java.util.SortedSet; +import com.google.common.primitives.Longs; +import com.google.gson.annotations.SerializedName; + /** * Represents any job in GoGrid system * (jobs include server creation, stopping, etc) @@ -47,7 +47,7 @@ public class Job implements Comparable { private JobState currentState; private int attempts; private String owner; - private SortedSet history; + private Set history; @SerializedName("detail") /*NOTE: as of Feb 28, 10, there is a contradiction b/w the name in documentation (details) and actual param @@ -108,8 +108,8 @@ public class Job implements Comparable { return owner; } - public SortedSet getHistory() { - return ImmutableSortedSet.copyOf(history); + public Set getHistory() { + return history; } public Map getDetails() { diff --git a/gogrid/src/main/java/org/jclouds/gogrid/domain/LoadBalancer.java b/gogrid/src/main/java/org/jclouds/gogrid/domain/LoadBalancer.java index b1b64f0b23..5b03a9dac9 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/domain/LoadBalancer.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/domain/LoadBalancer.java @@ -18,12 +18,11 @@ */ package org.jclouds.gogrid.domain; -import com.google.common.collect.ImmutableSortedSet; +import java.util.Set; + import com.google.common.primitives.Longs; import com.google.gson.annotations.SerializedName; -import java.util.SortedSet; - /** * @author Oleksiy Yarmula */ @@ -35,7 +34,7 @@ public class LoadBalancer implements Comparable { @SerializedName("virtualip") private IpPortPair virtualIp; @SerializedName("realiplist") - private SortedSet realIpList; + private Set realIpList; private LoadBalancerType type; private LoadBalancerPersistenceType persistence; private LoadBalancerOs os; @@ -48,7 +47,7 @@ public class LoadBalancer implements Comparable { } public LoadBalancer(long id, String name, String description, - IpPortPair virtualIp, SortedSet realIpList, LoadBalancerType type, + IpPortPair virtualIp, Set realIpList, LoadBalancerType type, LoadBalancerPersistenceType persistence, LoadBalancerOs os, LoadBalancerState state) { this.id = id; @@ -78,8 +77,8 @@ public class LoadBalancer implements Comparable { return virtualIp; } - public SortedSet getRealIpList() { - return ImmutableSortedSet.copyOf(realIpList); + public Set getRealIpList() { + return realIpList; } public LoadBalancerType getType() { diff --git a/gogrid/src/main/java/org/jclouds/gogrid/domain/ServerImage.java b/gogrid/src/main/java/org/jclouds/gogrid/domain/ServerImage.java index af52f91395..1cfba9fb1f 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/domain/ServerImage.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/domain/ServerImage.java @@ -23,204 +23,210 @@ */ 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.gson.annotations.SerializedName; -import java.util.Date; -import java.util.SortedSet; - /** * @author Oleksiy Yarmula */ public class ServerImage implements Comparable { - private long id; - private String name; - private String friendlyName; - private String description; - private Option os; - private Option architecture; - private ServerImageType type; - private ServerImageState state; - private double price; - private String location; - private boolean isActive; - private boolean isPublic; - private Date createdTime; - private Date updatedTime; - @SerializedName("billingtokens") - private SortedSet billingTokens; - private Customer owner; + private long id; + private String name; + private String friendlyName; + private String description; + private Option os; + private Option architecture; + private ServerImageType type; + private ServerImageState state; + private double price; + private String location; + private boolean isActive; + private boolean isPublic; + private Date createdTime; + private Date updatedTime; + @SerializedName("billingtokens") + private Set billingTokens; + private Customer owner; - /** - * A no-args constructor is required for deserialization - */ - public ServerImage() { - } + /** + * A no-args constructor is required for deserialization + */ + public ServerImage() { + } - public ServerImage(long id, String name, String friendlyName, - String description, Option os, Option architecture, - ServerImageType type, ServerImageState state, double price, String location, - boolean active, boolean aPublic, Date createdTime, - Date updatedTime, SortedSet billingTokens, Customer owner) { - this.id = id; - this.name = name; - this.friendlyName = friendlyName; - this.description = description; - this.os = os; - this.architecture = architecture; - this.type = type; - this.state = state; - this.price = price; - this.location = location; - isActive = active; - isPublic = aPublic; - this.createdTime = createdTime; - this.updatedTime = updatedTime; - this.billingTokens = billingTokens; - this.owner = owner; - } + public ServerImage(long id, String name, String friendlyName, String description, Option os, + Option architecture, ServerImageType type, ServerImageState state, double price, + String location, boolean active, boolean aPublic, Date createdTime, Date updatedTime, + Set billingTokens, Customer owner) { + this.id = id; + this.name = name; + this.friendlyName = friendlyName; + this.description = description; + this.os = os; + this.architecture = architecture; + this.type = type; + this.state = state; + this.price = price; + this.location = location; + isActive = active; + isPublic = aPublic; + this.createdTime = createdTime; + this.updatedTime = updatedTime; + this.billingTokens = billingTokens; + this.owner = owner; + } - public long getId() { - return id; - } + public long getId() { + return id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public String getFriendlyName() { - return friendlyName; - } + public String getFriendlyName() { + return friendlyName; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public Option getOs() { - return os; - } + public Option getOs() { + return os; + } - public Option getArchitecture() { - return architecture; - } + public Option getArchitecture() { + return architecture; + } - public ServerImageType getType() { - return type; - } + public ServerImageType getType() { + return type; + } - public ServerImageState getState() { - return state; - } + public ServerImageState getState() { + return state; + } - public double getPrice() { - return price; - } + public double getPrice() { + return price; + } - public String getLocation() { - return location; - } + public String getLocation() { + return location; + } - public boolean isActive() { - return isActive; - } + public boolean isActive() { + return isActive; + } - public boolean isPublic() { - return isPublic; - } + public boolean isPublic() { + return isPublic; + } - public Date getCreatedTime() { - return createdTime; - } + public Date getCreatedTime() { + return createdTime; + } - public Date getUpdatedTime() { - return updatedTime; - } + public Date getUpdatedTime() { + return updatedTime; + } - public SortedSet getBillingTokens() { - return ImmutableSortedSet.copyOf(billingTokens); - } + public Set getBillingTokens() { + return billingTokens; + } - public Customer getOwner() { - return owner; - } + public Customer getOwner() { + return owner; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + @Override + public boolean equals(Object o) { + if (this == o) + 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 (isActive != that.isActive) return false; - if (isPublic != that.isPublic) 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; + if (id != that.id) + return false; + if (isActive != that.isActive) + return false; + if (isPublic != that.isPublic) + 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 true; - } + return true; + } - @Override - public int hashCode() { - int result; - long temp; - result = (int) (id ^ (id >>> 32)); - result = 31 * result + name.hashCode(); - result = 31 * result + (friendlyName != null ? friendlyName.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + os.hashCode(); - result = 31 * result + type.hashCode(); - result = 31 * result + state.hashCode(); - temp = price != +0.0d ? Double.doubleToLongBits(price) : 0L; - result = 31 * result + (int) (temp ^ (temp >>> 32)); - result = 31 * result + (location != null ? location.hashCode() : 0); - result = 31 * result + (isActive ? 1 : 0); - result = 31 * result + (isPublic ? 1 : 0); - result = 31 * result + createdTime.hashCode(); - result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0); - result = 31 * result + (billingTokens != null ? billingTokens.hashCode() : 0); - result = 31 * result + (owner != null ? owner.hashCode() : 0); - return result; - } + @Override + public int hashCode() { + int result; + long temp; + result = (int) (id ^ (id >>> 32)); + result = 31 * result + name.hashCode(); + result = 31 * result + (friendlyName != null ? friendlyName.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + os.hashCode(); + result = 31 * result + type.hashCode(); + result = 31 * result + state.hashCode(); + temp = price != +0.0d ? Double.doubleToLongBits(price) : 0L; + result = 31 * result + (int) (temp ^ (temp >>> 32)); + result = 31 * result + (location != null ? location.hashCode() : 0); + result = 31 * result + (isActive ? 1 : 0); + result = 31 * result + (isPublic ? 1 : 0); + result = 31 * result + createdTime.hashCode(); + result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0); + result = 31 * result + (billingTokens != null ? billingTokens.hashCode() : 0); + result = 31 * result + (owner != null ? owner.hashCode() : 0); + return result; + } - @Override - public int compareTo(ServerImage o) { - return Longs.compare(id, o.getId()); - } + @Override + public int compareTo(ServerImage o) { + return Longs.compare(id, o.getId()); + } - @Override - public String toString() { - return "ServerImage{" + - "id=" + id + - ", name='" + name + '\'' + - ", friendlyName='" + friendlyName + '\'' + - ", description='" + description + '\'' + - ", os=" + os + - ", architecture=" + architecture + - ", type=" + type + - ", state=" + state + - ", price=" + price + - ", location='" + location + '\'' + - ", isActive=" + isActive + - ", isPublic=" + isPublic + - ", createdTime=" + createdTime + - ", updatedTime=" + updatedTime + - ", billingTokens=" + billingTokens + - ", owner=" + owner + - '}'; - } + @Override + public String toString() { + return "ServerImage{" + "id=" + id + ", name='" + name + '\'' + ", friendlyName='" + + friendlyName + '\'' + ", description='" + description + '\'' + ", os=" + os + + ", architecture=" + architecture + ", type=" + type + ", state=" + state + + ", price=" + price + ", location='" + location + '\'' + ", isActive=" + isActive + + ", isPublic=" + isPublic + ", createdTime=" + createdTime + ", updatedTime=" + + updatedTime + ", billingTokens=" + billingTokens + ", owner=" + owner + '}'; + } }