Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The main problem I see here are the method parameters, which restrict which methods can actually be used for which events, and there's no compile-time help for that.</p> <p>This is what makes interfaces attractive to me for observer pattern implementations like the Java event model. Tools like eclipse can autogen method stubs so you can't get the signatures wrong. In your example, it's very easy to use the wrong parameter type and never know it until an event occurs (which might be an error case several months down the line) </p> <p>One thing you might try are my annotations &amp; processor for implementing observers and null object implementations. Suppose you have</p> <pre><code>package a.b.c; public interface SomeListener { void fee(); void fie(); void fo(); void fum(); } </code></pre> <p>and wanted to create a listener instance. You could write</p> <pre><code>package x.y.z; import a.b.c.SomeListener; import com.javadude.annotation.Bean; import com.javadude.annotation.NullObject; @Bean(nullObjectImplementations = {@NullObject(type = SomeListener.class) }) public class Foo extends FooGen implements SomeListener { @Override public void fie() { // whatever code you need here } } </code></pre> <p>To create a source for these events, you can write</p> <pre><code>package a.b.c; import com.javadude.annotation.Bean; import com.javadude.annotation.Observer; @Bean(observers = {@Observer(type = SomeListener.class)}) public class Source extends SourceGen { // SourceGen will have add/remove listener and fire methods // for each method in SomeListener } </code></pre> <p>See <a href="http://code.google.com/p/javadude/wiki/Annotations" rel="nofollow noreferrer">http://code.google.com/p/javadude/wiki/Annotations</a> if you're interested. Might give you some other ideas as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload