forked from OpenFeign/feign
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGsonCodec.java
More file actions
37 lines (30 loc) · 896 Bytes
/
GsonCodec.java
File metadata and controls
37 lines (30 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package feign.gson;
import com.google.gson.Gson;
import feign.RequestTemplate;
import feign.Response;
import feign.codec.Decoder;
import feign.codec.Encoder;
import javax.inject.Inject;
import java.io.IOException;
import java.lang.reflect.Type;
/**
* @deprecated use {@link GsonEncoder} and {@link GsonDecoder} instead
*/
@Deprecated
public class GsonCodec implements Encoder, Decoder {
private final GsonEncoder encoder;
private final GsonDecoder decoder;
public GsonCodec() {
this(new Gson());
}
@Inject public GsonCodec(Gson gson) {
this.encoder = new GsonEncoder(gson);
this.decoder = new GsonDecoder(gson);
}
@Override public void encode(Object object, RequestTemplate template) {
encoder.encode(object, template);
}
@Override public Object decode(Response response, Type type) throws IOException {
return decoder.decode(response, type);
}
}