mirror of https://github.com/apache/jclouds.git
Improve use of Splitter.omitEmptyStrings
This commit is contained in:
parent
674e8f6c04
commit
cca02ae02d
|
@ -18,9 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudsigma.functions;
|
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 static com.google.common.collect.Sets.newTreeSet;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -49,6 +46,6 @@ public class SplitNewlines implements Function<HttpResponse, Set<String>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> apply(HttpResponse response) {
|
public Set<String> 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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.elasticstack.functions;
|
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 static com.google.common.collect.Sets.newTreeSet;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -49,6 +46,6 @@ public class SplitNewlines implements Function<HttpResponse, Set<String>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> apply(HttpResponse response) {
|
public Set<String> 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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.s3.handlers;
|
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 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_SERVICE_PATH;
|
||||||
import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS;
|
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()
|
} else if (command.getCurrentRequest().getEndpoint().getPath()
|
||||||
.indexOf(servicePath.equals("/") ? "/" : servicePath + "/") == 0) {
|
.indexOf(servicePath.equals("/") ? "/" : servicePath + "/") == 0) {
|
||||||
String path = command.getCurrentRequest().getEndpoint().getPath().substring(servicePath.length());
|
String path = command.getCurrentRequest().getEndpoint().getPath().substring(servicePath.length());
|
||||||
List<String> parts = newArrayList(filter(Splitter.on('/').split(path), not(equalTo(""))));
|
List<String> parts = newArrayList(Splitter.on('/').omitEmptyStrings().split(path));
|
||||||
if (parts.size() == 1) {
|
if (parts.size() == 1) {
|
||||||
exception = new ContainerNotFoundException(parts.get(0), message);
|
exception = new ContainerNotFoundException(parts.get(0), message);
|
||||||
} else if (parts.size() > 1) {
|
} else if (parts.size() > 1) {
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cim.xml;
|
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.currentOrNull;
|
||||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
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.jclouds.http.functions.ParseSax;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,15 +97,7 @@ public class VirtualSystemSettingDataHandler extends ParseSax.HandlerWithResult<
|
||||||
} else if (equalsOrSuffix(qName, "VirtualSystemIdentifier")) {
|
} else if (equalsOrSuffix(qName, "VirtualSystemIdentifier")) {
|
||||||
builder.virtualSystemIdentifier(current);
|
builder.virtualSystemIdentifier(current);
|
||||||
} else if (equalsOrSuffix(qName, "VirtualSystemType")) {
|
} else if (equalsOrSuffix(qName, "VirtualSystemType")) {
|
||||||
builder.virtualSystemTypes(filter(transform(Splitter.on(',').split(current),
|
builder.virtualSystemTypes(Splitter.on(',').trimResults().omitEmptyStrings().split(current));
|
||||||
new Function<String, String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String apply(String input) {
|
|
||||||
return input.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
}), not(equalTo(""))));
|
|
||||||
} else if (equalsOrSuffix(qName, "Notes")) {
|
} else if (equalsOrSuffix(qName, "Notes")) {
|
||||||
builder.notes(current);
|
builder.notes(current);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
package org.jclouds.providers.internal;
|
package org.jclouds.providers.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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;
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_BUILD_VERSION;
|
import static org.jclouds.Constants.PROPERTY_BUILD_VERSION;
|
||||||
|
@ -85,7 +82,7 @@ public class UpdateProviderMetadataFromProperties implements Function<Properties
|
||||||
.toBuilder()
|
.toBuilder()
|
||||||
.apiMetadata(apiMetadata)
|
.apiMetadata(apiMetadata)
|
||||||
.id(providerId)
|
.id(providerId)
|
||||||
.iso3166Codes(filter(Splitter.on(',').split(isoCodes), not(equalTo(""))))
|
.iso3166Codes(Splitter.on(',').omitEmptyStrings().split(isoCodes))
|
||||||
.endpoint(endpoint).defaultProperties(mutable).build();
|
.endpoint(endpoint).defaultProperties(mutable).build();
|
||||||
|
|
||||||
return providerMetadata;
|
return providerMetadata;
|
||||||
|
|
Loading…
Reference in New Issue