}
}
// Deserialize contents and layout hints
if (UILayout.class.isAssignableFrom(elementMetadata.getType())) {
UILayout layout = (UILayout) element;
Class<? extends LayoutHint> layoutHintType = (Class<? extends LayoutHint>)
ReflectionUtil.getTypeParameter(elementMetadata.getType().getGenericSuperclass(), 0);
if (jsonObject.has(CONTENTS_FIELD)) {
for (JsonElement child : jsonObject.getAsJsonArray(CONTENTS_FIELD)) {
UIWidget childElement = context.deserialize(child, UIWidget.class);
if (childElement != null) {
LayoutHint hint = null;
if (child.isJsonObject()) {
JsonObject childObject = child.getAsJsonObject();
if (layoutHintType != null && !layoutHintType.isInterface() && !Modifier.isAbstract(layoutHintType.getModifiers())
&& childObject.has(LAYOUT_INFO_FIELD)) {
hint = context.deserialize(childObject.get(LAYOUT_INFO_FIELD), layoutHintType);
}
}
layout.addWidget(childElement, hint);
}
}
}
}
return element;