Enum ValidWhenComparison

java.lang.Object
java.lang.Enum<ValidWhenComparison>
org.apache.struts.validator.validwhen.ValidWhenComparison
All Implemented Interfaces:
Serializable, Comparable<ValidWhenComparison>, java.lang.constant.Constable

public enum ValidWhenComparison extends Enum<ValidWhenComparison>
Enum for comparing two values.
Since:
Struts 1.4.1
Author:
Graff Stefan
  • Enum Constant Details

  • Method Details

    • values

      public static ValidWhenComparison[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ValidWhenComparison valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getComp

      public static ValidWhenComparison getComp(int tokenNum)
      Get the ValidWhenComparison for given token-number.
      Parameters:
      tokenNum - the token-number
      Returns:
      the ValidWhenComparison or null when not found
    • compareWithNull

      protected boolean compareWithNull(Object v1, Object v2)
      Method to compare two values where at least one of them is null.
      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      true or false depending of the ValidWhenComparison
    • compareTo

      protected <T extends Comparable<T>> boolean compareTo(T v1, T v2)
      Method to compare two values, neither of which is null.
      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      true or false depending of the ValidWhenComparison
    • compareTo

      protected abstract boolean compareTo(int compareTo)
      Method for the correct interpretation of the return-value of compareTo, depending on ValidWhenComparison.
      Parameters:
      compareTo - the return-value of compareTo
      Returns:
      true or false depending of the ValidWhenComparison
    • compare

      public boolean compare(ValidWhenResult<?> v1, ValidWhenResult<?> v2)
      Compares two values with consideration of ValidWhenComparison.

      Following the comparing-steps:

      1. Tests whether at least one value is null. If so, then it is only possible to compare for (non)-equality.
      2. Try to convert both values into numbers and compares them.
      3. Compares both values as Strings.
      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      true or false depending of the ValidWhenComparison