01: package org.cougaar.demo.mandelbrot.v3;
02:
03: import org.cougaar.core.util.UID;
04: import org.cougaar.core.util.UniqueObject;
05: import org.cougaar.util.FutureResult;
06: import org.cougaar.demo.mandelbrot.util.Arguments;
07:
08: /**
09: * A blackboard object representing a fractal request.
10: */
11: public final class Job implements UniqueObject {
12:
13: private final UID uid;
14: private final Arguments args;
15: private final FutureResult future;
16:
17: /**
18: * Create a new Job instance.
19: * @param uid the unique job identifier, as generated by the
20: * {@link org.cougaar.core.service.UIDService}
21: * @param args the fractal calculation arguments
22: * @param future a synchronizer to notify with the calculation
23: * result.
24: */
25: public Job(UID uid, Arguments args, FutureResult future) {
26: this .uid = uid;
27: this .args = args;
28: this .future = future;
29:
30: String s = (uid == null ? "uid" : args == null ? "args"
31: : future == null ? "future" : null);
32: if (s != null) {
33: throw new IllegalArgumentException("null " + s);
34: }
35: }
36:
37: public UID getUID() {
38: return uid;
39: }
40:
41: public void setUID(UID uid) {
42: throw new UnsupportedOperationException("UID already set");
43: }
44:
45: public Arguments getArguments() {
46: return args;
47: }
48:
49: public FutureResult getFutureResult() {
50: return future;
51: }
52:
53: // all blackboard objects require good hashCode/equals methods,
54: // since the blackboard is essentially a HashSet.
55: public int hashCode() {
56: return uid.hashCode();
57: }
58:
59: public boolean equals(Object o) {
60: if (o == this )
61: return true;
62: if (!(o instanceof Job))
63: return false;
64: return uid.equals(((Job) o).uid);
65: }
66:
67: public String toString() {
68: return "(job uid=" + uid + ")";
69: }
70: }
|