This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 04e58ab0d7 Marshall module improvements
04e58ab0d7 is described below

commit 04e58ab0d7bca8ad6857ba308e7e03aefc4ad441
Author: James Bognar <[email protected]>
AuthorDate: Sat Dec 6 10:42:25 2025 -0500

    Marshall module improvements
---
 .../apache/juneau/commons/reflect/Property.java    |   4 +-
 .../org/apache/juneau/commons/reflect/Setter.java  | 142 -------------------
 .../main/java/org/apache/juneau/config/Config.java |   1 -
 .../src/main/java/org/apache/juneau/ClassMeta.java |  12 +-
 .../org/apache/juneau/parser/ParserSession.java    |   2 +-
 .../apache/juneau/commons/reflect/Setter_Test.java | 154 ---------------------
 .../juneau/commons/time/TimeProvider_Test.java     |   5 -
 7 files changed, 8 insertions(+), 312 deletions(-)

diff --git 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Property.java
 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Property.java
index fc8785327c..a91dadc474 100644
--- 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Property.java
+++ 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Property.java
@@ -28,8 +28,7 @@ import org.apache.juneau.commons.function.*;
  *
  * <p>
  * This class provides a flexible, builder-based approach to defining 
properties on objects,
- * supporting both method-based and field-based access patterns. It's an 
improvement over
- * {@link Setter} by providing bidirectional access (getters and setters) and 
type safety.
+ * supporting both method-based and field-based access patterns.
  *
  * <h5 class='section'>Features:</h5>
  * <ul class='spaced-list'>
@@ -72,7 +71,6 @@ import org.apache.juneau.commons.function.*;
  * </p>
  *
  * <h5 class='section'>See Also:</h5><ul>
- *     <li class='jc'>{@link Setter} - Legacy setter interface
  *     <li class='jc'>{@link FieldInfo} - Field introspection
  *     <li class='jc'>{@link MethodInfo} - Method introspection
  *     <li class='link'><a class="doclink" 
