@@ -620,33 +620,31 @@ private static boolean valuesMatch(Object queryValue, Object defaultValue, Field
620620 */
621621 @ SuppressWarnings ("unchecked" )
622622 private static boolean defaultValueSatisfiesGreaterThan (Object defaultValue , Object queryValue , boolean orEqualTo ) {
623- try {
624- if (defaultValue instanceof Comparable && queryValue .getClass ().isAssignableFrom (defaultValue .getClass ())) {
625- Comparable <Object > defaultComp = (Comparable <Object >) defaultValue ;
626- int comparison = defaultComp .compareTo (queryValue );
627- return orEqualTo ? comparison >= 0 : comparison > 0 ;
628- }
629- } catch (ClassCastException e ) {
630- // If comparison fails, assume default doesn't satisfy the condition
623+ // If types don't match, can't compare
624+ if (!defaultValue .getClass ().equals (queryValue .getClass ())) {
625+ return false ;
631626 }
632- return false ;
627+
628+ // Both are the same type; cast and compare
629+ Comparable <Object > defaultComp = (Comparable <Object >) defaultValue ;
630+ int comparison = defaultComp .compareTo (queryValue );
631+ return orEqualTo ? comparison >= 0 : comparison > 0 ;
633632 }
634633
635634 /**
636635 * Check if the default value satisfies a less-than condition
637636 */
638637 @ SuppressWarnings ("unchecked" )
639638 private static boolean defaultValueSatisfiesLessThan (Object defaultValue , Object queryValue , boolean orEqualTo ) {
640- try {
641- if (defaultValue instanceof Comparable && queryValue .getClass ().isAssignableFrom (defaultValue .getClass ())) {
642- Comparable <Object > defaultComp = (Comparable <Object >) defaultValue ;
643- int comparison = defaultComp .compareTo (queryValue );
644- return orEqualTo ? comparison <= 0 : comparison < 0 ;
645- }
646- } catch (ClassCastException e ) {
647- // If comparison fails, assume default doesn't satisfy the condition
639+ // If types don't match, can't compare
640+ if (!defaultValue .getClass ().equals (queryValue .getClass ())) {
641+ return false ;
648642 }
649- return false ;
643+
644+ // Both are the same type; cast and compare
645+ Comparable <Object > defaultComp = (Comparable <Object >) defaultValue ;
646+ int comparison = defaultComp .compareTo (queryValue );
647+ return orEqualTo ? comparison <= 0 : comparison < 0 ;
650648 }
651649
652650 /**
0 commit comments