{"id":1927,"date":"2025-11-24T10:00:09","date_gmt":"2025-11-24T15:00:09","guid":{"rendered":"http:\/\/www.mymiller.name\/wordpress\/?p=1927"},"modified":"2025-11-24T10:00:09","modified_gmt":"2025-11-24T15:00:09","slug":"reflection-made-easy","status":"publish","type":"post","link":"https:\/\/www.mymiller.name\/wordpress\/java_extra\/reflection-made-easy\/","title":{"rendered":"Reflection made Easy!"},"content":{"rendered":"\n<p>I have not done any work prior to using reflection in my Java projects. &nbsp;A project I was working on I needed to be able to access the Getter\/Setter of an object. &nbsp;I honestly never dreamed it was this easy. &nbsp;Four simple methods that make it extremely easy to access the fields of any class. &nbsp;Now you do have to know the name of the field you wish to set, but there are so many ways to code and plan for this to make it easy.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package name.mymiller.extensions.lang.reflect;\n\nimport java.beans.IntrospectionException;\nimport java.beans.PropertyDescriptor;\nimport java.lang.reflect.InvocationTargetException;\n\n\/**\n * Collection of Utility functions around Reflection to assist with creating, setting\n * and getting values on an object.\n *\n * @author jmiller\n *\/\npublic class ReflectionUtil {\n    \/**\n     * Instantiate a class via it's name. Must have a default constructor otherwise it will fail.\n     *\n     * @param className Full package name plus Class Name for the Class to instantiate.\n     * @return Object of the type Class\n     * @throws InstantiationException Failed to instantiate the class, most often the class is missing\n     *                                the default constructor.\n     * @throws IllegalAccessException Lack the security access to instantiate that class.\n     * @throws ClassNotFoundException Class not found.\n     *\/\n    static public Object instantiateClass(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {\n        return Class.forName(className).getDeclaredConstructor().newInstance();\n    }\n\n    \/**\n     * Set the value on a field of a class.  The field must have an mutator.\n     *\n     * @param object    Object containing the field to set.\n     * @param fieldName String containing the name of the field to set.\n     * @param value     Value to set the field to.\n     * @throws IntrospectionException    Unable to identify the proper method.\n     * @throws IllegalAccessException    Lack the security access to set the field.\n     * @throws IllegalArgumentException  Unable to find the field indicated.\n     * @throws InvocationTargetException Object passed in the invocation is not of the right type.\n     *\/\n    static public void setField(Object object, String fieldName, Object value) throws IntrospectionException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\n        ReflectionUtil.getPropertyDescriptor(object, fieldName).getWriteMethod().invoke(object, value);\n    }\n\n    \/**\n     * Get the value on a field of a class.  The field must have an accessor.\n     *\n     * @param object    Object containing the field to set.\n     * @param fieldName String containing the name of the field to set.\n     * @throws IntrospectionException    Unable to identify the proper method.\n     * @throws IllegalAccessException    Lack the security access to set the field.\n     * @throws IllegalArgumentException  Unable to find the field indicated.\n     * @throws InvocationTargetException Object passed in the invocation is not of the right type.\n     *\/\n    static public Object getField(Object object, String fieldName) throws IntrospectionException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {\n        return ReflectionUtil.getPropertyDescriptor(object, fieldName).getReadMethod().invoke(object);\n    }\n\n    \/**\n     * Get the value on a field of a class.  The field must have an accessor.\n     *\n     * @param object    Object containing the field to set.\n     * @param fieldName String containing the name of the field to set.\n     * @throws IntrospectionException Unable to identify the proper method.\n     *\/\n    static private PropertyDescriptor getPropertyDescriptor(Object object, String fieldName) throws IntrospectionException {\n        return new PropertyDescriptor(fieldName, object.getClass());\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>Simple inline methods for all of it. I have had a number of instances I could have done things much simpler than I had in the past. &nbsp;Unfortunately, I never took the time to really look at reflection. Yes shame on me. &nbsp;However, I won&#8217;t make that mistake anymore. &nbsp;I hope you find this useful.<\/p>\n\n\n\n<p>bob<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have not done any work prior to using reflection in my Java projects. &nbsp;A project I was working on I needed to be able to access the Getter\/Setter of an object. &nbsp;I honestly never dreamed it was this easy. &nbsp;Four simple methods that make it extremely easy to access the fields of any class. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[457],"tags":[69],"series":[],"class_list":["post-1927","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java_extra","tag-java-2"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2016\/09\/monkey-3512996_640.jpg?fit=640%2C426&ssl=1","jetpack-related-posts":[{"id":3786,"url":"https:\/\/www.mymiller.name\/wordpress\/spring_ai\/integrating-easy-rules-with-a-spring-boot-microservice\/","url_meta":{"origin":1927,"position":0},"title":"Integrating Easy Rules with a Spring Boot Microservice","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"This post will walk you through integrating the lightweight and straightforward Easy Rules engine with your Spring Boot microservice. We'll cover the necessary dependencies, basic setup, and an example service to demonstrate its usage. 1. Project Setup and Dependencies Start by creating a Spring Boot project. Next, add the following\u2026","rel":"","context":"In &quot;Spring AI&quot;","block_context":{"text":"Spring AI","link":"https:\/\/www.mymiller.name\/wordpress\/category\/spring_ai\/"},"img":{"alt_text":"","src":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/office-4249395_1280-jpg.avif","width":350,"height":200,"srcset":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/office-4249395_1280-jpg.avif 1x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/office-4249395_1280-jpg.avif 1.5x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/office-4249395_1280-jpg.avif 2x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/office-4249395_1280-jpg.avif 3x"},"classes":[]},{"id":3380,"url":"https:\/\/www.mymiller.name\/wordpress\/java\/synchronous-to-asynchronous\/","url_meta":{"origin":1927,"position":1},"title":"Synchronous to Asynchronous","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"Converting a synchronous method to an asynchronous one in Java involves modifying the code to allow other tasks to execute while it is waiting for input\/output operations to complete. Here's an example of how to convert a synchronous method to an asynchronous one in Java: Let's say we have a\u2026","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2023\/06\/multitasking-ga6749a2b2_640.jpg?fit=640%2C394&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2023\/06\/multitasking-ga6749a2b2_640.jpg?fit=640%2C394&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2023\/06\/multitasking-ga6749a2b2_640.jpg?fit=640%2C394&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3795,"url":"https:\/\/www.mymiller.name\/wordpress\/spring_ai\/evrete-a-modern-java-rule-engine\/","url_meta":{"origin":1927,"position":2},"title":"EVRete: A Modern Java Rule Engine","author":"Jeffery Miller","date":"November 24, 2025","format":false,"excerpt":"EVRete is a high-performance, lightweight, and open-source rule engine designed for Java applications. It offers a flexible and expressive way to implement rule-based logic, making it a compelling alternative to traditional rule engines like Drools. This article delves into EVRete\u2019s features, focusing on its annotation-based approach to rule definition. Why\u2026","rel":"","context":"In &quot;Spring AI&quot;","block_context":{"text":"Spring AI","link":"https:\/\/www.mymiller.name\/wordpress\/category\/spring_ai\/"},"img":{"alt_text":"","src":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/compliance-5899194_1280-jpg.avif","width":350,"height":200,"srcset":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/compliance-5899194_1280-jpg.avif 1x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/compliance-5899194_1280-jpg.avif 1.5x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/compliance-5899194_1280-jpg.avif 2x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/10\/compliance-5899194_1280-jpg.avif 3x"},"classes":[]},{"id":3704,"url":"https:\/\/www.mymiller.name\/wordpress\/spring_databases\/mastering-location-data-with-spring-jpa-a-comprehensive-guide\/","url_meta":{"origin":1927,"position":3},"title":"Mastering Location Data with Spring JPA: A Comprehensive Guide","author":"Jeffery Miller","date":"November 24, 2025","format":false,"excerpt":"In today\u2019s interconnected world, location data plays a pivotal role in numerous applications, from e-commerce and logistics to travel and social networking. Efficiently managing and accessing this wealth of geographical information is crucial for developers. This article delves into the realm of location data management using Spring JPA (Java Persistence\u2026","rel":"","context":"In &quot;Spring Databases&quot;","block_context":{"text":"Spring Databases","link":"https:\/\/www.mymiller.name\/wordpress\/category\/spring_databases\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/international-1751293_1280.png?fit=1186%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/international-1751293_1280.png?fit=1186%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/international-1751293_1280.png?fit=1186%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/international-1751293_1280.png?fit=1186%2C1200&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/international-1751293_1280.png?fit=1186%2C1200&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3680,"url":"https:\/\/www.mymiller.name\/wordpress\/aws\/sending-sms-and-mms-messages-with-aws-sns-and-java-spring-integration\/","url_meta":{"origin":1927,"position":4},"title":"Sending SMS and MMS Messages with AWS SNS and Java (Spring Integration)","author":"Jeffery Miller","date":"September 22, 2025","format":false,"excerpt":"AWS Simple Notification Service (SNS) provides a robust platform for sending notifications across various channels, including SMS and MMS. Let\u2019s explore how to implement this functionality using Java within a Spring framework. Prerequisites AWS Account: An active AWS account is necessary. AWS SDK for Java: Make sure you have the\u2026","rel":"","context":"In &quot;AWS&quot;","block_context":{"text":"AWS","link":"https:\/\/www.mymiller.name\/wordpress\/category\/aws\/"},"img":{"alt_text":"","src":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/smartphone-3152679_1280-jpg.avif","width":350,"height":200,"srcset":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/smartphone-3152679_1280-jpg.avif 1x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/smartphone-3152679_1280-jpg.avif 1.5x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/smartphone-3152679_1280-jpg.avif 2x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/09\/smartphone-3152679_1280-jpg.avif 3x"},"classes":[]},{"id":3903,"url":"https:\/\/www.mymiller.name\/wordpress\/docker\/the-s3-local-dev-trick-using-minio-to-simplify-cloud-native-developmen\/","url_meta":{"origin":1927,"position":5},"title":"The S3 Local Dev Trick: Using MinIO to Simplify Cloud-Native Developmen","author":"Jeffery Miller","date":"August 25, 2025","format":false,"excerpt":"As a software architect building cloud-native solutions, you know that working with cloud services like AWS S3 can be a bit tricky in a local development environment. You don't want to constantly connect to a remote bucket, and setting up complex local testing environments can be a pain. But what\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/www.mymiller.name\/wordpress\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/08\/ai-generated-9268117_1280.avif","width":350,"height":200,"srcset":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/08\/ai-generated-9268117_1280.avif 1x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/08\/ai-generated-9268117_1280.avif 1.5x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/08\/ai-generated-9268117_1280.avif 2x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/08\/ai-generated-9268117_1280.avif 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/1927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/comments?post=1927"}],"version-history":[{"count":7,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/1927\/revisions"}],"predecessor-version":[{"id":2911,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/1927\/revisions\/2911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/media\/2343"}],"wp:attachment":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/media?parent=1927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/categories?post=1927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/tags?post=1927"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/series?post=1927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}