Skip to content

Commit 526208a

Browse files
committed
Add JsonNull check for habitats in PokemonSpecies
1 parent a75d54c commit 526208a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/eu/iamgio/pokedex/pokemon/PokemonSpecies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public static PokemonSpecies fromPokemonName(String pokemonName) throws PokedexE
189189
pokedexNumbers,
190190
Generation.fromJson(json),
191191
evolvesFromSpecies.isJsonNull() ? null : new NamedResource(evolvesFromSpecies.getAsJsonObject()).getName(),
192-
PokemonHabitat.valueOf(new NamedResource(json.get("habitat")).toEnumName()),
192+
json.get("habitat").isJsonNull() ? null : PokemonHabitat.valueOf(new NamedResource(json.get("habitat")).toEnumName()),
193193
NamedResource.getNames(json.getAsJsonArray("egg_groups"))
194194
.stream()
195195
.map(StringUtil::toEnumName)

0 commit comments

Comments
 (0)