Last active
March 14, 2017 02:08
-
-
Save jeffersontpadua/eff83f47c761a7eaabd6939ce9e99de1 to your computer and use it in GitHub Desktop.
Main para execução do padrão Builder
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 ExecutarPadraoBuilder { | |
public static void main(String[] args) { | |
Pessoa.Builder builder = new Pessoa.Builder(); | |
builder.setNome("Jefferson Tavares de Pádua") | |
.setCpf("111.111.111-11"); | |
Pessoa pessoa = builder.build(); | |
System.out.println(pessoa.getNome()); //O nome Jefferson Tavares de Pádua será mostrado na tela | |
Pessoa outraPessoa = new Pessoa.Builder() | |
.from(pessoa) | |
.setDataNascimento(LocalDate.of(1995, 6, 30)) | |
.build(); | |
/* | |
* O nome Jefferson Tavares de Pádua será mostrado novamente, uma vez que esse objeto foi construído | |
* a partir dos valores do objeto anterior | |
*/ | |
System.out.println(outraPessoa.getNome()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment