https://github.com/asrieldreemurrgm/java_reflections_and_annotations
Study project focused on runtime reflections and custom annotations, showcasing how attributes can be used to interact with objects dynamically.
https://github.com/asrieldreemurrgm/java_reflections_and_annotations
annotations exceptions java oop reflections spring-tool-suite4
Last synced: about 1 year ago
JSON representation
Study project focused on runtime reflections and custom annotations, showcasing how attributes can be used to interact with objects dynamically.
- Host: GitHub
- URL: https://github.com/asrieldreemurrgm/java_reflections_and_annotations
- Owner: AsrielDreemurrGM
- Created: 2025-06-10T12:54:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-12T22:23:49.000Z (about 1 year ago)
- Last Synced: 2025-06-12T23:32:25.601Z (about 1 year ago)
- Topics: annotations, exceptions, java, oop, reflections, spring-tool-suite4
- Language: Java
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Study_Of_Reflections
About
Study project focused on Java Reflections and Custom Annotations, demonstrating how to interact with objects and metadata dynamically at runtime.
It includes examples involving class analysis, constructor usage, field access, and annotation-based behavior replacement.
📌 Features
- Created and used a custom annotation
KeyTypeto identify entity keys (e.g., CPF or Product Code); - Used reflections to get class names, constructors, and method return types at runtime;
- Dynamic instantiation and data printing using reflection API;
- Handled exceptions when fetching annotation values with detailed Javadocs;
- Project based on and adapted from a Java CRUD example I previously developed.
🗂️ Project Structure
-
br.com.eaugusto.reflection: Contains reflection logic and main applicationAppReflections; -
br.com.eaugusto.model: Holds theProductclass with fields like code, description, and price; -
br.com.eaugusto.annotations: Contains theKeyTypeannotation and related handling logic.
🚀 How to Run
- Clone the repository and open it in your IDE (STS, Eclipse, IntelliJ);
- Run
AppReflections.javato see class and field reflection in action; - Explore
KeyTypeand see how it replaces logic from previous interfaces. - Additionally, run
App.javaand see the CRUD in action.
📅 Commit Highlights
June 11, 2025
- Added exception handling in
getKey()and documented it with Javadoc; - Created and applied
KeyTypeannotation to entities (replacinggetCodeOrCPF()); - Removed unnecessary storage logic to simplify the study focus;
- Copied base CRUD from a previous repository for annotation integration.
June 10, 2025
- Implemented logic to return method names and their types using reflection;
- Suppressed non-critical warnings specific to study context.
June 9, 2025
- Created main class
AppReflectionsusing Java Reflection to get class details, instantiate objects and print data; - Created the
Productclass with fields:code,description, andprice.
📚 Learning Goals
- Understand the use of Java Reflection to inspect and manipulate class structure at runtime;
- Learn how to create and apply custom annotations for metadata-driven logic;
- Replace interface logic with annotations for more flexible code design.