Updating to NBMs from NetBeans 8.0.1 as some of them are required to run on JDK8
1 package org.apidesign.openfixed;
3 /** Sample bean using the {@link ModificationListener}
4 * to <b>add</b> numbers.
6 * @author Jaroslav Tulach <jtulach@netbeans.org>
8 // BEGIN: openfixed.bean
9 public final class Calculator {
10 private final EventSupport listeners;
13 private Calculator(EventSupport listeners) {
14 this.listeners = listeners;
17 /** An abstraction over various types of event delivery
18 * to listeners. Comes with four different implementations.
19 * A trivial one, asynchronous one, one with support for
20 * pending events and one for a batch events delivery.
22 interface EventSupport {
23 public void fireModificationEvent(ModificationEvent ev);
24 public void add(ModificationListener l);
25 public void remove(ModificationListener l);
28 public static Calculator create() {
29 return new Calculator(new TrivialEventSupport());
32 public static Calculator createAsynch() {
33 return new Calculator(new AsyncEventSupport());
37 public static Calculator createPending() {
38 return new Calculator(new PendingEventSupport());
42 public static Calculator createBatch() {
43 return new Calculator(new PostEventSupport());
46 public synchronized void add(int add) {
48 listeners.fireModificationEvent(new ModificationEvent(this, add));
51 public synchronized int getSum() {
55 public void addModificationListener(ModificationListener l) {
58 public void removeModificationListener(ModificationListener l) {
62 // END: openfixed.bean