Last active
September 19, 2016 05:27
-
-
Save bassaer/346b867a2b51384e8e9192992d4785b1 to your computer and use it in GitHub Desktop.
【Android・Java】連続でセッターを記述できるようにする方法 ref: http://qiita.com/bassaer/items/52350a13dec4dd6df909
This file contains 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
Message message = new Message(); | |
message.setTitle("Hello"); | |
message.setContent("How are you?"); | |
message.setAddress("hoge@foobar.com"); | |
. | |
. | |
. |
This file contains 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
Message message = new Message(); | |
message.setTitle("Hello") | |
.setContent("How are you?") | |
.setAddress("hoge@foobar.com") | |
.setSender("John") | |
.send(); |
This file contains 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
new Message.Builder() | |
.setTitle("Hello") | |
.setContent("How are you?") | |
.setAddress("hoge@foobar.com") | |
.setSender("John") | |
.build(); |
This file contains 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 Message { | |
private String mTitle; | |
private String mContent; | |
private String mSender; | |
private String mAddress; | |
static class Builder { | |
private Message message; | |
public Builder() { | |
message = new Message(); | |
} | |
public Builder setTitle(String title) { | |
message.setTitle(title); | |
return this; | |
} | |
public Builder setContent(String content) { | |
message.setContent(content); | |
return this; | |
} | |
public Builder setSender(String sender) { | |
message.setSender(sender); | |
return this; | |
} | |
public Builder setAddress(String address) { | |
message.setAddress(address); | |
return this; | |
} | |
public Message build() { | |
return message; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment