|
| 1 | +/* |
| 2 | + * Jooby https://jooby.io |
| 3 | + * Apache License Version 2.0 https://jooby.io/LICENSE.txt |
| 4 | + * Copyright 2014 Edgar Espina |
| 5 | + */ |
1 | 6 | package io.jooby.internal; |
2 | 7 |
|
3 | | -import edu.umd.cs.findbugs.annotations.NonNull; |
4 | | -import io.jooby.Context; |
5 | | -import io.jooby.ValueNode; |
6 | 8 | import java.util.List; |
7 | 9 | import java.util.Map; |
8 | 10 | import java.util.Set; |
9 | 11 | import java.util.TreeMap; |
10 | 12 |
|
| 13 | +import edu.umd.cs.findbugs.annotations.NonNull; |
| 14 | +import io.jooby.Context; |
| 15 | +import io.jooby.ValueNode; |
| 16 | + |
11 | 17 | public class HeadersValue extends HashValue implements ValueNode { |
12 | 18 |
|
13 | | - public HeadersValue(final Context ctx) { |
14 | | - super(ctx); |
15 | | - } |
| 19 | + public HeadersValue(final Context ctx) { |
| 20 | + super(ctx); |
| 21 | + } |
16 | 22 |
|
17 | | - @Override |
18 | | - protected Map<String, ValueNode> hash() { |
19 | | - if (hash == EMPTY) { |
20 | | - hash = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
21 | | - } |
22 | | - return hash; |
23 | | - } |
| 23 | + @Override |
| 24 | + protected Map<String, ValueNode> hash() { |
| 25 | + if (hash == EMPTY) { |
| 26 | + hash = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
| 27 | + } |
| 28 | + return hash; |
| 29 | + } |
24 | 30 |
|
25 | | - @NonNull |
26 | | - @Override |
27 | | - public Map<String, String> toMap() { |
28 | | - Map<String, String> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
29 | | - toMultimap().forEach((k, v) -> map.put(k, v.get(0))); |
30 | | - return map; |
31 | | - } |
| 31 | + @NonNull @Override |
| 32 | + public Map<String, String> toMap() { |
| 33 | + Map<String, String> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
| 34 | + toMultimap().forEach((k, v) -> map.put(k, v.get(0))); |
| 35 | + return map; |
| 36 | + } |
32 | 37 |
|
33 | | - @NonNull |
34 | | - @Override |
35 | | - public Map<String, List<String>> toMultimap() { |
36 | | - Map<String, List<String>> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
37 | | - Set<Map.Entry<String, ValueNode>> entries = hash.entrySet(); |
38 | | - for (Map.Entry<String, ValueNode> entry : entries) { |
39 | | - ValueNode value = entry.getValue(); |
40 | | - result.putAll(value.toMultimap()); |
41 | | - } |
42 | | - return result; |
43 | | - } |
| 38 | + @NonNull @Override |
| 39 | + public Map<String, List<String>> toMultimap() { |
| 40 | + Map<String, List<String>> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
| 41 | + Set<Map.Entry<String, ValueNode>> entries = hash.entrySet(); |
| 42 | + for (Map.Entry<String, ValueNode> entry : entries) { |
| 43 | + ValueNode value = entry.getValue(); |
| 44 | + result.putAll(value.toMultimap()); |
| 45 | + } |
| 46 | + return result; |
| 47 | + } |
44 | 48 | } |
0 commit comments