@@ -78,7 +78,7 @@ public Truthness evaluate(CqlQueryOperation op, CassandraRow candidateRow) {
7878 } else if (op instanceof ContainsKeyOperation <?>) {
7979 return evaluateContainsKey ((ContainsKeyOperation <?>) op , candidateRow );
8080 } else {
81- return FALSE_TRUTHNESS ;
81+ throw new IllegalArgumentException ( "Unsupported operation: " + op . getClass (). getName ()) ;
8282 }
8383 }
8484
@@ -168,7 +168,7 @@ private Truthness compareByType(Object rowValue, Object literalValue, Comparison
168168 } else if (isTemporalType (rowValue )) {
169169 return compareTemporal (rowValue , literalValue , comparisonType );
170170 } else if (isCqlDuration (rowValue )) {
171- return compareDuration (rowValue , literalValue , comparisonType );
171+ return compareDuration (( TemporalAmount ) rowValue , literalValue , comparisonType );
172172 } else {
173173 throw new IllegalArgumentException ("Unsupported row value type: " + rowValue .getClass ().getName ());
174174 }
@@ -184,33 +184,33 @@ private Truthness compareNumeric(Object rowValue, Object literalValue, Compariso
184184 private Truthness compareString (Object rowValue , Object literalValue , ComparisonType comparisonType ) {
185185 if (comparisonType != ComparisonType .EQUALS ) {
186186 throw new IllegalArgumentException ("Unsupported operator for string literals: " + comparisonType );
187- } else {
188- String a = (rowValue instanceof InetAddress )
189- ? ((InetAddress ) rowValue ).getHostAddress ()
190- : (String ) rowValue ;
191- String b = (String ) literalValue ;
192-
193- return TruthnessUtils .getStringEqualityTruthness (a , b );
194187 }
188+
189+ String a = (rowValue instanceof InetAddress )
190+ ? ((InetAddress ) rowValue ).getHostAddress ()
191+ : (String ) rowValue ;
192+ String b = (String ) literalValue ;
193+
194+ return TruthnessUtils .getStringEqualityTruthness (a , b );
195195 }
196196
197197 private Truthness compareBoolean (Object rowValue , Object literalValue , ComparisonType comparisonType ) {
198198 if (comparisonType != ComparisonType .EQUALS ) {
199199 throw new IllegalArgumentException ("Unsupported operator for boolean literals: " + comparisonType );
200- } else {
201- double x = ((Boolean ) rowValue ) ? 1.0 : 0.0 ;
202- double y = ((Boolean ) literalValue ) ? 1.0 : 0.0 ;
203-
204- return TruthnessUtils .getEqualityTruthness (x , y );
205200 }
201+
202+ double x = ((Boolean ) rowValue ) ? 1.0 : 0.0 ;
203+ double y = ((Boolean ) literalValue ) ? 1.0 : 0.0 ;
204+
205+ return TruthnessUtils .getEqualityTruthness (x , y );
206206 }
207207
208208 private Truthness compareUuid (Object rowValue , Object literalValue , ComparisonType comparisonType ) {
209209 if (comparisonType != ComparisonType .EQUALS ) {
210210 throw new IllegalArgumentException ("Unsupported operator for UUID literals: " + comparisonType );
211- } else {
212- return TruthnessUtils .getEqualityTruthness ((UUID ) rowValue , (UUID ) literalValue );
213211 }
212+
213+ return TruthnessUtils .getEqualityTruthness ((UUID ) rowValue , (UUID ) literalValue );
214214 }
215215
216216 private static boolean isTemporalType (Object rowValue ) {
@@ -226,7 +226,7 @@ private Truthness compareTemporal(Object rowValue, Object literalValue, Comparis
226226
227227 return getTruthnessForNumeric (comparisonType , x , y );
228228 } catch (Exception e ) {
229- return FALSE_TRUTHNESS ;
229+ throw new IllegalArgumentException ( "Failed to compare temporal values: " + e . getMessage (), e ) ;
230230 }
231231 }
232232
@@ -350,23 +350,26 @@ private static boolean isCqlDuration(Object rowValue) {
350350 }
351351 }
352352
353- private Truthness compareDuration (Object rowValue , Object literalValue , ComparisonType comparisonType ) {
353+ private Truthness compareDuration (TemporalAmount rowValue , Object literalValue , ComparisonType comparisonType ) {
354354 if (comparisonType != ComparisonType .EQUALS ) {
355355 throw new IllegalArgumentException ("Unsupported operator for duration literals: " + comparisonType );
356- } else {
357- TemporalAmount duration = (TemporalAmount ) rowValue ;
358- long months = duration .get (ChronoUnit .MONTHS );
359- long days = duration .get (ChronoUnit .DAYS );
360- long nanos = duration .get (ChronoUnit .NANOS );
361-
362- CqlDurationLiteral literalDurationValue = CqlDurationLiteralParser .parse ((String ) literalValue );
363-
364- return TruthnessUtils .buildAndAggregationTruthness (
365- TruthnessUtils .getEqualityTruthness (months , literalDurationValue .months ),
366- TruthnessUtils .getEqualityTruthness (days , literalDurationValue .days ),
367- TruthnessUtils .getEqualityTruthness (nanos , literalDurationValue .nanos )
368- );
369356 }
357+
358+ long months = rowValue .get (ChronoUnit .MONTHS );
359+ long days = rowValue .get (ChronoUnit .DAYS );
360+ long nanos = rowValue .get (ChronoUnit .NANOS );
361+
362+ CqlDurationLiteral literalDurationValue = CqlDurationLiteralParser .parse ((String ) literalValue );
363+
364+ Truthness monthsTruthness = TruthnessUtils .getEqualityTruthness (months , literalDurationValue .months );
365+ Truthness daysTruthness = TruthnessUtils .getEqualityTruthness (days , literalDurationValue .days );
366+ Truthness nanosTruthness = TruthnessUtils .getEqualityTruthness (nanos , literalDurationValue .nanos );
367+
368+ return TruthnessUtils .buildAndAggregationTruthness (
369+ monthsTruthness ,
370+ daysTruthness ,
371+ nanosTruthness
372+ );
370373 }
371374
372375 private Truthness any (Object value , List <?> candidates ) {
0 commit comments