|
|
@@ -23,34 +23,34 @@ public interface DeprecationHandler {
|
|
|
*/
|
|
|
DeprecationHandler THROW_UNSUPPORTED_OPERATION = new DeprecationHandler() {
|
|
|
@Override
|
|
|
- public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName, String replacedWith) {
|
|
|
+ public void logReplacedField(String parserName, Supplier<XContentLocation> location, String oldName, String replacedName) {
|
|
|
if (parserName != null) {
|
|
|
throw new UnsupportedOperationException("deprecated fields not supported in [" + parserName + "] but got ["
|
|
|
- + usedName + "] at [" + location.get() + "] which is a deprecated name for [" + replacedWith + "]");
|
|
|
+ + oldName + "] at [" + location.get() + "] which is a deprecated name for [" + replacedName + "]");
|
|
|
} else {
|
|
|
throw new UnsupportedOperationException("deprecated fields not supported here but got ["
|
|
|
- + usedName + "] which is a deprecated name for [" + replacedWith + "]");
|
|
|
+ + oldName + "] which is a deprecated name for [" + replacedName + "]");
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
- public void usedDeprecatedName(String parserName, Supplier<XContentLocation> location, String usedName, String modernName) {
|
|
|
+ public void logRenamedField(String parserName, Supplier<XContentLocation> location, String oldName, String currentName) {
|
|
|
if (parserName != null) {
|
|
|
throw new UnsupportedOperationException("deprecated fields not supported in [" + parserName + "] but got ["
|
|
|
- + usedName + "] at [" + location.get() + "] which has been replaced with [" + modernName + "]");
|
|
|
+ + oldName + "] at [" + location.get() + "] which has been replaced with [" + currentName + "]");
|
|
|
} else {
|
|
|
throw new UnsupportedOperationException("deprecated fields not supported here but got ["
|
|
|
- + usedName + "] which has been replaced with [" + modernName + "]");
|
|
|
+ + oldName + "] which has been replaced with [" + currentName + "]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName) {
|
|
|
+ public void logRemovedField(String parserName, Supplier<XContentLocation> location, String removedName) {
|
|
|
if (parserName != null) {
|
|
|
throw new UnsupportedOperationException("deprecated fields not supported in [" + parserName + "] but got ["
|
|
|
- + usedName + "] at [" + location.get() + "] which has been deprecated entirely");
|
|
|
+ + removedName + "] at [" + location.get() + "] which has been deprecated entirely");
|
|
|
} else {
|
|
|
throw new UnsupportedOperationException("deprecated fields not supported here but got ["
|
|
|
- + usedName + "] which has been deprecated entirely");
|
|
|
+ + removedName + "] which has been deprecated entirely");
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -60,41 +60,69 @@ public interface DeprecationHandler {
|
|
|
*/
|
|
|
DeprecationHandler IGNORE_DEPRECATIONS = new DeprecationHandler() {
|
|
|
@Override
|
|
|
- public void usedDeprecatedName(String parserName, Supplier<XContentLocation> location, String usedName, String modernName) {
|
|
|
+ public void logRenamedField(String parserName, Supplier<XContentLocation> location, String oldName, String currentName) {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName, String replacedWith) {
|
|
|
+ public void logReplacedField(String parserName, Supplier<XContentLocation> location, String oldName, String replacedName) {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName) {
|
|
|
+ public void logRemovedField(String parserName, Supplier<XContentLocation> location, String removedName) {
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Called when the provided field name matches a deprecated name for the field.
|
|
|
- * @param usedName the provided field name
|
|
|
- * @param modernName the modern name for the field
|
|
|
+ * @param oldName the provided field name
|
|
|
+ * @param currentName the modern name for the field
|
|
|
*/
|
|
|
- void usedDeprecatedName(String parserName, Supplier<XContentLocation> location, String usedName, String modernName);
|
|
|
+ void logRenamedField(String parserName, Supplier<XContentLocation> location, String oldName, String currentName);
|
|
|
|
|
|
/**
|
|
|
* Called when the provided field name matches the current field but the entire
|
|
|
* field has been marked as deprecated and another field should be used
|
|
|
- * @param usedName the provided field name
|
|
|
- * @param replacedWith the name of the field that replaced this field
|
|
|
+ * @param oldName the provided field name
|
|
|
+ * @param replacedName the name of the field that replaced this field
|
|
|
*/
|
|
|
- void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName, String replacedWith);
|
|
|
+ void logReplacedField(String parserName, Supplier<XContentLocation> location, String oldName, String replacedName);
|
|
|
|
|
|
/**
|
|
|
* Called when the provided field name matches the current field but the entire
|
|
|
* field has been marked as deprecated with no replacement
|
|
|
- * @param usedName the provided field name
|
|
|
+ * Emits a compatible api warning instead of deprecation warning when isCompatibleDeprecation is true
|
|
|
+ * @param removedName the provided field name
|
|
|
*/
|
|
|
- void usedDeprecatedField(String parserName, Supplier<XContentLocation> location, String usedName);
|
|
|
+ void logRemovedField(String parserName, Supplier<XContentLocation> location, String removedName);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see DeprecationHandler#logRenamedField(String, Supplier, String, String)
|
|
|
+ * Emits a compatible api warning instead of deprecation warning when isCompatibleDeprecation is true
|
|
|
+ */
|
|
|
+ default void logRenamedField(String parserName, Supplier<XContentLocation> location, String oldName, String currentName,
|
|
|
+ boolean isCompatibleDeprecation) {
|
|
|
+ logRenamedField(parserName, location, oldName, currentName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see DeprecationHandler#logReplacedField(String, Supplier, String, String)
|
|
|
+ * Emits a compatible api warning instead of deprecation warning when isCompatibleDeprecation is true
|
|
|
+ */
|
|
|
+ default void logReplacedField(String parserName, Supplier<XContentLocation> location, String oldName, String replacedName,
|
|
|
+ boolean isCompatibleDeprecation) {
|
|
|
+ logReplacedField(parserName, location, oldName, replacedName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see DeprecationHandler#logRemovedField(String, Supplier, String)
|
|
|
+ * Emits a compatible api warning instead of deprecation warning when isCompatibleDeprecation is true
|
|
|
+ */
|
|
|
+ default void logRemovedField(String parserName, Supplier<XContentLocation> location, String removedName,
|
|
|
+ boolean isCompatibleDeprecation) {
|
|
|
+ logRemovedField(parserName, location, removedName);
|
|
|
+ }
|
|
|
|
|
|
}
|