X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.api%2Fsrc%2Forg%2Fargeo%2Fapi%2Fgcr%2FContent.java;h=b2fc3c9063a37f156135f5efb078e7a7eb18a850;hb=098eeffb896a24b56371b5173d4104071685f50e;hp=c5cee9f0e6676495acd7f791a98204bec9f6c8d8;hpb=06af25d84c049b149ee9db2235faeff3170b4f7e;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.api/src/org/argeo/api/gcr/Content.java b/org.argeo.api/src/org/argeo/api/gcr/Content.java index c5cee9f0e..b2fc3c906 100644 --- a/org.argeo.api/src/org/argeo/api/gcr/Content.java +++ b/org.argeo.api/src/org/argeo/api/gcr/Content.java @@ -2,21 +2,28 @@ package org.argeo.api.gcr; import java.util.Map; +/** + * A semi-structured content, with attributes, within a hierarchical structure. + */ public interface Content extends Iterable, Map { String getName(); // Iterable keys(); - A get(String key, Class clss); + A get(String key, Class clss) throws IllegalArgumentException; - ContentSession getSession(); +// ContentSession getSession(); /* * DEFAULT METHODS */ - default A adapt(Class clss) { - return null; + default A adapt(Class clss) throws IllegalArgumentException { + throw new IllegalArgumentException("Cannot adapt content " + this + " to " + clss.getName()); + } + + default C open(Class clss) throws Exception, IllegalArgumentException { + throw new IllegalArgumentException("Cannot open content " + this + " as " + clss.getName()); } /* @@ -26,12 +33,12 @@ public interface Content extends Iterable, Map { return get(key, String.class); } - default String attr(Enum key) { - return attr(key.name()); + default String attr(Object key) { + return key != null ? attr(key.toString()) : attr(null); } - default A get(Enum key, Class clss) { - return get(key.name(), clss); + default A get(Object key, Class clss) { + return key != null ? get(key.toString(), clss) : get(null, clss); } /*