Skip to content

Commit

Permalink
Merge pull request #309 from rpmoore/final-iter-update
Browse files Browse the repository at this point in the history
One final update to the way that filters are applied to the fluent it…
  • Loading branch information
RachelTucker authored Jul 27, 2016
2 parents fe7b6fc + 0a30dfa commit 4ea2806
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ public abstract Iterable<Contents> listObjects(final String bucket, final String
*/
public abstract Iterable<Ds3Object> removePrefixFromDs3ObjectsList(final Iterable<Ds3Object> objectsList, final String prefix);

public Iterable<Ds3Object> toDs3Iterable(final Iterable<Contents> objects) {
return toDs3Iterable(objects, null);
}

@SafeVarargs
public final Iterable<Ds3Object> toDs3Iterable(final Iterable<Contents> objects, final Predicate<Contents>... filters) {

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

for (final Predicate<Contents> filter : filters) {
fluentIterable = fluentIterable.filter(new com.google.common.base.Predicate<Contents>() {
@Override
public boolean apply(@Nullable final Contents input) {
if (filter != null) {
return filter.test(input);
} else {
return true; // do not filter anything if filter is null
if (filters != null) {
for (final Predicate<Contents> filter : filters) {
fluentIterable = fluentIterable.filter(new com.google.common.base.Predicate<Contents>() {
@Override
public boolean apply(@Nullable final Contents input) {
if (filter != null) {
return filter.test(input);
} else {
return true; // do not filter anything if filter is null
}
}
}
});
});
}
}

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

0 comments on commit 4ea2806

Please sign in to comment.