diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7a853cf..0d24c6c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -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 \ No newline at end of file + - 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 diff --git a/processor/src/main/java/io/jonasg/bob/definitions/TypeDefinition.java b/processor/src/main/java/io/jonasg/bob/definitions/TypeDefinition.java index 5223689..0feb30f 100644 --- a/processor/src/main/java/io/jonasg/bob/definitions/TypeDefinition.java +++ b/processor/src/main/java/io/jonasg/bob/definitions/TypeDefinition.java @@ -59,8 +59,8 @@ public List 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); @@ -75,6 +75,12 @@ public List 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(); }