/** * When a new Dom object is created, ensures that all @NotNull annotated * elements have a value. * */ public void addDefaultChildren() { List<Dom.Child> children = new ArrayList<Dom.Child>(); ensureConstraints(children); if (!children.isEmpty()) { setChildren(children); } }
/** * Copy constructor, used to get a deep copy of the passed instance * @param source the instance to copy */ public Dom(Dom source, Dom parent) { this(source.getHabitat(), source.document, parent, source.model); List<Child> newChildren = new ArrayList<Child>(); for (Child child : source.children) { newChildren.add(child.deepCopy(this)); } setChildren(newChildren); attributes.putAll(source.attributes); }
/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(getHabitat(), null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
dom.setChildren(children);
/** * When a new Dom object is created, ensures that all @NotNull annotated * elements have a value. * */ public void addDefaultChildren() { List<Dom.Child> children = new ArrayList<Dom.Child>(); ensureConstraints(children); if (!children.isEmpty()) { setChildren(children); } }
/** * When a new Dom object is created, ensures that all @NotNull annotated * elements have a value. * */ public void addDefaultChildren() { List<Dom.Child> children = new ArrayList<Dom.Child>(); ensureConstraints(children); if (!children.isEmpty()) { setChildren(children); } }
/** * When a new Dom object is created, ensures that all @NotNull annotated * elements have a value. * */ public void addDefaultChildren() { List<Dom.Child> children = new ArrayList<Dom.Child>(); ensureConstraints(children); if (!children.isEmpty()) { setChildren(children); } }
/** * When a new Dom object is created, ensures that all @NotNull annotated * elements have a value. * */ public void addDefaultChildren() { List<Dom.Child> children = new ArrayList<Dom.Child>(); ensureConstraints(children); if (!children.isEmpty()) { setChildren(children); } }
/** * Copy constructor, used to get a deep copy of the passed instance * @param source the instance to copy */ public Dom(Dom source, Dom parent) { this(source.habitat, source.document, parent, source.model); List<Child> newChildren = new ArrayList<Child>(); for (Child child : source.children) { newChildren.add(child.deepCopy(this)); } setChildren(newChildren); attributes.putAll(source.attributes); }
/** * Copy constructor, used to get a deep copy of the passed instance * @param source the instance to copy */ public Dom(Dom source, Dom parent) { this(source.habitat, source.document, parent, source.model); List<Child> newChildren = new ArrayList<Child>(); for (Child child : source.children) { newChildren.add(child.deepCopy(this)); } setChildren(newChildren); attributes.putAll(source.attributes); }
/** * Copy constructor, used to get a deep copy of the passed instance * @param source the instance to copy */ public Dom(Dom source, Dom parent) { this(source.getHabitat(), source.document, parent, source.model); List<Child> newChildren = new ArrayList<Child>(); for (Child child : source.children) { newChildren.add(child.deepCopy(this)); } setChildren(newChildren); attributes.putAll(source.attributes); }
/** * Copy constructor, used to get a deep copy of the passed instance * @param source the instance to copy */ public Dom(Dom source, Dom parent) { this(source.getHabitat(), source.document, parent, source.model); List<Child> newChildren = new ArrayList<Child>(); for (Child child : source.children) { newChildren.add(child.deepCopy(this)); } setChildren(newChildren); attributes.putAll(source.attributes); }
/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(habitat, null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(habitat, null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(getHabitat(), null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
/* package */ void ensureConstraints(List<Child> children) { Set<String> nullElements = new HashSet<String>(model.getElementNames()); for (Child child : children) { nullElements.remove(child.name); } for (String s : nullElements) { ConfigModel.Property p = model.getElement(s); for (String annotation : p.getAnnotations()) { if (annotation.equals(NotNull.class.getName())) { if (p instanceof ConfigModel.Node) { ConfigModel childModel = ((ConfigModel.Node) p).model; Dom child = document.make(getHabitat(), null, this, childModel); child.register(); children.add(new Dom.NodeChild(s, child)); // recursive call to ensure the children constraints are also respected List<Child> grandChildren = new ArrayList<Child>(); child.ensureConstraints(grandChildren); if (!grandChildren.isEmpty()) { child.setChildren(grandChildren); } child.initializationCompleted(); } } } } }
dom.setChildren(children);
dom.setChildren(children);
dom.setChildren(children);
dom.setChildren(children);