*/
public JSONObject ensureFirstChild(JSONObject metaElem, boolean acceptsNoChild, String parentWidgetId) throws CruxGeneratorException
{
if (!acceptsNoChild && !metaElem.has("_children"))
{
throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
}
JSONArray children = metaElem.optJSONArray("_children");
if (acceptsNoChild && children == null)
{
return null;
}
if (!acceptsNoChild && (children == null || children.length() == 0))
{
throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on view ["+getView().getId()+"], must contain at least one child.");
}
JSONObject firstChild = children.optJSONObject(0);
if (!acceptsNoChild && firstChild == null)
{
throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
}
return firstChild;
}