1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jexl3.internal;
18
19 import java.util.Objects;
20
21 import org.apache.commons.jexl3.JexlFeatures;
22
23
24
25
26
27
28 public final class Source implements Comparable<Source> {
29
30 private final int hashCode;
31
32 private final JexlFeatures features;
33
34 private final String str;
35
36
37
38
39
40
41 Source(final JexlFeatures theFeatures, final String theStr) {
42 this.features = theFeatures;
43 this.str = theStr;
44 int hash = 3;
45 hash = 37 * hash + features.hashCode();
46 hash = 37 * hash + str.hashCode() ;
47 this.hashCode = hash;
48 }
49
50 @Override
51 public int compareTo(final Source s) {
52 return str.compareTo(s.str);
53 }
54
55 @Override
56 public boolean equals(final Object obj) {
57 if (this == obj) {
58 return true;
59 }
60 if (obj == null) {
61 return false;
62 }
63 if (getClass() != obj.getClass()) {
64 return false;
65 }
66 final Source other = (Source) obj;
67 if (!Objects.equals(this.features, other.features)) {
68 return false;
69 }
70 if (!Objects.equals(this.str, other.str)) {
71 return false;
72 }
73 return true;
74 }
75
76
77
78
79 public JexlFeatures getFeatures() {
80 return features;
81 }
82
83 @Override
84 public int hashCode() {
85 return hashCode;
86 }
87
88
89
90
91 int length() {
92 return str.length();
93 }
94
95 @Override
96 public String toString() {
97 return str;
98 }
99
100 }