Class Compare

java.lang.Object
ortus.boxlang.runtime.operators.Compare
All Implemented Interfaces:
IOperator

public class Compare extends Object implements IOperator
Performs EQ, GT, and LT comparisons Compares numbers as numbers, compares strings case insensitive
  • Field Details

    • lenientDateComparison

      public static boolean lenientDateComparison
      Flag to allow compat to set the comparison mode for dates to loose
  • Constructor Details

    • Compare

      public Compare()
  • Method Details

    • invoke

      public static int invoke(Object left, Object right)
      Invokes the comparison
      Parameters:
      left - The left operand
      right - The right operand
      Returns:
      1 if greater than, -1 if less than, = if equal
    • invoke

      public static int invoke(Object left, Object right, boolean caseSensitive)
      Invokes the comparison
      Parameters:
      left - The left operand
      right - The right operand
      caseSensitive - Whether to compare strings case sensitive
      Returns:
      1 if greater than, -1 if less than, = if equal
    • attempt

      public static Integer attempt(Object left, Object right, boolean caseSensitive)
      Invokes the comparison
      Parameters:
      left - The left operand
      right - The right operand
      caseSensitive - Whether to compare strings case sensitive
      fail - True to throw an exception if the left and right arguments cannot be compared
      Returns:
      1 if greater than, -1 if less than, 0 if equal
    • attempt

      public static Integer attempt(Object left, Object right, boolean caseSensitive, Locale locale)
      Invokes the comparison
      Parameters:
      left - The left operand
      right - The right operand
      caseSensitive - Whether to compare strings case sensitive
      locale - The locale to use for comparison
      Returns:
      1 if greater than, -1 if less than, 0 if equal
    • invoke

      public static Integer invoke(Object left, Object right, boolean caseSensitive, boolean fail, Locale locale)
      Invokes the comparison
      Parameters:
      left - The left operand
      right - The right operand
      caseSensitive - Whether to compare strings case sensitive *
      fail - True to throw an exception if the left and right arguments cannot be compared
      locale - The locale to use for comparison
      Returns:
      1 if greater than, -1 if less than, 0 if equal. Null if fail=false and the left and right arguments cannot be compared