Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:11:02+00:00 2026-06-15T22:11:02+00:00

How do I get all the fields and properties of an object (not class)

  • 0

How do I get all the fields and properties of an object (not class) that are annotated with specific annotation without iterating through all its fields or property descriptors?

My objective is to avoid unnecessary iteration through each and every field or property that is obviously not even annotated such as getClass() or any field of the class that is not a field or member variable of an instance.

Or is iteration the only way to go? Is there no other better way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:11:04+00:00Added an answer on June 15, 2026 at 10:11 pm

    You could use the reflections package that does all the work for you. The description of the project:

    Reflections scans your classpath, indexes the metadata, allows you to query it on runtime and may save and collect that information for many modules within your project.

    Using Reflections you can query your metadata such as:

    • get all subtypes of some type
    • get all types/methods/fields annotated with some annotation, w/o annotation parameters matching
    • get all resources matching matching a regular expression

    Example:

     Reflections reflections = new Reflections("my.project.prefix");
    
     Set<Class<? extends SomeType>> subTypes = 
               reflections.getSubTypesOf(SomeType.class);
    
     Set<Class<?>> annotated = 
               reflections.getTypesAnnotatedWith(SomeAnnotation.class);
    
     Set<Class<?>> annotated1 =
               reflections.getTypesAnnotatedWith(new SomeAnnotation() {
                    public String value() { return "1"; }
                    public Class<? extends Annotation> annotationType() { 
                        return SomeAnnotation.class; 
                    }
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get what all fields(input,select) are changed during keyup and change
Can get all triples with value null in specific field? All people with date_of_birth
I am trying to get all Books from the server (local PHP script), that
I am using the Reflection classes in order to get all the fields inside
I've created an inherited field type annotation that is placed on private properties in
I have a simple class that includes 2 properties, one String and one a
I have a complex object hierarchy that I've been wrestling with to get passed
I`m trying to display classes that have properties of type some custom class inside
I have an Address object that has properties AddressLine1, AddressLine2, Suburb, State, ZipCode. (there
How can I get a list of all the selected values ​​for a field?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.