美文网首页
链式编程

链式编程

作者: JianLee | 来源:发表于2017-04-17 09:30 被阅读10次
    package cainiao.phoneassistant;
    
    /**
     * 项目名称:PhoneAide
     * 创建人:LI
     * 创建时间:2017/4/17 8:42
     * 功能描述:
     */
    public class Car {
        public  Builder builder;
        private Car() {
        }
    
        public Car(Builder builder) {
            this.builder = builder;
        }
        public static Builder builder(){
            return new Builder();
        }
    
        public static class Builder{
            private String name;
            private String age;
            public Builder setName(String name){
                name=name;
                return this;
            }
            public Builder setAge(String age)
            {
                age=age;
                return this;
            }
            public Car build(){
                return new Car(this);
            }
    
        }
    }
    
    

    相关文章

      网友评论

          本文标题:链式编程

          本文链接:https://www.haomeiwen.com/subject/khazattx.html