java - Constructor method must contain all instance variables -


many times i'm faced class constructor method must contain list of arguments identical list of class instance variables.

as see in example there "some" code make hapend. i'm wondering how can make process less painful?

example:

public class vimeouser extends schema {      @getter @setter private string uri;     @getter @setter private string name;     @getter @setter private string link;     @getter @setter private string location;     @getter @setter private string bio;     @getter @setter private string createdtime;     @getter @setter private string account;      @getter @setter private map<string,integer> statistics = new hashmap<>();      @getter @setter private list<website> websites = new arraylist<>();     @getter @setter private list<portrait> portraits = new arraylist<>();      public vimeouser(             string uri,             string name,             string link,             string location,             string bio,             string createdtime,             string account,             map<string,integer> statistics,             list<website> websites,             list<portrait> portraits){      this.uri = uri;     this.name = name;     this.link = link;     this.location = location;     this.bio = bio;     this.createdtime = createdtime;     this.account = account;     this.statistics = statistics;     this.websites = websites;     this.portraits = portraits;      } } 

i see using lombok. there @allargsconstructor class-level annotation generate constructor you. if want default constructor, too, use @noargsconstructor additionally.

more info on constructor-generating annotations here.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -