From: Mathieu Baudier Date: Sun, 25 Jun 2023 05:43:28 +0000 (+0200) Subject: Add hasProperty X-Git-Tag: v2.3.15~4 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=c1b4da761724e41dbc0d1a6ba2b943ba437f696b;p=gpl%2Fargeo-jcr.git Add hasProperty --- diff --git a/org.argeo.cms.jcr/src/org/argeo/jcr/Jcr.java b/org.argeo.cms.jcr/src/org/argeo/jcr/Jcr.java index 88f5345..bdeaac7 100644 --- a/org.argeo.cms.jcr/src/org/argeo/jcr/Jcr.java +++ b/org.argeo.cms.jcr/src/org/argeo/jcr/Jcr.java @@ -431,6 +431,20 @@ public class Jcr { } } + /** + * Whether this node has this property. + * + * @see Node#hasProperty(String) + * @throws JcrException caused by {@link RepositoryException} + */ + public static boolean hasProperty(Node node, String property) { + try { + return node.hasProperty(property); + } catch (RepositoryException e) { + throw new JcrException("Cannot check whether " + node + " has property " + property, e); + } + } + /** * Set a property to the given value, or remove it if the value is * null. @@ -603,6 +617,7 @@ public class Jcr { } } + @SuppressWarnings("unchecked") public static T getAs(Node node, String property, Class clss) { if (String.class.isAssignableFrom(clss)) { return (T) get(node, property);