jhipster / jhipster/prettier-java

Format record properties equivalent to class fields

Open
#520 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
120
Avg merge
1d 14h
Merged PRs (30d)
27

Description

**Prettier-Java 1.6.0**

```sh
--print-width 80
```

**Input:**

```java
public record PolicyDto(
@NotNull
@Pattern(regexp = "\\d{10}")
String policyNumber,

@NotEmpty List<@NotNull @Valid ContractRelationDto> contractRelations,

@NotNull
@JsonSerialize(using = ContractStateSerializer.class)
@Schema(type = "integer", description = "some description")
ContractState contractState
) {}
```

**Output:**

```java
public record PolicyDto(
@NotNull @Pattern(regexp = "\\d{10}") String policyNumber,

@NotEmpty List<@NotNull @Valid ContractRelationDto> contractRelations,

@NotNull
@JsonSerialize(using = ContractStateSerializer.class)
@Schema(type = "integer", description = "some description")
ContractState contractState
) {}
```

**Expected behavior:**
```java
public record PolicyDto(
@NotNull
@Pattern(regexp = "\\d{10}")
String policyNumber,

@NotEmpty
List<@NotNull @Valid ContractRelationDto> contractRelations,

@NotNull
@JsonSerialize(using = ContractStateSerializer.class)
@Schema(type = "integer", description = "some description")
ContractState contractState
) {}
```
Format document properties equivalent to class fields. For this, each annotation needs to be put on a separate line (regardless of whether the print-width is exceeded).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.