KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > prevayler > demos > demo1 > NumberKeeper


1 package org.prevayler.demos.demo1;
2
3 import java.util.*;
4
5
6 /**
7  * The NumberKeeper and all its references are the prevalent system.
8  * i.e: They are the "business objects" and will be transparently persisted by Prevayler.
9  */

10 class NumberKeeper implements java.io.Serializable JavaDoc {
11
12   private final List numbers = new ArrayList();
13
14
15   void keep(int nextNumber) {
16     numbers.add(new Integer JavaDoc(nextNumber));
17   }
18
19   List numbers() {
20     return numbers;
21   }
22
23   int lastNumber() {
24     return numbers.isEmpty()
25       ? 0
26       : ((Integer JavaDoc)numbers.get(numbers.size() - 1)).intValue();
27   }
28
29 }
30
Popular Tags