Skip to content

Commit

Permalink
chore(processor): add test for record support
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranVanBelle committed Apr 25, 2024
1 parent 178b842 commit 28421ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
- name: Build with Maven if records are not supported
if: ${{ matrix.java }} == 11
run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --file pom.xml
run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --file pom.xml

- name: Build with Maven if records are supported
if: ${{ matrix.java }} != 11
run: mvn -B -ntp verify --file pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public List<SetterMethodDefinition> getSetterMethods() {
for (FieldDefinition field : fields) {
String name = field.name().substring(0, 1).toUpperCase() + field.name().substring(1);
methodsWithOneParam.stream()
.filter(m -> m.name().equals(field.name()) || (m.name().equals(field.name().substring(2))
&& field.type().getKind().equals(TypeKind.BOOLEAN)))
.filter(m -> m.name().equals(field.name()) ||
isABooleanField(field, m))
.findFirst()
.map(m -> new SetterMethodDefinition(m.name(), field, m.parameters().get(0)))
.ifPresent(setters::add);
Expand All @@ -75,6 +75,12 @@ public List<SetterMethodDefinition> getSetterMethods() {
return setters;
}

private boolean isABooleanField(FieldDefinition field, MethodDefinition m) {
return field.name().startsWith("is")
&& m.name().equalsIgnoreCase(field.name().substring(2))
&& field.type().getKind().equals(TypeKind.BOOLEAN);
}

public boolean containsSetterMethods() {
return !getSetterMethods().isEmpty();
}
Expand Down

0 comments on commit 28421ef

Please sign in to comment.