Last active
September 21, 2015 14:43
-
-
Save up1/865936df93e7c2b4c821 to your computer and use it in GitHub Desktop.
Better java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataHolder { | |
public final String data; | |
public DataHolder(String data) { | |
this.data = data; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TrainWreckPattern { | |
public static void main(String[] args) { | |
new Mailer() | |
.to("[email protected]") | |
.from("[email protected]") | |
.subject("Some subject") | |
.body("Some content") | |
.send(); | |
} | |
} | |
class Mailer{ | |
public Mailer to(String address){ | |
System.out.println("To: "+address); | |
return this; | |
} | |
public Mailer from(String address){ | |
System.out.println("From: "+address); | |
return this; | |
} | |
public Mailer subject(String sub){ | |
System.out.println("Subject: "+sub); | |
return this; | |
} | |
public Mailer body(String body){ | |
System.out.println("Body: "+body); | |
return this; | |
} | |
public void send(){ | |
System.out.println("Sending ..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment