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

  • SEARCH
  • Home
  • 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 8473879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:28:30+00:00 2026-06-10T17:28:30+00:00

What should be a best way to create key/value pairs for all the string

  • 0

What should be a best way to create key/value pairs for all the string instance variables of a class? Is there any library exists doing such a task?

I am doing the same using a reflection based backward look-up. But it seems doing to much work.

For example:

I have a class

public class Account implements ManagedEntity {

private String accountNumber;

public Account(String accountNumber) {
    this.accountNumber = accountNumber;
}
}

If an instance of Account class is created like blelow,
Account ac = new Account(“abc”);

The output map should be like: [{“accountNumber”, “abc”}].

  • 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-10T17:28:31+00:00Added an answer on June 10, 2026 at 5:28 pm

    As Peter Lawrey already pointed out in one of the comments, if you are looking for a library that can do that transformation for you then one possible answer is Apache Commons BeanUtils:

    You could use the BeanUtils class from that library:

    Account account = new Account("abc");
    Map accountMap = new HashMap();
    BeanUtils.populate(account, accountMap);
    

    Or using the BeanMap implementation it would be even easier:

    Account account = new Account("abc");
    Map accountMap = new BeanMap(account);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

what is the best way to implement some action that should be executed each
Trying to figure out the best way to do this: Should I do something
What is the most standard or best way to persist data between requests? Should
It should work similar to the android home screen. Which way has the best
What would be the best way to create an array that can have an
What's the best way to create a real-time communication with wcf? I.e. for games,
I am currently trying to figure out what the best way is to create
What is the best way to store a map of key object to a
The problem is I have an array that has the key value pairs as
How should I best approach drawing a scatter plot diagram in Cocoa?

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.