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;
|
||||
|
||||
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<HttpResponse, Set<String>> {
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
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<HttpResponse, Set<String>> {
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
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<String> parts = newArrayList(filter(Splitter.on('/').split(path), not(equalTo(""))));
|
||||
List<String> parts = newArrayList(Splitter.on('/').omitEmptyStrings().split(path));
|
||||
if (parts.size() == 1) {
|
||||
exception = new ContainerNotFoundException(parts.get(0), message);
|
||||
} else if (parts.size() > 1) {
|
||||
|
|
|
@ -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<String, String>() {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
|
|
@ -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<Properties
|
|||
.toBuilder()
|
||||
.apiMetadata(apiMetadata)
|
||||
.id(providerId)
|
||||
.iso3166Codes(filter(Splitter.on(',').split(isoCodes), not(equalTo(""))))
|
||||
.iso3166Codes(Splitter.on(',').omitEmptyStrings().split(isoCodes))
|
||||
.endpoint(endpoint).defaultProperties(mutable).build();
|
||||
|
||||
return providerMetadata;
|
||||
|
|
Loading…
Reference in New Issue