Skip to content

Commit adeb9e7

Browse files
author
Gerald Unterrainer
committed
setting application/json as default media-type
1 parent 8518c34 commit adeb9e7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>rest-client</artifactId>
13-
<version>0.0.8</version>
13+
<version>0.0.9</version>
1414
<name>RestClient</name>
1515
<packaging>jar</packaging>
1616

src/main/java/info/unterrainer/commons/restclient/BaseBuilder.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ public R isListJson() {
7676
return (R) this;
7777
}
7878

79+
/**
80+
* Sets the return-type to be of {@link List} with the generic type you provided
81+
* when starting this builder.
82+
*
83+
* @return a {@link BaseBuilder} to provide a fluent interface.
84+
*/
85+
@SuppressWarnings("unchecked")
86+
public R isList() {
87+
JsonMapper mapper = client.jsonMapper;
88+
TypeFactory typeFactory = mapper.getTypeFactory();
89+
javaType = typeFactory.constructParametricType(List.class, type);
90+
return (R) this;
91+
}
92+
7993
/**
8094
* Adds a header to the call.
8195
* <p>

src/main/java/info/unterrainer/commons/restclient/BasePostBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class BasePostBuilder<T, R> extends BaseBuilder<T, BasePostBuilder<T, R>> {
1010

11-
protected String mediaType;
11+
protected String mediaType = "application/json";
1212
protected String body;
1313

1414
BasePostBuilder(final RestClient client, final Class<?> type) {

0 commit comments

Comments
 (0)