Enum Class UnknownKeyPolicy

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

public enum UnknownKeyPolicy extends Enum<UnknownKeyPolicy>
What to do about configuration keys that no metadata on the project classpath describes.

This is deliberately separate from FailurePolicy. A deprecated property is a fact stated by the metadata, whereas an unrecognised key is only an absence of evidence: the key may have been removed from Spring Boot, or it may be read by application code the migrator cannot see. Folding the two together would let an advisory finding break builds that were configured to fail only on real deprecations.

  • Enum Constant Details

    • OFF

      public static final UnknownKeyPolicy OFF
      Do not look for unrecognised keys at all.
    • REPORT

      public static final UnknownKeyPolicy REPORT
      Report unrecognised keys without ever failing the build.
    • FAIL

      public static final UnknownKeyPolicy FAIL
      Report unrecognised keys and fail the build when any remains.
  • Method Details

    • values

      public static UnknownKeyPolicy[] 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 UnknownKeyPolicy 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 UnknownKeyPolicy 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 OFF
      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
    • isEnabled

      public boolean isEnabled()
      Returns whether the detector should run.
      Returns:
      whether unrecognised keys are looked for
    • 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