]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.api.acr/src/org/argeo/api/acr/Content.java
Add cr:path name
[lgpl/argeo-commons.git] / org.argeo.api.acr / src / org / argeo / api / acr / Content.java
index df5c149e6fc1fc696187d197766ad5f9cf0c2c52..f7600f540e63ea3b20311c94f2824cd2c7703151 100644 (file)
@@ -89,12 +89,29 @@ public interface Content extends Iterable<Content>, Map<QName, Object> {
        /*
         * CONTENT OPERATIONS
         */
+       /** Adds a new empty {@link Content} to this {@link Content}. */
        Content add(QName name, QName... classes);
 
+       /**
+        * Adds a new {@link Content} to this {@link Content}, setting the provided
+        * attributes. The provided attributes can be used as hints by the
+        * implementation. In particular, setting {@link DName#getcontenttype} will
+        * imply that this content has a file semantic.
+        */
+       default Content add(QName name, Map<QName, Object> attrs, QName... classes) {
+               Content child = add(name, classes);
+               putAll(attrs);
+               return child;
+       }
+
        default Content add(String name, QName... classes) {
                return add(unqualified(name), classes);
        }
 
+       default Content add(String name, Map<QName, Object> attrs, QName... classes) {
+               return add(unqualified(name), attrs, classes);
+       }
+
        void remove();
 
        /*
@@ -227,6 +244,10 @@ public interface Content extends Iterable<Content>, Map<QName, Object> {
                return Optional.of(res.get(0));
        }
 
+       default Content soleOrAddChild(QName name, QName... classes) {
+               return soleChild(name).orElseGet(() -> this.add(name, classes));
+       }
+
        default Content child(QName name) {
                return soleChild(name).orElseThrow();
        }