diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/DeviceDetails.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/DeviceDetails.java
index f10a5ec873..fca976cd97 100644
--- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/DeviceDetails.java
+++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/DeviceDetails.java
@@ -42,6 +42,7 @@ public class DeviceDetails {
private final DeviceType deviceType;
public DeviceDetails(int port, int deviceSlot, DeviceType deviceType) {
+ checkNotNull(deviceType, "deviceType");
this.port = port;
this.deviceSlot = deviceSlot;
this.deviceType = deviceType;
diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/IsoImage.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/IsoImage.java
index 2bafab7015..529535ce38 100644
--- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/IsoImage.java
+++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/IsoImage.java
@@ -21,6 +21,8 @@ package org.jclouds.virtualbox.domain;
import com.google.common.base.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Represents an optical medium (DVD) in a VirtualBox VM.
*
@@ -32,6 +34,8 @@ public class IsoImage {
private String sourcePath;
public IsoImage(DeviceDetails deviceDetails, String sourcePath) {
+ checkNotNull(deviceDetails, "deviceDetails");
+ checkNotNull(sourcePath, "sourcePath");
this.deviceDetails = deviceDetails;
this.sourcePath = sourcePath;
}
diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/NatAdapter.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/NatAdapter.java
index d41c7daac8..18df5527b6 100644
--- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/NatAdapter.java
+++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/NatAdapter.java
@@ -26,6 +26,8 @@ import org.virtualbox_4_1.NATProtocol;
import java.util.Collections;
import java.util.Set;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Represents a NAT network adapter in VirtualBox.
*
@@ -36,6 +38,7 @@ public class NatAdapter {
private final Set redirectRules = Sets.newLinkedHashSet();
public NatAdapter(Set redirectRules) {
+ checkNotNull(redirectRules);
this.redirectRules.addAll(redirectRules);
}
diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/RedirectRule.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/RedirectRule.java
index a151114647..e52b3b9a98 100644
--- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/RedirectRule.java
+++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/RedirectRule.java
@@ -22,6 +22,8 @@ package org.jclouds.virtualbox.domain;
import com.google.common.base.Objects;
import org.virtualbox_4_1.NATProtocol;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* @author Mattias Holmqvist
*/
@@ -34,6 +36,9 @@ public class RedirectRule {
private final int guestPort;
public RedirectRule(NATProtocol protocol, String host, int hostPort, String guest, int guestPort) {
+ checkNotNull(protocol);
+ checkNotNull(host);
+ checkNotNull(guest);
this.protocol = protocol;
this.host = host;
this.hostPort = hostPort;
diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java
index aa15c85cae..7bdcd6a7f1 100644
--- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java
+++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/StorageController.java
@@ -19,6 +19,7 @@
package org.jclouds.virtualbox.domain;
+import com.google.common.base.Objects;
import org.virtualbox_4_1.DeviceType;
import org.virtualbox_4_1.StorageBus;
@@ -30,7 +31,7 @@ import static org.jclouds.virtualbox.domain.HardDisk.DEFAULT_DISK_FORMAT;
/**
* Represents a storage controller in a VirtualBox VM.
- *
+ *
* name is the unique name of the controller.
* bus is the type of connection bus for the controller
* hardDisks contains the hard disks that are attached (or should be attached) to this controller
@@ -45,6 +46,10 @@ public class StorageController {
private Set isoImages;
public StorageController(String name, StorageBus bus, Set hardDisks, Set isoImages) {
+ checkNotNull(name, "name");
+ checkNotNull(bus, "bus");
+ checkNotNull(hardDisks, "hardDisks");
+ checkNotNull(isoImages, "isoImages");
this.name = name;
this.bus = bus;
this.hardDisks = hardDisks;
@@ -70,25 +75,19 @@ public class StorageController {
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- StorageController that = (StorageController) o;
-
- if (bus != that.bus) return false;
- if (isoImages != null ? !isoImages.equals(that.isoImages) : that.isoImages != null) return false;
- if (hardDisks != null ? !hardDisks.equals(that.hardDisks) : that.hardDisks != null) return false;
- if (name != null ? !name.equals(that.name) : that.name != null) return false;
-
- return true;
+ if (o instanceof StorageController) {
+ StorageController other = (StorageController) o;
+ return Objects.equal(name, other.name) &&
+ Objects.equal(bus, other.bus) &&
+ Objects.equal(hardDisks, other.hardDisks) &&
+ Objects.equal(isoImages, other.isoImages);
+ }
+ return false;
}
@Override
public int hashCode() {
- int result = name != null ? name.hashCode() : 0;
- result = 31 * result + (bus != null ? bus.hashCode() : 0);
- result = 31 * result + (hardDisks != null ? hardDisks.hashCode() : 0);
- result = 31 * result + (isoImages != null ? isoImages.hashCode() : 0);
- return result;
+ return Objects.hashCode(name, bus, hardDisks, isoImages);
}
@Override
diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/VmSpec.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/VmSpec.java
index 7ae269598d..cafccf50a2 100644
--- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/VmSpec.java
+++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/VmSpec.java
@@ -25,6 +25,7 @@ import java.util.*;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
/**
* A description of a Virtual Machine in VirtualBox.
@@ -40,6 +41,11 @@ public class VmSpec {
private final Set controllers;
public VmSpec(String vmId, String vmName, String osTypeId, long memory, boolean forceOverwrite, Set controllers, Map natNetworkAdapters) {
+ checkNotNull(vmId, "vmId");
+ checkNotNull(vmName, "vmName");
+ checkArgument(memory > 0, "memory must be > 0");
+ checkNotNull(controllers, "controllers");
+ checkNotNull(natNetworkAdapters, "natNetworkAdapters");
this.vmId = vmId;
this.vmName = vmName;
this.osTypeId = osTypeId;