Created
November 16, 2016 19:38
-
-
Save edermfl/41df7279aed2169c7f4efc5a1ac4717b to your computer and use it in GitHub Desktop.
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 Nf { | |
Cliente cliente; | |
List<Item> itens; | |
Integer numero; | |
public Nf(final Integer pNumero) { | |
numero = pNumero; | |
itens = new ArrayList<Item>(); | |
} | |
public static NumeroStep emitirNf() { | |
return new NfSteps(); | |
} | |
public static interface ClienteStep { | |
ItemStepStep paraCliente(String nome); | |
} | |
public static interface EmitirStep { | |
EmitirStep eCom(int quantidade, String nome); | |
Nf gerarNf(); | |
} | |
public static interface ItemStepStep { | |
EmitirStep com(int quantidade, String nome); | |
} | |
public static interface NumeroStep { | |
ClienteStep numero(Integer numero); | |
} | |
private static class NfSteps implements NumeroStep, | |
ClienteStep, ItemStepStep, EmitirStep { | |
Nf nf; | |
public EmitirStep com(final int quantidade, final String nome) { | |
nf.itens.add(new Item(nome, quantidade)); | |
return this; | |
} | |
public EmitirStep eCom(final int quantidade, final String nome) { | |
nf.itens.add(new Item(nome, quantidade)); | |
return this; | |
} | |
public Nf gerarNf() { | |
return nf; | |
} | |
public ClienteStep numero(final Integer numero) { | |
nf = new Nf(numero); | |
return this; | |
} | |
public ItemStepStep paraCliente(final String nome) { | |
nf.cliente = new Cliente(nome); | |
return this; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment