samples/openfixed/src/org/apidesign/openfixed/TrivialEventSupport.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 20 Mar 2011 20:52:33 +0100
changeset 375 3abae898011d
parent 374 35da2d439e3d
child 395 837ae5b09036
permissions -rw-r--r--
More code snippets for openfixed project
     1 /*
     2  * To change this template, choose Tools | Templates
     3  * and open the template in the editor.
     4  */
     5 package org.apidesign.openfixed;
     6 
     7 import java.util.List;
     8 import java.util.concurrent.CopyOnWriteArrayList;
     9 
    10 /**
    11  *
    12  * @author Jaroslav Tulach <jtulach@netbeans.org>
    13  */
    14 final class TrivialEventSupport implements EventSupport {
    15     List<ModificationListener> listener = new CopyOnWriteArrayList<ModificationListener>();
    16     
    17     TrivialEventSupport() {
    18     }
    19 
    20     // BEGIN: openfixed.trivial
    21     @Override
    22     public void fireModificationEvent(ModificationEvent ev) {
    23         for (ModificationListener l : listener) {
    24             l.modification(ev);
    25         }
    26     }
    27     // END: openfixed.trivial
    28 
    29     @Override
    30     public void add(ModificationListener l) {
    31         listener.add(l);
    32     }
    33 
    34     @Override
    35     public void remove(ModificationListener l) {
    36         listener.remove(l);
    37     }
    38     
    39 }