DmrModelReference extends DmrModelObject implements ModelReference { @Override public PathAddress getValue() { if (value.hasDefined("_ref")) { return PathAddress.pathAddress(value.get("_ref").asString()); } else { return null; } } DmrModelReference(ModelNode value); @Override PathAddress getValue(); @Override ModelReference set(PathAddress address);  }
@Test public void test_Init() { assertFalse(modelRef().isDefined()); assertNull(modelRef().getValue()); }
@Test public void testFromJson() throws Exception { String json = "{\"page\" : {\n" + " \"name\" : \"home\",\n" + " \"_ref\" : \"/pages/home\"\n" + "}}"; ModelObject model = DmrModelValue.readFromJsonStream(new ByteArrayInputStream(json.getBytes()), ModelObject.class); ModelReference pageRef = model.get("page", ModelReference.class); assertNotNull(pageRef); assertEquals(pageRef.get("name", ModelString.class).getValue(), "home"); assertEquals(PathAddress.pathAddress("pages", "home"), pageRef.getValue()); }