Class DeprecationCatalog
The catalog also knows the declared type of every metadata property, which lets the
engine detect renames whose value would no longer be valid, and it resolves chained
deprecations (a -> b -> c) to their terminal replacement so that migrating
twice is a no-op.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanchangesType(String from, String to) Returns whether migratingfromtotois known to change the value type, which means the existing value is unlikely to remain valid.intReturns how many deprecated properties the catalog knows about.booleandescribesNamespace(String namespace) Returns whether the metadata describes at least one property in a namespace.static DeprecationCatalogempty()Returns an empty catalog, used when no metadata could be resolved.Looks up a deprecated property, honouring relaxed binding so thatserver.maxHttpHeaderSizematchesserver.max-http-header-size.static DeprecationCatalogfrom(Map<String, org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty> metadataProperties) Builds a catalog from raw configuration metadata properties.booleanisEmpty()Returns whether the catalog holds no metadata at all, which usually means the project classpath could not be resolved rather than that the project is clean.booleanReturns whether the metadata describes the given key, honouring the fact that aggregate properties are declared at their prefix rather than per entry.resolveReplacement(DeprecatedProperty property) Follows chained deprecations to the property a user should end up with.Returns the declared type of a property, when the metadata knows it.
-
Method Details
-
from
public static DeprecationCatalog from(Map<String, org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty> metadataProperties) Builds a catalog from raw configuration metadata properties.- Parameters:
metadataProperties- all properties known to the resolved metadata repository- Returns:
- the catalog
-
empty
Returns an empty catalog, used when no metadata could be resolved.- Returns:
- an empty catalog
-
find
Looks up a deprecated property, honouring relaxed binding so thatserver.maxHttpHeaderSizematchesserver.max-http-header-size.- Parameters:
key- the property name exactly as written in the configuration file- Returns:
- the deprecation, if the property is deprecated
-
resolveReplacement
Follows chained deprecations to the property a user should end up with.Metadata may declare
a -> bwhilebis itself deprecated in favour ofc. Migrating straight tockeeps a second migration run a no-op.- Parameters:
property- the deprecated property to resolve- Returns:
- the terminal replacement, or empty when the chain is cyclic
-
changesType
Returns whether migratingfromtotois known to change the value type, which means the existing value is unlikely to remain valid.A missing type on either side is not treated as a mismatch: the metadata simply does not say, and refusing to migrate then would block many safe renames.
- Parameters:
from- the deprecated property nameto- the replacement property name- Returns:
- whether both types are known and differ
-
typeOf
Returns the declared type of a property, when the metadata knows it.- Parameters:
key- the property name- Returns:
- the fully qualified type name
-
isKnown
Returns whether the metadata describes the given key, honouring the fact that aggregate properties are declared at their prefix rather than per entry.A
Map-typed property such aslogging.levelstands for every key written below it, and a collection-typed property such asspring.config.importstands for every indexed element. Without that rule every map entry in a project would look unrecognised.- Parameters:
key- the property name exactly as written in the configuration file- Returns:
- whether the key is backed by a metadata property
-
describesNamespace
Returns whether the metadata describes at least one property in a namespace.This is what tells an absent optional module apart from a wrong key. When Actuator is not on the classpath nothing describes
management.*, and every key a project writes there would otherwise look unrecognised.- Parameters:
namespace- the top-level namespace, such asmanagement- Returns:
- whether any known property lives under the namespace
-
isEmpty
public boolean isEmpty()Returns whether the catalog holds no metadata at all, which usually means the project classpath could not be resolved rather than that the project is clean.- Returns:
- whether no metadata was loaded
-
deprecationCount
public int deprecationCount()Returns how many deprecated properties the catalog knows about.- Returns:
- the number of deprecated properties
-