diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java index f81b1edb4b..041fc22fd7 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java @@ -19,6 +19,7 @@ package org.jclouds.atmos.domain.internal; import java.net.URI; +import java.util.Date; import org.jclouds.atmos.domain.MutableContentMetadata; import org.jclouds.io.ContentMetadataBuilder; @@ -154,8 +155,13 @@ public class DelegatingMutableContentMetadata implements MutableContentMetadata } @Override - public void setPropertiesFromHttpHeaders(Multimap headers) { - delegate.setPropertiesFromHttpHeaders(headers); + public void setExpires(Date expires) { + delegate.setExpires(expires); + } + + @Override + public Date getExpires() { + return delegate.getExpires(); } @Override diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java index 0fe81361d1..c45336cdd0 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ReturnEndpointIfAlreadyExists.java @@ -19,7 +19,6 @@ package org.jclouds.atmos.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.util.Throwables2.propagateOrNull; import java.net.URI; @@ -30,6 +29,7 @@ import org.jclouds.rest.InvocationContext; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; +import com.google.common.base.Throwables; /** * @@ -44,7 +44,7 @@ public class ReturnEndpointIfAlreadyExists implements Function, if (checkNotNull(from, "exception") instanceof KeyAlreadyExistsException) { return endpoint; } - return URI.class.cast(propagateOrNull(from)); + throw Throwables.propagate(from); } @Override diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java index 79555eae05..7f262289ab 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java @@ -21,6 +21,9 @@ package org.jclouds.atmos.blobstore; import static org.testng.Assert.assertEquals; import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import org.jclouds.apis.ApiMetadata; import org.jclouds.atmos.AtmosApiMetadata; @@ -32,6 +35,7 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; +import org.jclouds.io.ContentMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -89,6 +93,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest deletePath(String path) { if (path.indexOf('/') == path.length() - 1) { // chop off the trailing slash - return Futures.compose(blobStore.deleteContainerImpl(path.substring(0, path.length() - 1)), + return Futures.compose(blobStore.deleteContainerIfEmpty(path.substring(0, path.length() - 1)), new Function() { public Void apply(Boolean from) { diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java index 03b7ee2982..89c64ff620 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java @@ -45,13 +45,13 @@ public class BindBackupScheduleToJsonPayload extends BindToJsonPayload { } @Override - public R bindToRequest(R request, Map postParams) { + public R bindToRequest(R request, Map postParams) { throw new IllegalStateException("Replace Backup Schedule needs an BackupSchedule object, not a Map"); } @Override public R bindToRequest(R request, Object toBind) { checkArgument(toBind instanceof BackupSchedule, "this binder is only valid for BackupSchedules!"); - return super.bindToRequest(request, ImmutableMap.of("backupSchedule", toBind)); + return super.bindToRequest(request, (Object) ImmutableMap.of("backupSchedule", toBind)); } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index 9747eca77f..2810f6012a 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -22,10 +22,12 @@ import java.util.Map; import javax.inject.Singleton; +import org.jclouds.cloudservers.compute.extensions.CloudServersImageExtension; import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage; import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem; import org.jclouds.cloudservers.compute.functions.FlavorToHardware; import org.jclouds.cloudservers.compute.functions.ServerToNodeMetadata; +import org.jclouds.cloudservers.compute.predicates.GetImageWhenStatusActivePredicateWithResult; import org.jclouds.cloudservers.compute.strategy.CloudServersComputeServiceAdapter; import org.jclouds.cloudservers.domain.Flavor; import org.jclouds.cloudservers.domain.Server; @@ -37,13 +39,17 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.extensions.ImageExtension; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; +import org.jclouds.predicates.PredicateWithResult; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; +import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -77,6 +83,12 @@ public class CloudServersComputeServiceContextModule extends // we aren't converting location from a provider-specific type bind(new TypeLiteral>() { }).to((Class) IdentityFunction.class); + + bind(new TypeLiteral() { + }).to(CloudServersImageExtension.class); + + bind(new TypeLiteral>() { + }).to(GetImageWhenStatusActivePredicateWithResult.class); } @@ -112,6 +124,10 @@ public class CloudServersComputeServiceContextModule extends Map provideServerToNodeState() { return serverToNodeState; } - + + @Override + protected Optional provideImageExtension(Injector i) { + return Optional.of(i.getInstance(ImageExtension.class)); + } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtension.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtension.java new file mode 100644 index 0000000000..946e6e1017 --- /dev/null +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtension.java @@ -0,0 +1,120 @@ +/** + * 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.cloudservers.compute.extensions; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import java.util.NoSuchElementException; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.Constants; +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.cloudservers.domain.Server; +import org.jclouds.compute.domain.CloneImageTemplate; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.ImageTemplate; +import org.jclouds.compute.domain.ImageTemplateBuilder; +import org.jclouds.compute.extensions.ImageExtension; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.concurrent.Futures; +import org.jclouds.logging.Logger; +import org.jclouds.predicates.PredicateWithResult; +import org.jclouds.predicates.Retryables; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * CloudServers implementation of {@link ImageExtension} + * + * @author David Alves + * + */ +@Singleton +public class CloudServersImageExtension implements ImageExtension { + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + private final CloudServersClient client; + private final ExecutorService executor; + private final PredicateWithResult imageAvailablePredicate; + @com.google.inject.Inject(optional = true) + @Named("IMAGE_MAX_WAIT") + private long maxWait = 3600; + @com.google.inject.Inject(optional = true) + @Named("IMAGE_WAIT_PERIOD") + private long waitPeriod = 1; + + @Inject + public CloudServersImageExtension(CloudServersClient client, + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, + PredicateWithResult imageAvailablePredicate) { + this.client = checkNotNull(client); + this.executor = userThreads; + this.imageAvailablePredicate = imageAvailablePredicate; + } + + @Override + public ImageTemplate buildImageTemplateFromNode(String name, final String id) { + Server server = client.getServer(Integer.parseInt(id)); + if (server == null) + throw new NoSuchElementException("Cannot find server with id: " + id); + CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build(); + return template; + } + + @Override + public ListenableFuture createImage(ImageTemplate template) { + checkState(template instanceof CloneImageTemplate, + " openstack-nova only supports creating images through cloning."); + CloneImageTemplate cloneTemplate = (CloneImageTemplate) template; + final org.jclouds.cloudservers.domain.Image image = client.createImageFromServer(cloneTemplate.getName(), + Integer.parseInt(cloneTemplate.getSourceNodeId())); + return Futures.makeListenable(executor.submit(new Callable() { + @Override + public Image call() throws Exception { + return Retryables.retryGettingResultOrFailing(imageAvailablePredicate, image.getId(), maxWait, waitPeriod, + TimeUnit.SECONDS, "Image was not created within the time limit, Giving up! [Limit: " + maxWait + + " secs.]"); + } + }), executor); + + } + + @Override + public boolean deleteImage(String id) { + try { + this.client.deleteImage(Integer.parseInt(id)); + } catch (Exception e) { + return false; + } + return true; + } + +} diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java index 125c750f30..a161ad4aa3 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java @@ -19,6 +19,7 @@ package org.jclouds.cloudservers.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue; import java.util.Map; import java.util.NoSuchElementException; @@ -111,7 +112,7 @@ public class ServerToNodeMetadata implements Function { builder.hostname(from.getName()); builder.location(new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()).description( from.getHostId()).parent(location.get()).build()); - builder.userMetadata(from.getMetadata()); + addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); builder.imageId(from.getImageId() + ""); builder.operatingSystem(parseOperatingSystem(from)); diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/predicates/GetImageWhenStatusActivePredicateWithResult.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/predicates/GetImageWhenStatusActivePredicateWithResult.java new file mode 100644 index 0000000000..8f71f12361 --- /dev/null +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/predicates/GetImageWhenStatusActivePredicateWithResult.java @@ -0,0 +1,99 @@ +/** + * 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.cloudservers.compute.predicates; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; + +import org.jclouds.cloudservers.CloudServersClient; +import org.jclouds.cloudservers.options.ListOptions; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.logging.Logger; +import org.jclouds.predicates.PredicateWithResult; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; + +/** + * + * @author David Alves + * + */ +public final class GetImageWhenStatusActivePredicateWithResult implements PredicateWithResult { + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + private final CloudServersClient client; + private final Function cloudserversImageToImage; + private org.jclouds.cloudservers.domain.Image result; + private RuntimeException lastFailure; + + @Inject + public GetImageWhenStatusActivePredicateWithResult(CloudServersClient client, + Function cloudserversImageToImage) { + this.client = client; + this.cloudserversImageToImage = cloudserversImageToImage; + } + + @Override + public boolean apply(Integer input) { + result = checkNotNull(findImage(input)); + switch (result.getStatus()) { + case ACTIVE: + logger.info("<< Image %s is available for use. %s", input, result); + return true; + case QUEUED: + case PREPARING: + case SAVING: + logger.debug("<< Image %s is not available yet. %s", input, result); + return false; + default: + lastFailure = new IllegalStateException("Image " + input + " was not created. " + result); + throw lastFailure; + } + } + + @Override + public Image getResult() { + return cloudserversImageToImage.apply(result); + } + + @Override + public Throwable getLastFailure() { + return lastFailure; + } + + private org.jclouds.cloudservers.domain.Image findImage(final int id) { + return Iterables.tryFind(client.listImages(new ListOptions().withDetails()), + new Predicate() { + @Override + public boolean apply(org.jclouds.cloudservers.domain.Image input) { + return input.getId() == id; + } + }).orNull(); + + } +} \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersComputeServiceAdapter.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersComputeServiceAdapter.java index 4ff7c642f5..df7a956be2 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersComputeServiceAdapter.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/strategy/CloudServersComputeServiceAdapter.java @@ -21,6 +21,7 @@ package org.jclouds.cloudservers.compute.strategy; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withMetadata; import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails; +import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue; import javax.inject.Inject; import javax.inject.Singleton; @@ -59,11 +60,13 @@ public class CloudServersComputeServiceAdapter implements ComputeServiceAdapter< Template template) { Server server = client .createServer(name, Integer.parseInt(template.getImage().getProviderId()), Integer.parseInt(template - .getHardware().getProviderId()), withMetadata(template.getOptions().getUserMetadata())); + .getHardware().getProviderId()), withMetadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions()))); return new NodeAndInitialCredentials(server, server.getId() + "", LoginCredentials.builder().password( server.getAdminPass()).build()); } + + @Override public Iterable listHardwareProfiles() { diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Image.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Image.java index 77320ede4c..7ed580d302 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Image.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Image.java @@ -138,8 +138,8 @@ public class Image { @Override public String toString() { - return "Image [created=" + created + ", id=" + id + ", name=" + name + ", serverId=" - + serverId + "]"; + return "Image [created=" + created + ", id=" + id + ", name=" + name + ", serverId=" + serverId + ", status=" + + status + "]"; } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java index 9aae773267..db6d2bbb6c 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java @@ -20,6 +20,7 @@ package org.jclouds.cloudservers.domain; import java.util.Map; +import com.google.common.base.Objects; import com.google.common.collect.Maps; /** @@ -109,6 +110,10 @@ public class Server { return imageId; } + public void setName(String name) { + this.name = name; + } + public String getName() { return name; } @@ -141,86 +146,32 @@ public class Server { return status; } + @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((addresses == null) ? 0 : addresses.hashCode()); - result = prime * result + ((adminPass == null) ? 0 : adminPass.hashCode()); - result = prime * result + ((flavorId == null) ? 0 : flavorId.hashCode()); - result = prime * result + ((hostId == null) ? 0 : hostId.hashCode()); - result = prime * result + id; - result = prime * result + ((imageId == null) ? 0 : imageId.hashCode()); - result = prime * result + ((metadata == null) ? 0 : metadata.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((sharedIpGroupId == null) ? 0 : sharedIpGroupId.hashCode()); - return result; + return Objects.hashCode(id, name); } @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Server other = (Server) obj; - if (addresses == null) { - if (other.addresses != null) - return false; - } else if (!addresses.equals(other.addresses)) - return false; - if (adminPass == null) { - if (other.adminPass != null) - return false; - } else if (!adminPass.equals(other.adminPass)) - return false; - if (flavorId == null) { - if (other.flavorId != null) - return false; - } else if (!flavorId.equals(other.flavorId)) - return false; - if (hostId == null) { - if (other.hostId != null) - return false; - } else if (!hostId.equals(other.hostId)) - return false; - if (id != other.id) - return false; - if (imageId == null) { - if (other.imageId != null) - return false; - } else if (!imageId.equals(other.imageId)) - return false; - if (metadata == null) { - if (other.metadata != null) - return false; - } else if (!metadata.equals(other.metadata)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (sharedIpGroupId == null) { - if (other.sharedIpGroupId != null) - return false; - } else if (!sharedIpGroupId.equals(other.sharedIpGroupId)) - return false; - return true; - } - - public void setName(String name) { - this.name = name; + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Server that = Server.class.cast(obj); + return Objects.equal(this.getId(), that.getId()) + && Objects.equal(this.name, that.name); } @Override public String toString() { - return "Server [addresses=" + addresses + ", adminPass=" + adminPass + ", flavorId=" - + flavorId + ", hostId=" + hostId + ", id=" + id + ", imageId=" + imageId - + ", metadata=" + metadata + ", name=" + name + ", sharedIpGroupId=" - + sharedIpGroupId + "]"; + return Objects.toStringHelper("") + .add("id", getId()) + .add("name", name) + .add("addresses", addresses) + .add("flavorId", flavorId) + .add("imageId", imageId) + .add("hostId", hostId) + .add("metadata", metadata) + .add("sharedIpGroupId", sharedIpGroupId).toString(); } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java index 63b947a9c7..180c42aec0 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java @@ -94,10 +94,10 @@ public class CreateServerOptions implements MapBinder { private String publicIp; @Override - public R bindToRequest(R request, Map postParams) { - ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present"), - Integer.parseInt(checkNotNull(postParams.get("imageId"), "imageId parameter not present")), Integer - .parseInt(checkNotNull(postParams.get("flavorId"), "flavorId parameter not present"))); + public R bindToRequest(R request, Map postParams) { + ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present").toString(), + Integer.parseInt(checkNotNull(postParams.get("imageId"), "imageId parameter not present").toString()), + Integer.parseInt(checkNotNull(postParams.get("flavorId"), "flavorId parameter not present").toString())); if (metadata.size() > 0) server.metadata = metadata; if (files.size() > 0) @@ -202,7 +202,7 @@ public class CreateServerOptions implements MapBinder { public static class Builder { /** - * @see CreateServerOptions#withFile(String,byte []) + * @see CreateServerOptions#withFile(String,byte[]) */ public static CreateServerOptions withFile(String path, byte[] contents) { CreateServerOptions options = new CreateServerOptions(); diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java index 9091fb1e26..38ef57a8e0 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java @@ -57,8 +57,8 @@ public class CreateSharedIpGroupOptions implements MapBinder { } @Override - public R bindToRequest(R request, Map postParams) { - SharedIpGroupRequest createRequest = new SharedIpGroupRequest(checkNotNull(postParams.get("name")), serverId); + public R bindToRequest(R request, Map postParams) { + SharedIpGroupRequest createRequest = new SharedIpGroupRequest(checkNotNull(postParams.get("name")).toString(), serverId); return jsonBinder.bindToRequest(request, ImmutableMap.of("sharedIpGroup", createRequest)); } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java index 894176ca89..e9e20525b3 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java @@ -43,7 +43,7 @@ public class RebuildServerOptions implements MapBinder { Integer imageId; @Override - public R bindToRequest(R request, Map postParams) { + public R bindToRequest(R request, Map postParams) { Map image = Maps.newHashMap(); if (imageId != null) image.put("imageId", imageId); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 1dcefe6553..453db3bc55 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -53,6 +53,7 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; +import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; @@ -64,6 +65,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.net.HostAndPort; import com.google.inject.Injector; +import com.google.inject.Module; /** * Tests behavior of {@code CloudServersClient} @@ -603,4 +605,9 @@ public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTes client.deleteSharedIpGroup(sharedIpGroupId); } } + + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java new file mode 100644 index 0000000000..069b680d28 --- /dev/null +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java @@ -0,0 +1,47 @@ +/** + * 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.cloudservers.compute.extensions; + +import org.jclouds.compute.extensions.ImageExtension; +import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.Test; + +import com.google.inject.Module; + +/** + * Live test for cloudservers {@link ImageExtension} implementation + * + * @author David Alves + * + */ +@Test(groups = "live", singleThreaded = true, testName = "CloudServersImageExtensionLiveTest") +public class CloudServersImageExtensionLiveTest extends BaseImageExtensionLiveTest { + + public CloudServersImageExtensionLiveTest() { + provider = "cloudservers"; + } + + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } + +} diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/predicates/GetImageWhenStatusActivePredicateWithResultExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/predicates/GetImageWhenStatusActivePredicateWithResultExpectTest.java new file mode 100644 index 0000000000..e479d22897 --- /dev/null +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/predicates/GetImageWhenStatusActivePredicateWithResultExpectTest.java @@ -0,0 +1,97 @@ +/** + * 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.cloudservers.compute.predicates; + +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; + +import java.net.URI; +import java.util.Map; + +import org.jclouds.cloudservers.internal.BaseCloudServersComputeServiceExpectTest; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.domain.Image; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.predicates.PredicateWithResult; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.net.HttpHeaders; +import com.google.inject.Injector; + +/** + * + * @author David Alves + * + */ +@Test(groups = "unit", testName = "GetImageWhenStatusActivePredicateWithResultExpectTest") +public class GetImageWhenStatusActivePredicateWithResultExpectTest extends + BaseCloudServersComputeServiceExpectTest { + + private final HttpRequest listImagesDetail = HttpRequest + .builder() + .method("GET") + .endpoint( + URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json&now=1257695648897")) + .headers(ImmutableMultimap. builder() + .put(HttpHeaders.ACCEPT, "application/json") + .put("X-Auth-Token", authToken).build()).build(); + + private final HttpResponse listImagesResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/test_list_images_detail_imageextension.json")).build(); + + private final Map requestResponseMap = ImmutableMap. builder() + .put(listImagesDetail, listImagesResponse).put(initialAuth, responseWithAuth).build(); + + public void testReturnsFalseOnQueuedAndSavingAndTrueOnActive() { + Injector injector = requestsSendResponses(requestResponseMap); + PredicateWithResult predicate = injector + .getInstance(GetImageWhenStatusActivePredicateWithResult.class); + assertTrue(predicate.apply(2));// ACTIVE + assertFalse(predicate.apply(743));// SAVING + assertFalse(predicate.apply(744));// QUEUED + assertFalse(predicate.apply(747));// PREPARING + } + + public void testFailsOnOtherStatuses() { + Injector injector = requestsSendResponses(requestResponseMap); + PredicateWithResult predicate = injector + .getInstance(GetImageWhenStatusActivePredicateWithResult.class); + assertTrue(illegalStateExceptionThrown(predicate, 745));// UNRECOGNIZED + assertTrue(illegalStateExceptionThrown(predicate, 746));// UNKNOWN + assertTrue(illegalStateExceptionThrown(predicate, 748));// FAILED + } + + private boolean illegalStateExceptionThrown(PredicateWithResult predicate, Integer id) { + try { + predicate.apply(id); + } catch (IllegalStateException e) { + return true; + } + return false; + } + + @Override + public Injector apply(ComputeServiceContext input) { + return input.utils().injector(); + } + +} diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersComputeServiceExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersComputeServiceExpectTest.java new file mode 100644 index 0000000000..fac67a523c --- /dev/null +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersComputeServiceExpectTest.java @@ -0,0 +1,103 @@ +/** + * 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.cloudservers.internal; + +import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; + +import java.util.Date; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudservers.CloudServersApiMetadata; +import org.jclouds.cloudservers.config.CloudServersRestClientModule; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; +import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest; +import org.jclouds.rest.ConfiguresRestClient; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.inject.Module; + +/** + * + * @author David Alves + * + */ +public abstract class BaseCloudServersComputeServiceExpectTest extends BaseKeystoneRestClientExpectTest implements + Function { + + public BaseCloudServersComputeServiceExpectTest() { + provider = "cloudservers"; + } + + protected static final String CONSTANT_DATE = "2009-11-08T15:54:08.897Z"; + + public static class TestAuthenticationServiceModule extends AuthenticationServiceModule { + @Override + protected void configure() { + super.configure(); + } + } + + @Override + protected Module createModule() { + return new TestCloudServersRestClientModule(); + } + + @ConfiguresRestClient + protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { + + @Override + public Supplier provideCacheBusterDate() { + return new Supplier() { + public Date get() { + return new SimpleDateFormatDateService().iso8601DateParse(CONSTANT_DATE); + } + }; + } + } + + @Override + protected ApiMetadata createApiMetadata() { + return new CloudServersApiMetadata(); + } + + @Override + protected Properties setupProperties() { + Properties overrides = new Properties(); + overrides.setProperty(PROPERTY_REGIONS, "US"); + overrides.setProperty(provider + ".endpoint", endpoint); + return overrides; + } + + @Override + public T createClient(Function fn, Module module, Properties props) { + return apply(createComputeServiceContext(fn, module, props)); + } + + private ComputeServiceContext createComputeServiceContext(Function fn, Module module, + Properties props) { + return createInjector(fn, module, props).getInstance(ComputeServiceContext.class); + } + +} diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateServerOptionsTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateServerOptionsTest.java index 8305566b7e..d0e07cc1f4 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateServerOptionsTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateServerOptionsTest.java @@ -55,7 +55,7 @@ public class CreateServerOptionsTest { private HttpRequest buildRequest(CreateServerOptions options) { injector.injectMembers(options); HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); - options.bindToRequest(request, ImmutableMap.of("name", "foo", "imageId", "1", "flavorId", "2")); + options.bindToRequest(request, ImmutableMap.of("name", "foo", "imageId", "1", "flavorId", "2")); return request; } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptionsTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptionsTest.java index 40838ef4ac..5604526968 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptionsTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptionsTest.java @@ -53,7 +53,7 @@ public class CreateSharedIpGroupOptionsTest { private HttpRequest buildRequest(CreateSharedIpGroupOptions options) { injector.injectMembers(options); HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); - options.bindToRequest(request, ImmutableMap.of("name", "foo")); + options.bindToRequest(request, ImmutableMap.of("name", "foo")); return request; } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/RebuildServerOptionsTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/RebuildServerOptionsTest.java index 42c58151a5..a2cbacc294 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/RebuildServerOptionsTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/options/RebuildServerOptionsTest.java @@ -53,7 +53,7 @@ public class RebuildServerOptionsTest { private HttpRequest buildRequest(RebuildServerOptions options) { injector.injectMembers(options); HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); - options.bindToRequest(request, new HashMap()); + options.bindToRequest(request, new HashMap()); return request; } diff --git a/apis/cloudservers/src/test/resources/test_list_images_detail_imageextension.json b/apis/cloudservers/src/test/resources/test_list_images_detail_imageextension.json new file mode 100644 index 0000000000..e01acb20ba --- /dev/null +++ b/apis/cloudservers/src/test/resources/test_list_images_detail_imageextension.json @@ -0,0 +1,65 @@ +{ + "images" : [ + { + "id" : 2, + "name" : "CentOS 5.2", + "updated" : "2010-10-10T12:00:00Z", + "created" : "2010-08-10T12:00:00Z", + "status" : "ACTIVE" + }, + { + "id" : 743, + "name" : "My Server Backup", + "serverId" : 12, + "updated" : "2010-10-10T12:00:00Z", + "created" : "2009-07-07T09:56:16-05:00", + "status" : "SAVING", + "progress" : 80 + } + , + { + "id" : 744, + "name" : "My Server Backup", + "serverId" : 12, + "updated" : "2010-10-10T12:00:00Z", + "created" : "2009-07-07T09:56:16-05:00", + "status" : "QUEUED" + } + , + { + "id" : 745, + "name" : "My Server Backup", + "serverId" : 12, + "updated" : "2010-10-10T12:00:00Z", + "created" : "2009-07-07T09:56:16-05:00", + "status" : "UNRECOGNIZED" + } + , + { + "id" : 746, + "name" : "My Server Backup", + "serverId" : 12, + "updated" : "2010-10-10T12:00:00Z", + "created" : "2009-07-07T09:56:16-05:00", + "status" : "UNKNOWN" + } + , + { + "id" : 747, + "name" : "My Server Backup", + "serverId" : 12, + "updated" : "2010-10-10T12:00:00Z", + "created" : "2009-07-07T09:56:16-05:00", + "status" : "PREPARING" + } + , + { + "id" : 748, + "name" : "My Server Backup", + "serverId" : 12, + "updated" : "2010-10-10T12:00:00Z", + "created" : "2009-07-07T09:56:16-05:00", + "status" : "FAILED" + } + ] +} \ No newline at end of file diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java index 6ea2798e47..cd0a6100c7 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java @@ -19,6 +19,7 @@ package org.jclouds.cloudsigma; import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; import java.net.URI; import java.util.Properties; @@ -67,6 +68,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata { // from a race condition applying the password set script properties.setProperty("jclouds.ssh.max-retries", "7"); properties.setProperty("jclouds.ssh.retry-auth", "true"); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,imageNameMatches=.*[Aa]utomated SSH Access.*,os64Bit=true"); return properties; } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java index 297a5f7ed2..e784ff24a4 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java @@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkState; import java.util.Map; +import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import javax.ws.rs.core.MediaType; @@ -35,8 +36,10 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.MapBinder; import org.jclouds.rest.internal.GeneratedHttpRequest; +import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * @@ -53,7 +56,7 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder { } @Override - public R bindToRequest(R request, Map postParams) { + public R bindToRequest(R request, Map postParams) { checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests!"); @SuppressWarnings("unchecked") @@ -62,10 +65,15 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder { CloneDriveOptions options = findOptionsInArgsOrNull(gRequest); if (options != null) { - postParams = ImmutableMap. builder().putAll(postParams).putAll(options.getOptions()).build(); + postParams = ImmutableMap. builder().putAll(postParams).putAll(options.getOptions()).build(); } - request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(postParams))); + request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(Maps.transformValues(postParams, new Function() { + @Override + public String apply(@Nullable Object input) { + return input == null ? null : input.toString(); + } + })))); request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); return request; } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java index 51afbb8c76..8587c587cb 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java @@ -43,7 +43,6 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.Volume; @@ -59,7 +58,6 @@ import com.google.common.base.Predicates; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -70,11 +68,6 @@ import com.google.inject.TypeLiteral; public class CloudSigmaComputeServiceContextModule extends ComputeServiceAdapterContextModule { - @Override - protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(OsFamily.UBUNTU).imageNameMatches(".*[Aa]utomated SSH Access.*").os64Bit(true); - } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void configure() { diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java index e040fee83c..a360e67605 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java @@ -47,16 +47,16 @@ public class BindCloneDriveOptionsToPlainTextStringTest { BindCloneDriveOptionsToPlainTextString.class); public void testDefault() throws IOException { - assertInputAndArgsCreatesPayload(ImmutableMap.of("name", "newdrive"), ImmutableList. of(), + assertInputAndArgsCreatesPayload(ImmutableMap.of("name", "newdrive"), ImmutableList. of(), "name newdrive"); } public void testWithSize() throws IOException { - assertInputAndArgsCreatesPayload(ImmutableMap.of("name", "newdrive"), + assertInputAndArgsCreatesPayload(ImmutableMap.of("name", "newdrive"), ImmutableList. of(new CloneDriveOptions().size(1024)), "name newdrive\nsize 1024"); } - protected void assertInputAndArgsCreatesPayload(ImmutableMap inputMap, List args, + protected void assertInputAndArgsCreatesPayload(ImmutableMap inputMap, List args, String expected) { GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); expect(request.getArgs()).andReturn(args).atLeastOnce(); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java index 14b0a4e457..463e172ff1 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java @@ -39,6 +39,7 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.base.Throwables; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.TypeLiteral; @@ -50,13 +51,13 @@ import com.google.inject.TypeLiteral; @Test(groups = { "unit" }) public class BindServerToPlainTextStringTest { - public static String CREATED_SERVER; + public static final String CREATED_SERVER; static { try { CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class .getResourceAsStream("/create_server.txt")); } catch (IOException e) { - CREATED_SERVER = null; + throw Throwables.propagate(e); } } public static final Server SERVER = new Server.Builder() diff --git a/apis/cloudstack/pom.xml b/apis/cloudstack/pom.xml index f74c2df4e0..7da9779f74 100644 --- a/apis/cloudstack/pom.xml +++ b/apis/cloudstack/pom.xml @@ -94,10 +94,16 @@ org.jclouds.driver - jclouds-log4j + jclouds-slf4j ${project.version} test + + ch.qos.logback + logback-classic + 1.0.0 + test + diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java index 23af639fe9..18964f9e73 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java @@ -106,11 +106,11 @@ public class CloudStackComputeServiceContextModule extends bind(new TypeLiteral>() { }).to(TemplateToOperatingSystem.class); install(new FactoryModuleBuilder().build(StaticNATVirtualMachineInNetwork.Factory.class)); - bind(new TypeLiteral>>() { + bind(new TypeLiteral>>() { }).to(GetIPForwardingRulesByVirtualMachine.class); - bind(new TypeLiteral>() { + bind(new TypeLiteral>() { }).to(ZoneIdToZone.class); - bind(new TypeLiteral>>() { + bind(new TypeLiteral>>() { }).to(ZoneIdToZoneSupplier.class); // to have the compute service adapter override default locations install(new LocationsFromComputeServiceAdapterModule(){}); @@ -119,12 +119,12 @@ public class CloudStackComputeServiceContextModule extends @Provides @Singleton @Memoized - public Supplier> listOSCategories(AtomicReference authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds, + public Supplier> listOSCategories(AtomicReference authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds, final CloudStackClient client) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, + seconds, new Supplier>() { @Override - public Map get() { + public Map get() { GuestOSClient guestOSClient = client.getGuestOSClient(); return guestOSClient.listOSCategories(); } @@ -134,17 +134,17 @@ public class CloudStackComputeServiceContextModule extends @Provides @Singleton @Memoized - public Supplier> listOSTypes(AtomicReference authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds, + public Supplier> listOSTypes(AtomicReference authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds, final CloudStackClient client) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, + seconds, new Supplier>() { @Override - public Map get() { + public Map get() { GuestOSClient guestOSClient = client.getGuestOSClient(); - return Maps.uniqueIndex(guestOSClient.listOSTypes(), new Function() { + return Maps.uniqueIndex(guestOSClient.listOSTypes(), new Function() { @Override - public Long apply(OSType arg0) { + public String apply(OSType arg0) { return arg0.getId(); } }); @@ -155,9 +155,9 @@ public class CloudStackComputeServiceContextModule extends @Provides @Singleton @Memoized - public Supplier> listNetworks(AtomicReference authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds, + public Supplier> listNetworks(AtomicReference authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds, final NetworksForCurrentUser networksForCurrentUser) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, seconds, networksForCurrentUser); } @@ -172,20 +172,20 @@ public class CloudStackComputeServiceContextModule extends @Provides @Singleton - protected Predicate jobComplete(JobComplete jobComplete) { + protected Predicate jobComplete(JobComplete jobComplete) { // TODO: parameterize - return new RetryablePredicate(jobComplete, 1200, 1, 5, TimeUnit.SECONDS); + return new RetryablePredicate(jobComplete, 1200, 1, 5, TimeUnit.SECONDS); } @Provides @Singleton - protected LoadingCache> getIPForwardingRulesByVirtualMachine( - CacheLoader> getIPForwardingRules) { + protected LoadingCache> getIPForwardingRulesByVirtualMachine( + CacheLoader> getIPForwardingRules) { return CacheBuilder.newBuilder().build(getIPForwardingRules); } @Singleton - public static class GetIPForwardingRulesByVirtualMachine extends CacheLoader> { + public static class GetIPForwardingRulesByVirtualMachine extends CacheLoader> { private final CloudStackClient client; @Inject @@ -198,7 +198,7 @@ public class CloudStackComputeServiceContextModule extends * when there is no ip forwarding rule available for the VM */ @Override - public Set load(Long input) { + public Set load(String input) { Set rules = client.getNATClient().getIPForwardingRulesForVirtualMachine(input); return rules != null ? rules : ImmutableSet.of(); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToImage.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToImage.java index 6b9f63e1d6..5384178636 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToImage.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToImage.java @@ -75,7 +75,7 @@ public class TemplateToImage implements Function { @Override public boolean matches(Template from, Location input) { - return input.getId().equals(Long.toString(from.getZoneId())); + return input.getId().equals(from.getZoneId()); } } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java index fb4df381fa..93dcd51541 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java @@ -55,13 +55,13 @@ public class TemplateToOperatingSystem implements Function> osTypes; - private final Supplier> osCategories; + private final Supplier> osTypes; + private final Supplier> osCategories; private final Map> osVersionMap; @Inject - public TemplateToOperatingSystem(@Memoized Supplier> osTypes, - @Memoized Supplier> osCategories, Map> osVersionMap) { + public TemplateToOperatingSystem(@Memoized Supplier> osTypes, + @Memoized Supplier> osCategories, Map> osVersionMap) { this.osTypes = checkNotNull(osTypes, "osTypes"); this.osCategories = checkNotNull(osCategories, "osCategories"); this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap"); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java index 5f2af18028..8c551f66f7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java @@ -78,13 +78,13 @@ public class VirtualMachineToNodeMetadata implements Function> getIPForwardingRulesByVirtualMachine; + private final LoadingCache> getIPForwardingRulesByVirtualMachine; private final GroupNamingConvention nodeNamingConvention; @Inject VirtualMachineToNodeMetadata(FindLocationForVirtualMachine findLocationForVirtualMachine, FindImageForVirtualMachine findImageForVirtualMachine, - LoadingCache> getIPForwardingRulesByVirtualMachine, + LoadingCache> getIPForwardingRulesByVirtualMachine, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); this.findLocationForVirtualMachine = checkNotNull(findLocationForVirtualMachine, "findLocationForVirtualMachine"); @@ -178,7 +178,7 @@ public class VirtualMachineToNodeMetadata implements Function { @Override public Location apply(Zone zone) { return new LocationBuilder().scope(LocationScope.ZONE).metadata(ImmutableMap. of()) - .description(zone.getName()).id(Long.toString(zone.getId())) + .description(zone.getName()).id(zone.getId()) .parent(Iterables.getOnlyElement(provider.get())).build(); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java index 10c47bc944..812c1becfd 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java @@ -54,9 +54,9 @@ import com.google.common.collect.Sets; */ public class CloudStackTemplateOptions extends TemplateOptions implements Cloneable { - protected Set securityGroupIds = Sets. newLinkedHashSet(); - protected Set networkIds = Sets. newLinkedHashSet(); - protected Map ipsToNetworks = Maps.newLinkedHashMap(); + protected Set securityGroupIds = Sets. newLinkedHashSet(); + protected Set networkIds = Sets. newLinkedHashSet(); + protected Map ipsToNetworks = Maps.newLinkedHashMap(); protected String ipOnDefaultNetwork; protected String keyPair; protected boolean setupStaticNat = true; @@ -85,7 +85,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see DeployVirtualMachineOptions#securityGroupId */ - public CloudStackTemplateOptions securityGroupId(long securityGroupId) { + public CloudStackTemplateOptions securityGroupId(String securityGroupId) { this.securityGroupIds.add(securityGroupId); return this; } @@ -93,19 +93,19 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see DeployVirtualMachineOptions#securityGroupIds */ - public CloudStackTemplateOptions securityGroupIds(Iterable securityGroupIds) { + public CloudStackTemplateOptions securityGroupIds(Iterable securityGroupIds) { Iterables.addAll(this.securityGroupIds, checkNotNull(securityGroupIds, "securityGroupIds was null")); return this; } - public Set getSecurityGroupIds() { + public Set getSecurityGroupIds() { return securityGroupIds; } /** * @see DeployVirtualMachineOptions#networkId */ - public CloudStackTemplateOptions networkId(long networkId) { + public CloudStackTemplateOptions networkId(String networkId) { this.networkIds.add(networkId); return this; } @@ -113,12 +113,12 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see DeployVirtualMachineOptions#networkIds */ - public CloudStackTemplateOptions networkIds(Iterable networkIds) { + public CloudStackTemplateOptions networkIds(Iterable networkIds) { Iterables.addAll(this.networkIds, checkNotNull(networkIds, "networkIds was null")); return this; } - public Set getNetworkIds() { + public Set getNetworkIds() { return networkIds; } @@ -146,12 +146,12 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see DeployVirtualMachineOptions#ipOnDefaultNetwork(String) */ - public CloudStackTemplateOptions ipsToNetworks(Map ipsToNetworks) { + public CloudStackTemplateOptions ipsToNetworks(Map ipsToNetworks) { this.ipsToNetworks.putAll(ipsToNetworks); return this; } - public Map getIpsToNetworks() { + public Map getIpsToNetworks() { return ipsToNetworks; } @@ -174,7 +174,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see CloudStackTemplateOptions#securityGroupId */ - public static CloudStackTemplateOptions securityGroupId(long id) { + public static CloudStackTemplateOptions securityGroupId(String id) { CloudStackTemplateOptions options = new CloudStackTemplateOptions(); return options.securityGroupId(id); } @@ -182,7 +182,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see CloudStackTemplateOptions#securityGroupIds */ - public static CloudStackTemplateOptions securityGroupIds(Iterable securityGroupIds) { + public static CloudStackTemplateOptions securityGroupIds(Iterable securityGroupIds) { CloudStackTemplateOptions options = new CloudStackTemplateOptions(); return options.securityGroupIds(securityGroupIds); } @@ -190,7 +190,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see CloudStackTemplateOptions#networkId */ - public static CloudStackTemplateOptions networkId(long id) { + public static CloudStackTemplateOptions networkId(String id) { CloudStackTemplateOptions options = new CloudStackTemplateOptions(); return options.networkId(id); } @@ -198,7 +198,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see CloudStackTemplateOptions#networkIds */ - public static CloudStackTemplateOptions networkIds(Iterable networkIds) { + public static CloudStackTemplateOptions networkIds(Iterable networkIds) { CloudStackTemplateOptions options = new CloudStackTemplateOptions(); return options.networkIds(networkIds); } @@ -214,7 +214,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea /** * @see CloudStackTemplateOptions#ipsToNetworks */ - public static CloudStackTemplateOptions ipsToNetworks(Map ipToNetworkMap) { + public static CloudStackTemplateOptions ipsToNetworks(Map ipToNetworkMap) { CloudStackTemplateOptions options = new CloudStackTemplateOptions(); return options.ipsToNetworks(ipToNetworkMap); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/AdvancedNetworkOptionsConverter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/AdvancedNetworkOptionsConverter.java index 15cf65672d..d34cdc0238 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/AdvancedNetworkOptionsConverter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/AdvancedNetworkOptionsConverter.java @@ -39,7 +39,7 @@ import com.google.common.collect.Iterables; */ public class AdvancedNetworkOptionsConverter implements OptionsConverter { @Override - public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map networks, long zoneId, DeployVirtualMachineOptions options) { + public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map networks, String zoneId, DeployVirtualMachineOptions options) { // security groups not allowed. // at least one network must be given to CloudStack, // but jclouds will try to autodetect an appropriate network if none given. diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/BasicNetworkOptionsConverter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/BasicNetworkOptionsConverter.java index e14c049d5f..32b367dac8 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/BasicNetworkOptionsConverter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/BasicNetworkOptionsConverter.java @@ -31,7 +31,7 @@ import org.jclouds.cloudstack.options.DeployVirtualMachineOptions; */ public class BasicNetworkOptionsConverter implements OptionsConverter { @Override - public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map networks, long zoneId, DeployVirtualMachineOptions options) { + public DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map networks, String zoneId, DeployVirtualMachineOptions options) { // both security groups and networks are optional, and CloudStack will // use the zone/user's default network/security group if none given if (templateOptions.getSecurityGroupIds().size() > 0) { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java index c7225110b5..8aeb94ff19 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java @@ -81,24 +81,24 @@ public class CloudStackComputeServiceAdapter implements protected Logger logger = Logger.NULL; private final CloudStackClient client; - private final Predicate jobComplete; - private final Supplier> networkSupplier; + private final Predicate jobComplete; + private final Supplier> networkSupplier; private final BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult; private final Factory staticNATVMInNetwork; private final CreatePortForwardingRulesForIP setupPortForwardingRulesForIP; - private final LoadingCache> vmToRules; + private final LoadingCache> vmToRules; private final Map credentialStore; private final Map optionsConverters; - private final Supplier> zoneIdToZone; + private final Supplier> zoneIdToZone; @Inject - public CloudStackComputeServiceAdapter(CloudStackClient client, Predicate jobComplete, - @Memoized Supplier> networkSupplier, + public CloudStackComputeServiceAdapter(CloudStackClient client, Predicate jobComplete, + @Memoized Supplier> networkSupplier, BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult, StaticNATVirtualMachineInNetwork.Factory staticNATVMInNetwork, - CreatePortForwardingRulesForIP setupPortForwardingRulesForIP, LoadingCache> vmToRules, + CreatePortForwardingRulesForIP setupPortForwardingRulesForIP, LoadingCache> vmToRules, Map credentialStore, Map optionsConverters, - Supplier> zoneIdToZone) { + Supplier> zoneIdToZone) { this.client = checkNotNull(client, "client"); this.jobComplete = checkNotNull(jobComplete, "jobComplete"); this.networkSupplier = checkNotNull(networkSupplier, "networkSupplier"); @@ -120,9 +120,9 @@ public class CloudStackComputeServiceAdapter implements checkArgument(template.getOptions().getClass().isAssignableFrom(CloudStackTemplateOptions.class), "options class %s should have been assignable from CloudStackTemplateOptions", template.getOptions() .getClass()); - Map networks = networkSupplier.get(); + Map networks = networkSupplier.get(); - final long zoneId = Long.parseLong(template.getLocation().getId()); + final String zoneId = template.getLocation().getId(); Zone zone = null; try { zone = zoneIdToZone.get().get(zoneId); @@ -155,10 +155,10 @@ public class CloudStackComputeServiceAdapter implements } } - long templateId = Long.parseLong(template.getImage().getId()); - long serviceOfferingId = Long.parseLong(template.getHardware().getId()); + String templateId = template.getImage().getId(); + String serviceOfferingId = template.getHardware().getId(); - logger.info("serviceOfferingId %d, templateId %d, zoneId %d, options %s%n", serviceOfferingId, templateId, + logger.info("serviceOfferingId %s, templateId %s, zoneId %s, options %s%n", serviceOfferingId, templateId, zoneId, options); AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachineInZone(zoneId, serviceOfferingId, templateId, options); @@ -172,7 +172,7 @@ public class CloudStackComputeServiceAdapter implements } if (templateOptions.shouldSetupStaticNat()) { // TODO: possibly not all network ids, do we want to do this - for (long networkId : options.getNetworkIds()) { + for (String networkId : options.getNetworkIds()) { logger.debug(">> creating static NAT for virtualMachine(%s) in network(%s)", vm.getId(), networkId); PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm); logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId()); @@ -211,13 +211,13 @@ public class CloudStackComputeServiceAdapter implements @Override public VirtualMachine getNode(String id) { - long virtualMachineId = Long.parseLong(id); + String virtualMachineId = id; return client.getVirtualMachineClient().getVirtualMachine(virtualMachineId); } @Override public void destroyNode(String id) { - long virtualMachineId = Long.parseLong(id); + String virtualMachineId = id; // There was a bug in 2.2.12 release happening when static nat IP address // was being released, and corresponding firewall rules were left behind. // So next time the same IP is allocated, it might be not be static nat @@ -231,7 +231,7 @@ public class CloudStackComputeServiceAdapter implements // the following: // 1) Delete IP forwarding rules associated with IP. - Set ipAddresses = deleteIPForwardingRulesForVMAndReturnDistinctIPs(virtualMachineId); + Set ipAddresses = deleteIPForwardingRulesForVMAndReturnDistinctIPs(virtualMachineId); // 2) Disable static nat rule for the IP. disableStaticNATOnIPAddresses(ipAddresses); @@ -244,16 +244,16 @@ public class CloudStackComputeServiceAdapter implements vmToRules.invalidate(virtualMachineId); } - public void disassociateIPAddresses(Set ipAddresses) { - for (long ipAddress : ipAddresses) { + public void disassociateIPAddresses(Set ipAddresses) { + for (String ipAddress : ipAddresses) { logger.debug(">> disassociating IPAddress(%s)", ipAddress); client.getAddressClient().disassociateIPAddress(ipAddress); } } - public void destroyVirtualMachine(long virtualMachineId) { + public void destroyVirtualMachine(String virtualMachineId) { - Long destroyVirtualMachine = client.getVirtualMachineClient().destroyVirtualMachine(virtualMachineId); + String destroyVirtualMachine = client.getVirtualMachineClient().destroyVirtualMachine(virtualMachineId); if (destroyVirtualMachine != null) { logger.debug(">> destroying virtualMachine(%s) job(%s)", virtualMachineId, destroyVirtualMachine); awaitCompletion(destroyVirtualMachine); @@ -263,10 +263,10 @@ public class CloudStackComputeServiceAdapter implements } - public void disableStaticNATOnIPAddresses(Set ipAddresses) { - Builder jobsToTrack = ImmutableSet.builder(); - for (Long ipAddress : ipAddresses) { - Long disableStaticNAT = client.getNATClient().disableStaticNATOnPublicIP(ipAddress); + public void disableStaticNATOnIPAddresses(Set ipAddresses) { + Builder jobsToTrack = ImmutableSet.builder(); + for (String ipAddress : ipAddresses) { + String disableStaticNAT = client.getNATClient().disableStaticNATOnPublicIP(ipAddress); if (disableStaticNAT != null) { logger.debug(">> disabling static NAT IPAddress(%s) job(%s)", ipAddress, disableStaticNAT); jobsToTrack.add(disableStaticNAT); @@ -275,18 +275,18 @@ public class CloudStackComputeServiceAdapter implements awaitCompletion(jobsToTrack.build()); } - public Set deleteIPForwardingRulesForVMAndReturnDistinctIPs(long virtualMachineId) { - Builder jobsToTrack = ImmutableSet.builder(); + public Set deleteIPForwardingRulesForVMAndReturnDistinctIPs(String virtualMachineId) { + Builder jobsToTrack = ImmutableSet.builder(); // immutable doesn't permit duplicates - Set ipAddresses = Sets.newLinkedHashSet(); + Set ipAddresses = Sets.newLinkedHashSet(); Set forwardingRules = client.getNATClient().getIPForwardingRulesForVirtualMachine( virtualMachineId); for (IPForwardingRule rule : forwardingRules) { if (!"Deleting".equals(rule.getState())) { ipAddresses.add(rule.getIPAddressId()); - Long deleteForwardingRule = client.getNATClient().deleteIPForwardingRule(rule.getId()); + String deleteForwardingRule = client.getNATClient().deleteIPForwardingRule(rule.getId()); if (deleteForwardingRule != null) { logger.debug(">> deleting IPForwardingRule(%s) job(%s)", rule.getId(), deleteForwardingRule); jobsToTrack.add(deleteForwardingRule); @@ -297,22 +297,22 @@ public class CloudStackComputeServiceAdapter implements return ipAddresses; } - public void awaitCompletion(Iterable jobs) { + public void awaitCompletion(Iterable jobs) { logger.debug(">> awaiting completion of jobs(%s)", jobs); - for (long job : jobs) + for (String job : jobs) awaitCompletion(job); logger.trace("<< completed jobs(%s)", jobs); } - public void awaitCompletion(long job) { + public void awaitCompletion(String job) { boolean completed = jobComplete.apply(job); logger.trace("<< job(%s) complete(%s)", job, completed); } @Override public void rebootNode(String id) { - long virtualMachineId = Long.parseLong(id); - Long job = client.getVirtualMachineClient().rebootVirtualMachine(virtualMachineId); + String virtualMachineId = id; + String job = client.getVirtualMachineClient().rebootVirtualMachine(virtualMachineId); if (job != null) { logger.debug(">> rebooting virtualMachine(%s) job(%s)", virtualMachineId, job); awaitCompletion(job); @@ -321,8 +321,8 @@ public class CloudStackComputeServiceAdapter implements @Override public void resumeNode(String id) { - long virtualMachineId = Long.parseLong(id); - Long job = client.getVirtualMachineClient().startVirtualMachine(Long.parseLong(id)); + String virtualMachineId = id; + String job = client.getVirtualMachineClient().startVirtualMachine(id); if (job != null) { logger.debug(">> starting virtualMachine(%s) job(%s)", virtualMachineId, job); awaitCompletion(job); @@ -331,8 +331,8 @@ public class CloudStackComputeServiceAdapter implements @Override public void suspendNode(String id) { - long virtualMachineId = Long.parseLong(id); - Long job = client.getVirtualMachineClient().stopVirtualMachine(Long.parseLong(id)); + String virtualMachineId = id; + String job = client.getVirtualMachineClient().stopVirtualMachine(id); if (job != null) { logger.debug(">> stopping virtualMachine(%s) job(%s)", virtualMachineId, job); awaitCompletion(job); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/OptionsConverter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/OptionsConverter.java index dbd30da725..0bcfb289cd 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/OptionsConverter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/OptionsConverter.java @@ -42,6 +42,6 @@ public interface OptionsConverter { * @param options where the resulting set of options will be applied * @return same as "options" parameter */ - DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map networks, long zoneId, DeployVirtualMachineOptions options); + DeployVirtualMachineOptions apply(CloudStackTemplateOptions templateOptions, Map networks, String zoneId, DeployVirtualMachineOptions options); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java index 91bd2075a4..4853cbe64d 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java @@ -80,11 +80,11 @@ public class CloudStackParserModule extends AbstractModule { } static final class PortForwardingRuleInternal { - private long id; + private String id; @SerializedName("ipaddress") private String IPAddress; @SerializedName("ipaddressid") - private long IPAddressId; + private String IPAddressId; @SerializedName("privateport") private int privatePort; private PortForwardingRule.Protocol protocol; @@ -94,7 +94,7 @@ public class CloudStackParserModule extends AbstractModule { @SerializedName("virtualmachinedisplayname") private String virtualMachineDisplayName; @SerializedName("virtualmachineid") - public long virtualMachineId; + public String virtualMachineId; @SerializedName("virtualmachinename") private String virtualMachineName; @SerializedName("cidrlist") @@ -132,7 +132,7 @@ public class CloudStackParserModule extends AbstractModule { } static final class FirewallRuleInternal { - private long id; + private String id; @SerializedName("cidrlist") private String CIDRs; @SerializedName("startport") @@ -146,7 +146,7 @@ public class CloudStackParserModule extends AbstractModule { @SerializedName("ipaddress") private String ipAddress; @SerializedName("ipaddressid") - private long ipAddressId; + private String ipAddressId; private FirewallRule.Protocol protocol; private FirewallRule.State state; } @@ -173,27 +173,27 @@ public class CloudStackParserModule extends AbstractModule { } static final class LoadBalancerRuleInternal { - private long id; + private String id; private String account; private LoadBalancerRule.Algorithm algorithm; private String description; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; private String name; @SerializedName("privateport") private int privatePort; @SerializedName("publicip") private String publicIP; @SerializedName("publicipid") - private long publicIPId; + private String publicIPId; @SerializedName("publicport") private int publicPort; private LoadBalancerRule.State state; @SerializedName("cidrlist") private String CIDRs; @SerializedName("zoneId") - private long zoneId; + private String zoneId; } } @@ -224,12 +224,12 @@ public class CloudStackParserModule extends AbstractModule { } static final class AccountInternal { - private long id; + private String id; @SerializedName("accounttype") private Account.Type type; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("ipavailable") private String IPsAvailable; @SerializedName("iplimit") diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java index d962601dd2..33dae7d1ca 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Account.java @@ -27,6 +27,7 @@ import javax.annotation.Nullable; import com.google.common.base.CaseFormat; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.collect.ForwardingSet; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; @@ -42,11 +43,11 @@ public class Account extends ForwardingSet implements Comparable } public static class Builder { - private long id; + private String id; private Type type; private String networkDomain; private String domain; - private long domainId; + private String domainId; private Long IPsAvailable; private Long IPLimit; private long IPs; @@ -71,7 +72,7 @@ public class Account extends ForwardingSet implements Comparable private long volumes; private Set users = ImmutableSet.of(); - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -91,7 +92,7 @@ public class Account extends ForwardingSet implements Comparable return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -284,14 +285,14 @@ public class Account extends ForwardingSet implements Comparable } - private long id; + private String id; @SerializedName("accounttype") private Type type; @SerializedName("networkdomain") private String networkDomain; private String domain; @SerializedName("domainId") - private long domainId; + private String domainId; @SerializedName("ipsavailable") private Long IPsAvailable; @SerializedName("iplimit") @@ -336,7 +337,7 @@ public class Account extends ForwardingSet implements Comparable private long volumes; private Set users; - public Account(long id, Type type, String networkDomain, String domain, long domainId, Long IPsAvailable, Long IPLimit, long iPs, + public Account(String id, Type type, String networkDomain, String domain, String domainId, Long IPsAvailable, Long IPLimit, long iPs, boolean cleanupRequired, String name, long receivedBytes, long sentBytes, Long snapshotsAvailable, Long snapshotLimit, long snapshots, org.jclouds.cloudstack.domain.Account.State state, Long templatesAvailable, Long templateLimit, long templates, Long VMsAvailable, Long VMLimit, long vMsRunning, @@ -381,7 +382,7 @@ public class Account extends ForwardingSet implements Comparable /** * @return the id of the account */ - public long getId() { + public String getId() { return id; } @@ -417,7 +418,7 @@ public class Account extends ForwardingSet implements Comparable /** * @return id of the Domain the account belongs to */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -597,7 +598,7 @@ public class Account extends ForwardingSet implements Comparable @Override public int compareTo(Account arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } @@ -637,12 +638,7 @@ public class Account extends ForwardingSet implements Comparable @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; + return Objects.hashCode(domainId, id, name); } @Override @@ -653,16 +649,11 @@ public class Account extends ForwardingSet implements Comparable return false; if (getClass() != obj.getClass()) return false; - Account other = (Account) obj; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; + Account that = (Account) obj; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(name, that.name)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java index e39ba9dce6..88ee6bb564 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + import java.util.Date; /** @@ -32,12 +34,12 @@ public class Alert implements Comparable { } public static class Builder { - private long id; + private String id; private String description; private Date sent; private String type; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -62,7 +64,7 @@ public class Alert implements Comparable { } } - private long id; + private String id; private String description; private Date sent; private String type; @@ -71,14 +73,14 @@ public class Alert implements Comparable { Alert() { } - private Alert(long id, String description, Date sent, String type) { + private Alert(String id, String description, Date sent, String type) { this.id = id; this.description = description; this.sent = sent; this.type = type; } - public long getId() { + public String getId() { return id; } @@ -99,23 +101,19 @@ public class Alert implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Alert alert = (Alert) o; + Alert that = (Alert) o; - if (id != alert.id) return false; - if (description != null ? !description.equals(alert.description) : alert.description != null) return false; - if (sent != null ? !sent.equals(alert.sent) : alert.sent != null) return false; - if (type != null ? !type.equals(alert.type) : alert.type != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(sent, that.sent)) return false; + if (!Objects.equal(type, that.type)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (sent != null ? sent.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; + return Objects.hashCode(id, description, sent, type); } @@ -131,6 +129,6 @@ public class Alert implements Comparable { @Override public int compareTo(Alert other) { - return Long.valueOf(this.getId()).compareTo(other.getId()); + return this.getId().compareTo(other.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java index 4f8fec19c2..4851c133a3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -81,19 +82,15 @@ public class ApiKeyPair implements Comparable { ApiKeyPair that = (ApiKeyPair) o; - if (apiKey != null ? !apiKey.equals(that.apiKey) : that.apiKey != null) - return false; - if (secretKey != null ? !secretKey.equals(that.secretKey) : that.secretKey != null) - return false; + if (!Objects.equal(apiKey, that.apiKey)) return false; + if (!Objects.equal(secretKey, that.secretKey)) return false; return true; } @Override public int hashCode() { - int result = apiKey != null ? apiKey.hashCode() : 0; - result = 31 * result + (secretKey != null ? secretKey.hashCode() : 0); - return result; + return Objects.hashCode(apiKey, secretKey); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java index aa56420c17..3c2ed009ca 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -27,9 +28,9 @@ import com.google.gson.annotations.SerializedName; public class AsyncCreateResponse { public static final AsyncCreateResponse UNINITIALIZED = new AsyncCreateResponse(); - private long id = -1; + private String id; @SerializedName("jobid") - private long jobId = -1; + private String jobId; /** * present only for serializer @@ -39,7 +40,7 @@ public class AsyncCreateResponse { } - public AsyncCreateResponse(long id, long jobId) { + public AsyncCreateResponse(String id, String jobId) { this.id = id; this.jobId = jobId; } @@ -47,24 +48,20 @@ public class AsyncCreateResponse { /** * @return id of the resource being created */ - public long getId() { + public String getId() { return id; } /** * @return id of the job in progress */ - public long getJobId() { + public String getJobId() { return jobId; } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (jobId ^ (jobId >>> 32)); - return result; + return Objects.hashCode(id, jobId); } @Override @@ -75,11 +72,11 @@ public class AsyncCreateResponse { return false; if (getClass() != obj.getClass()) return false; - AsyncCreateResponse other = (AsyncCreateResponse) obj; - if (id != other.id) - return false; - if (jobId != other.jobId) - return false; + AsyncCreateResponse that = (AsyncCreateResponse) obj; + + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java index cb4cfd25e8..93551fc603 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -102,21 +103,21 @@ public class AsyncJob { } public static class Builder { - private long accountId = -1; + private String accountId; private String cmd; private Date created; - private long id = -1; - private long instanceId = -1; + private String id; + private String instanceId; private String instanceType; - private int progress = -1; + private int progress; private T result; private ResultCode resultCode = ResultCode.UNKNOWN; private String resultType; private AsyncJobError error; private Status status = Status.UNKNOWN; - private int userId = -1; + private String userId; - public Builder accountId(long accountId) { + public Builder accountId(String accountId) { this.accountId = accountId; return this; } @@ -131,12 +132,12 @@ public class AsyncJob { return this; } - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } - public Builder instanceId(long instanceId) { + public Builder instanceId(String instanceId) { this.instanceId = instanceId; return this; } @@ -176,7 +177,7 @@ public class AsyncJob { return this; } - public Builder userId(int userId) { + public Builder userId(String userId) { this.userId = userId; return this; } @@ -194,17 +195,17 @@ public class AsyncJob { } @SerializedName("accountid") - private long accountId = -1; + private String accountId; private String cmd; private Date created; @SerializedName("jobid") - private long id = -1; + private String id; @SerializedName("jobinstanceid") - private long instanceId = -1; + private String instanceId; @SerializedName("jobinstancetype") private String instanceType; @SerializedName("jobprocstatus") - private int progress = -1; + private int progress; @SerializedName("jobresult") private T result; @SerializedName("jobresultcode") @@ -214,11 +215,11 @@ public class AsyncJob { @SerializedName("jobstatus") private Status status = Status.UNKNOWN; @SerializedName("userid") - private int userId = -1; + private String userId; private AsyncJobError error; - public AsyncJob(long accountId, String cmd, Date created, long id, long instanceId, String instanceType, - int progress, T result, ResultCode resultCode, String resultType, Status status, int userId, AsyncJobError error) { + public AsyncJob(String accountId, String cmd, Date created, String id, String instanceId, String instanceType, + int progress, T result, ResultCode resultCode, String resultType, Status status, String userId, AsyncJobError error) { this.accountId = accountId; this.cmd = cmd; this.created = created; @@ -245,7 +246,7 @@ public class AsyncJob { /** * @return the account that executed the async command */ - public long getAccountId() { + public String getAccountId() { return accountId; } @@ -266,14 +267,14 @@ public class AsyncJob { /** * @return async job ID */ - public long getId() { + public String getId() { return id; } /** * @return the unique ID of the instance/entity object related to the job */ - public long getInstanceId() { + public String getInstanceId() { return instanceId; } @@ -322,7 +323,7 @@ public class AsyncJob { /** * @return the user that executed the async command */ - public int getUserId() { + public String getUserId() { return userId; } @@ -346,22 +347,8 @@ public class AsyncJob { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (accountId ^ (accountId >>> 32)); - result = prime * result + ((cmd == null) ? 0 : cmd.hashCode()); - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (int) (instanceId ^ (instanceId >>> 32)); - result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode()); - result = prime * result + ((error == null) ? 0 : error.hashCode()); - result = prime * result + progress; - result = prime * result + ((this.result == null) ? 0 : this.result.hashCode()); - result = prime * result + resultCode.code(); - result = prime * result + ((resultType == null) ? 0 : resultType.hashCode()); - result = prime * result + status.code(); - result = prime * result + userId; - return result; + return Objects.hashCode(accountId, cmd, created, id, instanceId, instanceType, error, progress, + result, resultCode, resultType, status, userId); } @Override @@ -372,51 +359,23 @@ public class AsyncJob { return false; if (getClass() != obj.getClass()) return false; - AsyncJob other = (AsyncJob) obj; - if (accountId != other.accountId) - return false; - if (cmd == null) { - if (other.cmd != null) - return false; - } else if (!cmd.equals(other.cmd)) - return false; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (id != other.id) - return false; - if (instanceId != other.instanceId) - return false; - if (instanceType == null) { - if (other.instanceType != null) - return false; - } else if (!instanceType.equals(other.instanceType)) - return false; - if (error == null) { - if (other.error != null) - return false; - } else if (!error.equals(other.error)) - return false; - if (progress != other.progress) - return false; - if (result == null) { - if (other.result != null) - return false; - } else if (!result.equals(other.result)) - return false; - if (resultCode != other.resultCode) - return false; - if (resultType == null) { - if (other.resultType != null) - return false; - } else if (!resultType.equals(other.resultType)) - return false; - if (status != other.status) - return false; - if (userId != other.userId) - return false; + + AsyncJob that = (AsyncJob) obj; + + if (!Objects.equal(accountId, that.accountId)) return false; + if (!Objects.equal(cmd, that.cmd)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(instanceId, that.instanceId)) return false; + if (!Objects.equal(instanceType, that.instanceType)) return false; + if (!Objects.equal(error, that.error)) return false; + if (!Objects.equal(progress, that.progress)) return false; + if (!Objects.equal(result, that.result)) return false; + if (!Objects.equal(resultCode, that.resultCode)) return false; + if (!Objects.equal(resultType, that.resultType)) return false; + if (!Objects.equal(status, that.status)) return false; + if (!Objects.equal(userId, that.userId)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java index a446dbf42f..f57fbd5e22 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -92,11 +93,7 @@ public class AsyncJobError { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + errorCode.code(); - result = prime * result + ((errorText == null) ? 0 : errorText.hashCode()); - return result; + return Objects.hashCode(errorCode, errorText); } @Override @@ -107,14 +104,11 @@ public class AsyncJobError { return false; if (getClass() != obj.getClass()) return false; - AsyncJobError other = (AsyncJobError) obj; - if (errorCode != other.errorCode) - return false; - if (errorText == null) { - if (other.errorText != null) - return false; - } else if (!errorText.equals(other.errorText)) - return false; + AsyncJobError that = (AsyncJobError) obj; + + if (!Objects.equal(errorCode, that.errorCode)) return false; + if (!Objects.equal(errorText, that.errorText)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java index 027cad05cf..4d83b8bca1 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -129,14 +130,7 @@ public class Capabilities { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (canShareTemplates ? 1231 : 1237); - result = prime * result + ((cloudStackVersion == null) ? 0 : cloudStackVersion.hashCode()); - result = prime * result + (securityGroupsEnabled ? 1231 : 1237); - result = prime * result + (firewallRuleUiEnabled ? 1231 : 1237); - result = prime * result + (supportELB ? 1231 : 1237); - return result; + return Objects.hashCode(canShareTemplates, cloudStackVersion, securityGroupsEnabled, firewallRuleUiEnabled, supportELB); } @Override @@ -147,20 +141,14 @@ public class Capabilities { return false; if (getClass() != obj.getClass()) return false; - Capabilities other = (Capabilities) obj; - if (canShareTemplates != other.canShareTemplates) - return false; - if (cloudStackVersion == null) { - if (other.cloudStackVersion != null) - return false; - } else if (!cloudStackVersion.equals(other.cloudStackVersion)) - return false; - if (securityGroupsEnabled != other.securityGroupsEnabled) - return false; - if (firewallRuleUiEnabled != other.firewallRuleUiEnabled) - return false; - if (supportELB != other.supportELB) - return false; + Capabilities that = (Capabilities) obj; + + if (!Objects.equal(canShareTemplates, that.canShareTemplates)) return false; + if (!Objects.equal(cloudStackVersion, that.cloudStackVersion)) return false; + if (!Objects.equal(securityGroupsEnabled, that.securityGroupsEnabled)) return false; + if (!Objects.equal(firewallRuleUiEnabled, that.firewallRuleUiEnabled)) return false; + if (!Objects.equal(supportELB, that.supportELB)) return false; + return true; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java index a674727131..1f39af815f 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Capacity.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.gson.annotations.SerializedName; @@ -43,10 +44,10 @@ public class Capacity implements Comparable { private long capacityTotal; private long capacityUsed; private double percentUsed; - private long podId; + private String podId; private String podName; private Type type; - private long zoneId; + private String zoneId; private String zoneName; public Builder capacityTotal(long capacityTotal) { @@ -64,7 +65,7 @@ public class Capacity implements Comparable { return this; } - public Builder podId(long podId) { + public Builder podId(String podId) { this.podId = podId; return this; } @@ -79,7 +80,7 @@ public class Capacity implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -141,12 +142,12 @@ public class Capacity implements Comparable { @SerializedName("percentused") private double percentUsed; @SerializedName("podid") - private long podId = -1; + private String podId; @SerializedName("podname") private String podName; private Capacity.Type type; @SerializedName("zoneid") - private long zoneId = -1; + private String zoneId; @SerializedName("zonename") private String zoneName; @@ -154,7 +155,7 @@ public class Capacity implements Comparable { Capacity() { } - public Capacity(long capacityTotal, long capacityUsed, double percentUsed, long podId, String podName, Type type, long zoneId, String zoneName) { + public Capacity(long capacityTotal, long capacityUsed, double percentUsed, String podId, String podName, Type type, String zoneId, String zoneName) { this.capacityTotal = capacityTotal; this.capacityUsed = capacityUsed; this.percentUsed = percentUsed; @@ -177,7 +178,7 @@ public class Capacity implements Comparable { return percentUsed; } - public long getPodId() { + public String getPodId() { return podId; } @@ -189,7 +190,7 @@ public class Capacity implements Comparable { return type; } - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -202,34 +203,24 @@ public class Capacity implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Capacity capacity = (Capacity) o; + Capacity that = (Capacity) o; - if (capacityTotal != capacity.capacityTotal) return false; - if (capacityUsed != capacity.capacityUsed) return false; - if (Double.compare(capacity.percentUsed, percentUsed) != 0) return false; - if (podId != capacity.podId) return false; - if (zoneId != capacity.zoneId) return false; - if (podName != null ? !podName.equals(capacity.podName) : capacity.podName != null) return false; - if (type != capacity.type) return false; - if (zoneName != null ? !zoneName.equals(capacity.zoneName) : capacity.zoneName != null) return false; + if (!Objects.equal(capacityTotal, that.capacityTotal)) return false; + if (!Objects.equal(capacityUsed, that.capacityUsed)) return false; + if (!Objects.equal(percentUsed, that.percentUsed)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result; - long temp; - result = (int) (capacityTotal ^ (capacityTotal >>> 32)); - result = 31 * result + (int) (capacityUsed ^ (capacityUsed >>> 32)); - temp = percentUsed != +0.0d ? Double.doubleToLongBits(percentUsed) : 0L; - result = 31 * result + (int) (temp ^ (temp >>> 32)); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(capacityTotal, capacityUsed, percentUsed, podId, podName, + type, zoneId, zoneName); } @Override @@ -248,9 +239,9 @@ public class Capacity implements Comparable { @Override public int compareTo(Capacity other) { - int comparison = Long.valueOf(this.zoneId).compareTo(other.zoneId); + int comparison = this.zoneId.compareTo(other.zoneId); if (comparison != 0) return comparison; - comparison = Long.valueOf(this.podId).compareTo(other.podId); + comparison = this.podId.compareTo(other.podId); if (comparison != 0) return comparison; return Integer.valueOf(this.type.code).compareTo(other.type.code); } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java index cd3714775c..cb167a9af1 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Cluster.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -56,18 +57,18 @@ public class Cluster implements Comparable { } public static class Builder { - private long id; + private String id; private AllocationState allocationState; private Host.ClusterType clusterType; private String hypervisor; private ManagedState managedState; private String name; - private long podId; + private String podId; private String podName; - private long zoneId; + private String zoneId; private String zoneName; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -97,7 +98,7 @@ public class Cluster implements Comparable { return this; } - public Builder podId(long podId) { + public Builder podId(String podId) { this.podId = podId; return this; } @@ -107,7 +108,7 @@ public class Cluster implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -122,21 +123,21 @@ public class Cluster implements Comparable { } } - private long id; + private String id; @SerializedName("allocationstate") private AllocationState allocationState; @SerializedName("clustertype") private Host.ClusterType clusterType; @SerializedName("hypervisortype") private String hypervisor; @SerializedName("managedstate") private ManagedState managedState; private String name; - @SerializedName("podid") private long podId; + @SerializedName("podid") private String podId; @SerializedName("podname") private String podName; - @SerializedName("zoneid") private long zoneId; + @SerializedName("zoneid") private String zoneId; @SerializedName("zonename") private String zoneName; // Just for the serializer Cluster() {} - public Cluster(long id, AllocationState allocationState, Host.ClusterType clusterType, String hypervisor, ManagedState managedState, String name, long podId, String podName, long zoneId, String zoneName) { + public Cluster(String id, AllocationState allocationState, Host.ClusterType clusterType, String hypervisor, ManagedState managedState, String name, String podId, String podName, String zoneId, String zoneName) { this.id = id; this.allocationState = allocationState; this.clusterType = clusterType; @@ -149,7 +150,7 @@ public class Cluster implements Comparable { this.zoneName = zoneName; } - public long getId() { + public String getId() { return id; } @@ -173,7 +174,7 @@ public class Cluster implements Comparable { return name; } - public long getPodId() { + public String getPodId() { return podId; } @@ -181,7 +182,7 @@ public class Cluster implements Comparable { return podName; } - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -194,35 +195,26 @@ public class Cluster implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Cluster cluster = (Cluster) o; + Cluster that = (Cluster) o; - if (id != cluster.id) return false; - if (podId != cluster.podId) return false; - if (zoneId != cluster.zoneId) return false; - if (allocationState != cluster.allocationState) return false; - if (clusterType != cluster.clusterType) return false; - if (hypervisor != null ? !hypervisor.equals(cluster.hypervisor) : cluster.hypervisor != null) return false; - if (managedState != cluster.managedState) return false; - if (name != null ? !name.equals(cluster.name) : cluster.name != null) return false; - if (podName != null ? !podName.equals(cluster.podName) : cluster.podName != null) return false; - if (zoneName != null ? !zoneName.equals(cluster.zoneName) : cluster.zoneName != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(allocationState, that.allocationState)) return false; + if (!Objects.equal(clusterType, that.clusterType)) return false; + if (!Objects.equal(hypervisor, that.hypervisor)) return false; + if (!Objects.equal(managedState, that.managedState)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); - result = 31 * result + (clusterType != null ? clusterType.hashCode() : 0); - result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); - result = 31 * result + (managedState != null ? managedState.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, + zoneId, zoneName); } @Override @@ -243,6 +235,6 @@ public class Cluster implements Comparable { @Override public int compareTo(Cluster other) { - return Long.valueOf(this.id).compareTo(other.id); + return this.id.compareTo(other.id); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java index 475652134c..d3a655bf1b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ConfigurationEntry.java @@ -19,6 +19,8 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + /** * Representation of the API configuration entry response * @@ -106,25 +108,17 @@ public class ConfigurationEntry implements Comparable { ConfigurationEntry that = (ConfigurationEntry) o; - if (category != null ? !category.equals(that.category) : that.category != null) - return false; - if (description != null ? !description.equals(that.description) : that.description != null) - return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (value != null ? !value.equals(that.value) : that.value != null) - return false; + if (!Objects.equal(category, that.category)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(value, that.value)) return false; return true; } @Override public int hashCode() { - int result = category != null ? category.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (value != null ? value.hashCode() : 0); - return result; + return Objects.hashCode(category, description, name, value); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java index 6e2cd0be60..5128faeb63 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java @@ -24,6 +24,7 @@ import java.util.Date; import java.util.Set; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -39,17 +40,17 @@ public class DiskOffering implements Comparable { } public static class Builder { - private long id; + private String id; private String name; private String displayText; private Date created; private String domain; - private long domainId; + private String domainId; private int diskSize; private boolean customized; private Set tags = ImmutableSet.of(); - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -74,7 +75,7 @@ public class DiskOffering implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -99,21 +100,21 @@ public class DiskOffering implements Comparable { } } - private long id; + private String id; private String name; @SerializedName("displaytext") private String displayText; private Date created; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("disksize") private int diskSize; @SerializedName("iscustomized") private boolean customized; private String tags; - public DiskOffering(long id, String name, String displayText, Date created, String domain, long domainId, + public DiskOffering(String id, String name, String displayText, Date created, String domain, String domainId, int diskSize, boolean customized, Set tags) { this.id = id; this.name = name; @@ -138,7 +139,7 @@ public class DiskOffering implements Comparable { * * @return the id of the disk offering */ - public long getId() { + public String getId() { return id; } @@ -179,7 +180,7 @@ public class DiskOffering implements Comparable { * * @return the domain id of the disk offering */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -209,18 +210,7 @@ public class DiskOffering implements Comparable { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + (customized ? 1231 : 1237); - result = prime * result + diskSize; - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - return result; + return Objects.hashCode(created, customized, diskSize, displayText, domain, domainId, id, name, tags); } @Override @@ -231,40 +221,18 @@ public class DiskOffering implements Comparable { return false; if (getClass() != obj.getClass()) return false; - DiskOffering other = (DiskOffering) obj; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (customized != other.customized) - return false; - if (diskSize != other.diskSize) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; + DiskOffering that = (DiskOffering) obj; + + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(customized, that.customized)) return false; + if (!Objects.equal(diskSize, that.diskSize)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(tags, that.tags)) return false; + return true; } @@ -285,7 +253,7 @@ public class DiskOffering implements Comparable { @Override public int compareTo(DiskOffering arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java index 3e1fc7ab0c..565e1f6c19 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Domain.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -34,15 +35,15 @@ public class Domain implements Comparable { public static class Builder { - private long id; + private String id; private boolean hasChild; private long level; private String name; private String networkDomain; - private long parentDomainId; + private String parentDomainId; private String parentDomainName; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -67,7 +68,7 @@ public class Domain implements Comparable { return this; } - public Builder parentDomainId(long parentDomainId) { + public Builder parentDomainId(String parentDomainId) { this.parentDomainId = parentDomainId; return this; } @@ -87,7 +88,7 @@ public class Domain implements Comparable { Domain() { } - private long id; + private String id; @SerializedName("haschild") private boolean hasChild; private long level; @@ -95,12 +96,12 @@ public class Domain implements Comparable { @SerializedName("networkdomain") private String networkDomain; @SerializedName("parentdomainid") - private long parentDomainId; + private String parentDomainId; @SerializedName("parentdomainname") private String parentDomainName; - public Domain(long id, boolean hasChild, long level, String name, String networkDomain, - long parentDomainId, String parentDomainName) { + public Domain(String id, boolean hasChild, long level, String name, String networkDomain, + String parentDomainId, String parentDomainName) { this.id = id; this.hasChild = hasChild; this.level = level; @@ -110,7 +111,7 @@ public class Domain implements Comparable { this.parentDomainName = parentDomainName; } - public long getId() { + public String getId() { return id; } @@ -130,7 +131,7 @@ public class Domain implements Comparable { return networkDomain; } - public long getParentDomainId() { + public String getParentDomainId() { return parentDomainId; } @@ -143,50 +144,40 @@ public class Domain implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Domain domain = (Domain) o; + Domain that = (Domain) o; - if (hasChild != domain.hasChild) return false; - if (id != domain.id) return false; - if (level != domain.level) return false; - if (parentDomainId != domain.parentDomainId) return false; - if (name != null ? !name.equals(domain.name) : domain.name != null) - return false; - if (networkDomain != null ? !networkDomain.equals(domain.networkDomain) : domain.networkDomain != null) - return false; - if (parentDomainName != null ? !parentDomainName.equals(domain.parentDomainName) : domain.parentDomainName != null) - return false; + if (!Objects.equal(hasChild, that.hasChild)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(level, that.level)) return false; + if (!Objects.equal(parentDomainId, that.parentDomainId)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(networkDomain, that.networkDomain)) return false; + if (!Objects.equal(parentDomainName, that.parentDomainName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (hasChild ? 1 : 0); - result = 31 * result + (int) (level ^ (level >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (networkDomain != null ? networkDomain.hashCode() : 0); - result = 31 * result + (int) (parentDomainId ^ (parentDomainId >>> 32)); - result = 31 * result + (parentDomainName != null ? parentDomainName.hashCode() : 0); - return result; + return Objects.hashCode(id, hasChild, level, name, networkDomain, parentDomainId, parentDomainName); } @Override public String toString() { return "Domain{" + - "id=" + id + + "id='" + id + '\'' + ", hasChild=" + hasChild + ", level=" + level + ", name='" + name + '\'' + ", networkDomain='" + networkDomain + '\'' + - ", parentDomainId=" + parentDomainId + + ", parentDomainId='" + parentDomainId + '\'' + ", parentDomainName='" + parentDomainName + '\'' + '}'; } @Override public int compareTo(Domain arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java index 40ecd2a476..fcec6d9174 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/EncryptedPasswordAndPrivateKey.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + /** * @author Andrei Savu */ @@ -52,18 +54,15 @@ public class EncryptedPasswordAndPrivateKey { EncryptedPasswordAndPrivateKey that = (EncryptedPasswordAndPrivateKey) o; - if (encryptedPassword != null ? !encryptedPassword.equals(that.encryptedPassword) : that.encryptedPassword != null) - return false; - if (privateKey != null ? !privateKey.equals(that.privateKey) : that.privateKey != null) return false; + if (!Objects.equal(encryptedPassword, that.encryptedPassword)) return false; + if (!Objects.equal(privateKey, that.privateKey)) return false; return true; } @Override public int hashCode() { - int result = encryptedPassword != null ? encryptedPassword.hashCode() : 0; - result = 31 * result + (privateKey != null ? privateKey.hashCode() : 0); - return result; + return Objects.hashCode(encryptedPassword, privateKey); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java index afeb56c04d..c1b6c1a7b6 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Event.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; + import java.util.Date; /** @@ -30,12 +32,12 @@ public class Event implements Comparable { } public static class Builder { - private long id; + private String id; private String account; private String description; private Date created; private String domain; - private long domainId; + private String domainId; //TODO Change to enum : the event level (INFO, WARN, ERROR) private String level; private String parentId; @@ -44,7 +46,7 @@ public class Event implements Comparable { private String type; private String username; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -69,7 +71,7 @@ public class Event implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -105,12 +107,12 @@ public class Event implements Comparable { } - private long id; + private String id; private String account; private String description; private Date created; private String domain; - private long domainId; + private String domainId; //TODO Change to enum : the event level (INFO, WARN, ERROR) private String level; private String parentId; @@ -119,7 +121,7 @@ public class Event implements Comparable { private String type; private String username; - public Event(long id, String account, String description, Date created, String domain, long domainId, String level, + public Event(String id, String account, String description, Date created, String domain, String domainId, String level, String parentId, String state, String type, String username) { this.id = id; this.account = account; @@ -144,7 +146,7 @@ public class Event implements Comparable { /** * @return the ID of the event */ - public long getId() { + public String getId() { return id; } @@ -180,7 +182,7 @@ public class Event implements Comparable { /** * @return the id of the account's domain */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -222,7 +224,7 @@ public class Event implements Comparable { @Override public int compareTo(Event arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } @Override @@ -230,37 +232,26 @@ public class Event implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Event event = (Event) o; + Event that = (Event) o; - if (domainId != event.domainId) return false; - if (id != event.id) return false; - if (account != null ? !account.equals(event.account) : event.account != null) return false; - if (created != null ? !created.equals(event.created) : event.created != null) return false; - if (description != null ? !description.equals(event.description) : event.description != null) return false; - if (domain != null ? !domain.equals(event.domain) : event.domain != null) return false; - if (level != null ? !level.equals(event.level) : event.level != null) return false; - if (parentId != null ? !parentId.equals(event.parentId) : event.parentId != null) return false; - if (state != null ? !state.equals(event.state) : event.state != null) return false; - if (type != null ? !type.equals(event.type) : event.type != null) return false; - if (username != null ? !username.equals(event.username) : event.username != null) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(level, that.level)) return false; + if (!Objects.equal(parentId, that.parentId)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(username, that.username)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (account != null ? account.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (domain != null ? domain.hashCode() : 0); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + (level != null ? level.hashCode() : 0); - result = 31 * result + (parentId != null ? parentId.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (username != null ? username.hashCode() : 0); - return result; + return Objects.hashCode(id, account, description, created, domain, domainId, level, parentId, state, type, username); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java index a8375b96b7..9c3a188f49 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/FirewallRule.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import java.util.Set; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -77,7 +78,7 @@ public class FirewallRule implements Comparable { } public static class Builder { - private long id; + private String id; private Set CIDRs; private int startPort; @@ -87,12 +88,12 @@ public class FirewallRule implements Comparable { private String icmpType; private String ipAddress; - private long ipAddressId; + private String ipAddressId; private Protocol protocol; private State state; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -127,7 +128,7 @@ public class FirewallRule implements Comparable { return this; } - public Builder ipAddressId(long ipAddressId) { + public Builder ipAddressId(String ipAddressId) { this.ipAddressId = ipAddressId; return this; } @@ -148,7 +149,7 @@ public class FirewallRule implements Comparable { } } - private long id; + private String id; @SerializedName("cidrlist") private Set CIDRs; @SerializedName("startport") @@ -162,12 +163,12 @@ public class FirewallRule implements Comparable { @SerializedName("ipaddress") private String ipAddress; @SerializedName("ipaddressid") - private long ipAddressId; + private String ipAddressId; private Protocol protocol; private State state; - public FirewallRule(long id, Set CIDRs, int startPort, int endPort, - String icmpCode, String icmpType, String ipAddress, long ipAddressId, + public FirewallRule(String id, Set CIDRs, int startPort, int endPort, + String icmpCode, String icmpType, String ipAddress, String ipAddressId, Protocol protocol, State state) { this.id = id; this.CIDRs = ImmutableSet.copyOf(CIDRs); @@ -183,10 +184,10 @@ public class FirewallRule implements Comparable { @Override public int compareTo(FirewallRule arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } - public long getId() { + public String getId() { return id; } @@ -214,7 +215,7 @@ public class FirewallRule implements Comparable { return ipAddress; } - public long getIpAddressId() { + public String getIpAddressId() { return ipAddressId; } @@ -233,40 +234,23 @@ public class FirewallRule implements Comparable { FirewallRule that = (FirewallRule) o; - if (endPort != that.endPort) return false; - if (id != that.id) return false; - if (startPort != that.startPort) return false; - if (CIDRs != null ? !CIDRs.equals(that.CIDRs) : that.CIDRs != null) - return false; - if (icmpCode != null ? !icmpCode.equals(that.icmpCode) : that.icmpCode != null) - return false; - if (icmpType != null ? !icmpType.equals(that.icmpType) : that.icmpType != null) - return false; - if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) - return false; - if (ipAddressId != that.ipAddressId) - return false; - if (protocol != null ? !protocol.equals(that.protocol) : that.protocol != null) - return false; - if (state != null ? !state.equals(that.state) : that.state != null) - return false; + if (!Objects.equal(endPort, that.endPort)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(startPort, that.startPort)) return false; + if (!Objects.equal(CIDRs, that.CIDRs)) return false; + if (!Objects.equal(icmpCode, that.icmpCode)) return false; + if (!Objects.equal(icmpType, that.icmpType)) return false; + if (!Objects.equal(ipAddress, that.ipAddress)) return false; + if (!Objects.equal(ipAddressId, that.ipAddressId)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(state, that.state)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (CIDRs != null ? CIDRs.hashCode() : 0); - result = 31 * result + startPort; - result = 31 * result + endPort; - result = 31 * result + (icmpCode != null ? icmpCode.hashCode() : 0); - result = 31 * result + (icmpType != null ? icmpType.hashCode() : 0); - result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); - result = 31 * result + (int) (ipAddressId ^ (ipAddressId >>> 32)); - result = 31 * result + (protocol != null ? protocol.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - return result; + return Objects.hashCode(endPort, id, startPort, CIDRs, icmpCode, icmpType, ipAddress, ipAddressId, protocol, state); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java index 18ae419ab7..a92ba74b19 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java @@ -23,6 +23,7 @@ import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -120,11 +121,11 @@ public class Host implements Comparable { } public static class Builder { - private long id; + private String id; private AllocationState allocationState; private int averageLoad; private String capabilities; - private long clusterId; + private String clusterId; private String clusterName; private ClusterType clusterType; private String cpuAllocated; @@ -142,28 +143,28 @@ public class Host implements Comparable { private String hypervisor; private String ipAddress; private boolean localStorageActive; - private long jobId; + private String jobId; private AsyncJob.Status jobStatus; private Date lastPinged; - private long managementServerId; + private String managementServerId; private long memoryAllocated; private long memoryTotal; private long memoryUsed; private String name; private long networkKbsRead; private long networkKbsWrite; - private long osCategoryId; - private long osCategoryName; - private long podId; + private String osCategoryId; + private String osCategoryName; + private String podId; private String podName; private Date removed; private State state; private Type type; private String version; - private long zoneId; + private String zoneId; private String zoneName; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -183,7 +184,7 @@ public class Host implements Comparable { return this; } - public Builder clusterId(long clusterId) { + public Builder clusterId(String clusterId) { this.clusterId = clusterId; return this; } @@ -273,7 +274,7 @@ public class Host implements Comparable { return this; } - public Builder jobId(long jobId) { + public Builder jobId(String jobId) { this.jobId = jobId; return this; } @@ -288,7 +289,7 @@ public class Host implements Comparable { return this; } - public Builder managementServerId(long managementServerId) { + public Builder managementServerId(String managementServerId) { this.managementServerId = managementServerId; return this; } @@ -323,17 +324,17 @@ public class Host implements Comparable { return this; } - public Builder osCategoryId(long osCategoryId) { + public Builder osCategoryId(String osCategoryId) { this.osCategoryId = osCategoryId; return this; } - public Builder osCategoryName(long osCategoryName) { + public Builder osCategoryName(String osCategoryName) { this.osCategoryName = osCategoryName; return this; } - public Builder podId(long podId) { + public Builder podId(String podId) { this.podId = podId; return this; } @@ -363,7 +364,7 @@ public class Host implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -387,7 +388,7 @@ public class Host implements Comparable { } } - private long id; + private String id; @SerializedName("allocationstate") private AllocationState allocationState; @SerializedName("averageload") @@ -395,7 +396,7 @@ public class Host implements Comparable { @SerializedName("capabilities") private String capabilities; @SerializedName("clusterid") - private long clusterId; + private String clusterId; @SerializedName("clustername") private String clusterName; @SerializedName("clustertype") @@ -427,13 +428,13 @@ public class Host implements Comparable { @SerializedName("islocalstorageactive") private boolean localStorageActive; @SerializedName("jobid") - private long jobId; + private String jobId; @SerializedName("jobstatus") private AsyncJob.Status jobStatus; @SerializedName("lastpinged") private Date lastPinged; @SerializedName("managementserverid") - private long managementServerId; + private String managementServerId; @SerializedName("memoryallocated") private long memoryAllocated; @SerializedName("memorytotal") @@ -446,11 +447,11 @@ public class Host implements Comparable { @SerializedName("networkkbswrite") private long networkKbsWrite; @SerializedName("oscategoryid") - private long osCategoryId; + private String osCategoryId; @SerializedName("oscategoryname") - private long osCategoryName; + private String osCategoryName; @SerializedName("podid") - private long podId; + private String podId; @SerializedName("podname") private String podName; private Date removed; @@ -458,7 +459,7 @@ public class Host implements Comparable { private Type type; private String version; @SerializedName("zoneid") - private long zoneId; + private String zoneId; @SerializedName("zonename") private String zoneName; @@ -466,16 +467,16 @@ public class Host implements Comparable { Host() { } - public Host(long id, AllocationState allocationState, int averageLoad, String capabilities, - long clusterId, String clusterName, ClusterType clusterType, String cpuAllocated, + public Host(String id, AllocationState allocationState, int averageLoad, String capabilities, + String clusterId, String clusterName, ClusterType clusterType, String cpuAllocated, int cpuNumber, int cpuSpeed, String cpuUsed, float cpuWithOverProvisioning, Date created, Date disconnected, long diskSizeAllocated, long diskSizeTotal, String events, boolean hasEnoughCapacity, String hostTags, String hypervisor, - String ipAddress, boolean localStorageActive, long jobId, AsyncJob.Status jobStatus, - Date lastPinged, long managementServerId, long memoryAllocated, long memoryTotal, + String ipAddress, boolean localStorageActive, String jobId, AsyncJob.Status jobStatus, + Date lastPinged, String managementServerId, long memoryAllocated, long memoryTotal, long memoryUsed, String name, long networkKbsRead, long networkKbsWrite, - long osCategoryId, long osCategoryName, long podId, String podName, Date removed, - State state, Type type, String version, long zoneId, String zoneName) { + String osCategoryId, String osCategoryName, String podId, String podName, Date removed, + State state, Type type, String version, String zoneId, String zoneName) { this.id = id; this.allocationState = allocationState; this.averageLoad = averageLoad; @@ -520,7 +521,7 @@ public class Host implements Comparable { this.zoneName = zoneName; } - public long getId() { + public String getId() { return id; } @@ -536,7 +537,7 @@ public class Host implements Comparable { return capabilities; } - public long getClusterId() { + public String getClusterId() { return clusterId; } @@ -608,7 +609,7 @@ public class Host implements Comparable { return localStorageActive; } - public long getJobId() { + public String getJobId() { return jobId; } @@ -620,7 +621,7 @@ public class Host implements Comparable { return lastPinged; } - public long getManagementServerId() { + public String getManagementServerId() { return managementServerId; } @@ -648,15 +649,15 @@ public class Host implements Comparable { return networkKbsWrite; } - public long getOsCategoryId() { + public String getOsCategoryId() { return osCategoryId; } - public long getOsCategoryName() { + public String getOsCategoryName() { return osCategoryName; } - public long getPodId() { + public String getPodId() { return podId; } @@ -680,7 +681,7 @@ public class Host implements Comparable { return version; } - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -693,101 +694,64 @@ public class Host implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Host host = (Host) o; + Host that = (Host) o; - if (averageLoad != host.averageLoad) return false; - if (clusterId != host.clusterId) return false; - if (cpuNumber != host.cpuNumber) return false; - if (cpuSpeed != host.cpuSpeed) return false; - if (Float.compare(host.cpuWithOverProvisioning, cpuWithOverProvisioning) != 0) return false; - if (diskSizeAllocated != host.diskSizeAllocated) return false; - if (diskSizeTotal != host.diskSizeTotal) return false; - if (hasEnoughCapacity != host.hasEnoughCapacity) return false; - if (id != host.id) return false; - if (jobId != host.jobId) return false; - if (localStorageActive != host.localStorageActive) return false; - if (managementServerId != host.managementServerId) return false; - if (memoryAllocated != host.memoryAllocated) return false; - if (memoryTotal != host.memoryTotal) return false; - if (memoryUsed != host.memoryUsed) return false; - if (networkKbsRead != host.networkKbsRead) return false; - if (networkKbsWrite != host.networkKbsWrite) return false; - if (osCategoryId != host.osCategoryId) return false; - if (osCategoryName != host.osCategoryName) return false; - if (podId != host.podId) return false; - if (zoneId != host.zoneId) return false; - if (allocationState != host.allocationState) return false; - if (capabilities != null ? !capabilities.equals(host.capabilities) : host.capabilities != null) return false; - if (clusterName != null ? !clusterName.equals(host.clusterName) : host.clusterName != null) return false; - if (clusterType != host.clusterType) return false; - if (cpuAllocated != null ? !cpuAllocated.equals(host.cpuAllocated) : host.cpuAllocated != null) return false; - if (cpuUsed != null ? !cpuUsed.equals(host.cpuUsed) : host.cpuUsed != null) return false; - if (created != null ? !created.equals(host.created) : host.created != null) return false; - if (disconnected != null ? !disconnected.equals(host.disconnected) : host.disconnected != null) return false; - if (events != null ? !events.equals(host.events) : host.events != null) return false; - if (hostTags != null ? !hostTags.equals(host.hostTags) : host.hostTags != null) return false; - if (hypervisor != null ? !hypervisor.equals(host.hypervisor) : host.hypervisor != null) return false; - if (ipAddress != null ? !ipAddress.equals(host.ipAddress) : host.ipAddress != null) return false; - if (jobStatus != host.jobStatus) return false; - if (lastPinged != null ? !lastPinged.equals(host.lastPinged) : host.lastPinged != null) return false; - if (name != null ? !name.equals(host.name) : host.name != null) return false; - if (podName != null ? !podName.equals(host.podName) : host.podName != null) return false; - if (removed != null ? !removed.equals(host.removed) : host.removed != null) return false; - if (state != host.state) return false; - if (type != host.type) return false; - if (version != null ? !version.equals(host.version) : host.version != null) return false; - if (zoneName != null ? !zoneName.equals(host.zoneName) : host.zoneName != null) return false; + if (!Objects.equal(averageLoad, that.averageLoad)) return false; + if (!Objects.equal(clusterId, that.clusterId)) return false; + if (!Objects.equal(cpuNumber, that.cpuNumber)) return false; + if (!Objects.equal(cpuSpeed, that.cpuSpeed)) return false; + if (!Objects.equal(cpuWithOverProvisioning, that.cpuWithOverProvisioning)) return false; + if (!Objects.equal(diskSizeAllocated, that.diskSizeAllocated)) return false; + if (!Objects.equal(diskSizeTotal, that.diskSizeTotal)) return false; + if (!Objects.equal(hasEnoughCapacity, that.hasEnoughCapacity)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + if (!Objects.equal(localStorageActive, that.localStorageActive)) return false; + if (!Objects.equal(managementServerId, that.managementServerId)) return false; + if (!Objects.equal(memoryAllocated, that.memoryAllocated)) return false; + if (!Objects.equal(memoryTotal, that.memoryTotal)) return false; + if (!Objects.equal(memoryUsed, that.memoryUsed)) return false; + if (!Objects.equal(networkKbsRead, that.networkKbsRead)) return false; + if (!Objects.equal(networkKbsWrite, that.networkKbsWrite)) return false; + if (!Objects.equal(osCategoryId, that.osCategoryId)) return false; + if (!Objects.equal(osCategoryName, that.osCategoryName)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(allocationState, that.allocationState)) return false; + if (!Objects.equal(capabilities, that.capabilities)) return false; + if (!Objects.equal(clusterName, that.clusterName)) return false; + if (!Objects.equal(clusterType, that.clusterType)) return false; + if (!Objects.equal(cpuAllocated, that.cpuAllocated)) return false; + if (!Objects.equal(cpuUsed, that.cpuUsed)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(disconnected, that.disconnected)) return false; + if (!Objects.equal(events, that.events)) return false; + if (!Objects.equal(hostTags, that.hostTags)) return false; + if (!Objects.equal(hypervisor, that.hypervisor)) return false; + if (!Objects.equal(ipAddress, that.ipAddress)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + if (!Objects.equal(lastPinged, that.lastPinged)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(removed, that.removed)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(version, that.version)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); - result = 31 * result + averageLoad; - result = 31 * result + (capabilities != null ? capabilities.hashCode() : 0); - result = 31 * result + (int) (clusterId ^ (clusterId >>> 32)); - result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0); - result = 31 * result + (clusterType != null ? clusterType.hashCode() : 0); - result = 31 * result + (cpuAllocated != null ? cpuAllocated.hashCode() : 0); - result = 31 * result + cpuNumber; - result = 31 * result + cpuSpeed; - result = 31 * result + (cpuUsed != null ? cpuUsed.hashCode() : 0); - result = 31 * result + (cpuWithOverProvisioning != +0.0f ? Float.floatToIntBits(cpuWithOverProvisioning) : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (disconnected != null ? disconnected.hashCode() : 0); - result = 31 * result + (int) (diskSizeAllocated ^ (diskSizeAllocated >>> 32)); - result = 31 * result + (int) (diskSizeTotal ^ (diskSizeTotal >>> 32)); - result = 31 * result + (events != null ? events.hashCode() : 0); - result = 31 * result + (hasEnoughCapacity ? 1 : 0); - result = 31 * result + (hostTags != null ? hostTags.hashCode() : 0); - result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); - result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); - result = 31 * result + (localStorageActive ? 1 : 0); - result = 31 * result + (int) (jobId ^ (jobId >>> 32)); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - result = 31 * result + (lastPinged != null ? lastPinged.hashCode() : 0); - result = 31 * result + (int) (managementServerId ^ (managementServerId >>> 32)); - result = 31 * result + (int) (memoryAllocated ^ (memoryAllocated >>> 32)); - result = 31 * result + (int) (memoryTotal ^ (memoryTotal >>> 32)); - result = 31 * result + (int) (memoryUsed ^ (memoryUsed >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (networkKbsRead ^ (networkKbsRead >>> 32)); - result = 31 * result + (int) (networkKbsWrite ^ (networkKbsWrite >>> 32)); - result = 31 * result + (int) (osCategoryId ^ (osCategoryId >>> 32)); - result = 31 * result + (int) (osCategoryName ^ (osCategoryName >>> 32)); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (removed != null ? removed.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(averageLoad, clusterId, cpuNumber, cpuSpeed, cpuWithOverProvisioning, diskSizeAllocated, + diskSizeTotal, hasEnoughCapacity, id, jobId, localStorageActive, managementServerId, + memoryAllocated, memoryTotal, memoryUsed, networkKbsRead, networkKbsWrite, osCategoryId, + osCategoryName, podId, zoneId, allocationState, capabilities, clusterName, clusterType, + cpuAllocated, cpuUsed, created, disconnected, events, hostTags, hypervisor, ipAddress, + jobStatus, lastPinged, name, podName, removed, state, type, version, zoneName); } - + @Override public String toString() { return "Host{" + @@ -838,6 +802,6 @@ public class Host implements Comparable { @Override public int compareTo(Host other) { - return Long.valueOf(this.getId()).compareTo(other.getId()); + return this.getId().compareTo(other.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java index 4dca3a0c52..46a0b1133b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IPForwardingRule.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import java.util.Collections; import java.util.Set; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.gson.annotations.SerializedName; @@ -34,22 +35,22 @@ public class IPForwardingRule implements Comparable { } public static class Builder { - private long id; + private String id; private String IPAddress; - private long IPAddressId; + private String IPAddressId; private int startPort; private String protocol; public int endPort; private String state; private String virtualMachineDisplayName; - public long virtualMachineId; + public String virtualMachineId; private String virtualMachineName; private Set CIDRs = ImmutableSet.of(); private int privateEndPort; private int publicEndPort; public int publicPort; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -59,7 +60,7 @@ public class IPForwardingRule implements Comparable { return this; } - public Builder IPAddressId(long IPAddressId) { + public Builder IPAddressId(String IPAddressId) { this.IPAddressId = IPAddressId; return this; } @@ -89,7 +90,7 @@ public class IPForwardingRule implements Comparable { return this; } - public Builder virtualMachineId(long virtualMachineId) { + public Builder virtualMachineId(String virtualMachineId) { this.virtualMachineId = virtualMachineId; return this; } @@ -125,11 +126,11 @@ public class IPForwardingRule implements Comparable { } } - private long id; + private String id; @SerializedName("ipaddress") private String IPAddress; @SerializedName("ipaddressid") - private long IPAddressId; + private String IPAddressId; @SerializedName("startport") private int startPort; private String protocol; @@ -139,7 +140,7 @@ public class IPForwardingRule implements Comparable { @SerializedName("virtualmachinedisplayname") private String virtualMachineDisplayName; @SerializedName("virtualmachineid") - public long virtualMachineId; + public String virtualMachineId; @SerializedName("virtualmachinename") private String virtualMachineName; @SerializedName("publicport") @@ -156,8 +157,8 @@ public class IPForwardingRule implements Comparable { } - public IPForwardingRule(long id, String iPAddress, long iPAddressId, int startPort, String protocol, int endPort, - String state, String virtualMachineDisplayName, long virtualMachineId, String virtualMachineName, + public IPForwardingRule(String id, String iPAddress, String iPAddressId, int startPort, String protocol, int endPort, + String state, String virtualMachineDisplayName, String virtualMachineId, String virtualMachineName, int publicEndPort, int publicPort, Set CIDRs, int privateEndPort) { this.id = id; this.IPAddress = iPAddress; @@ -178,13 +179,13 @@ public class IPForwardingRule implements Comparable { @Override public int compareTo(IPForwardingRule arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } /** * @return the ID of the ip forwarding rule */ - public long getId() { + public String getId() { return id; } @@ -198,7 +199,7 @@ public class IPForwardingRule implements Comparable { /** * @return the public ip address id for the ip forwarding rule */ - public long getIPAddressId() { + public String getIPAddressId() { return IPAddressId; } @@ -240,7 +241,7 @@ public class IPForwardingRule implements Comparable { /** * @return the VM ID for the ip forwarding rule */ - public long getVirtualMachineId() { + public String getVirtualMachineId() { return virtualMachineId; } @@ -280,76 +281,34 @@ public class IPForwardingRule implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + (int) (IPAddressId ^ (IPAddressId >>> 32)); - result = prime * result + endPort; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); - result = prime * result + startPort; - result = prime * result + publicEndPort; - result = prime * result + privateEndPort; - result = prime * result + publicPort; - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); - result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); - result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + IPForwardingRule that = (IPForwardingRule) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(IPAddressId, that.IPAddressId)) return false; + if (!Objects.equal(endPort, that.endPort)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(startPort, that.startPort)) return false; + if (!Objects.equal(publicEndPort, that.publicEndPort)) return false; + if (!Objects.equal(privateEndPort, that.privateEndPort)) return false; + if (!Objects.equal(publicPort, that.publicPort)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false; + if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false; + if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - IPForwardingRule other = (IPForwardingRule) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (IPAddressId != other.IPAddressId) - return false; - if (endPort != other.endPort) - return false; - if (publicPort != other.publicPort) - return false; - if (publicEndPort != other.publicEndPort) - return false; - if (privateEndPort != other.privateEndPort) - return false; - if (id != other.id) - return false; - if (protocol == null) { - if (other.protocol != null) - return false; - } else if (!protocol.equals(other.protocol)) - return false; - if (startPort != other.startPort) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (virtualMachineDisplayName == null) { - if (other.virtualMachineDisplayName != null) - return false; - } else if (!virtualMachineDisplayName.equals(other.virtualMachineDisplayName)) - return false; - if (virtualMachineId != other.virtualMachineId) - return false; - if (virtualMachineName == null) { - if (other.virtualMachineName != null) - return false; - } else if (!virtualMachineName.equals(other.virtualMachineName)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, IPAddressId, endPort, id, protocol, startPort, publicEndPort, + privateEndPort, publicPort, state, virtualMachineDisplayName, + virtualMachineId, virtualMachineName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java index b38b81509d..6ed2242ec3 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISO.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -35,43 +36,43 @@ public class ISO implements Comparable { public static class Builder { - private long id; + private String id; private String account; - private long accountId; + private String accountId; private boolean bootable; private String checksum; private Date created; private boolean crossZones; private String displayText; private String domain; - private long domainid; + private String domainid; private String format; - private long hostId; + private String hostId; private String hostName; private String hypervisor; private boolean isExtractable; private boolean isFeatured; private boolean isPublic; private boolean isReady; - private long jobId; + private String jobId; private String jobStatus; private String name; - private long osTypeId; + private String osTypeId; private String osTypeName; private boolean passwordEnabled; private Date removed; private long size; - private long sourceTemplateId; + private String sourceTemplateId; private String status; private String templateTag; private String templateType; - private long zoneId; + private String zoneId; private String zoneName; /** * @param id the template ID */ - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -87,7 +88,7 @@ public class ISO implements Comparable { /** * @param accountId the account id to which the template belongs */ - public Builder accountId(long accountId) { + public Builder accountId(String accountId) { this.accountId = accountId; return this; } @@ -143,7 +144,7 @@ public class ISO implements Comparable { /** * @param domainid the ID of the domain to which the template belongs */ - public Builder domainid(long domainid) { + public Builder domainid(String domainid) { this.domainid = domainid; return this; } @@ -159,7 +160,7 @@ public class ISO implements Comparable { /** * @param hostId the ID of the secondary storage host for the template */ - public Builder hostId(long hostId) { + public Builder hostId(String hostId) { this.hostId = hostId; return this; } @@ -215,7 +216,7 @@ public class ISO implements Comparable { /** * @param jobId shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the template */ - public Builder jobId(long jobId) { + public Builder jobId(String jobId) { this.jobId = jobId; return this; } @@ -239,7 +240,7 @@ public class ISO implements Comparable { /** * @param osTypeId the ID of the OS type for this template. */ - public Builder osTypeId(long osTypeId) { + public Builder osTypeId(String osTypeId) { this.osTypeId = osTypeId; return this; } @@ -279,7 +280,7 @@ public class ISO implements Comparable { /** * @param sourceTemplateId the template ID of the parent template if present */ - public Builder sourceTemplateId(long sourceTemplateId) { + public Builder sourceTemplateId(String sourceTemplateId) { this.sourceTemplateId = sourceTemplateId; return this; } @@ -311,7 +312,7 @@ public class ISO implements Comparable { /** * @param zoneId the ID of the zone for this template */ - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -326,10 +327,10 @@ public class ISO implements Comparable { } - private long id; + private String id; private String account; @SerializedName("accountid") - private long accountId; + private String accountId; private boolean bootable; private String checksum; private Date created; @@ -338,10 +339,10 @@ public class ISO implements Comparable { private String displayText; private String domain; @SerializedName("domainId") - private long domainid; + private String domainid; private String format; @SerializedName("hostid") - private long hostId; + private String hostId; @SerializedName("hostname") private String hostName; private String hypervisor; @@ -354,12 +355,12 @@ public class ISO implements Comparable { @SerializedName("isready") private boolean isReady; @SerializedName("jobid") - private long jobId; + private String jobId; @SerializedName("jobstatus") private String jobStatus; private String name; @SerializedName("ostypeid") - private long osTypeId; + private String osTypeId; @SerializedName("ostypename") private String osTypeName; @SerializedName("passwordenabled") @@ -367,14 +368,14 @@ public class ISO implements Comparable { private Date removed; private long size; @SerializedName("sourcetemplateid") - private long sourceTemplateId; + private String sourceTemplateId; private String status; @SerializedName("templatetag") private String templateTag; @SerializedName("templatetype") private String templateType; @SerializedName("zoneid") - private long zoneId; + private String zoneId; @SerializedName("zonename") private String zoneName; @@ -387,7 +388,7 @@ public class ISO implements Comparable { /** * @return the template ID */ - public long getId() { + public String getId() { return id; } @@ -401,7 +402,7 @@ public class ISO implements Comparable { /** * @return the account id to which the template belongs */ - public long getAccountId() { + public String getAccountId() { return accountId; } @@ -450,7 +451,7 @@ public class ISO implements Comparable { /** * @return the ID of the domain to which the template belongs */ - public long getDomainid() { + public String getDomainid() { return domainid; } @@ -464,7 +465,7 @@ public class ISO implements Comparable { /** * @return the ID of the secondary storage host for the template */ - public long getHostId() { + public String getHostId() { return hostId; } @@ -513,7 +514,7 @@ public class ISO implements Comparable { /** * @return shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the template */ - public long getJobId() { + public String getJobId() { return jobId; } @@ -534,7 +535,7 @@ public class ISO implements Comparable { /** * @return the ID of the OS type for this template. */ - public long getOsTypeId() { + public String getOsTypeId() { return osTypeId; } @@ -569,7 +570,7 @@ public class ISO implements Comparable { /** * @return the template ID of the parent template if present */ - public long getSourceTemplateId() { + public String getSourceTemplateId() { return sourceTemplateId; } @@ -597,7 +598,7 @@ public class ISO implements Comparable { /** * @return the ID of the zone for this template */ - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -613,79 +614,50 @@ public class ISO implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ISO iso = (ISO) o; + ISO that = (ISO) o; - if (accountId != iso.accountId) return false; - if (bootable != iso.bootable) return false; - if (crossZones != iso.crossZones) return false; - if (domainid != iso.domainid) return false; - if (hostId != iso.hostId) return false; - if (id != iso.id) return false; - if (isExtractable != iso.isExtractable) return false; - if (isFeatured != iso.isFeatured) return false; - if (isPublic != iso.isPublic) return false; - if (isReady != iso.isReady) return false; - if (jobId != iso.jobId) return false; - if (osTypeId != iso.osTypeId) return false; - if (passwordEnabled != iso.passwordEnabled) return false; - if (size != iso.size) return false; - if (sourceTemplateId != iso.sourceTemplateId) return false; - if (zoneId != iso.zoneId) return false; - if (account != null ? !account.equals(iso.account) : iso.account != null) return false; - if (checksum != null ? !checksum.equals(iso.checksum) : iso.checksum != null) return false; - if (created != null ? !created.equals(iso.created) : iso.created != null) return false; - if (displayText != null ? !displayText.equals(iso.displayText) : iso.displayText != null) return false; - if (domain != null ? !domain.equals(iso.domain) : iso.domain != null) return false; - if (format != null ? !format.equals(iso.format) : iso.format != null) return false; - if (hostName != null ? !hostName.equals(iso.hostName) : iso.hostName != null) return false; - if (hypervisor != null ? !hypervisor.equals(iso.hypervisor) : iso.hypervisor != null) return false; - if (jobStatus != null ? !jobStatus.equals(iso.jobStatus) : iso.jobStatus != null) return false; - if (name != null ? !name.equals(iso.name) : iso.name != null) return false; - if (osTypeName != null ? !osTypeName.equals(iso.osTypeName) : iso.osTypeName != null) return false; - if (removed != null ? !removed.equals(iso.removed) : iso.removed != null) return false; - if (status != null ? !status.equals(iso.status) : iso.status != null) return false; - if (templateTag != null ? !templateTag.equals(iso.templateTag) : iso.templateTag != null) return false; - if (templateType != null ? !templateType.equals(iso.templateType) : iso.templateType != null) return false; - if (zoneName != null ? !zoneName.equals(iso.zoneName) : iso.zoneName != null) return false; + if (!Objects.equal(accountId, that.accountId)) return false; + if (!Objects.equal(bootable, that.bootable)) return false; + if (!Objects.equal(crossZones, that.crossZones)) return false; + if (!Objects.equal(domainid, that.domainid)) return false; + if (!Objects.equal(hostId, that.hostId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isExtractable, that.isExtractable)) return false; + if (!Objects.equal(isPublic, that.isPublic)) return false; + if (!Objects.equal(isReady, that.isReady)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + if (!Objects.equal(osTypeId, that.osTypeId)) return false; + if (!Objects.equal(passwordEnabled, that.passwordEnabled)) return false; + if (!Objects.equal(size, that.size)) return false; + if (!Objects.equal(sourceTemplateId, that.sourceTemplateId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(checksum, that.checksum)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(format, that.format)) return false; + if (!Objects.equal(hostName, that.hostName)) return false; + if (!Objects.equal(hypervisor, that.hypervisor)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(osTypeName, that.osTypeName)) return false; + if (!Objects.equal(removed, that.removed)) return false; + if (!Objects.equal(status, that.status)) return false; + if (!Objects.equal(templateTag, that.templateTag)) return false; + if (!Objects.equal(templateType, that.templateType)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (account != null ? account.hashCode() : 0); - result = 31 * result + (int) (accountId ^ (accountId >>> 32)); - result = 31 * result + (bootable ? 1 : 0); - result = 31 * result + (checksum != null ? checksum.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (crossZones ? 1 : 0); - result = 31 * result + (displayText != null ? displayText.hashCode() : 0); - result = 31 * result + (domain != null ? domain.hashCode() : 0); - result = 31 * result + (int) (domainid ^ (domainid >>> 32)); - result = 31 * result + (format != null ? format.hashCode() : 0); - result = 31 * result + (int) (hostId ^ (hostId >>> 32)); - result = 31 * result + (hostName != null ? hostName.hashCode() : 0); - result = 31 * result + (hypervisor != null ? hypervisor.hashCode() : 0); - result = 31 * result + (isExtractable ? 1 : 0); - result = 31 * result + (isFeatured ? 1 : 0); - result = 31 * result + (isPublic ? 1 : 0); - result = 31 * result + (isReady ? 1 : 0); - result = 31 * result + (int) (jobId ^ (jobId >>> 32)); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (osTypeId ^ (osTypeId >>> 32)); - result = 31 * result + (osTypeName != null ? osTypeName.hashCode() : 0); - result = 31 * result + (passwordEnabled ? 1 : 0); - result = 31 * result + (removed != null ? removed.hashCode() : 0); - result = 31 * result + (int) (size ^ (size >>> 32)); - result = 31 * result + (int) (sourceTemplateId ^ (sourceTemplateId >>> 32)); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (templateTag != null ? templateTag.hashCode() : 0); - result = 31 * result + (templateType != null ? templateType.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(accountId, bootable, crossZones, domainid, hostId, id, isExtractable, + isPublic, isReady, jobId, osTypeId, passwordEnabled, size, sourceTemplateId, + zoneId, account, checksum, created, displayText, domain, format, hostName, + hypervisor, jobStatus, name, osTypeName, removed, status, templateTag, + templateType, zoneName); } @Override @@ -728,7 +700,7 @@ public class ISO implements Comparable { @Override public int compareTo(ISO other) { - return new Long(id).compareTo(other.getId()); + return id.compareTo(other.getId()); } public enum ISOFilter { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java index 9fb91087c4..13e79e4048 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOExtraction.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.util.Date; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -33,10 +34,10 @@ public class ISOExtraction implements Comparable { public static class Builder { - private long id; - private long accountId; + private String id; + private String accountId; private Date created; - private long extractId; + private String extractId; private ExtractMode extractMode; private String name; private String state; @@ -44,13 +45,13 @@ public class ISOExtraction implements Comparable { private String storageType; private int uploadPercentage; private String url; - private long zoneId; + private String zoneId; private String zoneName; /** * @param id the id of extracted object */ - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -58,7 +59,7 @@ public class ISOExtraction implements Comparable { /** * @param accountId the account id to which the extracted object belongs */ - public Builder accountId(long accountId) { + public Builder accountId(String accountId) { this.accountId = accountId; return this; } @@ -74,7 +75,7 @@ public class ISOExtraction implements Comparable { /** * @param extractId the upload id of extracted object */ - public Builder extractId(long extractId) { + public Builder extractId(String extractId) { this.extractId = extractId; return this; } @@ -138,7 +139,7 @@ public class ISOExtraction implements Comparable { /** * @param zoneId zone ID the object was extracted from */ - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -153,11 +154,11 @@ public class ISOExtraction implements Comparable { } - private long id; + private String id; @SerializedName("accountid") - private long accountId; + private String accountId; private Date created; - private long extractId; + private String extractId; private ExtractMode extractMode; private String name; private String state; @@ -168,7 +169,7 @@ public class ISOExtraction implements Comparable { private int uploadPercentage; private String url; @SerializedName("zoneid") - private long zoneId; + private String zoneId; @SerializedName("zonename") private String zoneName; @@ -181,14 +182,14 @@ public class ISOExtraction implements Comparable { /** * @return the id of extracted object */ - public long getId() { + public String getId() { return id; } /** * @return the account id to which the extracted object belongs */ - public long getAccountId() { + public String getAccountId() { return accountId; } @@ -202,7 +203,7 @@ public class ISOExtraction implements Comparable { /** * @return the upload id of extracted object */ - public long getExtractId() { + public String getExtractId() { return extractId; } @@ -258,7 +259,7 @@ public class ISOExtraction implements Comparable { /** * @return zone ID the object was extracted from */ - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -276,39 +277,26 @@ public class ISOExtraction implements Comparable { ISOExtraction that = (ISOExtraction) o; - if (accountId != that.accountId) return false; - if (extractId != that.extractId) return false; - if (id != that.id) return false; - if (uploadPercentage != that.uploadPercentage) return false; - if (zoneId != that.zoneId) return false; - if (created != null ? !created.equals(that.created) : that.created != null) return false; - if (extractMode != that.extractMode) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (state != null ? !state.equals(that.state) : that.state != null) return false; - if (status != null ? !status.equals(that.status) : that.status != null) return false; - if (storageType != null ? !storageType.equals(that.storageType) : that.storageType != null) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - if (zoneName != null ? !zoneName.equals(that.zoneName) : that.zoneName != null) return false; + if (!Objects.equal(accountId, that.accountId)) return false; + if (!Objects.equal(extractId, that.extractId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(uploadPercentage, that.uploadPercentage)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(extractMode, that.extractMode)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(status, that.status)) return false; + if (!Objects.equal(storageType, that.storageType)) return false; + if (!Objects.equal(url, that.url)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (int) (accountId ^ (accountId >>> 32)); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (int) (extractId ^ (extractId >>> 32)); - result = 31 * result + (extractMode != null ? extractMode.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (storageType != null ? storageType.hashCode() : 0); - result = 31 * result + uploadPercentage; - result = 31 * result + (url != null ? url.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - return result; + return Objects.hashCode(accountId, extractId, id, uploadPercentage, zoneId, created, extractMode, name, state, status, storageType, url, zoneName); } @Override @@ -332,7 +320,7 @@ public class ISOExtraction implements Comparable { @Override public int compareTo(ISOExtraction other) { - return new Long(id).compareTo(other.getId()); + return id.compareTo(other.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java index ac0214507f..79d1efe929 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ISOPermissions.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.util.Set; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -33,15 +34,15 @@ public class ISOPermissions implements Comparable { public static class Builder { - private long id; + private String id; private String account; - private long domainId; + private String domainId; private boolean isPublic; /** * @param id the template ID */ - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -57,7 +58,7 @@ public class ISOPermissions implements Comparable { /** * @param domainId the ID of the domain to which the template belongs */ - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -72,11 +73,11 @@ public class ISOPermissions implements Comparable { } - private long id; + private String id; @SerializedName("account") private Set accounts; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("ispublic") private boolean isPublic; @@ -89,7 +90,7 @@ public class ISOPermissions implements Comparable { /** * @return the template ID */ - public long getId() { + public String getId() { return id; } @@ -103,7 +104,7 @@ public class ISOPermissions implements Comparable { /** * @return the ID of the domain to which the template belongs */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -115,37 +116,23 @@ public class ISOPermissions implements Comparable { } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ISOPermissions other = (ISOPermissions) obj; - if (accounts == null) { - if (other.accounts != null) - return false; - } else if (!accounts.equals(other.accounts)) - return false; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (isPublic != other.isPublic) - return false; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ISOPermissions that = (ISOPermissions) o; + + if (!Objects.equal(accounts, that.accounts)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isPublic, that.isPublic)) return false; + return true; } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accounts == null) ? 0 : accounts.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isPublic ? 1231 : 1237); - return result; + return Objects.hashCode(accounts, domainId, id, isPublic); } @Override @@ -160,7 +147,7 @@ public class ISOPermissions implements Comparable { @Override public int compareTo(ISOPermissions other) { - return new Long(id).compareTo(other.getId()); + return id.compareTo(other.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java index 4012e48101..ebff971c4a 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/IngressRule.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import static com.google.common.base.Preconditions.checkArgument; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -38,7 +39,7 @@ public class IngressRule implements Comparable { private int ICMPCode = -1; private int ICMPType = -1; private String protocol; - private long id = -1; + private String id; private String securityGroupName; private int startPort = -1; @@ -72,7 +73,7 @@ public class IngressRule implements Comparable { return this; } - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -103,7 +104,7 @@ public class IngressRule implements Comparable { private int ICMPType = -1; private String protocol; @SerializedName("ruleid") - private long id = -1; + private String id; @SerializedName("securitygroupname") private String securityGroupName; @SerializedName("startport") @@ -114,7 +115,7 @@ public class IngressRule implements Comparable { } - public IngressRule(String account, String CIDR, int endPort, int iCMPCode, int iCMPType, String protocol, long id, + public IngressRule(String account, String CIDR, int endPort, int iCMPCode, int iCMPType, String protocol, String id, String securityGroupName, int startPort) { if (account == null) checkArgument(securityGroupName == null && CIDR != null, @@ -178,7 +179,7 @@ public class IngressRule implements Comparable { /** * @return the id of the ingress rule */ - public long getId() { + public String getId() { return id; } @@ -197,61 +198,28 @@ public class IngressRule implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((CIDR == null) ? 0 : CIDR.hashCode()); - result = prime * result + ICMPCode; - result = prime * result + ICMPType; - result = prime * result + ((account == null) ? 0 : account.hashCode()); - result = prime * result + endPort; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); - result = prime * result + ((securityGroupName == null) ? 0 : securityGroupName.hashCode()); - result = prime * result + startPort; - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + IngressRule that = (IngressRule) o; + + if (!Objects.equal(CIDR, that.CIDR)) return false; + if (!Objects.equal(ICMPCode, that.ICMPCode)) return false; + if (!Objects.equal(ICMPType, that.ICMPType)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(endPort, that.endPort)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(securityGroupName, that.securityGroupName)) return false; + if (!Objects.equal(startPort, that.startPort)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - IngressRule other = (IngressRule) obj; - if (CIDR == null) { - if (other.CIDR != null) - return false; - } else if (!CIDR.equals(other.CIDR)) - return false; - if (ICMPCode != other.ICMPCode) - return false; - if (ICMPType != other.ICMPType) - return false; - if (account == null) { - if (other.account != null) - return false; - } else if (!account.equals(other.account)) - return false; - if (endPort != other.endPort) - return false; - if (id != other.id) - return false; - if (protocol == null) { - if (other.protocol != null) - return false; - } else if (!protocol.equals(other.protocol)) - return false; - if (securityGroupName == null) { - if (other.securityGroupName != null) - return false; - } else if (!securityGroupName.equals(other.securityGroupName)) - return false; - if (startPort != other.startPort) - return false; - return true; + public int hashCode() { + return Objects.hashCode(CIDR, ICMPCode, ICMPType, account, endPort, id, protocol, securityGroupName, startPort); } @Override @@ -271,6 +239,6 @@ public class IngressRule implements Comparable { @Override public int compareTo(IngressRule arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java index 823114a62a..f6b3bc469d 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/JobResult.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -60,17 +61,15 @@ public class JobResult implements Comparable { JobResult that = (JobResult) o; - if (success != that.success) return false; - if (displayText != null ? !displayText.equals(that.displayText) : that.displayText != null) return false; + if (!Objects.equal(success, that.success)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; return true; } @Override public int hashCode() { - int result = (success ? 1 : 0); - result = 31 * result + (displayText != null ? displayText.hashCode() : 0); - return result; + return Objects.hashCode(success, displayText); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java index 5feb52569c..28165de1ce 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -71,22 +72,22 @@ public class LoadBalancerRule implements Comparable { } public static class Builder { - private long id; + private String id; private String account; private Algorithm algorithm; private String description; private String domain; - private long domainId; + private String domainId; private String name; private int privatePort; private String publicIP; - private long publicIPId; + private String publicIPId; private int publicPort; private State state; private Set CIDRs = ImmutableSet.of(); - private long zoneId; + private String zoneId; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -111,7 +112,7 @@ public class LoadBalancerRule implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -131,7 +132,7 @@ public class LoadBalancerRule implements Comparable { return this; } - public Builder publicIPId(long publicIPId) { + public Builder publicIPId(String publicIPId) { this.publicIPId = publicIPId; return this; } @@ -151,7 +152,7 @@ public class LoadBalancerRule implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -162,36 +163,36 @@ public class LoadBalancerRule implements Comparable { } } - private long id; + private String id; private String account; private Algorithm algorithm; private String description; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; private String name; @SerializedName("privateport") private int privatePort; @SerializedName("publicip") private String publicIP; @SerializedName("publicipid") - private long publicIPId; + private String publicIPId; @SerializedName("publicport") private int publicPort; private State state; @SerializedName("cidrlist") private Set CIDRs; @SerializedName("zoneId") - private long zoneId; + private String zoneId; // for deserializer LoadBalancerRule() { } - public LoadBalancerRule(long id, String account, Algorithm algorithm, String description, String domain, - long domainId, String name, int privatePort, String publicIP, long publicIPId, int publicPort, State state, - long zoneId, Set CIDRs) { + public LoadBalancerRule(String id, String account, Algorithm algorithm, String description, String domain, + String domainId, String name, int privatePort, String publicIP, String publicIPId, int publicPort, State state, + String zoneId, Set CIDRs) { this.id = id; this.account = account; this.algorithm = algorithm; @@ -212,7 +213,7 @@ public class LoadBalancerRule implements Comparable { /** * @return the load balancer rule ID */ - public long getId() { + public String getId() { return id; } @@ -247,7 +248,7 @@ public class LoadBalancerRule implements Comparable { /** * @return the domain ID of the load balancer rule */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -275,7 +276,7 @@ public class LoadBalancerRule implements Comparable { /** * @return the public ip address id */ - public long getPublicIPId() { + public String getPublicIPId() { return publicIPId; } @@ -301,95 +302,45 @@ public class LoadBalancerRule implements Comparable { } /** - * @return the id of the zone the rule belongs to + * @return the id of the zone the rule beStrings to */ - public long getZoneId() { + public String getZoneId() { return zoneId; } @Override public int compareTo(LoadBalancerRule arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LoadBalancerRule that = (LoadBalancerRule) o; + + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(algorithm, that.algorithm)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(privatePort, that.privatePort)) return false; + if (!Objects.equal(publicIP, that.publicIP)) return false; + if (!Objects.equal(publicIPId, that.publicIPId)) return false; + if (!Objects.equal(publicPort, that.publicPort)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(state, that.state)) return false; + + return true; + } + @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((account == null) ? 0 : account.hashCode()); - result = prime * result + ((algorithm == null) ? 0 : algorithm.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + privatePort; - result = prime * result + ((publicIP == null) ? 0 : publicIP.hashCode()); - result = prime * result + (int) (publicIPId ^ (publicIPId >>> 32)); - result = prime * result + publicPort; - result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); - result = prime * result + ((state == null) ? 0 : state.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LoadBalancerRule other = (LoadBalancerRule) obj; - if (account == null) { - if (other.account != null) - return false; - } else if (!account.equals(other.account)) - return false; - if (algorithm == null) { - if (other.algorithm != null) - return false; - } else if (!algorithm.equals(other.algorithm)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (zoneId != other.zoneId) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (privatePort != other.privatePort) - return false; - if (publicIP == null) { - if (other.publicIP != null) - return false; - } else if (!publicIP.equals(other.publicIP)) - return false; - if (publicIPId != other.publicIPId) - return false; - if (publicPort != other.publicPort) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - return true; + return Objects.hashCode(account, algorithm, description, domain, domainId, id, name, privatePort, publicIP, publicIPId, publicPort, zoneId, state); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java index 9fc2474a2f..8fb36e4558 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoginResponse.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -35,9 +36,9 @@ public class LoginResponse implements Comparable { public static class Builder { private String username; - private long userId; + private String userId; private String password; - private long domainId; + private String domainId; private long timeout; private boolean registered; private String accountName; @@ -72,7 +73,7 @@ public class LoginResponse implements Comparable { return this; } - public Builder userId(long userId) { + public Builder userId(String userId) { this.userId = userId; return this; } @@ -82,7 +83,7 @@ public class LoginResponse implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -145,10 +146,10 @@ public class LoginResponse implements Comparable { private final String username; @SerializedName("userid") - private final long userId; + private final String userId; private final String password; @SerializedName("domainid") - private final long domainId; + private final String domainId; private final long timeout; private final boolean registered; @SerializedName("account") @@ -166,7 +167,7 @@ public class LoginResponse implements Comparable { private final String sessionKey; private final String jSessionId; - public LoginResponse(String username, long userId, String password, long domainId, long timeout, boolean registered, + public LoginResponse(String username, String userId, String password, String domainId, long timeout, boolean registered, String accountName, String firstName, String lastName, Account.Type accountType, String timezone, String timezoneOffset, String sessionKey, String jSessionId) { this.username = username; @@ -189,7 +190,7 @@ public class LoginResponse implements Comparable { return username; } - public long getUserId() { + public String getUserId() { return userId; } @@ -197,7 +198,7 @@ public class LoginResponse implements Comparable { return password; } - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -242,94 +243,35 @@ public class LoginResponse implements Comparable { } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LoginResponse other = (LoginResponse) obj; - if (accountName == null) { - if (other.accountName != null) - return false; - } else if (!accountName.equals(other.accountName)) - return false; - if (accountType == null) { - if (other.accountType != null) - return false; - } else if (!accountType.equals(other.accountType)) - return false; - if (domainId != other.domainId) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (jSessionId == null) { - if (other.jSessionId != null) - return false; - } else if (!jSessionId.equals(other.jSessionId)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (password == null) { - if (other.password != null) - return false; - } else if (!password.equals(other.password)) - return false; - if (registered != other.registered) - return false; - if (sessionKey == null) { - if (other.sessionKey != null) - return false; - } else if (!sessionKey.equals(other.sessionKey)) - return false; - if (timeout != other.timeout) - return false; - if (timezone == null) { - if (other.timezone != null) - return false; - } else if (!timezone.equals(other.timezone)) - return false; - if (timezoneOffset == null) { - if (other.timezoneOffset != null) - return false; - } else if (!timezoneOffset.equals(other.timezoneOffset)) - return false; - if (userId != other.userId) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LoginResponse that = (LoginResponse) o; + + if (!Objects.equal(accountName, that.accountName)) return false; + if (!Objects.equal(accountType, that.accountType)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(firstName, that.firstName)) return false; + if (!Objects.equal(jSessionId, that.jSessionId)) return false; + if (!Objects.equal(lastName, that.lastName)) return false; + if (!Objects.equal(password, that.password)) return false; + if (!Objects.equal(registered, that.registered)) return false; + if (!Objects.equal(sessionKey, that.sessionKey)) return false; + if (!Objects.equal(timeout, that.timeout)) return false; + if (!Objects.equal(timezone, that.timezone)) return false; + if (!Objects.equal(timezoneOffset, that.timezoneOffset)) return false; + if (!Objects.equal(userId, that.userId)) return false; + if (!Objects.equal(username, that.username)) return false; + return true; } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accountName == null) ? 0 : accountName.hashCode()); - result = prime * result + ((accountType == null) ? 0 : accountType.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((jSessionId == null) ? 0 : jSessionId.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((password == null) ? 0 : password.hashCode()); - result = prime * result + (registered ? 1231 : 1237); - result = prime * result + ((sessionKey == null) ? 0 : sessionKey.hashCode()); - result = prime * result + (int) (timeout ^ (timeout >>> 32)); - result = prime * result + ((timezone == null) ? 0 : timezone.hashCode()); - result = prime * result + ((timezoneOffset == null) ? 0 : timezoneOffset.hashCode()); - result = prime * result + (int) (userId ^ (userId >>> 32)); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; + return Objects.hashCode(accountName, accountType, domainId, firstName, jSessionId, lastName, + password, registered, sessionKey, timeout, timezone, timezoneOffset, + userId, username); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java index 22133eb85c..6ecf585dbf 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NIC.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.domain; import java.net.URI; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -32,7 +33,7 @@ public class NIC { } public static class Builder { - private long id; + private String id; private URI broadcastURI; private String gateway; private String IPAddress; @@ -40,11 +41,11 @@ public class NIC { private URI isolationURI; private String netmask; private String macAddress; - private long networkId; + private String networkId; private TrafficType trafficType; private GuestIPType guestIPType; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -84,7 +85,7 @@ public class NIC { return this; } - public Builder networkId(long networkId) { + public Builder networkId(String networkId) { this.networkId = networkId; return this; } @@ -106,7 +107,7 @@ public class NIC { } } - private long id; + private String id; @SerializedName("broadcasturi") private URI broadcastURI; private String gateway; @@ -120,7 +121,7 @@ public class NIC { @SerializedName("macaddress") private String macAddress; @SerializedName("networkid") - private long networkId; + private String networkId; @SerializedName("traffictype") private TrafficType trafficType; @SerializedName("type") @@ -133,8 +134,8 @@ public class NIC { } - public NIC(long id, URI broadcastURI, String gateway, String iPAddress, boolean isDefault, URI isolationURI, - String netmask, String macAddress, long networkId, TrafficType trafficType, GuestIPType guestIPType) { + public NIC(String id, URI broadcastURI, String gateway, String iPAddress, boolean isDefault, URI isolationURI, + String netmask, String macAddress, String networkId, TrafficType trafficType, GuestIPType guestIPType) { this.id = id; this.broadcastURI = broadcastURI; this.gateway = gateway; @@ -151,7 +152,7 @@ public class NIC { /** * the ID of the nic */ - public long getId() { + public String getId() { return id; } @@ -207,7 +208,7 @@ public class NIC { /** * the ID of the corresponding network */ - public long getNetworkId() { + public String getNetworkId() { return networkId; } @@ -226,73 +227,30 @@ public class NIC { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + ((broadcastURI == null) ? 0 : broadcastURI.hashCode()); - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((guestIPType == null) ? 0 : guestIPType.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isDefault ? 1231 : 1237); - result = prime * result + ((isolationURI == null) ? 0 : isolationURI.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((macAddress == null) ? 0 : macAddress.hashCode()); - result = prime * result + (int) (networkId ^ (networkId >>> 32)); - result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NIC that = (NIC) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(broadcastURI, that.broadcastURI)) return false; + if (!Objects.equal(gateway, that.gateway)) return false; + if (!Objects.equal(guestIPType, that.guestIPType)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isDefault, that.isDefault)) return false; + if (!Objects.equal(isolationURI, that.isolationURI)) return false; + if (!Objects.equal(netmask, that.netmask)) return false; + if (!Objects.equal(macAddress, that.macAddress)) return false; + if (!Objects.equal(networkId, that.networkId)) return false; + if (!Objects.equal(trafficType, that.trafficType)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NIC other = (NIC) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (broadcastURI == null) { - if (other.broadcastURI != null) - return false; - } else if (!broadcastURI.equals(other.broadcastURI)) - return false; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (guestIPType != other.guestIPType) - return false; - if (id != other.id) - return false; - if (isDefault != other.isDefault) - return false; - if (isolationURI == null) { - if (other.isolationURI != null) - return false; - } else if (!isolationURI.equals(other.isolationURI)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (macAddress == null) { - if (other.macAddress != null) - return false; - } else if (!macAddress.equals(other.macAddress)) - return false; - if (networkId != other.networkId) - return false; - if (trafficType != other.trafficType) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, broadcastURI, gateway, guestIPType, id, isDefault, isolationURI, netmask, macAddress, networkId, trafficType); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java index b5bf126503..f2b36311b2 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java @@ -28,6 +28,7 @@ import java.util.SortedSet; import javax.annotation.Nullable; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -43,7 +44,7 @@ public class Network implements Comparable { } public static class Builder { - private long id; + private String id; private String broadcastDomainType; private URI broadcastURI; private String displayText; @@ -58,24 +59,24 @@ public class Network implements Comparable { private String networkDomain; private String networkOfferingAvailability; private String networkOfferingDisplayText; - private long networkOfferingId; + private String networkOfferingId; private String networkOfferingName; - private long related; + private String related; private String startIP; private String name; private String state; private GuestIPType guestIPType; private String VLAN; private TrafficType trafficType; - private long zoneId; + private String zoneId; private Set services = ImmutableSet.of(); private String account; - private long domainId; + private String domainId; private boolean securityGroupEnabled; private Set tags = ImmutableSet.of(); - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -85,7 +86,7 @@ public class Network implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -160,7 +161,7 @@ public class Network implements Comparable { return this; } - public Builder networkOfferingId(long networkOfferingId) { + public Builder networkOfferingId(String networkOfferingId) { this.networkOfferingId = networkOfferingId; return this; } @@ -170,7 +171,7 @@ public class Network implements Comparable { return this; } - public Builder related(long related) { + public Builder related(String related) { this.related = related; return this; } @@ -205,7 +206,7 @@ public class Network implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -233,7 +234,7 @@ public class Network implements Comparable { } } - private long id; + private String id; private String account; @SerializedName("broadcastdomaintype") private String broadcastDomainType; @@ -247,7 +248,7 @@ public class Network implements Comparable { private String DNS2; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("endip") private String endIP; private String gateway; @@ -266,10 +267,10 @@ public class Network implements Comparable { @SerializedName("networkofferingdisplaytext") private String networkOfferingDisplayText; @SerializedName("networkofferingid") - private long networkOfferingId; + private String networkOfferingId; @SerializedName("networkofferingname") private String networkOfferingName; - private long related; + private String related; @SerializedName("startip") private String startIP; private String name; @@ -281,7 +282,7 @@ public class Network implements Comparable { @SerializedName("traffictype") private TrafficType trafficType; @SerializedName("zoneid") - private long zoneId; + private String zoneId; private String tags; @SerializedName("securitygroupenabled") private boolean securityGroupEnabled; @@ -296,12 +297,12 @@ public class Network implements Comparable { } - public Network(long id, String broadcastDomainType, URI broadcastURI, String displayText, - List DNS, String domain, long domainId, String endIP, String gateway, boolean isDefault, + public Network(String id, String broadcastDomainType, URI broadcastURI, String displayText, + List DNS, String domain, String domainId, String endIP, String gateway, boolean isDefault, boolean isShared, boolean isSystem, String netmask, String networkDomain, String networkOfferingAvailability, - String networkOfferingDisplayText, long networkOfferingId, String networkOfferingName, long related, + String networkOfferingDisplayText, String networkOfferingId, String networkOfferingName, String related, String startIP, String name, String state, GuestIPType type, String vLAN, TrafficType trafficType, - long zoneId, Set services, Set tags, boolean securityGroupEnabled, + String zoneId, Set services, Set tags, boolean securityGroupEnabled, String account) { this.id = id; this.broadcastDomainType = broadcastDomainType; @@ -339,7 +340,7 @@ public class Network implements Comparable { /** * @return network id */ - public long getId() { + public String getId() { return id; } @@ -386,7 +387,7 @@ public class Network implements Comparable { /** * @return the domain id of the Network */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -498,7 +499,7 @@ public class Network implements Comparable { /** * @return network offering id the network is created from */ - public long getNetworkOfferingId() { + public String getNetworkOfferingId() { return networkOfferingId; } @@ -512,7 +513,7 @@ public class Network implements Comparable { /** * @return related to what other network configuration */ - public long getRelated() { + public String getRelated() { return related; } @@ -526,7 +527,7 @@ public class Network implements Comparable { /** * @return zone id of the network */ - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -552,166 +553,52 @@ public class Network implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((DNS1 == null) ? 0 : DNS1.hashCode()); - result = prime * result + ((DNS2 == null) ? 0 : DNS2.hashCode()); - result = prime * result + ((VLAN == null) ? 0 : VLAN.hashCode()); - result = prime * result + ((broadcastDomainType == null) ? 0 : broadcastDomainType.hashCode()); - result = prime * result + ((broadcastURI == null) ? 0 : broadcastURI.hashCode()); - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + ((endIP == null) ? 0 : endIP.hashCode()); - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((guestIPType == null) ? 0 : guestIPType.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isDefault ? 1231 : 1237); - result = prime * result + (isShared ? 1231 : 1237); - result = prime * result + (isSystem ? 1231 : 1237); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((networkDomain == null) ? 0 : networkDomain.hashCode()); - result = prime * result + ((networkOfferingAvailability == null) ? 0 : networkOfferingAvailability.hashCode()); - result = prime * result + ((networkOfferingDisplayText == null) ? 0 : networkOfferingDisplayText.hashCode()); - result = prime * result + (int) (networkOfferingId ^ (networkOfferingId >>> 32)); - result = prime * result + ((networkOfferingName == null) ? 0 : networkOfferingName.hashCode()); - result = prime * result + (int) (related ^ (related >>> 32)); - result = prime * result + ((services == null) ? 0 : services.hashCode()); - result = prime * result + ((startIP == null) ? 0 : startIP.hashCode()); - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); - result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Network that = (Network) o; + + if (!Objects.equal(DNS1, that.DNS1)) return false; + if (!Objects.equal(DNS2, that.DNS2)) return false; + if (!Objects.equal(VLAN, that.VLAN)) return false; + if (!Objects.equal(broadcastDomainType, that.broadcastDomainType)) return false; + if (!Objects.equal(broadcastURI, that.broadcastURI)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(endIP, that.endIP)) return false; + if (!Objects.equal(gateway, that.gateway)) return false; + if (!Objects.equal(guestIPType, that.guestIPType)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isDefault, that.isDefault)) return false; + if (!Objects.equal(isShared, that.isShared)) return false; + if (!Objects.equal(isSystem, that.isSystem)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(netmask, that.netmask)) return false; + if (!Objects.equal(networkDomain, that.networkDomain)) return false; + if (!Objects.equal(networkOfferingAvailability, that.networkOfferingAvailability)) return false; + if (!Objects.equal(networkOfferingDisplayText, that.networkOfferingDisplayText)) return false; + if (!Objects.equal(networkOfferingId, that.networkOfferingId)) return false; + if (!Objects.equal(networkOfferingName, that.networkOfferingName)) return false; + if (!Objects.equal(related, that.related)) return false; + if (!Objects.equal(services, that.services)) return false; + if (!Objects.equal(startIP, that.startIP)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(trafficType, that.trafficType)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(tags, that.tags)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Network other = (Network) obj; - if (DNS1 == null) { - if (other.DNS1 != null) - return false; - } else if (!DNS1.equals(other.DNS1)) - return false; - if (DNS2 == null) { - if (other.DNS2 != null) - return false; - } else if (!DNS2.equals(other.DNS2)) - return false; - if (VLAN == null) { - if (other.VLAN != null) - return false; - } else if (!VLAN.equals(other.VLAN)) - return false; - if (broadcastDomainType == null) { - if (other.broadcastDomainType != null) - return false; - } else if (!broadcastDomainType.equals(other.broadcastDomainType)) - return false; - if (broadcastURI == null) { - if (other.broadcastURI != null) - return false; - } else if (!broadcastURI.equals(other.broadcastURI)) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (endIP == null) { - if (other.endIP != null) - return false; - } else if (!endIP.equals(other.endIP)) - return false; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (guestIPType != other.guestIPType) - return false; - if (id != other.id) - return false; - if (isDefault != other.isDefault) - return false; - if (isShared != other.isShared) - return false; - if (isSystem != other.isSystem) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (networkDomain == null) { - if (other.networkDomain != null) - return false; - } else if (!networkDomain.equals(other.networkDomain)) - return false; - if (networkOfferingAvailability == null) { - if (other.networkOfferingAvailability != null) - return false; - } else if (!networkOfferingAvailability.equals(other.networkOfferingAvailability)) - return false; - if (networkOfferingDisplayText == null) { - if (other.networkOfferingDisplayText != null) - return false; - } else if (!networkOfferingDisplayText.equals(other.networkOfferingDisplayText)) - return false; - if (networkOfferingId != other.networkOfferingId) - return false; - if (networkOfferingName == null) { - if (other.networkOfferingName != null) - return false; - } else if (!networkOfferingName.equals(other.networkOfferingName)) - return false; - if (related != other.related) - return false; - if (services == null) { - if (other.services != null) - return false; - } else if (!services.equals(other.services)) - return false; - if (startIP == null) { - if (other.startIP != null) - return false; - } else if (!startIP.equals(other.startIP)) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (trafficType != other.trafficType) - return false; - if (zoneId != other.zoneId) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; - if (domainId != other.domainId) - return false; - return true; + public int hashCode() { + return Objects.hashCode(DNS1, DNS2, VLAN, broadcastDomainType, broadcastURI, displayText, domain, + endIP, gateway, guestIPType, id, isDefault, isShared, isSystem, name, + netmask, networkDomain, networkOfferingAvailability, networkOfferingDisplayText, + networkOfferingId, networkOfferingName, related, services, startIP, state, + trafficType, zoneId, tags, domainId); } @Override @@ -753,6 +640,6 @@ public class Network implements Comparable { @Override public int compareTo(Network arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java index d074bd7bb3..c8d475bff8 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java @@ -26,6 +26,7 @@ import java.util.Set; import javax.annotation.Nullable; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -40,7 +41,7 @@ public class NetworkOffering implements Comparable { } public static class Builder { - private long id; + private String id; private String name; private String displayText; private Date created; @@ -53,7 +54,7 @@ public class NetworkOffering implements Comparable { private GuestIPType guestIPType; private Set tags = ImmutableSet.of(); - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -119,7 +120,7 @@ public class NetworkOffering implements Comparable { } } - private long id; + private String id; private String name; @SerializedName("displaytext") private String displayText; @@ -140,7 +141,7 @@ public class NetworkOffering implements Comparable { private int networkRate = -1; private String tags; - public NetworkOffering(long id, String name, String displayText, @Nullable Date created, + public NetworkOffering(String id, String name, String displayText, @Nullable Date created, NetworkOfferingAvailabilityType availability, boolean supportsVLAN, @Nullable Integer maxConnections, boolean isDefault, TrafficType trafficType, GuestIPType guestIPType, int networkRate, Set tags) { this.id = id; @@ -169,7 +170,7 @@ public class NetworkOffering implements Comparable { * * @return the id of the network offering */ - public long getId() { + public String getId() { return id; } @@ -266,70 +267,29 @@ public class NetworkOffering implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((availability == null) ? 0 : availability.hashCode()); - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isDefault ? 1231 : 1237); - result = prime * result + ((maxConnections == null) ? 0 : maxConnections.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + (supportsVLAN ? 1231 : 1237); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkOffering that = (NetworkOffering) o; + + if (!Objects.equal(availability, that.availability)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isDefault, that.isDefault)) return false; + if (!Objects.equal(maxConnections, that.maxConnections)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(supportsVLAN, that.supportsVLAN)) return false; + if (!Objects.equal(tags, that.tags)) return false; + if (!Objects.equal(trafficType, that.trafficType)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkOffering other = (NetworkOffering) obj; - if (availability == null) { - if (other.availability != null) - return false; - } else if (!availability.equals(other.availability)) - return false; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (id != other.id) - return false; - if (isDefault != other.isDefault) - return false; - if (maxConnections == null) { - if (other.maxConnections != null) - return false; - } else if (!maxConnections.equals(other.maxConnections)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (supportsVLAN != other.supportsVLAN) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; - if (trafficType != other.trafficType) - return false; - return true; + public int hashCode() { + return Objects.hashCode(availability, created, displayText, id, isDefault, maxConnections, name, supportsVLAN, tags, trafficType); } @Override @@ -352,7 +312,7 @@ public class NetworkOffering implements Comparable { @Override public int compareTo(NetworkOffering arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java index 39c910507b..71a1db51d0 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.SortedSet; import java.util.Map.Entry; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; @@ -51,34 +52,21 @@ public class NetworkService implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkService.Capability that = (NetworkService.Capability) o; + + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(value, that.value)) return false; + + return true; } - + @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkService.Capability other = (NetworkService.Capability) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(name, value); } @Override @@ -128,34 +116,21 @@ public class NetworkService implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkService that = (NetworkService) o; + + if (!Objects.equal(capabilities, that.capabilities)) return false; + if (!Objects.equal(name, that.name)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkService other = (NetworkService) obj; - if (capabilities == null) { - if (other.capabilities != null) - return false; - } else if (!capabilities.equals(other.capabilities)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(capabilities, name); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java index 314e4d45c4..1a1305ed9e 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/OSType.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -31,16 +32,16 @@ public class OSType implements Comparable { } public static class Builder { - private long id; - private long OSCategoryId; + private String id; + private String OSCategoryId; private String description; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } - public Builder OSCategoryId(long OSCategoryId) { + public Builder OSCategoryId(String OSCategoryId) { this.OSCategoryId = OSCategoryId; return this; } @@ -60,12 +61,12 @@ public class OSType implements Comparable { } - private long id; + private String id; @SerializedName("oscategoryid") - private long OSCategoryId; + private String OSCategoryId; private String description; - public OSType(long id, long OSCategoryId, String description) { + public OSType(String id, String OSCategoryId, String description) { this.id = id; this.OSCategoryId = OSCategoryId; this.description = description; @@ -74,14 +75,14 @@ public class OSType implements Comparable { /** * @return the ID of the OS type */ - public long getId() { + public String getId() { return id; } /** * @return the ID of the OS category */ - public long getOSCategoryId() { + public String getOSCategoryId() { return OSCategoryId; } @@ -93,34 +94,22 @@ public class OSType implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (OSCategoryId ^ (OSCategoryId >>> 32)); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + OSType that = (OSType) o; + + if (!Objects.equal(OSCategoryId, that.OSCategoryId)) return false; + if (!Objects.equal(description, that.description)) return false; + if (!Objects.equal(id, that.id)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OSType other = (OSType) obj; - if (OSCategoryId != other.OSCategoryId) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (id != other.id) - return false; - return true; + public int hashCode() { + return Objects.hashCode(OSCategoryId, description, id); } @Override @@ -134,7 +123,7 @@ public class OSType implements Comparable { @Override public int compareTo(OSType arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java index 2b46bbc8ac..db49ce654c 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Pod.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -33,9 +34,9 @@ public class Pod implements Comparable { public static class Builder { - private long id; + private String id; private String name; - private long zoneId; + private String zoneId; private String zoneName; private String gateway; private String netmask; @@ -48,7 +49,7 @@ public class Pod implements Comparable { /** * @param id the ID of the Pod */ - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -64,7 +65,7 @@ public class Pod implements Comparable { /** * @param zoneId the Zone ID of the Pod */ - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -126,9 +127,9 @@ public class Pod implements Comparable { } } - private long id; + private String id; private String name; - @SerializedName("zoneid") private long zoneId; + @SerializedName("zoneid") private String zoneId; @SerializedName("zonename") private String zoneName; private String gateway; private String netmask; @@ -139,7 +140,7 @@ public class Pod implements Comparable { /* Just for the serializer */ Pod() {} - public Pod(long id, String name, long zoneId, String zoneName, String gateway, String netmask, String startIp, String endIp, AllocationState allocationState) { + public Pod(String id, String name, String zoneId, String zoneName, String gateway, String netmask, String startIp, String endIp, AllocationState allocationState) { this.id = id; this.name = name; this.zoneId = zoneId; @@ -154,7 +155,7 @@ public class Pod implements Comparable { /** * @return id the ID of the Pod */ - public long getId() { + public String getId() { return id; } @@ -168,7 +169,7 @@ public class Pod implements Comparable { /** * @return zoneId the Zone ID of the Pod */ - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -219,33 +220,24 @@ public class Pod implements Comparable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Pod pod = (Pod) o; + Pod that = (Pod) o; - if (id != pod.id) return false; - if (zoneId != pod.zoneId) return false; - if (allocationState != pod.allocationState) return false; - if (endIp != null ? !endIp.equals(pod.endIp) : pod.endIp != null) return false; - if (gateway != null ? !gateway.equals(pod.gateway) : pod.gateway != null) return false; - if (name != null ? !name.equals(pod.name) : pod.name != null) return false; - if (netmask != null ? !netmask.equals(pod.netmask) : pod.netmask != null) return false; - if (startIp != null ? !startIp.equals(pod.startIp) : pod.startIp != null) return false; - if (zoneName != null ? !zoneName.equals(pod.zoneName) : pod.zoneName != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(allocationState, that.allocationState)) return false; + if (!Objects.equal(endIp, that.endIp)) return false; + if (!Objects.equal(gateway, that.gateway)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(netmask, that.netmask)) return false; + if (!Objects.equal(startIp, that.startIp)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - result = 31 * result + (gateway != null ? gateway.hashCode() : 0); - result = 31 * result + (netmask != null ? netmask.hashCode() : 0); - result = 31 * result + (startIp != null ? startIp.hashCode() : 0); - result = 31 * result + (endIp != null ? endIp.hashCode() : 0); - result = 31 * result + (allocationState != null ? allocationState.hashCode() : 0); - return result; + return Objects.hashCode(id, zoneId, allocationState, endIp, gateway, name, netmask, startIp, zoneName); } @Override @@ -265,6 +257,6 @@ public class Pod implements Comparable { @Override public int compareTo(Pod other) { - return Long.valueOf(this.id).compareTo(other.id); + return this.id.compareTo(other.id); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java index 67c8ddb8ce..7d0daf2dcf 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PortForwardingRule.java @@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain; import java.util.Set; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -77,21 +78,21 @@ public class PortForwardingRule implements Comparable { } public static class Builder { - private long id; + private String id; private String IPAddress; - private long IPAddressId; + private String IPAddressId; private int privatePort; private Protocol protocol; public int publicPort; private State state; private String virtualMachineDisplayName; - public long virtualMachineId; + public String virtualMachineId; private String virtualMachineName; private Set CIDRs = ImmutableSet.of(); private int privateEndPort; private int publicEndPort; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -101,7 +102,7 @@ public class PortForwardingRule implements Comparable { return this; } - public Builder IPAddressId(long IPAddressId) { + public Builder IPAddressId(String IPAddressId) { this.IPAddressId = IPAddressId; return this; } @@ -131,7 +132,7 @@ public class PortForwardingRule implements Comparable { return this; } - public Builder virtualMachineId(long virtualMachineId) { + public Builder virtualMachineId(String virtualMachineId) { this.virtualMachineId = virtualMachineId; return this; } @@ -162,11 +163,11 @@ public class PortForwardingRule implements Comparable { } } - private long id; + private String id; @SerializedName("ipaddress") private String IPAddress; @SerializedName("ipaddressid") - private long IPAddressId; + private String IPAddressId; @SerializedName("privateport") private int privatePort; private Protocol protocol; @@ -176,7 +177,7 @@ public class PortForwardingRule implements Comparable { @SerializedName("virtualmachinedisplayname") private String virtualMachineDisplayName; @SerializedName("virtualmachineid") - public long virtualMachineId; + public String virtualMachineId; @SerializedName("virtualmachinename") private String virtualMachineName; @SerializedName("cidrlist") @@ -186,8 +187,8 @@ public class PortForwardingRule implements Comparable { @SerializedName("publicendport") private int publicEndPort; - public PortForwardingRule(long id, String iPAddress, long iPAddressId, int privatePort, Protocol protocol, - int publicPort, State state, String virtualMachineDisplayName, long virtualMachineId, + public PortForwardingRule(String id, String iPAddress, String iPAddressId, int privatePort, Protocol protocol, + int publicPort, State state, String virtualMachineDisplayName, String virtualMachineId, String virtualMachineName, Set CIDRs, int privateEndPort, int publicEndPort) { this.id = id; this.IPAddress = iPAddress; @@ -206,13 +207,13 @@ public class PortForwardingRule implements Comparable { @Override public int compareTo(PortForwardingRule arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } /** * @return the ID of the port forwarding rule */ - public long getId() { + public String getId() { return id; } @@ -226,7 +227,7 @@ public class PortForwardingRule implements Comparable { /** * @return the public ip address id for the port forwarding rule */ - public long getIPAddressId() { + public String getIPAddressId() { return IPAddressId; } @@ -268,7 +269,7 @@ public class PortForwardingRule implements Comparable { /** * @return the VM ID for the port forwarding rule */ - public long getVirtualMachineId() { + public String getVirtualMachineId() { return virtualMachineId; } @@ -301,67 +302,29 @@ public class PortForwardingRule implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + (int) (IPAddressId ^ (IPAddressId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + privatePort; - result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); - result = prime * result + publicPort; - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); - result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); - result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PortForwardingRule that = (PortForwardingRule) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(IPAddressId, that.IPAddressId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(privatePort, that.privatePort)) return false; + if (!Objects.equal(protocol, that.protocol)) return false; + if (!Objects.equal(publicPort, that.publicPort)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false; + if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false; + if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PortForwardingRule other = (PortForwardingRule) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (IPAddressId != other.IPAddressId) - return false; - if (id != other.id) - return false; - if (privatePort != other.privatePort) - return false; - if (protocol == null) { - if (other.protocol != null) - return false; - } else if (!protocol.equals(other.protocol)) - return false; - if (privatePort != other.privatePort) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (virtualMachineDisplayName == null) { - if (other.virtualMachineDisplayName != null) - return false; - } else if (!virtualMachineDisplayName.equals(other.virtualMachineDisplayName)) - return false; - if (virtualMachineId != other.virtualMachineId) - return false; - if (virtualMachineName == null) { - if (other.virtualMachineName != null) - return false; - } else if (!virtualMachineName.equals(other.virtualMachineName)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, IPAddressId, id, privatePort, protocol, publicPort, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java index 18d865a01c..596cfc0e83 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/PublicIPAddress.java @@ -25,6 +25,7 @@ import java.util.Date; import javax.annotation.Nullable; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -37,29 +38,29 @@ public class PublicIPAddress implements Comparable { } public static class Builder { - private long id; + private String id; private String account; private Date allocated; - private long associatedNetworkId; + private String associatedNetworkId; private String domain; - private long domainId; + private String domainId; private boolean usesVirtualNetwork; private String IPAddress; private boolean isSourceNAT; private boolean isStaticNAT; - private long networkId; + private String networkId; private State state; private String virtualMachineDisplayName; - private long virtualMachineId = -1; + private String virtualMachineId; private String virtualMachineName; - private long VLANId; + private String VLANId; private String VLANName; - private long zoneId; + private String zoneId; private String zoneName; - private Long jobId; + private String jobId; private Integer jobStatus; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -74,7 +75,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder associatedNetworkId(long associatedNetworkId) { + public Builder associatedNetworkId(String associatedNetworkId) { this.associatedNetworkId = associatedNetworkId; return this; } @@ -84,7 +85,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -109,7 +110,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder networkId(long networkId) { + public Builder networkId(String networkId) { this.networkId = networkId; return this; } @@ -124,7 +125,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder virtualMachineId(long virtualMachineId) { + public Builder virtualMachineId(String virtualMachineId) { this.virtualMachineId = virtualMachineId; return this; } @@ -134,7 +135,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder VLANId(long VLANId) { + public Builder VLANId(String VLANId) { this.VLANId = VLANId; return this; } @@ -144,7 +145,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -154,7 +155,7 @@ public class PublicIPAddress implements Comparable { return this; } - public Builder jobId(Long jobId) { + public Builder jobId(String jobId) { this.jobId = jobId; return this; } @@ -171,14 +172,14 @@ public class PublicIPAddress implements Comparable { } } - private long id; + private String id; private String account; private Date allocated; @SerializedName("associatednetworkid") - private long associatedNetworkId; + private String associatedNetworkId; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("forvirtualnetwork") private boolean usesVirtualNetwork; @SerializedName("ipaddress") @@ -188,25 +189,25 @@ public class PublicIPAddress implements Comparable { @SerializedName("isstaticnat") private boolean isStaticNAT; @SerializedName("networkid") - private long networkId; + private String networkId; private State state; @SerializedName("virtualmachinedisplayname") private String virtualMachineDisplayName; @SerializedName("virtualmachineid") - private long virtualMachineId = -1; + private String virtualMachineId; @SerializedName("virtualmachinename") private String virtualMachineName; @SerializedName("VLANid") - private long VLANId; + private String VLANId; @SerializedName("VLANname") private String VLANName; @SerializedName("zoneid") - private long zoneId; + private String zoneId; @SerializedName("zonename") private String zoneName; @SerializedName("jobid") @Nullable - private Long jobId; + private String jobId; @SerializedName("jobstatus") @Nullable private Integer jobStatus; @@ -234,10 +235,10 @@ public class PublicIPAddress implements Comparable { } - public PublicIPAddress(long id, String account, Date allocated, long associatedNetworkId, String domain, - long domainId, boolean usesVirtualNetwork, String iPAddress, boolean isSourceNAT, boolean isStaticNAT, - long networkId, State state, String virtualMachineDisplayName, long virtualMachineId, - String virtualMachineName, long VLANId, String VLANName, long zoneId, String zoneName, Long jobId, + public PublicIPAddress(String id, String account, Date allocated, String associatedNetworkId, String domain, + String domainId, boolean usesVirtualNetwork, String iPAddress, boolean isSourceNAT, boolean isStaticNAT, + String networkId, State state, String virtualMachineDisplayName, String virtualMachineId, + String virtualMachineName, String VLANId, String VLANName, String zoneId, String zoneName, String jobId, Integer jobStatus) { this.id = id; this.account = account; @@ -265,13 +266,13 @@ public class PublicIPAddress implements Comparable { @Override public int compareTo(PublicIPAddress arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } /** * @return public IP address id */ - public long getId() { + public String getId() { return id; } @@ -295,7 +296,7 @@ public class PublicIPAddress implements Comparable { * machine */ @Nullable - public Long getJobId() { + public String getJobId() { return jobId; } @@ -311,7 +312,7 @@ public class PublicIPAddress implements Comparable { /** * @return the ID of the Network associated with the IP address */ - public long getAssociatedNetworkId() { + public String getAssociatedNetworkId() { return associatedNetworkId; } @@ -325,7 +326,7 @@ public class PublicIPAddress implements Comparable { /** * @return the domain ID the public IP address is associated with */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -360,7 +361,7 @@ public class PublicIPAddress implements Comparable { /** * @return the ID of the Network where ip belongs to */ - public long getNetworkId() { + public String getNetworkId() { return networkId; } @@ -384,7 +385,7 @@ public class PublicIPAddress implements Comparable { * @return virtual machine id the ip address is assigned to (not null only * for static nat Ip) */ - public long getVirtualMachineId() { + public String getVirtualMachineId() { return virtualMachineId; } @@ -399,7 +400,7 @@ public class PublicIPAddress implements Comparable { /** * @return the ID of the VLAN associated with the IP address */ - public long getVLANId() { + public String getVLANId() { return VLANId; } @@ -413,7 +414,7 @@ public class PublicIPAddress implements Comparable { /** * @return the ID of the zone the public IP address belongs to */ - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -425,117 +426,42 @@ public class PublicIPAddress implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((IPAddress == null) ? 0 : IPAddress.hashCode()); - result = prime * result + (int) (VLANId ^ (VLANId >>> 32)); - result = prime * result + ((VLANName == null) ? 0 : VLANName.hashCode()); - result = prime * result + ((account == null) ? 0 : account.hashCode()); - result = prime * result + ((allocated == null) ? 0 : allocated.hashCode()); - result = prime * result + (int) (associatedNetworkId ^ (associatedNetworkId >>> 32)); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + (isSourceNAT ? 1231 : 1237); - result = prime * result + (isStaticNAT ? 1231 : 1237); - result = prime * result + (int) (networkId ^ (networkId >>> 32)); - result = prime * result + ((state == null) ? 0 : state.hashCode()); - result = prime * result + (usesVirtualNetwork ? 1231 : 1237); - result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); - result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); - result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode()); - result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); - result = prime * result + ((zoneName == null) ? 0 : zoneName.hashCode()); - result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PublicIPAddress that = (PublicIPAddress) o; + + if (!Objects.equal(IPAddress, that.IPAddress)) return false; + if (!Objects.equal(VLANId, that.VLANId)) return false; + if (!Objects.equal(VLANName, that.VLANName)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(allocated, that.allocated)) return false; + if (!Objects.equal(associatedNetworkId, that.associatedNetworkId)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(isSourceNAT, that.isSourceNAT)) return false; + if (!Objects.equal(isStaticNAT, that.isStaticNAT)) return false; + if (!Objects.equal(networkId, that.networkId)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(usesVirtualNetwork, that.usesVirtualNetwork)) return false; + if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false; + if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false; + if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PublicIPAddress other = (PublicIPAddress) obj; - if (IPAddress == null) { - if (other.IPAddress != null) - return false; - } else if (!IPAddress.equals(other.IPAddress)) - return false; - if (VLANId != other.VLANId) - return false; - if (VLANName == null) { - if (other.VLANName != null) - return false; - } else if (!VLANName.equals(other.VLANName)) - return false; - if (account == null) { - if (other.account != null) - return false; - } else if (!account.equals(other.account)) - return false; - if (allocated == null) { - if (other.allocated != null) - return false; - } else if (!allocated.equals(other.allocated)) - return false; - if (associatedNetworkId != other.associatedNetworkId) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (isSourceNAT != other.isSourceNAT) - return false; - if (isStaticNAT != other.isStaticNAT) - return false; - if (networkId != other.networkId) - return false; - if (state == null) { - if (other.state != null) - return false; - } else if (!state.equals(other.state)) - return false; - if (usesVirtualNetwork != other.usesVirtualNetwork) - return false; - if (virtualMachineDisplayName == null) { - if (other.virtualMachineDisplayName != null) - return false; - } else if (!virtualMachineDisplayName.equals(other.virtualMachineDisplayName)) - return false; - if (virtualMachineId != other.virtualMachineId) - return false; - if (virtualMachineName == null) { - if (other.virtualMachineName != null) - return false; - } else if (!virtualMachineName.equals(other.virtualMachineName)) - return false; - if (zoneId != other.zoneId) - return false; - if (zoneName == null) { - if (other.zoneName != null) - return false; - } else if (!zoneName.equals(other.zoneName)) - return false; - if (jobId == null) { - if (other.jobId != null) - return false; - } else if (!jobId.equals(other.jobId)) - return false; - if (jobStatus == null) { - if (other.jobStatus != null) - return false; - } else if (!jobStatus.equals(other.jobStatus)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(IPAddress, VLANId, VLANName, account, allocated, associatedNetworkId, + domain, domainId, id, isSourceNAT, isStaticNAT, networkId, state, + usesVirtualNetwork, virtualMachineDisplayName, virtualMachineId, + virtualMachineName, zoneId, zoneName, jobStatus); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java index e10c840c3e..f2e6aa88f6 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ResourceLimit.java @@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.gson.annotations.SerializedName; @@ -41,7 +42,7 @@ public class ResourceLimit implements Comparable { private String account; private String domain; - private long domainId; + private String domainId; private int max; private ResourceType resourceType; @@ -55,7 +56,7 @@ public class ResourceLimit implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -83,12 +84,12 @@ public class ResourceLimit implements Comparable { private String account; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; private int max; @SerializedName("resourcetype") private ResourceType resourceType; - public ResourceLimit(String account, String domain, long domainId, int max, ResourceType resourceType) { + public ResourceLimit(String account, String domain, String domainId, int max, ResourceType resourceType) { this.account = account; this.domain = domain; this.domainId = domainId; @@ -104,7 +105,7 @@ public class ResourceLimit implements Comparable { return domain; } - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -123,22 +124,18 @@ public class ResourceLimit implements Comparable { ResourceLimit that = (ResourceLimit) o; - if (domainId != that.domainId) return false; - if (max != that.max) return false; - if (resourceType != that.resourceType) return false; - if (!account.equals(that.account)) return false; - if (!domain.equals(that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(max, that.max)) return false; + if (!Objects.equal(resourceType, that.resourceType)) return false; + if (!Objects.equal(account, that.account)) return false; + if (!Objects.equal(domain, that.domain)) return false; return true; } @Override public int hashCode() { - int result = account.hashCode(); - result = 31 * result + domain.hashCode(); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + max; - return result; + return Objects.hashCode(domainId, max, resourceType, account, domain); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java index 4301f172ea..88232c2048 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SecurityGroup.java @@ -25,6 +25,7 @@ import java.util.SortedSet; import javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.gson.annotations.SerializedName; @@ -38,18 +39,18 @@ public class SecurityGroup implements Comparable { } public static class Builder { - private long id; + private String id; private String account; private String name; private String description; private String domain; - private long domainId; - private Long jobId; + private String domainId; + private String jobId; private Integer jobStatus; private Set ingressRules = ImmutableSet.of(); - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -74,12 +75,12 @@ public class SecurityGroup implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } - public Builder jobId(Long jobId) { + public Builder jobId(String jobId) { this.jobId = jobId; return this; } @@ -99,16 +100,16 @@ public class SecurityGroup implements Comparable { } } - private long id; + private String id; private String account; private String name; private String description; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("jobid") @Nullable - private Long jobId; + private String jobId; @SerializedName("jobstatus") @Nullable private Integer jobStatus; @@ -116,8 +117,8 @@ public class SecurityGroup implements Comparable { // so that tests and serialization come out expected private SortedSet ingressRules = ImmutableSortedSet.of(); - public SecurityGroup(long id, String account, String name, String description, String domain, long domainId, - Long jobId, Integer jobStatus, Set ingressRules) { + public SecurityGroup(String id, String account, String name, String description, String domain, String domainId, + String jobId, Integer jobStatus, Set ingressRules) { this.id = id; this.account = account; this.name = name; @@ -139,7 +140,7 @@ public class SecurityGroup implements Comparable { /** * @return the id of the security group */ - public long getId() { + public String getId() { return id; } @@ -168,7 +169,7 @@ public class SecurityGroup implements Comparable { /** * @return the domain id of the security group */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -178,7 +179,7 @@ public class SecurityGroup implements Comparable { * machine */ @Nullable - public Long getJobId() { + public String getJobId() { return jobId; } @@ -205,39 +206,22 @@ public class SecurityGroup implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SecurityGroup that = (SecurityGroup) o; + + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SecurityGroup other = (SecurityGroup) obj; - if (domainId != other.domainId) - return false; - if (id != other.id) - return false; - if (jobId == null) { - if (other.jobId != null) - return false; - } else if (!jobId.equals(other.jobId)) - return false; - if (jobStatus == null) { - if (other.jobStatus != null) - return false; - } else if (!jobStatus.equals(other.jobStatus)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(domainId, id, jobStatus); } @Override @@ -257,6 +241,6 @@ public class SecurityGroup implements Comparable { @Override public int compareTo(SecurityGroup arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java index 44f5f26462..8fc731fd54 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java @@ -24,6 +24,7 @@ import java.util.Date; import java.util.Set; import com.google.common.base.Joiner; +import com.google.common.base.Objects; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; @@ -38,12 +39,12 @@ public class ServiceOffering implements Comparable { public static class Builder { - private long id; + private String id; private String name; private String displayText; private Date created; private String domain; - private long domainId; + private String domainId; private int cpuNumber; private int cpuSpeed; private int memory; @@ -58,7 +59,7 @@ public class ServiceOffering implements Comparable { private Set tags = ImmutableSet.of(); - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -83,7 +84,7 @@ public class ServiceOffering implements Comparable { return this; } - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -156,14 +157,14 @@ public class ServiceOffering implements Comparable { } } - private long id; + private String id; private String name; @SerializedName("displaytext") private String displayText; private Date created; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("cpunumber") private int cpuNumber; @SerializedName("cpuspeed") @@ -188,7 +189,7 @@ public class ServiceOffering implements Comparable { private boolean systemVmType; - public ServiceOffering(long id, String name, String displayText, Date created, String domain, long domainId, + public ServiceOffering(String id, String name, String displayText, Date created, String domain, String domainId, int cpuNumber, int cpuSpeed, int memory, boolean haSupport, StorageType storageType, Set tags, boolean defaultUse, String hostTags, boolean systemOffering, boolean cpuUseLimited, long networkRate, boolean systemVmType) { @@ -216,7 +217,7 @@ public class ServiceOffering implements Comparable { /** * @return the id of the service offering */ - public long getId() { + public String getId() { return id; } @@ -252,7 +253,7 @@ public class ServiceOffering implements Comparable { /** * @return the domain id of the service offering */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -341,73 +342,31 @@ public class ServiceOffering implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + cpuNumber; - result = prime * result + cpuSpeed; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((displayText == null) ? 0 : displayText.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + (int) (domainId ^ (domainId >>> 32)); - result = prime * result + (haSupport ? 1231 : 1237); - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + memory; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ServiceOffering that = (ServiceOffering) o; + + if (!Objects.equal(cpuNumber, that.cpuNumber)) return false; + if (!Objects.equal(cpuSpeed, that.cpuSpeed)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(displayText, that.displayText)) return false; + if (!Objects.equal(domain, that.domain)) return false; + if (!Objects.equal(domainId, that.domainId)) return false; + if (!Objects.equal(haSupport, that.haSupport)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(memory, that.memory)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(storageType, that.storageType)) return false; + if (!Objects.equal(tags, that.tags)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServiceOffering other = (ServiceOffering) obj; - if (cpuNumber != other.cpuNumber) - return false; - if (cpuSpeed != other.cpuSpeed) - return false; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (displayText == null) { - if (other.displayText != null) - return false; - } else if (!displayText.equals(other.displayText)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (domainId != other.domainId) - return false; - if (haSupport != other.haSupport) - return false; - if (id != other.id) - return false; - if (memory != other.memory) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (storageType != other.storageType) - return false; - if (tags == null) { - if (other.tags != null) - return false; - } else if (!tags.equals(other.tags)) - return false; - return true; + public int hashCode() { + return Objects.hashCode(cpuNumber, cpuSpeed, created, displayText, domain, domainId, haSupport, id, memory, name, storageType, tags); } @Override @@ -436,7 +395,7 @@ public class ServiceOffering implements Comparable { @Override public int compareTo(ServiceOffering arg0) { - return new Long(id).compareTo(arg0.getId()); + return id.compareTo(arg0.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java index feafd8f686..a4a97044be 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java @@ -37,25 +37,25 @@ public class Snapshot implements Comparable { public static class Builder { - private long id; + private String id; private String account; private Date created; private String domain; - private long domainId; + private String domainId; private Interval interval; - private long jobId; + private String jobId; private String jobStatus; private String name; private Type snapshotType; private State state; - private long volumeId; + private String volumeId; private String volumeName; private Volume.Type volumeType; /** * @param id ID of the snapshot */ - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -87,7 +87,7 @@ public class Snapshot implements Comparable { /** * @param domainId the domain ID of the snapshot's account */ - public Builder domainId(long domainId) { + public Builder domainId(String domainId) { this.domainId = domainId; return this; } @@ -103,7 +103,7 @@ public class Snapshot implements Comparable { /** * @param jobId the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job. */ - public Builder jobId(long jobId) { + public Builder jobId(String jobId) { this.jobId = jobId; return this; } @@ -143,7 +143,7 @@ public class Snapshot implements Comparable { /** * @param volumeId ID of the disk volume */ - public Builder volumeId(long volumeId) { + public Builder volumeId(String volumeId) { this.volumeId = volumeId; return this; } @@ -215,16 +215,16 @@ public class Snapshot implements Comparable { } } - private long id; + private String id; private String account; private Date created; private String domain; @SerializedName("domainid") - private long domainId; + private String domainId; @SerializedName("intervaltype") private Interval interval; @SerializedName("jobid") - private long jobId; + private String jobId; @SerializedName("jobstatus") private String jobStatus; private String name; @@ -232,14 +232,14 @@ public class Snapshot implements Comparable { private Type snapshotType; private State state; @SerializedName("volumeid") - private long volumeId; + private String volumeId; @SerializedName("volumename") private String volumeName; @SerializedName("volumetype") private Volume.Type volumeType; - public Snapshot(long id, String account, Date created, String domain, long domainId, Interval interval, long jobId, - String jobStatus, String name, Type snapshotType, State state, long volumeId, String volumeName, Volume.Type volumeType) { + public Snapshot(String id, String account, Date created, String domain, String domainId, Interval interval, String jobId, + String jobStatus, String name, Type snapshotType, State state, String volumeId, String volumeName, Volume.Type volumeType) { this.id = id; this.account = account; this.created = created; @@ -265,7 +265,7 @@ public class Snapshot implements Comparable { /** * @return ID of the snapshot */ - public long getId() { + public String getId() { return id; } @@ -293,7 +293,7 @@ public class Snapshot implements Comparable { /** * @return the domain ID of the snapshot's account */ - public long getDomainId() { + public String getDomainId() { return domainId; } @@ -307,7 +307,7 @@ public class Snapshot implements Comparable { /** * @return the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job. */ - public long getJobId() { + public String getJobId() { return jobId; } @@ -342,7 +342,7 @@ public class Snapshot implements Comparable { /** * @return ID of the disk volume */ - public long getVolumeId() { + public String getVolumeId() { return volumeId; } @@ -387,21 +387,9 @@ public class Snapshot implements Comparable { @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (account != null ? account.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (domain != null ? domain.hashCode() : 0); - result = 31 * result + (int) (domainId ^ (domainId >>> 32)); - result = 31 * result + (interval != null ? interval.hashCode() : 0); - result = 31 * result + (int) (jobId ^ (jobId >>> 32)); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (snapshotType != null ? snapshotType.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (int) (volumeId ^ (volumeId >>> 32)); - result = 31 * result + (volumeName != null ? volumeName.hashCode() : 0); - result = 31 * result + (volumeType != null ? volumeType.hashCode() : 0); - return result; + return Objects.hashCode(domainId, id, jobId, volumeId, account, created, domain, + interval, jobStatus, name, snapshotType, state, volumeName, + volumeType); } @Override @@ -426,6 +414,6 @@ public class Snapshot implements Comparable { @Override public int compareTo(Snapshot other) { - return new Long(this.id).compareTo(other.getId()); + return id.compareTo(other.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java index 96d645c3c2..b736eb73e9 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SnapshotPolicy.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -31,17 +32,17 @@ public class SnapshotPolicy implements Comparable { public static class Builder { - private long id; + private String id; private Snapshot.Interval interval; private long numberToRetain; private String schedule; private String timezone; - private long volumeId; + private String volumeId; /** * @param id the ID of the snapshot policy */ - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -81,7 +82,7 @@ public class SnapshotPolicy implements Comparable { /** * @param volumeId ID of the disk volume */ - public Builder volumeId(long volumeId) { + public Builder volumeId(String volumeId) { this.volumeId = volumeId; return this; } @@ -91,7 +92,7 @@ public class SnapshotPolicy implements Comparable { } } - private long id; + private String id; @SerializedName("intervaltype") private Snapshot.Interval interval; @SerializedName("maxsnaps") @@ -99,9 +100,9 @@ public class SnapshotPolicy implements Comparable { private String schedule; private String timezone; @SerializedName("volumeid") - private long volumeId; + private String volumeId; - public SnapshotPolicy(long id, Snapshot.Interval interval, long numberToRetain, String schedule, String timezone, long volumeId) { + public SnapshotPolicy(String id, Snapshot.Interval interval, long numberToRetain, String schedule, String timezone, String volumeId) { this.id = id; this.interval = interval; this.numberToRetain = numberToRetain; @@ -119,7 +120,7 @@ public class SnapshotPolicy implements Comparable { /** * @return the ID of the snapshot policy */ - public long getId() { + public String getId() { return id; } @@ -154,7 +155,7 @@ public class SnapshotPolicy implements Comparable { /** * @return ID of the disk volume */ - public long getVolumeId() { + public String getVolumeId() { return volumeId; } @@ -165,25 +166,19 @@ public class SnapshotPolicy implements Comparable { SnapshotPolicy that = (SnapshotPolicy) o; - if (id != that.id) return false; - if (numberToRetain != that.numberToRetain) return false; - if (volumeId != that.volumeId) return false; - if (interval != that.interval) return false; - if (schedule != null ? !schedule.equals(that.schedule) : that.schedule != null) return false; - if (timezone != null ? !timezone.equals(that.timezone) : that.timezone != null) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(numberToRetain, that.numberToRetain)) return false; + if (!Objects.equal(volumeId, that.volumeId)) return false; + if (!Objects.equal(interval, that.interval)) return false; + if (!Objects.equal(schedule, that.schedule)) return false; + if (!Objects.equal(timezone, that.timezone)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (interval != null ? interval.hashCode() : 0); - result = 31 * result + (int) (numberToRetain ^ (numberToRetain >>> 32)); - result = 31 * result + (schedule != null ? schedule.hashCode() : 0); - result = 31 * result + (timezone != null ? timezone.hashCode() : 0); - result = 31 * result + (int) (volumeId ^ (volumeId >>> 32)); - return result; + return Objects.hashCode(id, numberToRetain, volumeId, interval, schedule, timezone); } @Override @@ -200,7 +195,7 @@ public class SnapshotPolicy implements Comparable { @Override public int compareTo(SnapshotPolicy other) { - return new Long(id).compareTo(other.getId()); + return id.compareTo(other.getId()); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java index 134ab5468b..ef36ea3b77 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/SshKeyPair.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.domain; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -85,42 +86,22 @@ public class SshKeyPair implements Comparable { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fingerprint == null) ? 0 : fingerprint.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((privateKey == null) ? 0 : privateKey.hashCode()); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - return result; + SshKeyPair that = (SshKeyPair) o; + + if (!Objects.equal(fingerprint, that.fingerprint)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(privateKey, that.privateKey)) return false; + + return true; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SshKeyPair other = (SshKeyPair) obj; - if (fingerprint == null) { - if (other.fingerprint != null) - return false; - } else if (!fingerprint.equals(other.fingerprint)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (privateKey == null) { - if (other.privateKey != null) - return false; - } else if (!privateKey.equals(other.privateKey)) - return false; - - return true; + public int hashCode() { + return Objects.hashCode(fingerprint, name, privateKey); } @Override diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java index 70dbf8e68c..03471a05c5 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Date; import com.google.common.base.CaseFormat; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -93,26 +94,26 @@ public class StoragePool implements Comparable { private Builder() { } - private long id; + private String id; private String name; private String path; private String tags; private State state; private Type type; - private long zoneId; + private String zoneId; private String zoneName; - private long podId; + private String podId; private String podName; - private long clusterId; + private String clusterId; private String clusterName; private Date created; private long diskSizeAllocated; private long diskSizeTotal; private String ipAddress; - private Long jobId; + private String jobId; private String jobStatus; - public Builder id(long id) { + public Builder id(String id) { this.id = id; return this; } @@ -142,7 +143,7 @@ public class StoragePool implements Comparable { return this; } - public Builder zoneId(long zoneId) { + public Builder zoneId(String zoneId) { this.zoneId = zoneId; return this; } @@ -152,7 +153,7 @@ public class StoragePool implements Comparable { return this; } - public Builder podId(long podId) { + public Builder podId(String podId) { this.podId = podId; return this; } @@ -162,7 +163,7 @@ public class StoragePool implements Comparable { return this; } - public Builder clusterId(long clusterId) { + public Builder clusterId(String clusterId) { this.clusterId = clusterId; return this; } @@ -192,7 +193,7 @@ public class StoragePool implements Comparable { return this; } - public Builder jobId(Long jobId) { + public Builder jobId(String jobId) { this.jobId = jobId; return this; } @@ -207,30 +208,30 @@ public class StoragePool implements Comparable { } } - private long id; + private String id; private String name; private String path; private String tags; private State state; private Type type; - @SerializedName("zoneid") private long zoneId; + @SerializedName("zoneid") private String zoneId; @SerializedName("zonename") private String zoneName; - @SerializedName("podid") private long podId; + @SerializedName("podid") private String podId; @SerializedName("podname") private String podName; - @SerializedName("clusterid") private long clusterId; + @SerializedName("clusterid") private String clusterId; @SerializedName("clustername") private String clusterName; private Date created; @SerializedName("disksizeallocated") private long diskSizeAllocated; @SerializedName("disksizetotal") private long diskSizeTotal; @SerializedName("ipaddress") private String ipAddress; - @SerializedName("jobid") private Long jobId; + @SerializedName("jobid") private String jobId; @SerializedName("jobstatus") private String jobStatus; /* Exists only for the serializer */ StoragePool() { } - public StoragePool(long id, String name, String path, String tags, State state, Type type, long zoneId, String zoneName, long podId, String podName, long clusterId, String clusterName, Date created, long diskSizeAllocated, long diskSizeTotal, String ipAddress, Long jobId, String jobStatus) { + public StoragePool(String id, String name, String path, String tags, State state, Type type, String zoneId, String zoneName, String podId, String podName, String clusterId, String clusterName, Date created, long diskSizeAllocated, long diskSizeTotal, String ipAddress, String jobId, String jobStatus) { this.id = id; this.name = name; this.path = path; @@ -251,7 +252,7 @@ public class StoragePool implements Comparable { this.jobStatus = jobStatus; } - public long getId() { + public String getId() { return id; } @@ -275,7 +276,7 @@ public class StoragePool implements Comparable { return type; } - public long getZoneId() { + public String getZoneId() { return zoneId; } @@ -283,7 +284,7 @@ public class StoragePool implements Comparable { return zoneName; } - public long getPodId() { + public String getPodId() { return podId; } @@ -291,7 +292,7 @@ public class StoragePool implements Comparable { return podName; } - public long getClusterId() { + public String getClusterId() { return clusterId; } @@ -315,7 +316,7 @@ public class StoragePool implements Comparable { return ipAddress; } - public Long getJobId() { + public String getJobId() { return jobId; } @@ -330,49 +331,33 @@ public class StoragePool implements Comparable { StoragePool that = (StoragePool) o; - if (clusterId != that.clusterId) return false; - if (diskSizeAllocated != that.diskSizeAllocated) return false; - if (diskSizeTotal != that.diskSizeTotal) return false; - if (id != that.id) return false; - if (podId != that.podId) return false; - if (zoneId != that.zoneId) return false; - if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false; - if (created != null ? !created.equals(that.created) : that.created != null) return false; - if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) return false; - if (jobId != null ? !jobId.equals(that.jobId) : that.jobId != null) return false; - if (jobStatus != null ? !jobStatus.equals(that.jobStatus) : that.jobStatus != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (path != null ? !path.equals(that.path) : that.path != null) return false; - if (podName != null ? !podName.equals(that.podName) : that.podName != null) return false; - if (state != that.state) return false; - if (tags != null ? !tags.equals(that.tags) : that.tags != null) return false; - if (type != that.type) return false; - if (zoneName != null ? !zoneName.equals(that.zoneName) : that.zoneName != null) return false; + if (!Objects.equal(clusterId, that.clusterId)) return false; + if (!Objects.equal(diskSizeAllocated, that.diskSizeAllocated)) return false; + if (!Objects.equal(diskSizeTotal, that.diskSizeTotal)) return false; + if (!Objects.equal(id, that.id)) return false; + if (!Objects.equal(podId, that.podId)) return false; + if (!Objects.equal(zoneId, that.zoneId)) return false; + if (!Objects.equal(clusterName, that.clusterName)) return false; + if (!Objects.equal(created, that.created)) return false; + if (!Objects.equal(ipAddress, that.ipAddress)) return false; + if (!Objects.equal(jobId, that.jobId)) return false; + if (!Objects.equal(jobStatus, that.jobStatus)) return false; + if (!Objects.equal(name, that.name)) return false; + if (!Objects.equal(path, that.path)) return false; + if (!Objects.equal(podName, that.podName)) return false; + if (!Objects.equal(state, that.state)) return false; + if (!Objects.equal(tags, that.tags)) return false; + if (!Objects.equal(type, that.type)) return false; + if (!Objects.equal(zoneName, that.zoneName)) return false; return true; } @Override public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (path != null ? path.hashCode() : 0); - result = 31 * result + (tags != null ? tags.hashCode() : 0); - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (int) (zoneId ^ (zoneId >>> 32)); - result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0); - result = 31 * result + (int) (podId ^ (podId >>> 32)); - result = 31 * result + (podName != null ? podName.hashCode() : 0); - result = 31 * result + (int) (clusterId ^ (clusterId >>> 32)); - result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0); - result = 31 * result + (created != null ? created.hashCode() : 0); - result = 31 * result + (int) (diskSizeAllocated ^ (diskSizeAllocated >>> 32)); - result = 31 * result + (int) (diskSizeTotal ^ (diskSizeTotal >>> 32)); - result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); - result = 31 * result + (jobId != null ? jobId.hashCode() : 0); - result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0); - return result; + return Objects.hashCode(clusterId, diskSizeAllocated, diskSizeTotal, id, podId, zoneId, + clusterName, created, ipAddress, jobId, jobStatus, name, path, + podName, state, tags, type, zoneName); } @Override @@ -401,6 +386,6 @@ public class StoragePool implements Comparable { @Override public int compareTo(StoragePool other) { - return Long.valueOf(this.id).compareTo(other.id); + return this.id.compareTo(other.id); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java index 68a9d84f03..27c33c1220 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java @@ -24,6 +24,7 @@ import java.util.Date; import javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** @@ -35,16 +36,16 @@ public class Template implements Comparable