1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.sail.core.entity;
24
25 import java.beans.beancontext.BeanContext;
26 import java.beans.beancontext.BeanContextChildSupport;
27
28 import net.sf.sail.core.beans.Pod;
29 import net.sf.sail.core.uuid.PodUuid;
30
31 import org.doomdark.uuid.UUID;
32
33
34
35
36
37
38
39 public class Rim<T> extends BeanContextChildSupport {
40
41
42
43
44 private static final long serialVersionUID = 4637021392257551556L;
45
46 transient static int rimCount = 0;
47
48 transient int rimSerial = ++rimCount;
49
50 String name = "undefined" + rimSerial;
51
52
53
54 Class<T> shape = null;
55
56
57
58
59
60
61 public Rim() {
62
63 }
64
65 public Class<T> getShape() {
66 return shape;
67 }
68
69 public void setShape(Class<T> shape) {
70 if (shape == null)
71 throw new IllegalArgumentException("null shape set on rim");
72 this.shape = shape;
73 }
74
75 public String getName() {
76 return name;
77 }
78
79 public void setName(String name) {
80 if (name == null)
81 throw new IllegalArgumentException("null name set on rim");
82 this.name = name;
83 }
84
85 public UUID getContainerId() {
86 BeanContext bc = getBeanContext();
87 if (bc == null)
88 throw new NullPointerException("Rim without a BeanContext");
89 if (!(bc instanceof Pod))
90 throw new RuntimeException("Rim's BeanContext not a Pod");
91 Pod pod = (Pod) bc;
92 PodUuid podId = pod.getPodId();
93 if (podId == null)
94 throw new NullPointerException("pod has no id: " + pod);
95 return podId;
96 }
97
98 @Override
99 public String toString() {
100 return "Rim@" + rimSerial + "[" + name + ":" + shape + "]";
101 }
102 }