@@ -41,14 +41,12 @@ public JavaObjectValue(final Object object) {
41
41
this (null , object );
42
42
}
43
43
44
- public JavaObjectValue (final Expression expression , Object object ) {
44
+ public JavaObjectValue (final Expression expression , final Object object ) {
45
45
super (expression );
46
46
this .object = object ;
47
47
}
48
48
49
- /* (non-Javadoc)
50
- * @see org.exist.xquery.value.AtomicValue#getType()
51
- */
49
+ @ Override
52
50
public int getType () {
53
51
return Type .JAVA_OBJECT ;
54
52
}
@@ -57,67 +55,56 @@ public Object getObject() {
57
55
return object ;
58
56
}
59
57
60
- /* (non-Javadoc)
61
- * @see org.exist.xquery.value.Sequence#getStringValue()
62
- */
58
+ @ Override
63
59
public String getStringValue () {
64
60
return String .valueOf (object );
65
61
}
66
62
67
- /* (non-Javadoc)
68
- * @see org.exist.xquery.value.Sequence#convertTo(int)
69
- */
70
- public AtomicValue convertTo (int requiredType ) throws XPathException {
63
+ @ Override
64
+ public AtomicValue convertTo (final int requiredType ) throws XPathException {
71
65
if (requiredType == Type .JAVA_OBJECT ) {
72
66
return this ;
73
67
}
74
68
throw new XPathException (getExpression (), ErrorCodes .FORG0001 ,
75
69
"cannot convert Java object to " + Type .getTypeName (requiredType ));
76
70
}
77
71
72
+ @ Override
78
73
public boolean effectiveBooleanValue () throws XPathException {
79
74
throw new XPathException (getExpression (), "Called effectiveBooleanValue() on JavaObjectValue" );
80
75
}
81
76
82
77
@ Override
83
- public boolean compareTo (Collator collator , Comparison operator , AtomicValue other ) throws XPathException {
84
- throw new XPathException (getExpression (),
78
+ public boolean compareTo (final Collator collator , final Comparison operator , final AtomicValue other ) throws XPathException {
79
+ throw new XPathException (getExpression (),
85
80
"cannot compare Java object to " + Type .getTypeName (other .getType ()));
86
81
}
87
82
88
- /* (non-Javadoc)
89
- * @see org.exist.xquery.value.AtomicValue#compareTo(org.exist.xquery.value.AtomicValue)
90
- */
91
- public int compareTo (Collator collator , AtomicValue other ) throws XPathException {
92
- throw new XPathException (getExpression (),
83
+ @ Override
84
+ public int compareTo (final Collator collator , final AtomicValue other ) throws XPathException {
85
+ throw new XPathException (getExpression (),
93
86
"cannot compare Java object to " + Type .getTypeName (other .getType ()));
94
87
}
95
88
96
- /* (non-Javadoc)
97
- * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue)
98
- */
99
- public AtomicValue max (Collator collator , AtomicValue other ) throws XPathException {
89
+ @ Override
90
+ public AtomicValue max (final Collator collator , final AtomicValue other ) throws XPathException {
100
91
throw new XPathException (getExpression (), "Invalid argument to aggregate function: cannot compare Java objects" );
101
92
}
102
93
103
- public AtomicValue min (Collator collator , AtomicValue other ) throws XPathException {
94
+ @ Override
95
+ public AtomicValue min (final Collator collator , final AtomicValue other ) throws XPathException {
104
96
throw new XPathException (getExpression (), "Invalid argument to aggregate function: cannot compare Java objects" );
105
97
}
106
98
107
- /* (non-Javadoc)
108
- * @see org.exist.xquery.value.Item#conversionPreference(java.lang.Class)
109
- */
110
- public int conversionPreference (Class <?> javaClass ) {
99
+ @ Override
100
+ public int conversionPreference (final Class <?> javaClass ) {
111
101
if (javaClass .isAssignableFrom (object .getClass ())) {
112
102
return 0 ;
113
103
}
114
104
115
105
return Integer .MAX_VALUE ;
116
106
}
117
107
118
- /* (non-Javadoc)
119
- * @see org.exist.xquery.value.Item#toJavaObject(java.lang.Class)
120
- */
121
108
@ Override
122
109
public <T > T toJavaObject (final Class <T > target ) throws XPathException {
123
110
if (target .isAssignableFrom (object .getClass ())) {
@@ -128,4 +115,23 @@ public <T> T toJavaObject(final Class<T> target) throws XPathException {
128
115
129
116
throw new XPathException (getExpression (), "cannot convert value of type " + Type .getTypeName (getType ()) + " to Java object of type " + target .getName ());
130
117
}
118
+
119
+ @ Override
120
+ public boolean equals (final Object o ) {
121
+ if (this == o ) {
122
+ return true ;
123
+ }
124
+
125
+ if (o == null || getClass () != o .getClass ()) {
126
+ return false ;
127
+ }
128
+
129
+ final JavaObjectValue that = (JavaObjectValue ) o ;
130
+ return this .object .equals (that .object );
131
+ }
132
+
133
+ @ Override
134
+ public int hashCode () {
135
+ return this .object .hashCode ();
136
+ }
131
137
}
0 commit comments