href="https://juneau.apache.org/docs/topics/JuneauCommonsReflect";>juneau-commons-reflect</a>
diff --git 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Setter.java
 
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Setter.java
deleted file mode 100644
index abf30f2b42..0000000000
--- 
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/Setter.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.commons.reflect;
-
-import static org.apache.juneau.commons.reflect.ReflectionUtils.*;
-
-import java.lang.reflect.*;
-
-/**
- * Interface for setting values on bean objects, supporting both method 
setters and direct field access.
- *
- * <p>
- * This interface provides a unified abstraction for setting values on 
objects, whether through
- * setter methods or direct field access. It's used by frameworks that need to 
set bean properties
- * without knowing whether the property uses a setter method or a public field.
- *
- * <h5 class='section'>Features:</h5>
- * <ul class='spaced-list'>
- *     <li>Unified interface - works with both setter methods and fields
- *     <li>Exception handling - wraps reflection exceptions in {@link 
ExecutableException}
- *     <li>Type-agnostic - works with any object and value type
- * </ul>
- *
- * <h5 class='section'>Use Cases:</h5>
- * <ul class='spaced-list'>
- *     <li>Bean property setting in frameworks
- *     <li>Data binding and mapping operations
- *     <li>Dependency injection frameworks
- *     <li>Object construction and initialization
- * </ul>
- *
- * <h5 class='section'>Usage:</h5>
- * <p class='bjava'>
- *     <jc>// Create setter from method</jc>
- *     Method <jv>setterMethod</jv> = 
MyClass.<jk>class</jk>.getMethod(<js>"setName"</js>, String.<jk>class</jk>);
- *     Setter <jv>setter</jv> = <jk>new</jk> 
Setter.MethodSetter(<jv>setterMethod</jv>);
- *
- *     <jc>// Create setter from field</jc>
- *     Field <jv>field</jv> = MyClass.<jk>class</jk>.getField(<js>"name"</js>);
- *     Setter <jv>fieldSetter</jv> = <jk>new</jk> 
Setter.FieldSetter(<jv>field</jv>);
- *
- *     <jc>// Use setter</jc>
- *     MyClass <jv>obj</jv> = <jk>new</jk> MyClass();
- *     <jv>setter</jv>.set(<jv>obj</jv>, <js>"John"</js>);
- * </p>
- *
- * <h5 class='section'>See Also:</h5><ul>
- *     <li class='jc'>{@link ExecutableException} - Exception thrown by setters
- *     <li class='link'><a class="doclink" 
href="https://juneau.apache.org/docs/topics/JuneauCommonsReflect";>juneau-commons-reflect</a>
- * </ul>
- */
-public interface Setter {
-
-       /**
-        * Implementation of Setter that sets values directly on a field.
-        *
-        * <p>
-        * This implementation uses {@link Field#set(Object, Object)} to set 
field values directly,
-        * bypassing any setter methods. The field must be accessible (public 
or made accessible via
-        * {@link Field#setAccessible(boolean)}).
-        */
-       static class FieldSetter implements Setter {
-
-               private final FieldInfo f;
-
-               @Deprecated
-               public FieldSetter(Field f) {
-                       this.f = info(f);
-               }
-
-               public FieldSetter(FieldInfo f) {
-                       this.f = f;
-               }
-
-               @Override /* Overridden from Setter */
-               public void set(Object object, Object value) throws 
ExecutableException {
-                       f.set(object, value);
-               }
-       }
-
-       /**
-        * Implementation of Setter that sets values by invoking a setter 
method.
-        *
-        * <p>
-        * This implementation uses {@link Method#invoke(Object, Object...)} to 
call a setter method
-        * on the target object. The method must be accessible (public or made 
accessible via
-        * {@link Method#setAccessible(boolean)}).
-        */
-       static class MethodSetter implements Setter {
-
-               private final MethodInfo m;
-
-               @Deprecated
-               public MethodSetter(Method m) {
-                       this.m = info(m);
-               }
-
-               public MethodSetter(MethodInfo m) {
-                       this.m = m;
-               }
-
-               @Override /* Overridden from Setter */
-               public void set(Object object, Object value) throws 
ExecutableException {
-                       m.invoke(object, value);
-               }
-       }
-
-       /**
-        * Sets the value on the specified object using this setter.
-        *
-        * <p>
-        * For method setters, this invokes the setter method with the 
specified value.
-        * For field setters, this sets the field value directly.
-        *
-        * <h5 class='section'>Example:</h5>
-        * <p class='bjava'>
-        *      Setter <jv>setter</jv> = ...;
-        *      MyClass <jv>obj</jv> = <jk>new</jk> MyClass();
-        *      <jv>setter</jv>.set(<jv>obj</jv>, <js>"value"</js>);
-        * </p>
-        *
-        * @param object The object on which to set the value. Must not be 
<jk>null</jk>.
-        * @param value The value to set. Can be <jk>null</jk>.
-        * @throws ExecutableException If an error occurs while setting the 
value (e.g., field/method not accessible,
-        *                             type mismatch, or invocation target 
exception).
-        */
-       void set(Object object, Object value) throws ExecutableException;
-}
\ No newline at end of file
diff --git 
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java 
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
index 1a6544eded..33d8550ea9 100644
--- 
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
+++ 
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
@@ -27,7 +27,6 @@ import java.io.*;
 import java.lang.annotation.*;
 import java.lang.reflect.*;
 import java.util.*;
-import java.util.concurrent.atomic.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.collections.*;
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
index d180f07f53..2cd33f0595 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ClassMeta.java
@@ -1590,7 +1590,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                if (setterMethod.isPresent()) {
                        builder.setter(setterMethod.get().accessible());
-                       
+
                        // Try to find a corresponding getter method (even if 
not annotated)
                        // If setter is "setName", look for "getName" or 
"isName"
                        var setterName = setterMethod.get().getSimpleName();
@@ -1601,7 +1601,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                                var getter = getAllMethods()
                                        .stream()
