01: package com.completex.objective.components.persistency.key.impl;
02:
03: import com.completex.objective.components.persistency.key.OdalKeyPolicy;
04:
05: /**
06: * Default OdalKeyPolicy implementation.
07: *
08: * @see OdalKeyPolicy
09: * @author Gennady Krizhevsky
10: */
11: public class OdalKeyPolicyImpl implements OdalKeyPolicy {
12: private int identityPriority = OdalKeyPolicy.DEFAULT_IDENTITY_PRIORITY;
13: private int odalKeyPriority = OdalKeyPolicy.DEFAULT_ODAL_KEY_PRIORITY;
14: private int sequencePriority = OdalKeyPolicy.DEFAULT_SEQUENCE_PRIORITY;
15:
16: public OdalKeyPolicyImpl(int identityPriority, int odalKeyPriority,
17: int sequencePriority) {
18: this .identityPriority = identityPriority;
19: this .odalKeyPriority = odalKeyPriority;
20: this .sequencePriority = sequencePriority;
21: }
22:
23: public OdalKeyPolicyImpl() {
24: }
25:
26: public int getIdentityPriority() {
27: return identityPriority;
28: }
29:
30: public void setIdentityPriority(int identityPriority) {
31: this .identityPriority = identityPriority;
32: }
33:
34: public boolean isIdentityPriorityDisabled() {
35: return identityPriority == DISABLED_PRIORITY;
36: }
37:
38: public int getOdalKeyPriority() {
39: return odalKeyPriority;
40: }
41:
42: public void setOdalKeyPriority(int odalKeyPriority) {
43: this .odalKeyPriority = odalKeyPriority;
44: }
45:
46: public boolean isOdalKeyPriorityDisabled() {
47: return odalKeyPriority == DISABLED_PRIORITY;
48: }
49:
50: public int getSequencePriority() {
51: return sequencePriority;
52: }
53:
54: public void setSequencePriority(int sequencePriority) {
55: this .sequencePriority = sequencePriority;
56: }
57:
58: public boolean isSequencePriorityDisabled() {
59: return sequencePriority == DISABLED_PRIORITY;
60: }
61:
62: public boolean isDisabled() {
63: return isIdentityPriorityDisabled()
64: && isOdalKeyPriorityDisabled()
65: && isSequencePriorityDisabled();
66: }
67:
68: public static boolean isDisabled(int[] priorities) {
69: boolean enabled = true;
70: for (int i = 0; i < priorities.length; i++) {
71: int priority = priorities[i];
72: enabled &= (priority != DISABLED_PRIORITY);
73: }
74: return !enabled;
75: }
76:
77: public String toString() {
78: return new StringBuffer().append(
79: "OdalKeyPolicy = { identityPriority: ").append(
80: identityPriority).append("; odalKeyPriority: ").append(
81: odalKeyPriority).append("; sequencePriority: ").append(
82: sequencePriority).append("}").toString();
83: }
84: }
|