use of com.serotonin.json.spi.ObjectFactory in project ma-core-public by infiniteautomation.
the class PopulateTest method main.
public static void main(String[] args) throws Exception {
context = new JsonContext();
context.addFactory(new ObjectFactory() {
@Override
public Object create(JsonValue jsonValue) throws JsonException {
if (jsonValue.toJsonObject().containsKey("sub1Value"))
return new Subclass1();
if (jsonValue.toJsonObject().containsKey("sub2Value"))
return new Subclass2();
throw new JsonException("Unknown BaseClass: " + jsonValue);
}
}, BaseClass.class);
test1();
test2();
}
Aggregations