LocationDatatype extends SerializingCustomDatatype<Location> { @Override public Location deserialize(String serializedValue) { if (StringUtils.isEmpty(serializedValue)) { return null; } return Context.getLocationService().getLocation(Integer.valueOf(serializedValue)); }  @Override Location deserialize(String serializedValue); @Override String serialize(Location typedValue);  }
@Test public void deserialize() { Assert.assertThat(datatype.deserialize(null), is(nullValue())); Assert.assertThat(datatype.deserialize(""), is(nullValue())); Assert.assertThat(datatype.deserialize("2"), is(Context.getLocationService().getLocation(2))); }