Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BuildOrderHeaderRow()
- BuildLineItemSubHeaderRow()
- BuildOrderRow()
- BuildLineItemSubRow()
- Pizza(int size) { ... }
- Pizza(int size, boolean cheese) { ... }
- Pizza(int size, boolean cheese, boolean pepperoni) { ... }
- Pizza(int size, boolean cheese, boolean pepperoni, boolean bacon) { ... }
- Pizza pizza = new Pizza(12);
- pizza.setCheese(true);
- pizza.setPepperoni(true);
- pizza.setBacon(true);
- public class Pizza {
- private int size;
- private boolean cheese;
- private boolean pepperoni;
- private boolean bacon;
- public static class Builder {
- //required
- private final int size;
- //optional
- private boolean cheese = false;
- private boolean pepperoni = false;
- private boolean bacon = false;
- public Builder(int size) {
- this.size = size;
- }
- public Builder cheese(boolean value) {
- cheese = value;
- return this;
- }
- public Builder pepperoni(boolean value) {
- pepperoni = value;
- return this;
- }
- public Builder bacon(boolean value) {
- bacon = value;
- return this;
- }
- public Pizza build() {
- return new Pizza(this);
- }
- }
- private Pizza(Builder builder) {
- size = builder.size;
- cheese = builder.cheese;
- pepperoni = builder.pepperoni;
- bacon = builder.bacon;
- }
- }
- Pizza pizza = new Pizza.Builder(12).cheese(true).pepperoni(true).bacon(true).build();
- m.expects(once())
- .method("testMethod")
- .with(eq(1), eq(2))
- .returns("someResponse");
- Map<String, Integer> m = new HashMap<String, Integer>()
- .put("a", 1)
- .put("b", 2)
- .put("c", 3);
- class RestaurantObjectBuilder
- {
- IFactory _factory = new DefaultFoodFactory();
- //This can be used when you want to plugin the
- public void SetFoodFactory(IFactory customFactory)
- {
- _factory = customFactory;
- }
- public IFactory GetFoodFactory()
- {
- return _factory;
- }
- }
- class RestaurantObjectBuilder
- {
- IFactory _factory = new DefaultFoodFactory();
- //This can be used when you want to plugin the
- public void SetFoodFactory(IFactory customFactory)
- {
- _factory = customFactory;
- }
- public IFactory GetFoodFactory()
- {
- return _factory;
- }
- }
Add Comment
Please, Sign In to add comment