Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: danielnorberg/auto-matter
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.24.0
Choose a base ref
...
head repository: danielnorberg/auto-matter
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 2,040 additions and 417 deletions.
  1. +4 −4 .circleci/config.yml
  2. BIN .mvn/wrapper/maven-wrapper.jar
  3. +18 −2 .mvn/wrapper/maven-wrapper.properties
  4. +3 −3 README.md
  5. +1 −1 annotation/pom.xml
  6. +2 −2 bom/pom.xml
  7. +9 −14 dependencies/pom.xml
  8. +11 −11 example/pom.xml
  9. +3 −3 example/spotbugsexclude.xml
  10. +32 −0 example/src/main/java/io/norberg/automatter/example/NullableCollectionExample.java
  11. +1 −1 gson/pom.xml
  12. +1 −1 jackson-it.sh
  13. +1 −1 jackson/pom.xml
  14. +1 −1 jackson/src/main/java/io/norberg/automatter/jackson/AutoMatterAnnotationIntrospector.java
  15. +6 −6 jackson/src/main/java/io/norberg/automatter/jackson/AutoMatterResolver.java
  16. +15 −7 jackson/src/main/java/io/norberg/automatter/jackson/ValueTypeCache.java
  17. +20 −0 jackson/src/test/java/io/norberg/automatter/jackson/AutoMatterModuleTest.java
  18. +8 −0 jackson/src/test/java/io/norberg/automatter/jackson/GenericFoo.java
  19. +111 −113 mvnw
  20. +205 −182 mvnw.cmd
  21. +30 −25 pom.xml
  22. +1 −11 processor/pom.xml
  23. +58 −16 processor/src/main/java/io/norberg/automatter/processor/AutoMatterProcessor.java
  24. +68 −5 processor/src/main/java/io/norberg/automatter/processor/Descriptor.java
  25. +577 −0 processor/src/main/java/io/norberg/automatter/processor/Inflector.java
  26. +32 −0 processor/src/test/java/io/norberg/automatter/AutoMatterProcessorTest.java
  27. +3 −3 processor/src/test/resources/expected/NullableCollectionFieldsBuilder.java
  28. +112 −0 processor/src/test/resources/expected/inheritance/DefaultMethodOverrideSubTypeBuilder.java
  29. +131 −0 processor/src/test/resources/expected/inheritance/DefaultMethodOverrideSuperTypeBuilder.java
  30. +147 −0 processor/src/test/resources/expected/inheritance/InheritingPackageBuilder.java
  31. +97 −0 processor/src/test/resources/expected/inheritance/OtherPackageNestedInterfaceBuilder.java
  32. +12 −0 processor/src/test/resources/good/inheritance/DefaultMethodOverrideSubType.java
  33. +11 −0 processor/src/test/resources/good/inheritance/DefaultMethodOverrideSuperType.java
  34. +8 −0 processor/src/test/resources/good/inheritance/InheritingPackage.java
  35. +11 −0 processor/src/test/resources/good/inheritance/OtherPackage.java
  36. +22 −1 record-test/pom.xml
  37. +13 −0 record-test/src/test/java/io/norberg/automatter/RecordProcessingTest.java
  38. +101 −1 record-test/src/test/resources/expected/BazRecordBuilder.java
  39. +65 −0 record-test/src/test/resources/expected/FoobarRecordWithMethodBuilder.java
  40. +29 −2 record-test/src/test/resources/good/BazRecordContainer.java
  41. +11 −0 record-test/src/test/resources/good/FoobarRecordWithMethod.java
  42. +1 −1 test/pom.xml
  43. +16 −0 test/src/test/java/io/norberg/automatter/other/InheritenceR1.java
  44. +7 −0 test/src/test/java/io/norberg/automatter/test/NullableListFieldBuilderTest.java
  45. +25 −0 test/src/test/java/io/norberg/automatter/test/OtherPackageInheritanceTest.java
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ version: 2.1
jobs:
build:
docker:
- image: cimg/openjdk:11.0.13
- image: cimg/openjdk:17.0.9
steps:
- checkout
# Cache deps
@@ -27,7 +27,7 @@ jobs:

