1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.openpermis.policy.bean.basic; |
9 | |
|
10 | |
import static org.openpermis.policy.bean.basic.BasicUtilities.equalObjects; |
11 | |
import org.openpermis.policy.bean.ObligationBean; |
12 | |
import org.openpermis.policy.bean.SerialNumber; |
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
public class BasicObligation |
20 | |
extends BasicPartBean |
21 | |
implements ObligationBean |
22 | |
{ |
23 | |
|
24 | |
|
25 | |
|
26 | |
private static final long serialVersionUID = -6726829688085066146L; |
27 | |
|
28 | |
|
29 | |
|
30 | |
private String text; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
protected BasicObligation (SerialNumber serialNumber, String text) { |
41 | 138 | super(ObligationBean.class, serialNumber); |
42 | 138 | setText(text); |
43 | 137 | } |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public String getText () { |
53 | 89 | return this.text; |
54 | |
} |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
public void setText (String text) { |
62 | 138 | if (text == null) { |
63 | 1 | throw new IllegalArgumentException("Text is null."); |
64 | |
} |
65 | 137 | final String oldText = this.text; |
66 | 137 | this.text = text; |
67 | 137 | firePropertyChange("text", oldText, this.text); |
68 | 137 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
@Override |
76 | |
protected boolean comparablePart (BasicPart part) { |
77 | 56 | return part instanceof ObligationBean; |
78 | |
} |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
@Override |
84 | |
protected boolean equalPart (BasicPart part) { |
85 | 28 | return equalObjects(getText(), ((ObligationBean) part).getText()); |
86 | |
} |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
@Override |
92 | |
protected int partHashCode () { |
93 | 19 | return getText().hashCode(); |
94 | |
} |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
@Override |
100 | |
protected String getSimpleClassName () { |
101 | 0 | return ObligationBean.class.getSimpleName(); |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
@Override |
108 | |
protected void appendPartDetails (StringBuilder sb) { |
109 | 0 | appendDetails(sb, "obligation", getText()); |
110 | 0 | } |
111 | |
|
112 | |
} |