This is a simple example.
import org.apache.log4j.Logger; public abstract class BasePoop< T > { protected abstract Logger getLogger(); protected abstract Class< T > getClazz(); /* Now BasePoop can use getClazz() in all sorts of code that would benefit * Poopola and Crapola. T would be used wherever Poopola or Crapola are needed. */ ... }
Here are extending classes...
import org.apache.log4j.Logger; public class Poopola extends BasePoop< Poopola > { private static Logger log = Logger.getLogger( Poopola.class ); /* must implement these methods to meet contract... */ public Logger getLogger() { return log; } public Class< Poopola > getClazz() { return Poopola.class; } /* Poopla-specific methods */ ... }
import org.apache.log4j.Logger; public class Crapola extends BasePoop< Crapola > { private static Logger log = Logger.getLogger( Crapola.class ); /* must implement these methods to meet contract... */ public Logger getLogger() { return log; } public Class< Crapola > getClazz() { return Crapola.class; } /* Crapla-specific methods */ ... }