-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#244 Migrate Coffee API calls to graphQL
- Loading branch information
1 parent
24b715b
commit 8abf27c
Showing
7 changed files
with
170 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/net/ironoc/portfolio/domain/IngredientsDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.ironoc.portfolio.domain; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import net.ironoc.portfolio.exception.IronocJsonException; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class IngredientsDeserializer extends JsonDeserializer<List<String>> { | ||
|
||
@Override | ||
public List<String> deserialize(JsonParser p, DeserializationContext context) throws IOException, IronocJsonException { | ||
JsonNode node = p.getCodec().readTree(p); | ||
List<String> ingredients = new ArrayList<>(); | ||
|
||
if (node.isArray()) { | ||
for (JsonNode element : node) { | ||
ingredients.add(element.asText()); | ||
} | ||
} else { | ||
throw new IronocJsonException("Unexpected exception occurred deserializing ingredients"); | ||
} | ||
return ingredients; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/net/ironoc/portfolio/exception/IronocJsonException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.ironoc.portfolio.exception; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
|
||
public class IronocJsonException extends JsonProcessingException { | ||
|
||
public IronocJsonException(String message) { | ||
super(message); | ||
} | ||
|
||
public IronocJsonException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters