Skip to content

Commit fbc98ea

Browse files
committed
remove redundant type argument and some refactoring
1 parent 49519fc commit fbc98ea

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/main/java/com/zaneli/qiita/QiitaExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public <T extends QiitaResponse> PageableResponse<T> getPageableContents(
103103
try (InputStream in = response.getEntity().getContent()) {
104104
@SuppressWarnings("unchecked")
105105
T[] contents = JSON.decode(in, (Class<T[]>) Array.newInstance(responseType, 0).getClass());
106-
return new PageableResponse<T>(this, params, responseType, contents, linkHeaderValues);
106+
return new PageableResponse<>(this, params, responseType, contents, linkHeaderValues);
107107
}
108108
}
109109

src/main/java/com/zaneli/qiita/model/response/PageableResponse.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ private static enum Rel {
2323
private Rel(String value) {
2424
this.value = value;
2525
}
26+
String getValue() {
27+
return value;
28+
}
2629
}
2730

2831
private final QiitaExecutor executor;
@@ -52,34 +55,34 @@ public T[] getContents() {
5255

5356
public PageableResponse<T> getFirst() throws IOException, QiitaException {
5457
if (firstUri == null) {
55-
return new NullPageableResponse<T>(responseType, contents);
58+
return new NullPageableResponse<>(responseType);
5659
}
5760
return executor.getPageableContents(firstUri, params, responseType);
5861
}
5962

6063
public PageableResponse<T> getPrev() throws IOException, QiitaException {
6164
if (prevUri == null) {
62-
return new NullPageableResponse<T>(responseType, contents);
65+
return new NullPageableResponse<>(responseType);
6366
}
6467
return executor.getPageableContents(prevUri, params, responseType);
6568
}
6669

6770
public PageableResponse<T> getNext() throws IOException, QiitaException {
6871
if (nextUri == null) {
69-
return new NullPageableResponse<T>(responseType, contents);
72+
return new NullPageableResponse<>(responseType);
7073
}
7174
return executor.getPageableContents(nextUri, params, responseType);
7275
}
7376

7477
public PageableResponse<T> getLast() throws IOException, QiitaException {
7578
if (lastUri == null) {
76-
return new NullPageableResponse<T>(responseType, contents);
79+
return new NullPageableResponse<>(responseType);
7780
}
7881
return executor.getPageableContents(lastUri, params, responseType);
7982
}
8083

8184
private static URI retrieveUri(Rel rel, String[] linkHeaderValues) throws QiitaException {
82-
Pattern pattern = Pattern.compile("^<(.+)>;\\s+rel=\"" + rel.value + "\"$");
85+
Pattern pattern = Pattern.compile("^<(.+)>;\\s+rel=\"" + rel.getValue() + "\"$");
8386
for (String linkHeaderValue : linkHeaderValues) {
8487
String[] splitedLinkHeaderValues = linkHeaderValue.split(",");
8588
for (String splitedLinkHeaderValue : splitedLinkHeaderValues) {
@@ -99,7 +102,7 @@ private static URI retrieveUri(Rel rel, String[] linkHeaderValues) throws QiitaE
99102
private static class NullPageableResponse<T extends QiitaResponse> extends PageableResponse<T> {
100103
private final T[] emptyContent;
101104
@SuppressWarnings("unchecked")
102-
private NullPageableResponse(Class<T> responseType, T[] orgContents) throws QiitaException {
105+
NullPageableResponse(Class<T> responseType) throws QiitaException {
103106
super(null, Collections.<String, String>emptyMap(), responseType, null, new String[0]);
104107
this.emptyContent = (T[]) Array.newInstance(responseType, 0);
105108
}

src/test/java/com/zaneli/qiita/QiitaClientTestUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static void configureMock(
3737
configureMock(executor, statusCode, null);
3838
}
3939

40+
@SuppressWarnings({ "resource", "unused" })
4041
static void configureMock(
4142
final QiitaExecutor executor,
4243
final int statusCode,
@@ -65,7 +66,7 @@ static void configureMock(
6566
}
6667
{
6768
mockStatusLine.getStatusCode();
68-
returns(statusCode);
69+
returns(Integer.valueOf(statusCode));
6970
}
7071
{
7172
mockEntity.getContent();

0 commit comments

Comments
 (0)