Add support for deprecation level
This commit ensures that deprecation level set in manual metadata is properly merged in the generated one. Closes gh-9449
This commit is contained in:
@@ -124,6 +124,9 @@ public class ConfigurationMetadata {
|
||||
if (deprecation.getReplacement() != null) {
|
||||
matchingDeprecation.setReplacement(deprecation.getReplacement());
|
||||
}
|
||||
if (deprecation.getLevel() != null) {
|
||||
matchingDeprecation.setLevel(deprecation.getLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,12 +28,20 @@ public class ItemDeprecation {
|
||||
|
||||
private String replacement;
|
||||
|
||||
private String level;
|
||||
|
||||
public ItemDeprecation() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public ItemDeprecation(String reason, String replacement) {
|
||||
this(reason, replacement, null);
|
||||
}
|
||||
|
||||
public ItemDeprecation(String reason, String replacement, String level) {
|
||||
this.reason = reason;
|
||||
this.replacement = replacement;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
@@ -52,10 +60,19 @@ public class ItemDeprecation {
|
||||
this.replacement = replacement;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", "
|
||||
+ "replacement='" + this.replacement + '\'' + '}';
|
||||
+ "replacement='" + this.replacement + '\'' + ", "
|
||||
+ "level='" + this.level + '\'' + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,13 +85,15 @@ public class ItemDeprecation {
|
||||
}
|
||||
ItemDeprecation other = (ItemDeprecation) o;
|
||||
return nullSafeEquals(this.reason, other.reason)
|
||||
&& nullSafeEquals(this.replacement, other.replacement);
|
||||
&& nullSafeEquals(this.replacement, other.replacement)
|
||||
&& nullSafeEquals(this.level, other.level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = nullSafeHashCode(this.reason);
|
||||
result = 31 * result + nullSafeHashCode(this.replacement);
|
||||
result = 31 * result + nullSafeHashCode(this.level);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ class JsonConverter {
|
||||
if (deprecation != null) {
|
||||
jsonObject.put("deprecated", true); // backward compatibility
|
||||
JSONObject deprecationJsonObject = new JSONObject();
|
||||
if (deprecation.getLevel() != null) {
|
||||
deprecationJsonObject.put("level", deprecation.getLevel());
|
||||
}
|
||||
if (deprecation.getReason() != null) {
|
||||
deprecationJsonObject.put("reason", deprecation.getReason());
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ public class JsonMarshaller {
|
||||
if (object.has("deprecation")) {
|
||||
JSONObject deprecationJsonObject = object.getJSONObject("deprecation");
|
||||
ItemDeprecation deprecation = new ItemDeprecation();
|
||||
deprecation.setLevel(deprecationJsonObject.optString("level", null));
|
||||
deprecation.setReason(deprecationJsonObject.optString("reason", null));
|
||||
deprecation
|
||||
.setReplacement(deprecationJsonObject.optString("replacement", null));
|
||||
|
||||
Reference in New Issue
Block a user