Skip to content

Instantly share code, notes, and snippets.

@juanpabloprado
Created March 1, 2016 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloprado/382e65b58149d26b1e65 to your computer and use it in GitHub Desktop.
Save juanpabloprado/382e65b58149d26b1e65 to your computer and use it in GitHub Desktop.
/*
* Copyright 2016 Juan Pablo Prado
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.builder;
public class LunchOrder {
public static class Builder {
private String bread;
private String condiments;
private String dressing;
private String meat;
public Builder() {
}
public LunchOrder build() {
return new LunchOrder(this);
}
public Builder bread(String bread) {
this.bread = bread;
return this;
}
public Builder condiments(String condiments) {
this.condiments = condiments;
return this;
}
public Builder dressing(String dressing) {
this.dressing = dressing;
return this;
}
public Builder meat(String meat) {
this.meat = meat;
return this;
}
}
private final String bread;
private final String condiments;
private final String dressing;
private final String meat;
private LunchOrder(Builder builder) {
this.bread = builder.bread;
this.condiments = builder.condiments;
this.dressing = builder.dressing;
this.meat = builder.meat;
}
public String getBread() {
return bread;
}
public String getCondiments() {
return condiments;
}
public String getDressing() {
return dressing;
}
public String getMeat() {
return meat;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment