You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2016/04/19 17:12:42 UTC
jclouds-labs git commit: Make DockerTemplateOptions values null safe
Repository: jclouds-labs
Updated Branches:
refs/heads/1.9.x dbea9c3ea -> 5c892910d
Make DockerTemplateOptions values null safe
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/5c892910
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/5c892910
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/5c892910
Branch: refs/heads/1.9.x
Commit: 5c892910d9fe6842605611c08d8308bc7bdb0e75
Parents: dbea9c3
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Thu Apr 14 21:05:34 2016 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Tue Apr 19 17:07:09 2016 +0200
----------------------------------------------------------------------
.../compute/options/DockerTemplateOptions.java | 22 ++++++++++----------
.../jclouds/docker/internal/NullSafeCopies.java | 8 +++++++
2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5c892910/docker/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java
----------------------------------------------------------------------
diff --git a/docker/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java b/docker/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java
index 2bd7299..1139d68 100644
--- a/docker/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java
+++ b/docker/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java
@@ -51,15 +51,15 @@ import org.jclouds.scriptbuilder.domain.Statement;
public class DockerTemplateOptions extends TemplateOptions implements Cloneable {
protected List<String> dns = ImmutableList.of();
- protected String hostname;
- protected Integer memory;
- protected Integer cpuShares;
- protected List<String> entrypoint = ImmutableList.of();
- protected List<String> commands = ImmutableList.of();
+ @Nullable protected String hostname;
+ @Nullable protected Integer memory;
+ @Nullable protected Integer cpuShares;
+ @Nullable List<String> entrypoint;
+ @Nullable List<String> commands;
protected Map<String, String> volumes = ImmutableMap.of();
- protected List<String> env = ImmutableList.of();
+ @Nullable protected List<String> env;
protected Map<Integer, Integer> portBindings = ImmutableMap.of();
- protected String networkMode;
+ @Nullable protected String networkMode;
protected Map<String, String> extraHosts = ImmutableMap.of();
protected List<String> volumesFrom = ImmutableList.of();
@@ -138,12 +138,12 @@ public class DockerTemplateOptions extends TemplateOptions implements Cloneable
}
public DockerTemplateOptions dns(Iterable<String> dns) {
- this.dns = NullSafeCopies.copyWithNullOf(dns);
+ this.dns = NullSafeCopies.copyOf(dns);
return this;
}
public DockerTemplateOptions dns(String...dns) {
- this.dns = NullSafeCopies.copyWithNullOf(dns);
+ this.dns = NullSafeCopies.copyOf(dns);
return this;
}
@@ -227,7 +227,7 @@ public class DockerTemplateOptions extends TemplateOptions implements Cloneable
* @param extraHosts the map of host names to IP addresses
*/
public DockerTemplateOptions extraHosts(Map<String, String> extraHosts) {
- this.extraHosts = NullSafeCopies.copyWithNullOf(extraHosts);
+ this.extraHosts = NullSafeCopies.copyOf(extraHosts);
return this;
}
@@ -237,7 +237,7 @@ public class DockerTemplateOptions extends TemplateOptions implements Cloneable
* @param volumesFrom the list of container names
*/
public DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom) {
- this.volumesFrom = NullSafeCopies.copyWithNullOf(volumesFrom);
+ this.volumesFrom = NullSafeCopies.copyOf(volumesFrom);
return this;
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/5c892910/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java
----------------------------------------------------------------------
diff --git a/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java b/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java
index b6e190c..f3d9eb8 100644
--- a/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java
+++ b/docker/src/main/java/org/jclouds/docker/internal/NullSafeCopies.java
@@ -34,6 +34,14 @@ public class NullSafeCopies {
return list != null ? ImmutableList.copyOf(list) : ImmutableList.<E> of();
}
+ public static <E> List<E> copyOf(@Nullable Iterable<E> list) {
+ return list != null ? ImmutableList.copyOf(list) : ImmutableList.<E> of();
+ }
+
+ public static <E> List<E> copyOf(@Nullable E[] array) {
+ return array != null ? ImmutableList.copyOf(array) : ImmutableList.<E> of();
+ }
+
/**
* Copies given List with keeping null value if provided.
*