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 6804013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:24:53+00:00 2026-05-26T19:24:53+00:00

At work, I often have to deal with 3rd party libraries, which make heavy

  • 0

At work, I often have to deal with 3rd party libraries, which make heavy use of JavaBeans. Because working with JavaBeans (especially creation) is very tedious and violates dry (lots of replication), I often write a helper class to be able to create JavaBeans in more “oo-like” (i.e., pass all the needed information into the constructor), something like this

// left out the implementation of the method, just to give an idea
public class MyBean {
  public MyBean();

  public void setFoo(String foo);
  public void setBar(String bar);
}

public MyBeans {
  public static MyBean newMyBean(String foo, String bar);
}

Now, with using static imports, I can:

MyBean bean = newMyBean(foo, bar);

Instead of:

MyBean bean = new MyBean();
bean.setFoo(foo);
bean.setBar(bar);

Is this some sort of idiom, are there any downsides (I know, the static import is kinda controverse), and are there any Maven plugins which can generate these helper classes for me?

  • 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-05-26T19:24:53+00:00Added an answer on May 26, 2026 at 7:24 pm

    I know of no Maven plugin that will create these factories for you, but it’s a simple code generation library. It needs to be configurable to create various factories given a class, which properties you’d like to set, but must take class specifics into account.

    Because of the configuration needs (as I see it, anyway) I’ve never bothered wrapping my implementations into a Maven plugin. I generate them manually (along with fluid interface options), and never think about them again.

    IMO they usually require human intervention, so it’s not worth Mavenizing the process. Just generate them into the normal src/main/java tree and pretend you wrote them yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often have to go into other people's work to make modifications for short-term
At the company that I work with, we often have to integrate with client’s
I often work in Eclipse, but recently switched to TextMate, which is, in my
As a freelancer, I often work at companies who use Subversion repositories. It’d be
I often have to work with fragile legacy websites that break in unexpected ways
I work with the rather finnicky Oracle Business Intelligence software and we often have
In my applications, I often have to use relative paths. For example, when I
I use VIM as my main text editor here at work and I often
I often work with sales and marketing types that cannot figure out how to
At my company, we develop our ASP.NET applications as websites and often just work

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.