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 33b2fe9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 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
if: ${{ matrix.java }} == 11
run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --file pom.xml
- name: Build with Java 11
if: ${{ matrix.java == 11 }}
run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --file pom.xml

- name: Build with Java higher than 11
if: ${{ matrix.java != 11 }}
run: mvn -B -ntp verify -Dtest=\!RecordsTest.java --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 33b2fe9

Please sign in to comment.