From cca02ae02d62f175225601b8cc97ac76a9bcb894 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Wed, 7 Nov 2012 22:14:39 -0800 Subject: [PATCH] Improve use of Splitter.omitEmptyStrings --- .../cloudsigma/functions/SplitNewlines.java | 5 +---- .../elasticstack/functions/SplitNewlines.java | 5 +---- .../s3/handlers/ParseS3ErrorFromXmlContent.java | 5 +---- .../cim/xml/VirtualSystemSettingDataHandler.java | 15 +-------------- .../UpdateProviderMetadataFromProperties.java | 5 +---- 5 files changed, 5 insertions(+), 30 deletions(-) diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java index 72f3494c49..07c874aaac 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java @@ -18,9 +18,6 @@ */ package org.jclouds.cloudsigma.functions; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Sets.newTreeSet; import java.util.Set; @@ -49,6 +46,6 @@ public class SplitNewlines implements Function> { @Override public Set apply(HttpResponse response) { - return newTreeSet(filter(Splitter.on('\n').split(returnStringIf200.apply(response)), not(equalTo("")))); + return newTreeSet(Splitter.on('\n').omitEmptyStrings().split(returnStringIf200.apply(response))); } } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java index fe6affed77..76b8d89a4a 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java @@ -18,9 +18,6 @@ */ package org.jclouds.elasticstack.functions; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Sets.newTreeSet; import java.util.Set; @@ -49,6 +46,6 @@ public class SplitNewlines implements Function> { @Override public Set apply(HttpResponse response) { - return newTreeSet(filter(Splitter.on('\n').split(returnStringIf200.apply(response)), not(equalTo("")))); + return newTreeSet(Splitter.on('\n').omitEmptyStrings().split(returnStringIf200.apply(response))); } } diff --git a/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java b/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java index c6df0a609e..fc03338579 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java +++ b/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java @@ -18,9 +18,6 @@ */ package org.jclouds.s3.handlers; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Lists.newArrayList; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; @@ -88,7 +85,7 @@ public class ParseS3ErrorFromXmlContent extends ParseAWSErrorFromXmlContent { } else if (command.getCurrentRequest().getEndpoint().getPath() .indexOf(servicePath.equals("/") ? "/" : servicePath + "/") == 0) { String path = command.getCurrentRequest().getEndpoint().getPath().substring(servicePath.length()); - List parts = newArrayList(filter(Splitter.on('/').split(path), not(equalTo("")))); + List parts = newArrayList(Splitter.on('/').omitEmptyStrings().split(path)); if (parts.size() == 1) { exception = new ContainerNotFoundException(parts.get(0), message); } else if (parts.size() > 1) { diff --git a/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java b/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java index c537722ad9..73784502c3 100644 --- a/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java +++ b/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java @@ -18,10 +18,6 @@ */ package org.jclouds.cim.xml; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.util.SaxUtils.equalsOrSuffix; @@ -34,7 +30,6 @@ import org.jclouds.cim.VirtualSystemSettingData.AutomaticStartupAction; import org.jclouds.http.functions.ParseSax; import org.xml.sax.Attributes; -import com.google.common.base.Function; import com.google.common.base.Splitter; /** @@ -102,15 +97,7 @@ public class VirtualSystemSettingDataHandler extends ParseSax.HandlerWithResult< } else if (equalsOrSuffix(qName, "VirtualSystemIdentifier")) { builder.virtualSystemIdentifier(current); } else if (equalsOrSuffix(qName, "VirtualSystemType")) { - builder.virtualSystemTypes(filter(transform(Splitter.on(',').split(current), - new Function() { - - @Override - public String apply(String input) { - return input.trim(); - } - - }), not(equalTo("")))); + builder.virtualSystemTypes(Splitter.on(',').trimResults().omitEmptyStrings().split(current)); } else if (equalsOrSuffix(qName, "Notes")) { builder.notes(current); } diff --git a/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java b/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java index 62d77bbbe2..e813fb2b05 100644 --- a/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java +++ b/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java @@ -19,9 +19,6 @@ package org.jclouds.providers.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.filter; import static org.jclouds.Constants.PROPERTY_API; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; @@ -85,7 +82,7 @@ public class UpdateProviderMetadataFromProperties implements Function