It is not an abstract class, but an interface, which extends the Wrapper interface of the base module, and the wrapped type itself. This offers you the most flexible way to use it in your application.
The Wrapper type is just a typed interface and an abstract implementation of itself.
You can either implement the Wrapper interface and provide the wrapped instance via the wrapped() method, or you can extend the abstract class and hand over the wrapped instance to the super constructor.
Version with the abstract type:
Or only the interface, then you have to provide the wrapped instance via wrapped():
public interface Wrapper<W>
{
public W wrapped();
public abstract class Abstract<W> implements Wrapper<W>
{
private final W wrapped;
protected Abstract(final W wrapped)
{
super();
this.wrapped = wrapped;
}
@Override
public final W wrapped()
{
return this.wrapped;
}
}
}
public class PersistenceStoringWithLogging
extends Wrapper.Abstract<PersistenceStoring>
implements WrapperPersistenceStoring
{
public PersistenceStoringWithLogging(final PersistenceStoring wrapped)
{
super(wrapped);
}
@Override
public long store(Object instance)
{
Logger.getLogger(PersistenceStoring.class.getName())
.info("Object stored: " + instance);
return WrapperPersistenceStoring.super.store(instance);
}
}
public class PersistenceStoringWithLogging
implements WrapperPersistenceStoring
{
private final PersistenceStoring wrapped;
public PersistenceStoringWithLogging(final PersistenceStoring wrapped)
{
super();
this.wrapped = wrapped;
}
@Override
public PersistenceStoring wrapped()
{
return this.wrapped;
}
@Override
public long store(Object instance)
{
Logger.getLogger(PersistenceStoring.class.getName())
.info("Object stored: " + instance);
return WrapperPersistenceStoring.super.store(instance);
}
}