mirror of
https://github.com/google/nomulus
synced 2026-01-07 14:05:44 +00:00
Don't override toString() on enums
It is a bad idea to override toString() on enums to return something other than the actual name of the enum. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133318012
This commit is contained in:
@@ -133,8 +133,7 @@ public class RdapJsonFormatter {
|
|||||||
this.rfc7483String = rfc7483String;
|
this.rfc7483String = rfc7483String;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getDisplayName() {
|
||||||
public String toString() {
|
|
||||||
return rfc7483String;
|
return rfc7483String;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,8 +210,7 @@ public class RdapJsonFormatter {
|
|||||||
this.rfc7483String = rfc7483String;
|
this.rfc7483String = rfc7483String;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getDisplayName() {
|
||||||
public String toString() {
|
|
||||||
return rfc7483String;
|
return rfc7483String;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -821,7 +819,7 @@ public class RdapJsonFormatter {
|
|||||||
private static ImmutableMap<String, Object> makeEvent(
|
private static ImmutableMap<String, Object> makeEvent(
|
||||||
RdapEventAction eventAction, @Nullable String eventActor, DateTime eventDate) {
|
RdapEventAction eventAction, @Nullable String eventActor, DateTime eventDate) {
|
||||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
builder.put("eventAction", eventAction.toString());
|
builder.put("eventAction", eventAction.getDisplayName());
|
||||||
if (eventActor != null) {
|
if (eventActor != null) {
|
||||||
builder.put("eventActor", eventActor);
|
builder.put("eventActor", eventActor);
|
||||||
}
|
}
|
||||||
@@ -901,7 +899,11 @@ public class RdapJsonFormatter {
|
|||||||
return FluentIterable
|
return FluentIterable
|
||||||
.from(statusValues)
|
.from(statusValues)
|
||||||
.transform(Functions.forMap(statusToRdapStatusMap, RdapStatus.OBSCURED))
|
.transform(Functions.forMap(statusToRdapStatusMap, RdapStatus.OBSCURED))
|
||||||
.transform(Functions.toStringFunction())
|
.transform(new Function<RdapStatus, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(RdapStatus status) {
|
||||||
|
return status.getDisplayName();
|
||||||
|
}})
|
||||||
.toSortedSet(Ordering.natural())
|
.toSortedSet(Ordering.natural())
|
||||||
.asList();
|
.asList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user