Skip to content

Commit 42a0f12

Browse files
committed
Forgot simple response
1 parent de1900b commit 42a0f12

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.stubbornjava.common;
2+
3+
import java.util.Map;
4+
5+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
6+
import com.google.common.collect.Maps;
7+
8+
public class SimpleResponse {
9+
private Map<String, Object> data;
10+
11+
SimpleResponse() {
12+
super();
13+
this.data = null;
14+
}
15+
16+
@JsonAnyGetter
17+
public Map<String, Object> getData() {
18+
return data;
19+
}
20+
21+
public SimpleResponse with(String key, Object value) {
22+
if (null == data) {
23+
data = Maps.newLinkedHashMap();
24+
}
25+
if (data.containsKey(key)) {
26+
throw new IllegalArgumentException(key + " already has data");
27+
}
28+
data.put(key, value);
29+
return this;
30+
}
31+
32+
public static SimpleResponse create() {
33+
return new SimpleResponse();
34+
}
35+
}

0 commit comments

Comments
 (0)