Skip to content

Commit

Permalink
redundant code removed
Browse files Browse the repository at this point in the history
  • Loading branch information
faob-dev committed Apr 29, 2018
1 parent f21b80b commit 599c122
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/main/java/io/faob/utopian/service/DefaultUtopianService.java
Expand Up @@ -196,24 +196,7 @@ public ArrayType<Post> postsByAuthor(String userName, Map<String, Object> option
options.put("section", "author");
options.put("author", userName);

StringBuilder url = new StringBuilder(ENDPOINT_POSTS + "/?");
for (Map.Entry<String, Object> entry : options.entrySet()) {
url.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
}
url = new StringBuilder(url.substring(0, url.length() - 1));

TypeMapper<JsonArray> asJsonArray = jsonString -> {
JsonObject postsJson = new JsonParser().parse(jsonString).getAsJsonObject();
return postsJson.get("results").getAsJsonArray();
};

TypeMapper<List<Post>> asList = jsonString -> {
Type collectionType = new TypeToken<List<Post>>(){}.getType();
return new Gson().fromJson(asJsonArray.map(jsonString), collectionType);
};


return new ArrayType<>(url.toString(), asJsonArray, asList);
return posts(options);
}

@Override
Expand Down

0 comments on commit 599c122

Please sign in to comment.