This commit is contained in:
Phillip Webb
2015-07-16 12:56:49 -07:00
parent 4405ae4eaf
commit 728e64b929
19 changed files with 136 additions and 113 deletions

View File

@@ -210,10 +210,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean deprecated = hasDeprecateAnnotation(getter)
|| hasDeprecateAnnotation(setter)
|| hasDeprecateAnnotation(element);
this.metadataCollector.add(ItemMetadata
.newProperty(prefix, name, dataType, sourceType, null,
description, defaultValue,
deprecated ? new ItemDeprecation() : null));
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
dataType, sourceType, null, description, defaultValue,
(deprecated ? new ItemDeprecation() : null)));
}
}
}
@@ -240,10 +239,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
Object defaultValue = fieldValues.get(name);
boolean deprecated = hasDeprecateAnnotation(field)
|| hasDeprecateAnnotation(element);
this.metadataCollector.add(ItemMetadata
.newProperty(prefix, name, dataType, sourceType, null,
description, defaultValue,
deprecated ? new ItemDeprecation() : null));
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
dataType, sourceType, null, description, defaultValue,
(deprecated ? new ItemDeprecation() : null)));
}
}
}

View File

@@ -37,7 +37,7 @@ public class ItemDeprecation {
}
public String getReason() {
return reason;
return this.reason;
}
public void setReason(String reason) {
@@ -45,7 +45,7 @@ public class ItemDeprecation {
}
public String getReplacement() {
return replacement;
return this.replacement;
}
public void setReplacement(String replacement) {
@@ -54,26 +54,42 @@ public class ItemDeprecation {
@Override
public String toString() {
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", " +
"replacement='" + this.replacement + '\'' + '}';
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", "
+ "replacement='" + this.replacement + '\'' + '}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ItemDeprecation that = (ItemDeprecation) o;
if (reason != null ? !reason.equals(that.reason) : that.reason != null) return false;
return !(replacement != null ? !replacement.equals(that.replacement) : that.replacement != null);
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ItemDeprecation other = (ItemDeprecation) o;
return nullSafeEquals(this.reason, other.reason)
&& nullSafeEquals(this.replacement, other.replacement);
}
@Override
public int hashCode() {
int result = reason != null ? reason.hashCode() : 0;
result = 31 * result + (replacement != null ? replacement.hashCode() : 0);
int result = nullSafeHashCode(this.reason);
result = 31 * result + nullSafeHashCode(this.replacement);
return result;
}
private boolean nullSafeEquals(Object o1, Object o2) {
if (o1 == o2) {
return true;
}
if (o1 == null || o2 == null) {
return false;
}
return o1.equals(o2);
}
private int nullSafeHashCode(Object o) {
return (o == null ? 0 : o.hashCode());
}
}

View File

@@ -97,7 +97,7 @@ public class ItemMetadata implements Comparable<ItemMetadata> {
}
public ItemDeprecation getDeprecation() {
return deprecation;
return this.deprecation;
}
@Override

View File

@@ -221,7 +221,8 @@ public class JsonMarshaller {
JSONObject deprecationJsonObject = object.getJSONObject("deprecation");
ItemDeprecation deprecation = new ItemDeprecation();
deprecation.setReason(deprecationJsonObject.optString("reason", null));
deprecation.setReplacement(deprecationJsonObject.optString("replacement", null));
deprecation.setReplacement(deprecationJsonObject.optString("replacement",
null));
return deprecation;
}
return (object.optBoolean("deprecated") ? new ItemDeprecation() : null);