Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-555.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Simplify conjure object toString implementation
links:
- https://github.com/palantir/conjure-java/pull/555
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("BinaryExample")
.append('{')
.append("binary")
.append(": ")
.append(binary)
.append('}')
.toString();
return "BinaryExample{binary: " + binary + '}';
}

public static BinaryExample of(ByteBuffer binary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("OptionalExample")
.append('{')
.append("item")
.append(": ")
.append(item)
.append('}')
.toString();
return "OptionalExample{item: " + item + '}';
}

public static OptionalExample of(ByteBuffer item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,37 +124,21 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("AliasAsMapKeyExample")
.append('{')
.append("strings")
.append(": ")
.append(strings)
.append(", ")
.append("rids")
.append(": ")
.append(rids)
.append(", ")
.append("bearertokens")
.append(": ")
.append(bearertokens)
.append(", ")
.append("integers")
.append(": ")
.append(integers)
.append(", ")
.append("safelongs")
.append(": ")
.append(safelongs)
.append(", ")
.append("datetimes")
.append(": ")
.append(datetimes)
.append(", ")
.append("uuids")
.append(": ")
.append(uuids)
.append('}')
.toString();
return "AliasAsMapKeyExample{strings: "
+ strings
+ ", rids: "
+ rids
+ ", bearertokens: "
+ bearertokens
+ ", integers: "
+ integers
+ ", safelongs: "
+ safelongs
+ ", datetimes: "
+ datetimes
+ ", uuids: "
+ uuids
+ '}';
}

private static void validateFields(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("AnyExample")
.append('{')
.append("any")
.append(": ")
.append(any)
.append('}')
.toString();
return "AnyExample{any: " + any + '}';
}

public static AnyExample of(Object any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("AnyMapExample")
.append('{')
.append("items")
.append(": ")
.append(items)
.append('}')
.toString();
return "AnyMapExample{items: " + items + '}';
}

public static AnyMapExample of(Map<String, Object> items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("BearerTokenExample")
.append('{')
.append("bearerTokenValue")
.append(": ")
.append(bearerTokenValue)
.append('}')
.toString();
return "BearerTokenExample{bearerTokenValue: " + bearerTokenValue + '}';
}

public static BearerTokenExample of(BearerToken bearerTokenValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("BinaryExample")
.append('{')
.append("binary")
.append(": ")
.append(binary)
.append('}')
.toString();
return "BinaryExample{binary: " + binary + '}';
}

public static BinaryExample of(Bytes binary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("BooleanExample")
.append('{')
.append("coin")
.append(": ")
.append(coin)
.append('}')
.toString();
return "BooleanExample{coin: " + coin + '}';
}

public static BooleanExample of(boolean coin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("CovariantListExample")
.append('{')
.append("items")
.append(": ")
.append(items)
.append(", ")
.append("externalItems")
.append(": ")
.append(externalItems)
.append('}')
.toString();
return "CovariantListExample{items: " + items + ", externalItems: " + externalItems + '}';
}

public static CovariantListExample of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("CovariantOptionalExample")
.append('{')
.append("item")
.append(": ")
.append(item)
.append(", ")
.append("setItem")
.append(": ")
.append(setItem)
.append('}')
.toString();
return "CovariantOptionalExample{item: " + item + ", setItem: " + setItem + '}';
}

public static CovariantOptionalExample of(Object item, Set<StringAliasExample> setItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("DateTimeExample")
.append('{')
.append("datetime")
.append(": ")
.append(datetime)
.append('}')
.toString();
return "DateTimeExample{datetime: " + datetime + '}';
}

public static DateTimeExample of(OffsetDateTime datetime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("DoubleExample")
.append('{')
.append("doubleValue")
.append(": ")
.append(doubleValue)
.append('}')
.toString();
return "DoubleExample{doubleValue: " + doubleValue + '}';
}

public static DoubleExample of(double doubleValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("EnumFieldExample")
.append('{')
.append("enum")
.append(": ")
.append(enum_)
.append('}')
.toString();
return "EnumFieldExample{enum: " + enum_ + '}';
}

public static EnumFieldExample of(EnumExample enum_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,13 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("ExternalLongExample")
.append('{')
.append("externalLong")
.append(": ")
.append(externalLong)
.append(", ")
.append("optionalExternalLong")
.append(": ")
.append(optionalExternalLong)
.append(", ")
.append("listExternalLong")
.append(": ")
.append(listExternalLong)
.append('}')
.toString();
return "ExternalLongExample{externalLong: "
+ externalLong
+ ", optionalExternalLong: "
+ optionalExternalLong
+ ", listExternalLong: "
+ listExternalLong
+ '}';
}

public static ExternalLongExample of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("IntegerExample")
.append('{')
.append("integer")
.append(": ")
.append(integer)
.append('}')
.toString();
return "IntegerExample{integer: " + integer + '}';
}

public static IntegerExample of(int integer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,13 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("ListExample")
.append('{')
.append("items")
.append(": ")
.append(items)
.append(", ")
.append("primitiveItems")
.append(": ")
.append(primitiveItems)
.append(", ")
.append("doubleItems")
.append(": ")
.append(doubleItems)
.append('}')
.toString();
return "ListExample{items: "
+ items
+ ", primitiveItems: "
+ primitiveItems
+ ", doubleItems: "
+ doubleItems
+ '}';
}

public static ListExample of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,41 +147,23 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("ManyFieldExample")
.append('{')
.append("string")
.append(": ")
.append(string)
.append(", ")
.append("integer")
.append(": ")
.append(integer)
.append(", ")
.append("doubleValue")
.append(": ")
.append(doubleValue)
.append(", ")
.append("optionalItem")
.append(": ")
.append(optionalItem)
.append(", ")
.append("items")
.append(": ")
.append(items)
.append(", ")
.append("set")
.append(": ")
.append(set)
.append(", ")
.append("map")
.append(": ")
.append(map)
.append(", ")
.append("alias")
.append(": ")
.append(alias)
.append('}')
.toString();
return "ManyFieldExample{string: "
+ string
+ ", integer: "
+ integer
+ ", doubleValue: "
+ doubleValue
+ ", optionalItem: "
+ optionalItem
+ ", items: "
+ items
+ ", set: "
+ set
+ ", map: "
+ map
+ ", alias: "
+ alias
+ '}';
}

private static void validateFields(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder("MapExample")
.append('{')
.append("items")
.append(": ")
.append(items)
.append('}')
.toString();
return "MapExample{items: " + items + '}';
}

public static MapExample of(Map<String, String> items) {
Expand Down
Loading