Class DeprecationCatalog
java.lang.Object
com.patbaumgartner.spring.migrator.core.DeprecationCatalog
The set of deprecated properties known to the configuration metadata on a project's
classpath, indexed so that lookups honour Spring Boot's relaxed binding.
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.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.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
-
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
-