Better example (perhaps)...
You'd rather implement an Observer pattern than do this?!
Code:
class ThingyFlavouredClass implements CoparableWidgetSpawner { //some code.... @Override public ComparableWidget SpawnAComparableWidget() { return new ComparableWidget() { @Override public int compareTo(Object o) { if(!o instanceof ComparableWidget) return -1; ComparableWidget cw = (ComparableWidget)o; if cw.thingy == this.thingy return 0; else return cw.thingy < this.thingy ? 1 : -1; } }; } //some code.... }
You'd rather implement an Observer pattern than do this?!
Comment