#11 Very basic implementation with dummy data
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package ch.zhaw.gartenverwaltung.json;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GrowthPhaseTypeDeserializer extends StdDeserializer<GrowthPhaseType> {
|
||||
public GrowthPhaseTypeDeserializer(Class<?> vc) {
|
||||
super(vc);
|
||||
}
|
||||
|
||||
public GrowthPhaseTypeDeserializer() { this(null); }
|
||||
|
||||
@Override
|
||||
public GrowthPhaseType deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||
GrowthPhaseType result = null;
|
||||
try {
|
||||
result = GrowthPhaseType.valueOf(parser.getText().toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO: Log
|
||||
System.err.println("bad growth phase type");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package ch.zhaw.gartenverwaltung.json;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HardinessZoneDeserializer extends StdDeserializer<HardinessZone> {
|
||||
public HardinessZoneDeserializer(Class<?> vc) {
|
||||
super(vc);
|
||||
}
|
||||
public HardinessZoneDeserializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HardinessZone deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||
HardinessZone result = null;
|
||||
try {
|
||||
result = HardinessZone.valueOf(parser.getText().toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO: Log
|
||||
System.err.println("bad growth phase type");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user