google-java-format
google-java-format copied to clipboard
Records with annotations on components are formatted pretty badly
Example output by google-java-format on a record:
public record MyRecord(
@NotNull String firstName,
String lastName,
@NotEmpty List<String> friends,
@MyAnnotation(
propA = "The brown fox jumps over the lazy cat......",
propB = 11,
type = java.lang.Object.class)
@HelloWorld
String hello,
String world,
@Positive int numberA,
@MyAnnotation(propA = "The brown fox jumps over the lazy cat", type = java.lang.Object.class)
@HelloWorld
String hello) {}
Compare to if it was a class:
public class MyClass {
@NotNull String firstName;
String lastName;
@NotEmpty List<String> friends;
@MyAnnotation(
propA = "The brown fox jumps over the lazy cat......",
propB = 11,
type = Object.class)
@HelloWorld
String hello;
String world;
@Positive int numberA;
@MyAnnotation(propA = "The brown fox jumps over the lazy cat", type = Object.class)
@HelloWorld
String hello;
}
Yes, in records it looks awful!
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public record Game(
@JsonProperty("accounting_group") @JsonPropertyDescription("The accounting group of the game.")
String accountingGroup,
@JsonProperty("accumulating")
@JsonPropertyDescription("Marks which games with accumulating bonuses.")
Boolean accumulating,
@JsonProperty("bonus_buy") @JsonPropertyDescription("Games with purchasable bonuses.")
Boolean bonusBuy,
@JsonProperty("category")
@JsonPropertyDescription(
"Game's category. Allowed values: slots, roulette, card, "
+ "casual, lottery, poker, craps, video_poker")
String category,
@JsonProperty("hd") @JsonPropertyDescription("HD format games.") Boolean hd,
@JsonProperty("hit_rate")
@JsonPropertyDescription(
"Frequency of wins per 100 bets. The higher, the hit rate the lower the volatility "
+ "rating, and vice versa. Positive value. For slots only. "
+ "Match pattern: ^\\d{1,18}(\\.\\d{1,12})?$")
String hitRate,
@JsonProperty("params") @JsonPropertyDescription("Game's custom parameters.")
Map<String, String> params) {}
Can we expect any changes on this?
Same question...
Same here, hope it can be formatted as fields in a general class with same intents, and allow whitespce lines between fields.