test-release:
docker:
- image: cimg/openjdk:11.0.13
- image: cimg/openjdk:17.0.9
steps:
- checkout
- restore_cache:
@@ -74,12 +74,12 @@ jobs:
# 2. Compile examples
- run: ./mvnw -B -V clean test -pl example -Dfmt.skip=true
# 3. Compile and run tests
- run: ./mvnw -B -V clean test -pl test -Dfmt.skip=true
- run: ./mvnw -B -V clean test -pl test,record-test -Dfmt.skip=true

jackson-it:
parallelism: 4
docker:
- image: cimg/openjdk:11.0.13
- image: cimg/openjdk:17.0.9
steps:
- attach_workspace:
at: .
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
20 changes: 18 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ out.println("foobar: " + foobar);
<dependency>
<groupId>io.norberg</groupId>
<artifactId>auto-matter</artifactId>
<version>0.19.0</version>
<version>0.26.2</version>
<scope>provided</scope>
</dependency>
```
@@ -125,7 +125,7 @@ var foobar = ComplexFoobarBuilder.builder()
<dependency>
<groupId>io.norberg</groupId>
<artifactId>auto-matter-jackson</artifactId>
<version>0.19.0</version>
<version>0.26.2</version>
</dependency>
```

@@ -152,7 +152,7 @@ the `AutoMatterModule` is not needed as Jackson supports Records natively since
<dependency>
<groupId>io.norberg</groupId>
<artifactId>auto-matter-gson</artifactId>
<version>0.19.0</version>
<version>0.26.2</version>
</dependency>
```

2 changes: 1 addition & 1 deletion annotation/pom.xml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<parent>
<artifactId>auto-matter-parent</artifactId>
<groupId>io.norberg</groupId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

4 changes: 2 additions & 2 deletions bom/pom.xml
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@
<parent>
<groupId>io.norberg</groupId>
<artifactId>auto-matter-parent</artifactId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
</parent>

<artifactId>auto-matter-bom</artifactId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
<packaging>pom</packaging>

<dependencyManagement>
23 changes: 9 additions & 14 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@
<parent>
<groupId>io.norberg</groupId>
<artifactId>auto-matter-parent</artifactId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
</parent>

<artifactId>auto-matter-dependencies</artifactId>
<packaging>pom</packaging>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>

<dependencyManagement>
<dependencies>
@@ -30,7 +30,7 @@
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.24.0</version>
<version>3.25.6</version>
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
@@ -47,15 +47,10 @@
<artifactId>javapoet</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-common</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<version>2.10.1</version>
</dependency>

<!--conflict resolution-->
@@ -67,12 +62,12 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.1.3</version>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>com.google.testing.compile</groupId>
@@ -82,17 +77,17 @@
<dependency>
<groupId>com.google.auto</groupId>
<artifactId>auto-common</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>2.11.0</version>
<version>2.23.0</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.21.2</version>
<version>3.40.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
22 changes: 11 additions & 11 deletions example/pom.xml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
<parent>
<groupId>io.norberg</groupId>
<artifactId>auto-matter-parent</artifactId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
</parent>

<artifactId>auto-matter-example</artifactId>
@@ -27,7 +27,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version>
<version>3.11.0</version>
<configuration>
<source>8</source>
<target>8</target>
@@ -41,7 +41,7 @@
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.11.0</version>
<version>2.23.0</version>
</path>
<path>
<groupId>io.norberg</groupId>
@@ -64,7 +64,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version>
<version>3.11.0</version>
<configuration>
<source>8</source>
<target>8</target>
@@ -89,7 +89,7 @@
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.11.0</version>
<version>2.23.0</version>
</path>
<path>
<groupId>io.norberg</groupId>
@@ -110,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<version>3.6.2</version>
<configuration>
<source>8</source>
</configuration>
@@ -126,12 +126,12 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.5.3.0</version>
<version>4.8.1.0</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.5.3</version>
<version>4.8.1</version>
</dependency>
</dependencies>
<configuration>
@@ -165,7 +165,7 @@
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.13.1</version>
<version>2.15.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -201,12 +201,12 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
6 changes: 3 additions & 3 deletions example/spotbugsexclude.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
<!-- Learn about findbugs filters: http://findbugs.sourceforge.net/manual/filter.html -->
<Match>
<!-- https://github.com/spotbugs/spotbugs/issues/1219-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.norberg.automatter.example;

import static java.lang.System.out;

import io.norberg.automatter.AutoMatter;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;

public class NullableCollectionExample {

@AutoMatter
interface NullableCollectionFoobar {
List<String> oxen();

@Nullable
List<String> cows();

@Nullable
Map<String, Integer> ages();
}

public static void main(final String... args) throws IOException {
NullableCollectionFoobar foobar = new NullableCollectionFoobarBuilder().addOx("moo!").build();

out.println("oxen: " + foobar.oxen());
out.println("cows: " + foobar.cows());
out.println("ages: " + foobar.ages());
out.println("foobar: " + foobar);
}
}
2 changes: 1 addition & 1 deletion gson/pom.xml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<parent>
<artifactId>auto-matter-parent</artifactId>
<groupId>io.norberg</groupId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

2 changes: 1 addition & 1 deletion jackson-it.sh
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ function lookup_jackson_versions0() {
jq -r '[.response.docs | .[].v |
{p: split("."), v:.} |
{major:.p[0] | tonumber, minor: .p[1] | tonumber, v:.v} |
select(.major >= 2 and .minor >= 4)] |
select(.major >= 2 and .minor >= 7)] |
sort_by([.major, .minor, .v]) |
.[].v' |
grep -v rc | # omit rc versions
2 changes: 1 addition & 1 deletion jackson/pom.xml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<parent>
<artifactId>auto-matter-parent</artifactId>
<groupId>io.norberg</groupId>
<version>0.24.0</version>
<version>0.26.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ public JavaType refineSerializationType(

// Refine only if baseType is an interface explicitly annotated with @AutoMatter
if (cls.isInterface() && cls.isAnnotationPresent(AutoMatter.class)) {
return typeCache.resolveValueType(cls);
return typeCache.resolveValueType(baseType);
}
return super.refineSerializationType(config, a, baseType);
}
Original file line number Diff line number Diff line change
@@ -16,26 +16,26 @@ class AutoMatterResolver extends AbstractTypeResolver {

@SuppressWarnings("deprecation")
public JavaType resolveAbstractType(DeserializationConfig config, JavaType type) {
return resolveAbstractType0(config, type.getRawClass());
return resolveAbstractType0(config, type);
}

public JavaType resolveAbstractType(DeserializationConfig config, BeanDescription typeDesc) {
return resolveAbstractType0(config, typeDesc.getBeanClass());
return resolveAbstractType0(config, typeDesc.getType());
}

private JavaType resolveAbstractType0(final DeserializationConfig config, final Class<?> cls) {
if (!cls.isInterface()) {
private JavaType resolveAbstractType0(final DeserializationConfig config, JavaType type) {
if (!type.isInterface()) {
// Only resolve interface style @AutoMatter types.
return null;
}

final AutoMatter annotation = cls.getAnnotation(AutoMatter.class);
final AutoMatter annotation = type.getRawClass().getAnnotation(AutoMatter.class);
if (annotation == null) {
// This was not an @AutoMatter type.
return null;
}

// Resolve from cache.
return typeCache.resolveValueType(cls);
return typeCache.resolveValueType(type);
}
}
Loading