-                                       .filter(x -> !x.isStatic() && 
x.hasNumParameters(0) && 
+                                       .filter(x -> !x.isStatic() && 
x.hasNumParameters(0) &&
                                                (x.hasName(getterName1) || 
x.hasName(getterName2)) &&
                                                
!x.getReturnType().is(Void.TYPE))
                                        .findFirst();
@@ -1618,7 +1618,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                                        if (field.isPresent()) {
                                                var f = 
field.get().accessible();
-                                               builder.getter(obj -> 
(Object)f.get(obj));
+                                               builder.getter(obj -> 
f.get(obj));
                                        }
                                }
                        }
@@ -1682,7 +1682,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                if (setterMethod.isPresent()) {
                        builder.setter(setterMethod.get().accessible());
-                       
+
                        // Try to find a corresponding getter method (even if 
not annotated)
                        // If setter is "setParent", look for "getParent" or 
"isParent"
                        var setterName = setterMethod.get().getSimpleName();
@@ -1693,7 +1693,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                                var getter = getAllMethods()
                                        .stream()
-                                       .filter(x -> !x.isStatic() && 
x.hasNumParameters(0) && 
+                                       .filter(x -> !x.isStatic() && 
x.hasNumParameters(0) &&
                                                (x.hasName(getterName1) || 
x.hasName(getterName2)) &&
                                                
!x.getReturnType().is(Void.TYPE))
                                        .findFirst();
@@ -1710,7 +1710,7 @@ public class ClassMeta<T> extends ClassInfoTyped<T> {
 
                                        if (field.isPresent()) {
                                                var f = 
field.get().accessible();
-                                               builder.getter(obj -> 
(Object)f.get(obj));
+                                               builder.getter(obj -> 
f.get(obj));
                                        }
                                }
                        }
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
index 6b0a828ff8..ac516abb8f 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
@@ -235,7 +235,7 @@ public class ParserSession extends BeanSession {
         * @param parent The parent to set.
         * @throws ExecutableException Exception occurred on invoked 
constructor/method/field.
         */
-       @SuppressWarnings("unchecked")
+       @SuppressWarnings({ "unchecked", "rawtypes" })
        protected static final void setParent(ClassMeta<?> cm, Object o, Object 
parent) throws ExecutableException {
                Property m = cm.getParentProperty();
                if (nn(m) && m.canWrite())
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/commons/reflect/Setter_Test.java 
b/juneau-utest/src/test/java/org/apache/juneau/commons/reflect/Setter_Test.java
deleted file mode 100644
index 6a3bb81823..0000000000
--- 
a/juneau-utest/src/test/java/org/apache/juneau/commons/reflect/Setter_Test.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.commons.reflect;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import java.lang.reflect.*;
-
-import org.apache.juneau.*;
-import org.junit.jupiter.api.*;
-
-class Setter_Test extends TestBase {
-
-       public static class TestClass {
-               public String publicField;
-               private String privateField;
-
-               public void setPublicField(String value) {
-                       this.publicField = value;
-               }
-
-               public void setPrivateField(String value) {
-                       this.privateField = value;
-               }
-
-               public String getPrivateField() {
-                       return privateField;
-               }
-       }
-
-       
//====================================================================================================
-       // Setter.FieldSetter - set(Object, Object)
-       
//====================================================================================================
-       @Test
-       void a001_fieldSetter_set() throws Exception {
-               TestClass obj = new TestClass();
-               Field field = TestClass.class.getField("publicField");
-               Setter setter = new Setter.FieldSetter(field);
-
-               // Set value
-               setter.set(obj, "testValue");
-               assertEquals("testValue", obj.publicField);
-
-               // Set null
-               setter.set(obj, null);
-               assertNull(obj.publicField);
-       }
-
-       
//====================================================================================================
-       // Setter.FieldSetter - set(Object, Object) with private field
-       
//====================================================================================================
-       @Test
-       void a002_fieldSetter_setPrivate() throws Exception {
-               TestClass obj = new TestClass();
-               Field field = TestClass.class.getDeclaredField("privateField");
-               field.setAccessible(true);
-               Setter setter = new Setter.FieldSetter(field);
-
-               // Set value
-               setter.set(obj, "testValue");
-               assertEquals("testValue", obj.getPrivateField());
-       }
-
-       
//====================================================================================================
-       // Setter.FieldSetter - set(Object, Object) with type mismatch
-       
//====================================================================================================
-       @Test
-       void a003_fieldSetter_typeMismatch() throws Exception {
-               TestClass obj = new TestClass();
-               Field field = TestClass.class.getField("publicField");
-               Setter setter = new Setter.FieldSetter(field);
-
-               // Type mismatch should throw ExecutableException
-               assertThrows(IllegalArgumentException.class, () -> 
setter.set(obj, 123));
-       }
-
-       
//====================================================================================================
-       // Setter.MethodSetter - set(Object, Object)
-       
//====================================================================================================
-       @Test
-       void a004_methodSetter_set() throws Exception {
-               TestClass obj = new TestClass();
-               Method method = TestClass.class.getMethod("setPublicField", 
String.class);
-               Setter setter = new Setter.MethodSetter(method);
-
-               // Set value
-               setter.set(obj, "testValue");
-               assertEquals("testValue", obj.publicField);
-
-               // Set null
-               setter.set(obj, null);
-               assertNull(obj.publicField);
-       }
-
-       
//====================================================================================================
-       // Setter.MethodSetter - set(Object, Object) with private method
-       
//====================================================================================================
-       @Test
-       void a005_methodSetter_setPrivate() throws Exception {
-               TestClass obj = new TestClass();
-               Method method = TestClass.class.getMethod("setPrivateField", 
String.class);
-               Setter setter = new Setter.MethodSetter(method);
-
-               // Set value
-               setter.set(obj, "testValue");
-               assertEquals("testValue", obj.getPrivateField());
-       }
-
-       
//====================================================================================================
-       // Setter.MethodSetter - set(Object, Object) with type mismatch
-       
//====================================================================================================
-       @Test
-       void a006_methodSetter_typeMismatch() throws Exception {
-               TestClass obj = new TestClass();
-               Method method = TestClass.class.getMethod("setPublicField", 
String.class);
-               Setter setter = new Setter.MethodSetter(method);
-
-               // Type mismatch should throw ExecutableException
-               assertThrows(IllegalArgumentException.class, () -> 
setter.set(obj, 123));
-       }
-
-       
//====================================================================================================
-       // Setter.MethodSetter - set(Object, Object) with exception in method
-       
//====================================================================================================
-       @Test
-       void a007_methodSetter_invocationTargetException() throws Exception {
-               TestClass obj = new TestClass();
-               Method method = TestClass.class.getMethod("setPublicField", 
String.class);
-               Setter setter = new Setter.MethodSetter(method);
-
-               // Null object - Method.invoke throws NPE directly, which is 
wrapped in ExecutableException
-               // However, the NPE might be thrown before the invoke, so we 
test with a valid object
-               // that causes an InvocationTargetException
-               // Actually, let's test with a method that throws an exception
-               // But since we don't have such a method, let's just verify the 
setter works correctly
-               setter.set(obj, "test");
-               assertEquals("test", obj.publicField);
-       }
-}
-
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/commons/time/TimeProvider_Test.java
 
b/juneau-utest/src/test/java/org/apache/juneau/commons/time/TimeProvider_Test.java
index 1cdfe880f2..e713840b9c 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/commons/time/TimeProvider_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/commons/time/TimeProvider_Test.java
@@ -38,11 +38,6 @@ class TimeProvider_Test extends TestBase {
                assertNotNull(TimeProvider.INSTANCE);
        }
 
-       @Test
-       void a02_instanceIsTimeProvider() {
-               assertTrue(TimeProvider.INSTANCE instanceof TimeProvider);
-       }
-
        
//====================================================================================================
        // getSystemDefaultZoneId() tests
        
//====================================================================================================

Reply via email to