Interface StringComparableEnum

All Known Implementing Classes:
Condition.VarOperator, Statement.VarEffect

public interface StringComparableEnum
Interface for enums that can be compared and retrieved by string value.

Provides utility methods for case-insensitive string matching and conversion.

Since:
2025-02-28
Author:
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends Enum<T> & StringComparableEnum>
    T
    fromString(String value, Class<T> enumClass)
    Returns the enum constant matching the given string value (case-insensitive).
    Returns the string value associated with the enum constant.
    static boolean
    isValid(String value, Class<? extends Enum<?>> enumClass)
    Checks if the given string matches any value in the enum (case-insensitive).
  • Method Details

    • getValue

      String getValue()
      Returns the string value associated with the enum constant.
      Returns:
      the string value
    • isValid

      static boolean isValid(String value, Class<? extends Enum<?>> enumClass)
      Checks if the given string matches any value in the enum (case-insensitive).
      Parameters:
      value - the string to check
      enumClass - the enum class
      Returns:
      true if a match is found, false otherwise
    • fromString

      static <T extends Enum<T> & StringComparableEnum> T fromString(String value, Class<T> enumClass)
      Returns the enum constant matching the given string value (case-insensitive).
      Type Parameters:
      T - the enum type
      Parameters:
      value - the string value to match
      enumClass - the enum class
      Returns:
      the matching enum constant
      Throws:
      IllegalArgumentException - if no match is found