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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:02:15+00:00 2026-05-20T10:02:15+00:00

I need to custom eclipse setter template to return this object, like this public

  • 0

I need to custom eclipse setter template to return this object, like this

public Person setName(String name){
    this.name=name;
    return this;
}

but Java->Code Style->Templates only allow me to custom setter body part, not method definition. Is there any way to do it?

  • 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-20T10:02:15+00:00Added an answer on May 20, 2026 at 10:02 am

    I’m afraid I can’t offer a solution to allow you to modify the Eclipse template for this, however can I suggest that you rethink what you’re doing here?

    If you check the JavaBeans spec you’ll see that when you define your methods in this way they are no longer valid property setters. Setters should have a void return type; you may regret creating these non-standard beans in the long run. For instance, try using java.beans.Introspector to gather bean info for your class and you’ll see that your property ‘setters’ are not found.

    I know it’s nice to be able to quickly initialise your beans with chained calls like:

    new Person().setName("John Smith").setDateOfBirth(...).setAddress(...)
    

    Can I suggest as an alternative you use standard setters (that return void) and instead introduce builder methods like:

    public Person withName(String name) {
        this.setName(name);
        return this;
    }
    

    Your quick single line construction then looks like:

    new Person().withName("John Smith").withDateOfBirth(...).withAddress(...)
    

    I find the ‘with’ prefix reads nicely too.

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

Sidebar

Related Questions

I need a custom widget height. I tried using this Integer.toString(yourWidget.getElement().getOffsetHeight()) but, If I
So I need some custom colors on a layout, but I'm looking for a
I am working on a custom debug view in an Eclipse plugin. In this
I have extended org.eclipse.ui.editors.text.TextEditor to implement a custom editor. For this editor, I have
I am trying to override the DateTime template since I need custom class names
I'd like to extend the WTP(e.g. custom personal wizard), I need to view the
I need a custom layer (extended by new variable and a method) and did
I need create custom dialog and put JPanel into it. Is it possible?
I need a custom event that should raise if a new/existing file in a
I basically need a custom function to be used only when, for example, the

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.