protected void setValueComplex(T state, Field field, String xpath, Object value) throws PropertyException {
ComplexType complexType = (ComplexType) field.getType();
if (TypeConstants.isContentType(complexType)) {
if (value != null && !(value instanceof Blob)) {
throw new PropertyException(
"Expected Blob value for: " + xpath + ", got " + value.getClass().getName() + " instead");
}
setValueBlob(state, (Blob) value, xpath);
return;
}
if (value != null && !(value instanceof Map)) {
throw new PropertyException(
"Expected Map value for: " + xpath + ", got " + value.getClass().getName() + " instead");
}
@SuppressWarnings("unchecked")
Map<String, Object> map = value == null ? Collections.emptyMap() : (Map<String, Object>) value;
Set<String> keys = new HashSet<>(map.keySet());
for (Field f : complexType.getFields()) {
String name = f.getName().getPrefixedName();
keys.remove(name);
value = map.get(name);
setValueField(state, f, xpath + '/' + name, value);
}
if (!keys.isEmpty()) {
throw new PropertyException("Unknown key: " + keys.iterator().next() + " for " + xpath);
}
}