|
1 |
| package com.agical.rmock.core.match.reference; |
|
2 |
| |
|
3 |
| import java.io.IOException; |
|
4 |
| |
|
5 |
| import com.agical.rmock.core.describe.ExpressionDescriber; |
|
6 |
| import com.agical.rmock.core.match.Expression; |
|
7 |
| import com.agical.rmock.core.match.Reference; |
|
8 |
| |
|
9 |
| public class ExpressionReference implements Reference { |
|
10 |
| |
|
11 |
| private final Expression expression; |
|
12 |
| |
|
13 |
77
| public ExpressionReference(Expression expression) {
|
|
14 |
77
| this.expression = expression;
|
|
15 |
| } |
|
16 |
| |
|
17 |
10
| public Object getObject() {
|
|
18 |
10
| return expression;
|
|
19 |
| } |
|
20 |
| |
|
21 |
2
| public void describeWith(ExpressionDescriber expressionDescriber) throws IOException {
|
|
22 |
2
| if (expression != null) {
|
|
23 |
1
| expression.describeWith(expressionDescriber);
|
|
24 |
| } |
|
25 |
| } |
|
26 |
| |
|
27 |
55
| public boolean objectEquals(Object object) {
|
|
28 |
55
| return expression.equals(object);
|
|
29 |
| } |
|
30 |
| |
|
31 |
4
| public int objectCompareTo(Object object) {
|
|
32 |
4
| if(this.expression instanceof Comparable) {
|
|
33 |
1
| return ((Comparable)this.expression).compareTo(object);
|
|
34 |
| } |
|
35 |
3
| return this.expression.equals(object) ? 0 : (object.hashCode() > this.expression.hashCode()) ? -1 : +1;
|
|
36 |
| } |
|
37 |
| |
|
38 |
| } |