Enum Class FailurePolicy

java.lang.Object
java.lang.Enum<FailurePolicy>
com.patbaumgartner.spring.migrator.core.FailurePolicy
All Implemented Interfaces:
Serializable, Comparable<FailurePolicy>, Constable

public enum FailurePolicy extends Enum<FailurePolicy>
When a migration run should fail the build.

Replaces a plain failOnError flag, which only ever considered properties that had no replacement and so could not express the case teams actually want in CI: fail while any deprecated property remains.

  • Enum Constant Details

    • NEVER

      public static final FailurePolicy NEVER
      Report findings but always succeed.
    • MANUAL

      public static final FailurePolicy MANUAL
      Fail when a finding needs a human, either because migrating it is not provably safe or because the property has no replacement at all.
    • ANY

      public static final FailurePolicy ANY
      Fail when any deprecated property is present, including ones that were or could be migrated automatically.
  • Method Details

    • values

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

      public static FailurePolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • parse

      public static FailurePolicy parse(String value)
      Parses a policy name, ignoring case and surrounding whitespace.
      Parameters:
      value - the configured value, which may be null or blank
      Returns:
      the parsed policy, defaulting to NEVER
      Throws:
      IllegalArgumentException - if the value names no policy
    • names

      public static String names()
      Returns the accepted values, for use in error messages.
      Returns:
      a human-readable list of policy names
    • isViolatedBy

      public boolean isViolatedBy(MigrationPlan plan)
      Returns whether the plan violates this policy.
      Parameters:
      plan - the analysed plan
      Returns:
      whether the build should fail
    • describeViolation

      public String describeViolation(MigrationPlan plan)
      Describes why the policy was violated.
      Parameters:
      plan - the analysed plan
      Returns:
      a message for the build failure