Class Condition

java.lang.Object
org.forgerock.openig.util.Condition

public final class Condition extends Object
Hold a condition with a label.
  • Field Details

    • TYPE

      public static final org.forgerock.openig.model.type.UnionTypeDefinition TYPE
      The TypeDefinition of a condition.
    • ALWAYS_TRUE

      public static final Condition ALWAYS_TRUE
      An always true condition.
    • ALWAYS_FALSE

      public static final Condition ALWAYS_FALSE
      An always false condition.
    • ALWAYS_TRUE_DEFAULT

      public static final org.forgerock.openig.model.component.UnionDefaultValue ALWAYS_TRUE_DEFAULT
    • ALWAYS_FALSE_DEFAULT

      public static final org.forgerock.openig.model.component.UnionDefaultValue ALWAYS_FALSE_DEFAULT
  • Constructor Details

    • Condition

      public Condition(Expression<Boolean> expression, String label)
      Create a new Condition.
      Parameters:
      expression - the expression which will be evaluated
      label - its associated label
    • Condition

      public Condition(String expression) throws ExpressionException
      Creates a new condition.
      Parameters:
      expression - the expression that yield the condition
      Throws:
      ExpressionException
  • Method Details

    • condition

      public static Function<JsonValue,Condition,JsonValueException> condition(Bindings initialBindings)
      Maps a JsonValue to Condition. Three forms of condition are allowed:
      • Static boolean, such as: "myCondition": true
      • Inline expression, such as "myCondition": "${true}"
      • Labeled expression, such as "myCondition": {"expression": "${true}", "label": "..."}

      Usage: Condition condition = jsonValue.as(condition(initialBindings()))

      Parameters:
      initialBindings - The Bindings that will be used to evaluate the label at configuration time and as Expression's initial binding.
      Returns:
      The JsonValue to Condition mapper.
    • test

      public Promise<Boolean,NeverThrowsException> test(Bindings bindings)
      Test the condition. Guaranteed to never throw RuntimeException synchronously.
      Parameters:
      bindings - the bindings to pass to the underlying expression
      Returns:
      a promise of a boolean result
    • label

      public String label()
      Returns the label of this condition.
      Returns:
      the label of this condition