@Override public void bind(PropertyTree propertyTree, Object object, ReadContext context) throws Exception { for (PropertyTree child : propertyTree.getChildren()) { NodeId nodeId = child.getNodeId(); if (nodeId.isKey() && !constructor.hasParameter(nodeId.getKey())) { AccessibleProperty property = properties.get(nodeId.getKey()); if (property != null && property.isWritable()) { Object value = context.getObject(child); property.set(object, value); } } } }
@Override public Object instantiate(PropertyTree propertyTree, Object valueObject, ReadContext context) throws Exception { Object[] params = constructor.newParametersArray(); int i=0; for (String param : constructor.getParameters()) { PropertyTree child = propertyTree.get(NodeId.property(param)); Object value = child != null ? context.getObject(child) : null; params[i++] = value; } if (constructor.hasParameters()) { // Ensure that constructor parameters are bound context.bindAll(); } Object object = constructor.newInstance(params); if (identifier != null && !constructor.hasParameter(identifier.name) && identifier.property.isWritable()) { PropertyTree child = propertyTree.get(NodeId.property(identifier.name)); if (child != null) { Object value = context.getObject(child); if (value != null) { identifier.property.set(object, value); } } } return object; }