From c1b4da761724e41dbc0d1a6ba2b943ba437f696b Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 25 Jun 2023 07:43:28 +0200 Subject: [PATCH] Add hasProperty --- org.argeo.cms.jcr/src/org/argeo/jcr/Jcr.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); -- 2.30.2