- Preconditions.checkArgument(parent instanceof SimpleNodeDataWithSchema, "Node %s is not a simple type", parent.getSchema().getQName());
-
- final Object translatedValue = translateValueByType(value, parent.getSchema());
- ((SimpleNodeDataWithSchema) parent).setValue(translatedValue);
+ Preconditions.checkArgument(parent instanceof SimpleNodeDataWithSchema, "Node %s is not a simple type",
+ parent.getSchema().getQName());
+ final SimpleNodeDataWithSchema parentSimpleNode = (SimpleNodeDataWithSchema) parent;
+ Preconditions.checkArgument(parentSimpleNode.getValue() == null, "Node '%s' has already set its value to '%s'",
+ parentSimpleNode.getSchema().getQName(), parentSimpleNode.getValue());
+
+ final Object translatedValue = translateValueByType(value, parentSimpleNode.getSchema());
+ parentSimpleNode.setValue(translatedValue);