Class EzlibLoader.Condition<T>

java.lang.Object
com.saicone.ezlib.EzlibLoader.Condition<T>
Type Parameters:
T - the type of objects that may be compared.
Enclosing class:
EzlibLoader

public static class EzlibLoader.Condition<T> extends Object
Supplied condition script evaluator.
  • Field Details

    • LESS

      public static final int LESS
      Expected value representation for number less than actual value.
      See Also:
    • LESS_OR_EQUAL

      public static final int LESS_OR_EQUAL
      Expected value representation for number less than or equal to actual value.
      See Also:
    • EQUAL

      public static final int EQUAL
      Expected value representation for number equal than actual value.
      See Also:
    • GREATER_OR_EQUAL

      public static final int GREATER_OR_EQUAL
      Expected value representation for number greater than or equal to actual value.
      See Also:
    • GREATER

      public static final int GREATER
      Expected value representation for number greater than actual value.
      See Also:
  • Constructor Details

    • Condition

      public Condition(Function<String,T> mapper, Function<T,Integer> comparator)
      Constructs a condition using the provided string mapper and type comparator.
      Parameters:
      mapper - the mapper function that convert string into required value.
      comparator - the comparator that return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the expected value.
  • Method Details

    • valueOf

      public static EzlibLoader.Condition<Boolean> valueOf(boolean bool)
      Create a condition with a defined boolean value.
      Parameters:
      bool - the value that represent the state of the condition.
      Returns:
      a newly generated condition.
    • valueOf

      public static EzlibLoader.Condition<String> valueOf(Predicate<String> condition)
      Create a condition using a string comparator.
      Parameters:
      condition - the comparator that evaluates a string.
      Returns:
      a newly generated condition.
    • valueOfByte

      public static EzlibLoader.Condition<Byte> valueOfByte(Supplier<Byte> supplier)
      Create a condition that compares a supplied byte value.
      Parameters:
      supplier - the supplier that return the expected value.
      Returns:
      a newly generated condition.
    • valueOfShort

      public static EzlibLoader.Condition<Short> valueOfShort(Supplier<Short> supplier)
      Create a condition that compares a supplied short value.
      Parameters:
      supplier - the supplier that return the expected value.
      Returns:
      a newly generated condition.
    • valueOfInteger

      public static EzlibLoader.Condition<Integer> valueOfInteger(Supplier<Integer> supplier)
      Create a condition that compares a supplied integer value.
      Parameters:
      supplier - the supplier that return the expected value.
      Returns:
      a newly generated condition.
    • valueOfLong

      public static EzlibLoader.Condition<Long> valueOfLong(Supplier<Long> supplier)
      Create a condition that compares a supplied long value.
      Parameters:
      supplier - the supplier that return the expected value.
      Returns:
      a newly generated condition.
    • valueOfFloat

      public static EzlibLoader.Condition<Float> valueOfFloat(Supplier<Float> supplier)
      Create a condition that compares a supplied float value.
      Parameters:
      supplier - the supplier that return the expected value.
      Returns:
      a newly generated condition.
    • valueOfDouble

      public static EzlibLoader.Condition<Double> valueOfDouble(Supplier<Double> supplier)
      Create a condition that compares a supplied double value.
      Parameters:
      supplier - the supplier that return the expected value.
      Returns:
      a newly generated condition.
    • getMapper

      public Function<String,T> getMapper()
      Get the mapper function that convert string into required value.
      Returns:
      a string mapper.
    • getComparator

      public Function<T,Integer> getComparator()
      Get the comparator that return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the expected value.
      Returns:
      a type comparator function.
    • eval

      public boolean eval(int expected, String s)
      Evaluate if expected result is the same after compare converted string value.
      Parameters:
      expected - the expected result of comparator function.
      s - the string to convert and evaluate.
      Returns:
      true if the expected result is the same as the actual result.