I'll admit, I don't know WHAT I'm doing w.r.t. this wrapper concept. I just copy the stuff from the example, makes no sense why I would need this.
I shall go read up on it in Head First Java....
package com.codegym.task.task18.task1811;
/*
Wrapper (Decorator)
*/
public class Solution {
public static void main(String[] args) {
new Thread(new DecoratorRunnableImpl(new DecoratorMyRunnableImpl(new RunnableImpl()))).start();
}
public static class RunnableImpl implements Runnable {
@Override
public void run() {
System.out.println("RunnableImpl body");
}
}
public static class DecoratorRunnableImpl implements Runnable {
private Runnable component;
public DecoratorRunnableImpl(Runnable component) {
this.component = component;
}
@Override
public void run() {
System.out.print("DecoratorRunnableImpl body ");
component.run();
}
}
public static class DecoratorMyRunnableImpl extends DecoratorRunnableImpl implements Runnable{
//private Runnable component;
private DecoratorRunnableImpl original;
public DecoratorMyRunnableImpl(Runnable component) {
super(component);
this.original = original;
}
public void run() {
System.out.print("DecoratorMyRunnableImpl body ");
original.component.run();
}
}
}