samples/openfixed/src/org/apidesign/openfixed/TrivialEventSupport.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 20 Mar 2011 18:52:47 +0100
changeset 374 35da2d439e3d
child 375 3abae898011d
permissions -rw-r--r--
Calculator and various ways to deliver changes in its counter to listeners
     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     @Override
    21     public void fireModificationEvent(ModificationEvent ev) {
    22         for (ModificationListener l : listener) {
    23             l.modification(ev);
    24         }
    25     }
    26 
    27     @Override
    28     public void add(ModificationListener l) {
    29         listener.add(l);
    30     }
    31 
    32     @Override
    33     public void remove(ModificationListener l) {
    34         listener.remove(l);
    35     }
    36     
    37 }