Skip to content

Instantly share code, notes, and snippets.

@mgenov
Created July 12, 2011 10:24
Show Gist options
  • Save mgenov/1077741 to your computer and use it in GitHub Desktop.
Save mgenov/1077741 to your computer and use it in GitHub Desktop.
ReceiptItemBuilder.java
public static class ReceiptItemBuilder {
private DateTime from;
private DateTime to;
private String name;
private Double quantity;
private Double price;
private Double discount;
private String referenceId;
public ReceiptItemBuilder from(DateTime from) {
this.from = from;
return this;
}
public ReceiptItemBuilder to(DateTime to) {
this.to = to;
return this;
}
public ReceiptItemBuilder named(String name) {
this.name = name;
return this;
}
public ReceiptItemBuilder quantityOf(Double quantity) {
this.quantity = quantity;
return this;
}
public ReceiptItemBuilder priceOf(Double price) {
this.price = price;
return this;
}
public ReceiptItemBuilder discountOf(Double discount) {
this.discount = discount;
return this;
}
public ReceiptItemBuilder referencing(String referenceId) {
this.referenceId = referenceId;
return this;
}
public ReceiptItem build() {
return new ReceiptItem(from, to, name,quantity, price,discount,referenceId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment