Skip to content

Commit 4ea2806

Browse files
authored
Merge pull request #309 from rpmoore/final-iter-update
One final update to the way that filters are applied to the fluent it…
2 parents fe7b6fc + 0a30dfa commit 4ea2806

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/Ds3ClientHelpers.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ public abstract Iterable<Contents> listObjects(final String bucket, final String
291291
*/
292292
public abstract Iterable<Ds3Object> removePrefixFromDs3ObjectsList(final Iterable<Ds3Object> objectsList, final String prefix);
293293

294-
public Iterable<Ds3Object> toDs3Iterable(final Iterable<Contents> objects) {
295-
return toDs3Iterable(objects, null);
296-
}
297-
298294
@SafeVarargs
299295
public final Iterable<Ds3Object> toDs3Iterable(final Iterable<Contents> objects, final Predicate<Contents>... filters) {
300296

@@ -305,17 +301,19 @@ public boolean apply(@Nullable final Contents input) {
305301
}
306302
});
307303

308-
for (final Predicate<Contents> filter : filters) {
309-
fluentIterable = fluentIterable.filter(new com.google.common.base.Predicate<Contents>() {
310-
@Override
311-
public boolean apply(@Nullable final Contents input) {
312-
if (filter != null) {
313-
return filter.test(input);
314-
} else {
315-
return true; // do not filter anything if filter is null
304+
if (filters != null) {
305+
for (final Predicate<Contents> filter : filters) {
306+
fluentIterable = fluentIterable.filter(new com.google.common.base.Predicate<Contents>() {
307+
@Override
308+
public boolean apply(@Nullable final Contents input) {
309+
if (filter != null) {
310+
return filter.test(input);
311+
} else {
312+
return true; // do not filter anything if filter is null
313+
}
316314
}
317-
}
318-
});
315+
});
316+
}
319317
}
320318

321319
return fluentIterable.transform(new Function<Contents, Ds3Object>() {

0 commit comments

Comments
 (0)