@Test(expected = JsonParseException.class) public void testEvseIdAsUnparsableString() { JsonPrimitive jsonPrimitive = new JsonPrimitive("1x"); adapter.deserialize(jsonPrimitive, EvseId.class, null); }
@Override public EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { if (!json.isJsonPrimitive()) { throw new JsonParseException("EvseId must be a JSON primitive"); } int evseId; try { evseId = json.getAsInt(); } catch (ClassCastException | IllegalStateException | NumberFormatException e) { throw new JsonParseException("EvseId must be a JSON integer", e); } return new EvseId(evseId); }
EvseIdTypeAdapterDeserializer implements TypeAdapterDeserializer<EvseId> { @Override public EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { if (!json.isJsonPrimitive()) { throw new JsonParseException("EvseId must be a JSON primitive"); } int evseId; try { evseId = json.getAsInt(); } catch (ClassCastException | IllegalStateException | NumberFormatException e) { throw new JsonParseException("EvseId must be a JSON integer", e); } return new EvseId(evseId); } }
EvseIdTypeAdapterDeserializer implements TypeAdapterDeserializer<EvseId> { @Override public EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { if (!json.isJsonPrimitive()) { throw new JsonParseException("EvseId must be a JSON primitive"); } int evseId; try { evseId = json.getAsInt(); } catch (ClassCastException | IllegalStateException | NumberFormatException e) { throw new JsonParseException("EvseId must be a JSON integer", e); } return new EvseId(evseId); }  }
EvseIdTypeAdapterDeserializer implements TypeAdapterDeserializer<EvseId> { @Override public EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { if (!json.isJsonPrimitive()) { throw new JsonParseException("EvseId must be a JSON primitive"); } int evseId; try { evseId = json.getAsInt(); } catch (ClassCastException | IllegalStateException | NumberFormatException e) { throw new JsonParseException("EvseId must be a JSON integer", e); } return new EvseId(evseId); }  @Override EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context); @Override Class<?> getAdaptedType(); }
EvseIdTypeAdapterDeserializer implements TypeAdapterDeserializer<EvseId> { @Override public EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { if (!json.isJsonPrimitive()) { throw new JsonParseException("EvseId must be a JSON primitive"); } int evseId; try { evseId = json.getAsInt(); } catch (ClassCastException | IllegalStateException | NumberFormatException e) { throw new JsonParseException("EvseId must be a JSON integer", e); } return new EvseId(evseId); }  @Override EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context); @Override Class<?> getAdaptedType();  }