Skip to content

Instantly share code, notes, and snippets.

@mmhan
Forked from tkfx/complexConstructor.java
Created July 21, 2016 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmhan/452ae516ec19d7d0c78b9a06ba2f1876 to your computer and use it in GitHub Desktop.
Save mmhan/452ae516ec19d7d0c78b9a06ba2f1876 to your computer and use it in GitHub Desktop.
// simple constructor
//
private final int x;
private final int y;
private final String z;
public MyClass(int x, int y, String z) {
this.x = x;
this.y = y;
this.z = z;
}
// complex building
//
public static MyClass create(List<Stuff> list, Set<Stuff> set) {
// int x = some brains...
// int y = more brains...
// other brains...
// String z = more complex stuff here
//
return new MyClass(x, y, z);
}
private final int x;
private final int y;
private final String z;
private MyClass(int x, int y, String z) {
this.x = x;
this.y = y;
this.z = z;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment