01: package org.conform;
02:
03: import java.util.Arrays;
04:
05: /**
06: * A validation issue is uniquely identified by an id. It carries the property metas of the affected fields as well
07: * as a message code (aka error code) and optional arguments, that might be supplid by the validator for the sake of
08: * formatting a valuable error message.
09: */
10: public class Issue {
11: int id;
12: PropertyMeta[] metas;
13: String code;
14: Object[] arguments;
15:
16: public Issue(int id, PropertyMeta[] metas) {
17: this .id = id;
18: this .metas = metas;
19: }
20:
21: public Issue(int id, PropertyMeta[] metas, String code) {
22: this .id = id;
23: this .metas = metas;
24: this .code = code;
25: }
26:
27: public Issue(int id, PropertyMeta[] metas, String code,
28: Object... arguments) {
29: this .id = id;
30: this .metas = metas;
31: this .code = code;
32: this .arguments = arguments;
33: }
34:
35: public Issue(int id, PropertyMeta meta) {
36: this .id = id;
37: this .metas = new PropertyMeta[] { meta };
38: }
39:
40: public Issue(int id, PropertyMeta meta, String code) {
41: this .id = id;
42: this .metas = new PropertyMeta[] { meta };
43: this .code = code;
44: }
45:
46: public Issue(int id, PropertyMeta meta, String code,
47: Object... arguments) {
48: this .id = id;
49: this .metas = new PropertyMeta[] { meta };
50: this .code = code;
51: this .arguments = arguments;
52: }
53:
54: public int getId() {
55: return id;
56: }
57:
58: public PropertyMeta[] getMetas() {
59: return metas;
60: }
61:
62: public String getCode() {
63: return code;
64: }
65:
66: public Object[] getArguments() {
67: return arguments;
68: }
69:
70: public boolean equals(Object o) {
71: if (this == o)
72: return true;
73: if (o == null || getClass() != o.getClass())
74: return false;
75:
76: Issue issue = (Issue) o;
77:
78: if (id != issue.id)
79: return false;
80: if (!Arrays.equals(metas, issue.metas))
81: return false;
82:
83: return true;
84: }
85:
86: public int hashCode() {
87: return id;
88: }
89:
90: public String toString() {
91: return code;
92: }
93: }
|