From ff7bbd1653479139bbca09ceb5d80718be027a33 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 26 Dec 2021 07:25:33 +0100 Subject: [PATCH] Introduce open closeable method --- org.argeo.api/src/org/argeo/api/gcr/Content.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 b032aa7b8..b2fc3c906 100644 --- a/org.argeo.api/src/org/argeo/api/gcr/Content.java +++ b/org.argeo.api/src/org/argeo/api/gcr/Content.java @@ -11,15 +11,19 @@ public interface Content extends Iterable, Map { // Iterable keys(); - A get(String key, Class clss); + A get(String key, Class clss) throws IllegalArgumentException; // 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()); } /* -- 2.30.2