装饰模式

2、Decorator (recognizeable by creational methods taking an instance of same abstract/interface type which adds additional behaviour)

    --装饰模式(为一个对象动态的加上一系列的动作,而不需要因为这些动作的不同而产生大量的继承类)

例如:

public BufferedInputStream(InputStream in, int size) {
        super(in);
        if (size <= 0) {
            throw new IllegalArgumentException("Buffer size <= 0");
        }
        buf = new byte[size];
    }

 

 

 

posted @ 2019-09-05 16:42  学之精用  阅读(19)  评论(0)    收藏  举报