diff --git a/src/main/java/me/goudham/APIMapper.java b/src/main/java/me/goudham/APIMapper.java index 4e98ded..aa9b12b 100644 --- a/src/main/java/me/goudham/APIMapper.java +++ b/src/main/java/me/goudham/APIMapper.java @@ -4,10 +4,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import me.goudham.api.entity.series.Series; +import me.goudham.domain.series.Series; import me.goudham.exception.APIMapperException; -import me.goudham.api.entity.series.FilteredSeries; -import me.goudham.api.entity.waifu.Waifu; +import me.goudham.domain.series.FilteredSeries; +import me.goudham.domain.waifu.Waifu; import java.util.List; @@ -23,58 +23,58 @@ class APIMapper { } /** - * Using the given {@code entity}, {@link ObjectMapper} deserializes the given Json + * Using the given {@code model}, {@link ObjectMapper} deserializes the given Json * into a Java POJO * * @param result The result of the previous API response - * @param entity The actual class of the given entity. E.g {@link Waifu#getClass()} - * @param The type of entity to be returned. E.g {@link Waifu} or {@link Series} + * @param model The actual class of the given model. E.g {@link Waifu#getClass()} + * @param The type of model to be returned. E.g {@link Waifu} or {@link Series} * @return {@link Response} * @throws APIMapperException If {@link ObjectMapper} is not able to deserialize JSON to Java POJO properly * */ - Response deserialize(Result result, Class entity) throws APIMapperException { + Response deserialize(Result result, Class model) throws APIMapperException { Integer statusCode = result.getStatusCode(); String body = result.getBody(); - T newEntity = null; + T newModel = null; if (statusCode == 200) { try { String data = getJsonTree(body); - newEntity = objectMapper.readValue(data, entity); + newModel = objectMapper.readValue(data, model); } catch (JsonProcessingException jpe) { throwAPIMapperException(jpe); } } - return new Response<>(statusCode, body, newEntity); + return new Response<>(statusCode, body, newModel); } /** - * Using the given {@code entity}, {@link ObjectMapper} deserializes the given Json + * Using the given {@code model}, {@link ObjectMapper} deserializes the given Json * into a Java POJO. This method enables support for retrieving {@link List} of entities * * @param List of entities to be returned. E.g {@link List} of {@link FilteredSeries} * @param result The result of the previous API response - * @param entity The actual class of the given entity. E.g {@link Waifu#getClass()} + * @param model The actual class of the given model. E.g {@link Waifu#getClass()} * @return {@link Response} * @throws APIMapperException If {@link ObjectMapper} is not able to deserialize JSON to Java POJO properly */ - Response> deserialize(Result result, JavaType entity) throws APIMapperException { + Response> deserialize(Result result, JavaType model) throws APIMapperException { Integer statusCode = result.getStatusCode(); String body = result.getBody(); - List listOfEntity = null; + List listOfModels = null; if (statusCode == 200) { try { String data = getJsonTree(body); - listOfEntity = objectMapper.readValue(data, entity); + listOfModels = objectMapper.readValue(data, model); } catch (JsonProcessingException jpe) { throwAPIMapperException(jpe); } } - return new Response<>(statusCode, body, listOfEntity); + return new Response<>(statusCode, body, listOfModels); } /** diff --git a/src/main/java/me/goudham/exception/APIMapperException.java b/src/main/java/me/goudham/exception/APIMapperException.java index 4c7d9f3..9e5dd04 100644 --- a/src/main/java/me/goudham/exception/APIMapperException.java +++ b/src/main/java/me/goudham/exception/APIMapperException.java @@ -4,7 +4,7 @@ import me.goudham.APIWrapper; import me.goudham.Response; /** - * Thrown when {@link APIWrapper} fails to deserialize json into Java POJO's ({@link Response#getEntity()}) + * Thrown when {@link APIWrapper} fails to deserialize json into Java POJO's ({@link Response#getModel()}) * */ public class APIMapperException extends Throwable {