Package liquibase

Class ContextExpression

java.lang.Object
liquibase.ContextExpression

public class ContextExpression extends Object
Encapsulates logic for evaluating if a set of runtime contexts matches a context expression string.
  • Field Details

    • NOCONTEXTS

      public static final String NOCONTEXTS
      Pseudo-context that evaluates to true when no runtime contexts are specified.

      This can be used in context expressions to opt into stricter context-matching behaviour while keeping backward compatibility. For example, a changeset with context="!nocontexts AND specificcontext" will only be applied when at least one runtime context is provided and that context matches specificcontext. When no runtime context is specified the nocontexts pseudo-context evaluates to true, so !nocontexts evaluates to false and the changeset is skipped.

      See Also:
  • Constructor Details

    • ContextExpression

      public ContextExpression(String... contexts)
    • ContextExpression

      public ContextExpression(String contexts)
    • ContextExpression

      public ContextExpression(Collection<String> contexts)
  • Method Details

    • add

      public boolean add(String context)
    • getContexts

      public Set<String> getContexts()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • matches

      public boolean matches(Contexts runtimeContexts)
      Returns true if the passed runtime contexts match this context expression
    • isEmpty

      public boolean isEmpty()
    • matchesAll

      public static boolean matchesAll(Collection<ContextExpression> expressions, Contexts contexts)