|
1 |
| package com.agical.rmock.core.match.constraint; |
|
2 |
| |
|
3 |
| import java.io.IOException; |
|
4 |
| |
|
5 |
| import com.agical.rmock.core.describe.ExpressionDescriber; |
|
6 |
| import com.agical.rmock.core.match.Constraint; |
|
7 |
| import com.agical.rmock.core.match.Reference; |
|
8 |
| import com.agical.rmock.core.match.operator.AbstractExpression; |
|
9 |
| import com.agical.rmock.core.match.reference.ReferenceFactory; |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| public abstract class AbstractConstraint extends AbstractExpression implements Constraint { |
|
18 |
| private final String name; |
|
19 |
| private final Reference reference; |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
13
| public String getName() {
|
|
25 |
13
| return name;
|
|
26 |
| } |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
1208
| public Reference getReference() {
|
|
32 |
1208
| return reference;
|
|
33 |
| } |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
7293
| public AbstractConstraint(String name, Object reference) {
|
|
41 |
7293
| this.name = name;
|
|
42 |
7293
| this.reference = (new ReferenceFactory()).create(reference);
|
|
43 |
| } |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
13
| public void describeWith(ExpressionDescriber constraintDescriber) throws IOException {
|
|
50 |
13
| constraintDescriber.describe(this);
|
|
51 |
| } |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
1
| public int hashCode() {
|
|
57 |
1
| return reference.getObject().hashCode();
|
|
58 |
| } |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
53
| public boolean equals(Object other) {
|
|
64 |
53
| if( other == null) {
|
|
65 |
1
| return false;
|
|
66 |
| } |
|
67 |
52
| if (reference.getObject() == null) {
|
|
68 |
1
| return (((AbstractConstraint)other).reference.getObject() == null);
|
|
69 |
| } |
|
70 |
51
| return reference.getObject().equals(((AbstractConstraint)other).reference.getObject());
|
|
71 |
| } |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
1
| public String toString() {
|
|
77 |
1
| StringBuffer sb = new StringBuffer();
|
|
78 |
1
| sb.append("name: ").append(name).append(", reference: ").append(reference.getObject());
|
|
79 |
1
| return sb.toString();
|
|
80 |
| } |
|
81 |
| } |