Merge pull request #786 from andrewgaul/multimap-filter-keys

Use Multimaps and Predicates helpers
This commit is contained in:
Adrian Cole 2012-08-16 14:48:19 -07:00
commit c7f155d149
1 changed files with 5 additions and 8 deletions

View File

@ -157,6 +157,7 @@ import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
@ -558,16 +559,12 @@ public class RestAnnotationProcessor<T> {
} }
public static Multimap<String, String> filterOutContentHeaders(Multimap<String, String> headers) { public static Multimap<String, String> filterOutContentHeaders(Multimap<String, String> headers) {
// TODO make a filter like {@link Maps.filterKeys} instead of this
ImmutableMultimap.Builder<String, String> headersBuilder = ImmutableMultimap.builder();
// http message usually comes in as a null key header, let's filter it // http message usually comes in as a null key header, let's filter it
// out. // out.
for (String header : Iterables.filter(headers.keySet(), Predicates.notNull())) { return ImmutableMultimap.copyOf(Multimaps.filterKeys(headers,
if (!ContentMetadata.HTTP_HEADERS.contains(header)) { Predicates.and(
headersBuilder.putAll(header, headers.get(header)); Predicates.notNull(),
} Predicates.not(Predicates.in(ContentMetadata.HTTP_HEADERS)))));
}
return headersBuilder.build();
} }
public static final String BOUNDARY = "--JCLOUDS--"; public static final String BOUNDARY = "--JCLOUDS--";