This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git
commit 21fb8dfc510ad250bbdeee1212c0f36668243a4c Author: Gary D. Gregory <[email protected]> AuthorDate: Sun Mar 16 13:29:30 2025 -0400 No need to nest else --- .../ri/model/beans/PropertyOwnerPointer.java | 32 +++++++++------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java b/src/main/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java index 860ea50..dfd464a 100644 --- a/src/main/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java +++ b/src/main/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java @@ -144,14 +144,12 @@ public abstract class PropertyOwnerPointer extends NodePointer { @Override public void remove() { this.value = null; - if (parent != null) { - parent.remove(); - } - else { + if (parent == null) { throw new UnsupportedOperationException( "Cannot remove an object that is not " + "some other object's property or a collection element"); } + parent.remove(); } @Override @@ -170,23 +168,19 @@ public abstract class PropertyOwnerPointer extends NodePointer { @Override public void setValue(final Object value) { this.value = value; - if (parent != null) { - if (parent.isContainer()) { - parent.setValue(value); - } - else { - if (index == WHOLE_COLLECTION) { - throw new UnsupportedOperationException( - "Cannot setValue of an object that is not " - + "some other object's property"); - } - throw new JXPathInvalidAccessException( - "The specified collection element does not exist: " + this); - } - } - else { + if (parent == null) { throw new UnsupportedOperationException( "Cannot replace the root object"); } + if (!parent.isContainer()) { + if (index == WHOLE_COLLECTION) { + throw new UnsupportedOperationException( + "Cannot setValue of an object that is not " + + "some other object's property"); + } + throw new JXPathInvalidAccessException( + "The specified collection element does not exist: " + this); + } + parent.setValue(value); } }
