├── .github
├── FUNDING.yml
└── workflows
│ ├── maven_java17.yml
│ └── maven_java21.yml
├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── LICENSE
├── README.md
├── customizing.md
├── deconstructors.md
├── mvnw
├── mvnw.cmd
├── options.md
├── pom.xml
├── record-builder-core
├── pom.xml
└── src
│ └── main
│ └── java
│ └── io
│ └── soabase
│ └── recordbuilder
│ └── core
│ ├── DeconstructorFull.java
│ ├── IgnoreDefaultMethod.java
│ ├── RecordBuilder.java
│ ├── RecordBuilderFull.java
│ ├── RecordBuilderGenerated.java
│ └── RecordInterface.java
├── record-builder-processor
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── io
│ │ └── soabase
│ │ └── recordbuilder
│ │ └── processor
│ │ ├── ClassType.java
│ │ ├── CollectionBuilderUtils.java
│ │ ├── ElementUtils.java
│ │ ├── IncludeHelper.java
│ │ ├── InitializerUtil.java
│ │ ├── InternalDeconstructorProcessor.java
│ │ ├── InternalRecordBuilderProcessor.java
│ │ ├── InternalRecordInterfaceProcessor.java
│ │ ├── OptionalType.java
│ │ ├── RecordBuilderOptions.java
│ │ ├── RecordBuilderProcessor.java
│ │ ├── RecordClassType.java
│ │ └── RecordFacade.java
│ └── resources
│ └── META-INF
│ ├── gradle
│ └── incremental.annotation.processors
│ └── services
│ └── javax.annotation.processing.Processor
├── record-builder-test
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── soabase
│ │ └── recordbuilder
│ │ └── test
│ │ ├── Annotated.java
│ │ ├── BeanStyle.java
│ │ ├── Builder.java
│ │ ├── CollectionCopying.java
│ │ ├── CollectionInterface.java
│ │ ├── CollectionRecord.java
│ │ ├── CollectionRecordConflicts.java
│ │ ├── CustomMethodNames.java
│ │ ├── CustomMethodNamesWithFunctionalMethods.java
│ │ ├── Customer.java
│ │ ├── DuplicateMethodNames.java
│ │ ├── Empty.java
│ │ ├── ExceptionDetails.java
│ │ ├── FullRecord.java
│ │ ├── HasDefaults.java
│ │ ├── IgnoreAnnotated.java
│ │ ├── IncludeWithOption.java
│ │ ├── Initialized.java
│ │ ├── InterfaceTemplateTest.java
│ │ ├── MutableCollectionRecord.java
│ │ ├── MyInterfaceTemplate.java
│ │ ├── MyTemplate.java
│ │ ├── Nested.java
│ │ ├── NoBuilder.java
│ │ ├── NoStaticBuilder.java
│ │ ├── NonspecializedNullabeCollectionRecord.java
│ │ ├── NullableCollectionRecord.java
│ │ ├── NullableCollectionRecordInterpretingNotNulls.java
│ │ ├── OnceOnly.java
│ │ ├── Pair.java
│ │ ├── Person.java
│ │ ├── Point.java
│ │ ├── PublicConstructor.java
│ │ ├── RecordWithAnR.java
│ │ ├── RecordWithDefaultNotNull.java
│ │ ├── RecordWithOptional.java
│ │ ├── RecordWithOptional2.java
│ │ ├── RequestWithValid.java
│ │ ├── RequiredRecord.java
│ │ ├── RequiredRecord2.java
│ │ ├── SimpleGenericRecord.java
│ │ ├── SimpleRecord.java
│ │ ├── SingleItems.java
│ │ ├── SpecializedPerson.java
│ │ ├── StrippedFeaturesRecord.java
│ │ ├── TemplateTest.java
│ │ ├── Thingy.java
│ │ ├── UnmodifiableCollectionsRecord.java
│ │ ├── Usage.java
│ │ ├── WildcardSingleItems.java
│ │ ├── deconstructors
│ │ ├── ClassWithStaged.java
│ │ ├── ComplexClass.java
│ │ ├── GenericClass.java
│ │ ├── InterfaceTest.java
│ │ ├── MyClass.java
│ │ ├── NoRecordBuilder.java
│ │ ├── UniqueVarNameCheck.java
│ │ ├── UniqueVarNameCheck2.java
│ │ └── WithAnnotations.java
│ │ ├── includes
│ │ ├── IncludeFactory.java
│ │ ├── JustATest.java
│ │ └── pack
│ │ │ ├── AlsoIgnoreMe.java
│ │ │ ├── IgnoreMe.java
│ │ │ ├── PackRecord1.java
│ │ │ ├── PackRecord2.java
│ │ │ └── PackRecord3.java
│ │ ├── jacoco
│ │ └── FullRecordForJacoco.java
│ │ ├── naming
│ │ ├── Builder.java
│ │ └── ConvertRequest.java
│ │ ├── package-info.java
│ │ ├── staged
│ │ ├── CombinedGenericStaged.java
│ │ ├── CombinedSimpleStaged.java
│ │ ├── GenericStaged.java
│ │ ├── InitializedStaged.java
│ │ ├── NoFieldsStaged.java
│ │ ├── OptionalListStaged.java
│ │ ├── OptionalStagedRequiredOnly.java
│ │ ├── SimpleStaged.java
│ │ └── SingleFieldStaged.java
│ │ └── visibility
│ │ ├── PackagePrivateRecord.java
│ │ ├── PackagePrivateRecordWithPublicBuilder.java
│ │ └── Wrapper.java
│ └── test
│ └── java
│ └── io
│ └── soabase
│ └── recordbuilder
│ └── test
│ ├── TestAnnotated.java
│ ├── TestCollections.java
│ ├── TestCollectionsBuilder.java
│ ├── TestDefaultNotNull.java
│ ├── TestImmutableCollections.java
│ ├── TestIncludes.java
│ ├── TestInitialized.java
│ ├── TestNullableCollectionsBuilder.java
│ ├── TestOnceOnly.java
│ ├── TestOptional.java
│ ├── TestOptionsOnPackage.java
│ ├── TestPublicConstructor.java
│ ├── TestRecordBuilderFull.java
│ ├── TestRecordInterface.java
│ ├── TestSingleItems.java
│ ├── TestTemplate.java
│ ├── TestUnmodifiableCollectionsBuilder.java
│ ├── TestValidation.java
│ ├── TestVariousOptions.java
│ ├── TestWithers.java
│ ├── deconstructors
│ └── TestGenericClass.java
│ ├── staged
│ └── TestStagedBuilder.java
│ └── visibility
│ └── TestVisibility.java
├── record-builder-validator
├── pom.xml
└── src
│ └── main
│ └── java
│ └── io
│ └── soabase
│ └── recordbuilder
│ └── validator
│ └── RecordBuilderValidator.java
└── src
└── etc
└── header.txt
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: Randgalt
4 |
--------------------------------------------------------------------------------
/.github/workflows/maven_java17.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Maven Build - Java 17
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK
20 | uses: actions/setup-java@v1
21 | with:
22 | java-version: 17
23 | - name: Build with Maven
24 | run: ./mvnw -B package --file pom.xml
25 |
--------------------------------------------------------------------------------
/.github/workflows/maven_java21.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Maven Build - Java 21
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK
20 | uses: actions/setup-java@v1
21 | with:
22 | java-version: 21
23 | - name: Build with Maven
24 | run: ./mvnw -B package --file pom.xml -Djdk-version=21
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | .idea
3 | .classpath
4 | .project
5 | .settings/
6 | **/target/**
7 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Randgalt/record-builder/c4a6113607609503c65eb168edc331f2728223b6/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # https://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
19 |
--------------------------------------------------------------------------------
/customizing.md:
--------------------------------------------------------------------------------
1 | [◀︎ RecordBuilder](README.md) • Customizing RecordBuilder
2 |
3 | # RecordBuilderFull
4 |
5 | Note: `@RecordBuilderFull` has most optional features enabled. It's an alternate
6 | form of `@RecordBuilder` that uses the [templating mechanism](#create-a-custom-annotation) to
7 | enable optional features.
8 |
9 | # Customizing RecordBuilder
10 |
11 | RecordBuilder can be customized in a number of ways. The types of customizations will change over time. See
12 | [RecordBuilder Options](options.md)
13 | for the current set of customizations and their default values. For example, the `useImmutableCollections` option
14 | adds special handling for record components of type `java.util.List`, `java.util.Set`, `java.util.Map` and `java.util.Collection`. When the record is built, any components of these types are passed through an added shim method that uses the corresponding immutable collection (e.g. `List.copyOf(o)`) or an empty immutable collection if the component is `null`.
15 |
16 | You can:
17 |
18 | - [Customize an entire build](#customize-an-entire-build) - all uses of `@RecordBuilder` in your project
19 | - [Customize a single record](#customize-a-single-record) annotated with `@RecordBuilder`
20 | - [Create a custom annotation](#create-a-custom-annotation) that specifies your options and use that instead of `@RecordBuilder`
21 |
22 | ## Customize an entire build
23 |
24 | To customize an entire build, use javac's annotation processor options via `-A` on the command line.
25 | The options available are the same as the attributes in [@RecordBuilder.Options](record-builder-core/src/main/java/io/soabase/recordbuilder/core/RecordBuilder.java).
26 | i.e. to disable "prefixing enclosing class names", compile with:
27 |
28 | ```shell
29 | javac -AprefixEnclosingClassNames=false ...
30 | ```
31 |
32 | _Note: use a separate `-A` for each option._
33 |
34 | #### Maven
35 |
36 | If you are using Maven, specify the options in the compiler plugin:
37 |
38 | ```xml
39 |
40 | org.apache.maven.plugins
41 | maven-compiler-plugin
42 | ${maven-compiler-plugin-version}
43 |
44 |
45 | -AprefixEnclosingClassNames=false
46 | -AfileComment="something different"
47 |
48 |
49 |
50 | ```
51 |
52 | #### Gradle
53 |
54 | For Gradle, specify the options:
55 |
56 | ```groovy
57 | compilerArgs.addAll(['-AprefixEnclosingClassNames=false', '-AfileComment="something different"'])
58 | ```
59 |
60 | ## Customize a single record
61 |
62 | To customize a single record, add `@RecordBuilder.Options` ([options details](options.md)) in addition to
63 | `@RecordBuilder`.
64 |
65 | E.g.
66 |
67 | ```java
68 | @RecordBuilder.Options(withClassName = "Wither")
69 | @RecordBuilder
70 | public record MyRecord(String s){}
71 | ```
72 |
73 | ## Create a custom annotation
74 |
75 | Using `@RecordBuilder.Template` you can create your own RecordBuilder annotation
76 | that uses the set of options you want. E.g. to create a custom annotation that
77 | uses an alternate file comment and an alternate With classname:
78 |
79 | ```java
80 | @RecordBuilder.Template(options = @RecordBuilder.Options(
81 | fileComment = "MyCo license",
82 | withClassName = "Wither"
83 | ))
84 | @Retention(RetentionPolicy.SOURCE)
85 | @Target(ElementType.TYPE)
86 | @Inherited
87 | public @interface MyCoRecordBuilder {
88 | }
89 | ```
90 |
91 | Now, you can use `@MyCoRecordBuilder` instead of `@RecordBuilder` and the record
92 | will be built with options as specified.
93 |
94 | Note: the template mechanism also supports `@RecordInterface` templates via the `asRecordInterface` attribute.
95 | When it is set a `@RecordInterface` template is created instead.
96 |
--------------------------------------------------------------------------------
/deconstructors.md:
--------------------------------------------------------------------------------
1 | [◀︎ RecordBuilder](README.md) • Deconstructors
2 |
3 | # Deconstructors
4 |
5 | Deconstructors have been proposed for a future JDK. RecordBuilder's deconstructor support is based on this proposal. See: https://github.com/openjdk/amber-docs/blob/master/eg-drafts/deconstruction-patterns-records-and-classes.md#deconstructors-for-classes.
6 | Quoting the proposal:
7 |
8 | > A deconstruction pattern can be thought of as the dual of a constructor; a constructor takes N state components and
9 | > aggregates them into an object, and a deconstruction pattern takes an object and decomposes it into N state components.
10 |
11 | JDK `record`s have implicit deconstructors that are used throughout the JDK for pattern matching, etc. However, standard
12 | Java classes do not have deconstructors. RecordBuilder can generate records and builders from deconstructor-style methods in any Java class.
13 |
14 | A deconstructor is a method in any class or interface that:
15 |
16 | - returns `void`
17 | - is not `static`
18 | - has one or more parameters of type:
19 | - `Consumer`
20 | - `IntConsumer`
21 | - `LongConsumer`
22 | - `DoubleConsumer`
23 | - is annotated with `@RecordBuilder.Deconstructor`
24 |
25 | When RecordBuilder encounters a deconstructor method it generates a `record` that matches the deconstructor's parameters
26 | and, optionally, creates a record builder for it.
27 | The record's components are the same as the implied types of the deconstructor's parameters. The `record` will have a static
28 | method named `from` (you can change this) that
29 | takes an instance of the class containing the deconstructor method and returns an instance of the generated `record`.
30 | In other words, it deconstructs the class instance into a data access object that can be used in pattern matching,
31 | etc.
32 |
33 | ## Example
34 |
35 | Given this POJO:
36 |
37 | ```java
38 | public class MyClass {
39 | private final int qty;
40 | private final String name;
41 |
42 | public MyClass(int qty, String name) {
43 | this.qty = qty;
44 | this.name = name;
45 | }
46 |
47 | @Deconstructor
48 | public void deconstructor(IntConsumer qty, Consumer name) {
49 | qty.accept(this.qty);
50 | name.accept(this.name);
51 | }
52 | }
53 | ```
54 |
55 | RecordBuilder will generate a `record` (and record builder) similar to:
56 |
57 | ```java
58 | public record MyClassDao(int qty, String name) {
59 | public static MyClassDao from(MyClass rhs) {
60 | MyClassDaoBuilder builder = MyClassDaoBuilder.builder();
61 | rhs.deconstructor(builder::qty, builder::name);
62 | return builder.build();
63 | }
64 | }
65 | ```
66 |
67 | You can use it in switch statements, etc.:
68 |
69 | ```java
70 | MyClass myClass = ...
71 |
72 | switch (MyClassDao.from(myClass)) {
73 | case MyClassDao(var qty, var name) when qty > 0 -> ...
74 | case MyClassDao(var qty, var name) when qty == 0 -> ...
75 | case MyClassDao(var qty, var name) when name.isEmpty() -> ...
76 | ... etc. ...
77 | }
78 | ```
79 |
80 | ## Options
81 |
82 | The `@RecordBuilder.Deconstructor` annotation has several options that control how the record is generated.
83 | See [the definition](record-builder-core/src/main/java/io/soabase/recordbuilder/core/RecordBuilder.java) for details.
84 |
85 | When `addRecordBuilder()` is `true` a RecordBuilder is created for the generated record. You can add
86 | a `@RecordBuilder.Options` annotation to the deconstructor method to control how the record builder is generated.
87 | You can also create a `@DeconstructorTemplate` to build a custom deconstructor annotation. It is created
88 | in the same manner as a custom `@Template` annotation. See [Customizing](customizing.md#create-a-custom-annotation) for details.
89 |
90 | A pre-built template, `@DeconstructorFull` can be used which is an analog to `@RecordBuilderFull`.
91 |
--------------------------------------------------------------------------------
/record-builder-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | io.soabase.record-builder
22 | record-builder
23 | 48-SNAPSHOT
24 |
25 | 4.0.0
26 |
27 | record-builder-core
28 |
29 |
30 | ${project.parent.basedir}/src/etc/header.txt
31 | io.soabase.recordbuilder.core
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/record-builder-core/src/main/java/io/soabase/recordbuilder/core/DeconstructorFull.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.core;
17 |
18 | import java.lang.annotation.*;
19 |
20 | /**
21 | * An alternate form of {@code @Deconstructor} that has most optional features turned on for the generated record
22 | * builder
23 | */
24 | @RecordBuilder.DeconstructorTemplate(options = @RecordBuilder.Options(interpretNotNulls = true, useImmutableCollections = true, addSingleItemCollectionBuilders = true, addFunctionalMethodsToWith = true, addClassRetainedGenerated = true))
25 | @Retention(RetentionPolicy.SOURCE)
26 | @Target(ElementType.METHOD)
27 | @Inherited
28 | public @interface DeconstructorFull {
29 | }
30 |
--------------------------------------------------------------------------------
/record-builder-core/src/main/java/io/soabase/recordbuilder/core/IgnoreDefaultMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.core;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | @Retention(RetentionPolicy.SOURCE)
24 | @Target(ElementType.METHOD)
25 | public @interface IgnoreDefaultMethod {
26 | }
27 |
--------------------------------------------------------------------------------
/record-builder-core/src/main/java/io/soabase/recordbuilder/core/RecordBuilderFull.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.core;
17 |
18 | import java.lang.annotation.*;
19 |
20 | /**
21 | * An alternate form of {@code @RecordBuilder} that has most optional features turned on
22 | */
23 | @RecordBuilder.Template(options = @RecordBuilder.Options(interpretNotNulls = true, useImmutableCollections = true, addSingleItemCollectionBuilders = true, addFunctionalMethodsToWith = true, addClassRetainedGenerated = true))
24 | @Retention(RetentionPolicy.SOURCE)
25 | @Target({ ElementType.TYPE, ElementType.METHOD })
26 | @Inherited
27 | public @interface RecordBuilderFull {
28 | }
29 |
--------------------------------------------------------------------------------
/record-builder-core/src/main/java/io/soabase/recordbuilder/core/RecordBuilderGenerated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.core;
17 |
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | import static java.lang.annotation.ElementType.*;
23 |
24 | /**
25 | * Jacoco ignores classes and methods annotated with `*Generated`
26 | */
27 | @Target({ PACKAGE, TYPE, METHOD, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, PARAMETER })
28 | @Retention(RetentionPolicy.CLASS)
29 | public @interface RecordBuilderGenerated {
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-core/src/main/java/io/soabase/recordbuilder/core/RecordInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.core;
17 |
18 | import java.lang.annotation.*;
19 |
20 | @Retention(RetentionPolicy.SOURCE)
21 | @Target(ElementType.TYPE)
22 | @Inherited
23 | public @interface RecordInterface {
24 | boolean addRecordBuilder() default true;
25 |
26 | @Target({ ElementType.TYPE, ElementType.PACKAGE })
27 | @Retention(RetentionPolicy.SOURCE)
28 | @Inherited
29 | @interface Include {
30 | /**
31 | * @return collection of classes to include
32 | */
33 | Class>[] value() default {};
34 |
35 | /**
36 | * Synonym for {@code value()}. When using the other attributes it maybe clearer to use {@code classes()}
37 | * instead of {@code value()}. Note: both attributes are applied (i.e. a union of classes from both attributes).
38 | *
39 | * @return collection of classes
40 | */
41 | Class>[] classes() default {};
42 |
43 | /**
44 | * If true the generated record is annotated with {@code @RecordBuilder}
45 | *
46 | * @return true/false
47 | */
48 | boolean addRecordBuilder() default true;
49 |
50 | /**
51 | * Pattern used to generate the package for the generated class. The value is the literal package name however
52 | * two replacement values can be used. '@' is replaced with the package of the {@code Include} annotation. '*'
53 | * is replaced with the package of the included class.
54 | *
55 | * @return package pattern
56 | */
57 | String packagePattern() default "@";
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/record-builder-processor/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | io.soabase.record-builder
22 | record-builder
23 | 48-SNAPSHOT
24 |
25 | 4.0.0
26 |
27 | record-builder-processor
28 |
29 |
30 | ${project.parent.basedir}/src/etc/header.txt
31 | none
32 |
33 |
34 |
35 |
36 | io.soabase.java-composer
37 | java-composer
38 |
39 |
40 |
41 | io.soabase.record-builder
42 | record-builder-core
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/ClassType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import com.squareup.javapoet.TypeName;
19 |
20 | public class ClassType {
21 | private final TypeName typeName;
22 | private final String name;
23 |
24 | public ClassType(TypeName typeName, String name) {
25 | this.typeName = typeName;
26 | this.name = name;
27 | }
28 |
29 | public TypeName typeName() {
30 | return typeName;
31 | }
32 |
33 | public String name() {
34 | return name;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/IncludeHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import javax.annotation.processing.ProcessingEnvironment;
19 | import javax.lang.model.element.*;
20 | import javax.lang.model.type.TypeMirror;
21 | import javax.tools.Diagnostic;
22 | import java.util.ArrayList;
23 | import java.util.List;
24 | import java.util.Map;
25 |
26 | class IncludeHelper {
27 | private final boolean isValid;
28 | private final List classTypeElements;
29 | private final Map extends ExecutableElement, ? extends AnnotationValue> annotationValues;
30 |
31 | IncludeHelper(ProcessingEnvironment processingEnv, Element element, AnnotationMirror annotationMirror,
32 | boolean packagesSupported) {
33 | annotationValues = processingEnv.getElementUtils().getElementValuesWithDefaults(annotationMirror);
34 | var value = ElementUtils.getAnnotationValue(annotationValues, "value");
35 | var classes = ElementUtils.getAnnotationValue(annotationValues, "classes");
36 | var packages = ElementUtils.getAnnotationValue(annotationValues, "packages");
37 | var isValid = true;
38 | var classTypeElements = new ArrayList();
39 | if (value.isPresent() || classes.isPresent() || packages.isPresent()) {
40 | var valueList = value.map(ElementUtils::getAttributeTypeMirrorList).orElseGet(List::of);
41 | var classesList = classes.map(ElementUtils::getAttributeTypeMirrorList).orElseGet(List::of);
42 | var packagesList = packages.map(ElementUtils::getAttributeStringList).orElseGet(List::of);
43 | if (valueList.isEmpty() && classesList.isEmpty() && packagesList.isEmpty()) {
44 | if (packagesSupported) {
45 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
46 | "At least one of \"value\", \"classes\" or \"packages\" required", element);
47 | } else {
48 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
49 | "At least one of \"value\" or \"classes\" required", element);
50 | }
51 | isValid = false;
52 | }
53 | isValid = processList(processingEnv, isValid, element, valueList, classTypeElements);
54 | isValid = processList(processingEnv, isValid, element, classesList, classTypeElements);
55 | packages.ifPresent(annotationValue -> processPackages(processingEnv, classTypeElements, packagesList));
56 | } else {
57 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Could not read attribute for annotation",
58 | element);
59 | isValid = false;
60 | }
61 | this.isValid = isValid;
62 | this.classTypeElements = List.copyOf(classTypeElements);
63 | }
64 |
65 | Map extends ExecutableElement, ? extends AnnotationValue> getAnnotationValues() {
66 | return annotationValues;
67 | }
68 |
69 | boolean isValid() {
70 | return isValid;
71 | }
72 |
73 | List getClassTypeElements() {
74 | return classTypeElements;
75 | }
76 |
77 | private boolean processList(ProcessingEnvironment processingEnv, boolean isValid, Element element,
78 | List list, ArrayList classTypeElements) {
79 | for (var typeMirror : list) {
80 | TypeElement typeElement = (TypeElement) processingEnv.getTypeUtils().asElement(typeMirror);
81 | if (typeElement == null) {
82 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
83 | "Could not get element for: " + typeMirror, element);
84 | isValid = false;
85 | } else {
86 | classTypeElements.add(typeElement);
87 | }
88 | }
89 | return isValid;
90 | }
91 |
92 | private void processPackages(ProcessingEnvironment processingEnv, List classTypeElements,
93 | List packagesList) {
94 | for (var packageName : packagesList) {
95 | var packageElement = processingEnv.getElementUtils().getPackageElement(packageName);
96 | for (var child : packageElement.getEnclosedElements()) {
97 | if (child.getKind() == ElementKind.RECORD) {
98 | classTypeElements.add((TypeElement) child);
99 | }
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/InitializerUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import com.squareup.javapoet.CodeBlock;
19 | import io.soabase.recordbuilder.core.RecordBuilder;
20 |
21 | import javax.annotation.processing.ProcessingEnvironment;
22 | import javax.lang.model.element.*;
23 | import javax.tools.Diagnostic;
24 | import java.util.Map;
25 | import java.util.Optional;
26 | import java.util.stream.Collectors;
27 | import java.util.stream.Stream;
28 |
29 | import static io.soabase.recordbuilder.processor.ElementUtils.getAnnotationValue;
30 | import static io.soabase.recordbuilder.processor.ElementUtils.getStringAttribute;
31 |
32 | class InitializerUtil {
33 | static Map detectInitializers(ProcessingEnvironment processingEnv, TypeElement record) {
34 | return record.getEnclosedElements().stream().flatMap(element -> {
35 | var annotation = ElementUtils.findAnnotationMirror(processingEnv, element,
36 | RecordBuilder.Initializer.class.getName().replace("$", "."));
37 | var value = annotation.flatMap(mirror -> getAnnotationValue(mirror.getElementValues(), "value"));
38 | if (value.isEmpty()) {
39 | return Stream.of();
40 | }
41 |
42 | var source = annotation.flatMap(mirror -> getAnnotationValue(mirror.getElementValues(), "source"));
43 |
44 | var name = getStringAttribute(value.get(), "");
45 | var sourceElement = findSourceElement(processingEnv, record, source);
46 |
47 | Optional initializer = sourceElement.getEnclosedElements().stream()
48 | .filter(enclosedElement -> enclosedElement.getSimpleName().toString().equals(name))
49 | .flatMap(enclosedElement -> {
50 | if ((enclosedElement.getKind() == ElementKind.METHOD)
51 | && isValid(processingEnv, element, (ExecutableElement) enclosedElement)) {
52 | return Stream.of(CodeBlock.builder().add("$T.$L()", sourceElement, name).build());
53 | }
54 |
55 | if ((enclosedElement.getKind() == ElementKind.FIELD)
56 | && isValid(processingEnv, element, (VariableElement) enclosedElement)) {
57 | return Stream.of(CodeBlock.builder().add("$T.$L", sourceElement, name).build());
58 | }
59 |
60 | return Stream.of();
61 | }).findFirst();
62 |
63 | if (initializer.isEmpty()) {
64 | processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
65 | "No matching public static field or method found for initializer named: " + name, element);
66 | }
67 |
68 | return initializer.map(codeBlock -> Map.entry(element.getSimpleName().toString(), codeBlock)).stream();
69 | }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
70 | }
71 |
72 | private static boolean isValid(ProcessingEnvironment processingEnv, Element element,
73 | ExecutableElement executableElement) {
74 | if (executableElement.getModifiers().contains(Modifier.PUBLIC)
75 | && executableElement.getModifiers().contains(Modifier.STATIC)) {
76 | return processingEnv.getTypeUtils().isSameType(executableElement.getReturnType(), element.asType());
77 | }
78 | return false;
79 | }
80 |
81 | private static boolean isValid(ProcessingEnvironment processingEnv, Element element,
82 | VariableElement variableElement) {
83 | if (variableElement.getModifiers().contains(Modifier.PUBLIC)
84 | && variableElement.getModifiers().contains(Modifier.STATIC)
85 | && variableElement.getModifiers().contains(Modifier.FINAL)) {
86 | return processingEnv.getTypeUtils().isSameType(variableElement.asType(), element.asType());
87 | }
88 | return false;
89 | }
90 |
91 | private static TypeElement findSourceElement(ProcessingEnvironment processingEnv, TypeElement record,
92 | Optional extends AnnotationValue> source) {
93 | return source.flatMap(ElementUtils::getAttributeTypeMirror)
94 | .map(sourceMirror -> (TypeElement) processingEnv.getTypeUtils().asElement(sourceMirror)).orElse(record);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/OptionalType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import java.util.Optional;
19 | import java.util.OptionalDouble;
20 | import java.util.OptionalInt;
21 | import java.util.OptionalLong;
22 |
23 | import com.squareup.javapoet.ParameterizedTypeName;
24 | import com.squareup.javapoet.TypeName;
25 |
26 | public record OptionalType(TypeName typeName, TypeName valueType) {
27 |
28 | private static final TypeName optionalType = TypeName.get(Optional.class);
29 | private static final TypeName optionalIntType = TypeName.get(OptionalInt.class);
30 | private static final TypeName optionalLongType = TypeName.get(OptionalLong.class);
31 | private static final TypeName optionalDoubleType = TypeName.get(OptionalDouble.class);
32 |
33 | private static boolean isOptional(ClassType component) {
34 | if (component.typeName().equals(optionalType)) {
35 | return true;
36 | }
37 | return (component.typeName() instanceof ParameterizedTypeName parameterizedTypeName)
38 | && parameterizedTypeName.rawType.equals(optionalType);
39 | }
40 |
41 | static Optional fromClassType(final ClassType component) {
42 | if (isOptional(component)) {
43 | if (!(component.typeName() instanceof ParameterizedTypeName parameterizedType)) {
44 | return Optional.of(new OptionalType(optionalType, TypeName.get(Object.class)));
45 | }
46 | final TypeName containingType = parameterizedType.typeArguments.isEmpty() ? TypeName.get(Object.class)
47 | : parameterizedType.typeArguments.get(0);
48 | return Optional.of(new OptionalType(optionalType, containingType));
49 | }
50 | if (component.typeName().equals(optionalIntType)) {
51 | return Optional.of(new OptionalType(optionalIntType, TypeName.get(int.class)));
52 | }
53 | if (component.typeName().equals(optionalLongType)) {
54 | return Optional.of(new OptionalType(optionalLongType, TypeName.get(long.class)));
55 | }
56 | if (component.typeName().equals(optionalDoubleType)) {
57 | return Optional.of(new OptionalType(optionalDoubleType, TypeName.get(double.class)));
58 | }
59 | return Optional.empty();
60 | }
61 |
62 | public boolean isOptional() {
63 | return typeName.equals(optionalType);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/RecordBuilderOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import java.lang.reflect.Method;
20 | import java.lang.reflect.Proxy;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 | import java.util.Set;
24 | import java.util.stream.Collectors;
25 | import java.util.stream.Stream;
26 |
27 | class RecordBuilderOptions {
28 | private static final Map defaultValues = buildDefaultValues();
29 |
30 | static RecordBuilder.Options build(Map options) {
31 | return (RecordBuilder.Options) Proxy.newProxyInstance(RecordBuilderOptions.class.getClassLoader(),
32 | new Class[] { RecordBuilder.Options.class }, (proxy, method, args) -> {
33 | var name = method.getName();
34 | var defaultValue = defaultValues.get(name);
35 | var option = options.get(name);
36 | if (option != null) {
37 | if (defaultValue instanceof String) {
38 | return option;
39 | }
40 | if (defaultValue instanceof Boolean) {
41 | return Boolean.parseBoolean(option);
42 | }
43 | if (defaultValue instanceof Integer) {
44 | return Integer.parseInt(option);
45 | }
46 | if (defaultValue instanceof Long) {
47 | return Long.parseLong(option);
48 | }
49 | if (defaultValue instanceof Double) {
50 | return Double.parseDouble(option);
51 | }
52 | if (defaultValue instanceof RecordBuilder.BuilderMode) {
53 | return RecordBuilder.BuilderMode.valueOf(option);
54 | }
55 | throw new IllegalArgumentException("Unhandled option type: " + defaultValue.getClass());
56 | }
57 | return defaultValue;
58 | });
59 | }
60 |
61 | static Set optionNames() {
62 | return Stream.of(RecordBuilder.Options.class.getDeclaredMethods()).map(Method::getName)
63 | .collect(Collectors.toUnmodifiableSet());
64 | }
65 |
66 | private static Map buildDefaultValues() {
67 | var workMap = new HashMap();
68 | for (Method method : RecordBuilder.Options.class.getDeclaredMethods()) {
69 | workMap.put(method.getName(), method.getDefaultValue());
70 | }
71 | workMap.put("toString", "Generated RecordBuilder.Options");
72 | return Map.copyOf(workMap);
73 | }
74 |
75 | private RecordBuilderOptions() {
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/RecordClassType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import com.squareup.javapoet.TypeName;
19 |
20 | import javax.lang.model.element.AnnotationMirror;
21 | import java.util.List;
22 |
23 | public class RecordClassType extends ClassType {
24 | private final TypeName rawTypeName;
25 | private final List extends AnnotationMirror> accessorAnnotations;
26 | private final List extends AnnotationMirror> canonicalConstructorAnnotations;
27 |
28 | public RecordClassType(TypeName typeName, TypeName rawTypeName, String name,
29 | List extends AnnotationMirror> accessorAnnotations,
30 | List extends AnnotationMirror> canonicalConstructorAnnotations) {
31 | super(typeName, name);
32 | this.rawTypeName = rawTypeName;
33 | this.accessorAnnotations = accessorAnnotations;
34 | this.canonicalConstructorAnnotations = canonicalConstructorAnnotations;
35 | }
36 |
37 | public TypeName rawTypeName() {
38 | return rawTypeName;
39 | }
40 |
41 | public List extends AnnotationMirror> getAccessorAnnotations() {
42 | return accessorAnnotations;
43 | }
44 |
45 | public List extends AnnotationMirror> getCanonicalConstructorAnnotations() {
46 | return canonicalConstructorAnnotations;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/java/io/soabase/recordbuilder/processor/RecordFacade.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.processor;
17 |
18 | import com.squareup.javapoet.CodeBlock;
19 | import com.squareup.javapoet.TypeVariableName;
20 | import io.soabase.recordbuilder.core.RecordBuilder;
21 |
22 | import javax.annotation.processing.ProcessingEnvironment;
23 | import javax.lang.model.element.*;
24 | import java.util.List;
25 | import java.util.Map;
26 | import java.util.Optional;
27 | import java.util.Set;
28 | import java.util.stream.Collectors;
29 | import java.util.stream.IntStream;
30 |
31 | import static io.soabase.recordbuilder.processor.ElementUtils.generateName;
32 |
33 | record RecordFacade(Element element, String packageName, ClassType recordClassType, ClassType builderClassType,
34 | List typeVariables, List recordComponents,
35 | Map initializers, Set modifiers, boolean builderIsInRecordPackage) {
36 | public static RecordFacade fromTypeElement(ProcessingEnvironment processingEnv, TypeElement record,
37 | Optional packageNameOpt, RecordBuilder.Options metaData) {
38 | String recordActualPackage = ElementUtils.getPackageName(record);
39 | String packageName = packageNameOpt.orElse(recordActualPackage);
40 | ClassType recordClassType = ElementUtils.getClassType(record, record.getTypeParameters());
41 | ClassType builderClassType = ElementUtils.getClassType(packageName,
42 | generateName(record, recordClassType, metaData.suffix(), metaData.prefixEnclosingClassNames()),
43 | record.getTypeParameters());
44 | List typeVariables = record.getTypeParameters().stream().map(TypeVariableName::get)
45 | .collect(Collectors.toList());
46 | List recordComponents = buildRecordComponents(processingEnv, record);
47 | Map initializers = InitializerUtil.detectInitializers(processingEnv, record);
48 |
49 | return new RecordFacade(record, packageName, recordClassType, builderClassType, typeVariables, recordComponents,
50 | initializers, record.getModifiers(), recordActualPackage.equals(packageName));
51 | }
52 |
53 | private static List buildRecordComponents(ProcessingEnvironment processingEnv,
54 | TypeElement record) {
55 | var accessorAnnotations = record.getRecordComponents().stream().map(e -> (e.getAccessor() != null) ? e.getAccessor().getAnnotationMirrors() : List.of()).collect(Collectors.toList());
56 | var canonicalConstructorAnnotations = ElementUtils.findCanonicalConstructor(record)
57 | .map(constructor -> ((ExecutableElement) constructor).getParameters().stream()
58 | .map(Element::getAnnotationMirrors).collect(Collectors.toList()))
59 | .orElse(List.of());
60 | var recordComponents = record.getRecordComponents();
61 | return IntStream.range(0, recordComponents.size()).mapToObj(index -> {
62 | var thisAccessorAnnotations = (accessorAnnotations.size() > index) ? accessorAnnotations.get(index)
63 | : List. of();
64 | var thisCanonicalConstructorAnnotations = (canonicalConstructorAnnotations.size() > index)
65 | ? canonicalConstructorAnnotations.get(index) : List. of();
66 | return ElementUtils.getRecordClassType(processingEnv, recordComponents.get(index), thisAccessorAnnotations,
67 | thisCanonicalConstructorAnnotations);
68 | }).collect(Collectors.toList());
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/resources/META-INF/gradle/incremental.annotation.processors:
--------------------------------------------------------------------------------
1 | io.soabase.recordbuilder.processor.RecordBuilderProcessor,isolating
2 |
--------------------------------------------------------------------------------
/record-builder-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | io.soabase.recordbuilder.processor.RecordBuilderProcessor
--------------------------------------------------------------------------------
/record-builder-test/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | io.soabase.record-builder
22 | record-builder
23 | 48-SNAPSHOT
24 |
25 | 4.0.0
26 |
27 | record-builder-test
28 |
29 |
30 | ${project.parent.basedir}/src/etc/header.txt
31 | true
32 | true
33 |
34 |
35 |
36 |
37 | javax.validation
38 | validation-api
39 |
40 |
41 |
42 | jakarta.validation
43 | jakarta.validation-api
44 |
45 |
46 |
47 | io.soabase.record-builder
48 | record-builder-processor
49 | provided
50 |
51 |
52 |
53 | io.soabase.record-builder
54 | record-builder-validator
55 |
56 |
57 |
58 | org.hibernate.validator
59 | hibernate-validator
60 | provided
61 |
62 |
63 |
64 | org.glassfish
65 | javax.el
66 | provided
67 |
68 |
69 |
70 | org.junit.jupiter
71 | junit-jupiter
72 | test
73 |
74 |
75 |
76 | org.assertj
77 | assertj-core
78 | test
79 |
80 |
81 |
82 |
83 |
84 |
85 | org.jacoco
86 | jacoco-maven-plugin
87 |
88 |
89 | default-prepare-agent
90 |
91 | prepare-agent
92 |
93 |
94 |
95 | default-report
96 |
97 | report
98 |
99 |
100 |
101 | default-check
102 |
103 | check
104 |
105 |
106 |
107 | io/soabase/recordbuilder/test/jacoco/*
108 |
109 |
110 |
111 | BUNDLE
112 |
113 |
114 | COMPLEXITY
115 | COVEREDRATIO
116 | 0.60
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Annotated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import javax.validation.constraints.Max;
20 | import javax.validation.constraints.Min;
21 | import javax.validation.constraints.NotNull;
22 | import javax.validation.constraints.Null;
23 |
24 | @RecordBuilder
25 | public record Annotated(@NotNull @Null String hey, @Min(10) @Max(100) int i, double d) {
26 | }
27 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/BeanStyle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordInterface;
19 | import java.time.Instant;
20 |
21 | @RecordInterface
22 | public interface BeanStyle {
23 | String getName();
24 |
25 | Instant getDate();
26 |
27 | boolean isSomething();
28 | }
29 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Builder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import io.soabase.recordbuilder.core.RecordInterface;
20 |
21 | @RecordInterface.Include({ Thingy.class })
22 | @RecordBuilder.Include({ Nested.NestedRecord.class })
23 | public class Builder {
24 | }
25 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/CollectionCopying.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.time.Instant;
21 | import java.util.Collection;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | @RecordBuilder
27 | @RecordBuilder.Options(addSingleItemCollectionBuilders = true, useImmutableCollections = true, mutableListClassName = "PersonalizedMutableList")
28 | public record CollectionCopying(List list, Set set, Map map, Collection collection,
29 | int count) implements CollectionCopyingBuilder.With {
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/CollectionInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import io.soabase.recordbuilder.core.RecordInterface;
20 |
21 | import java.util.Collection;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | @RecordInterface
27 | @RecordBuilder.Options(useImmutableCollections = true)
28 | public interface CollectionInterface {
29 | List l();
30 |
31 | Set s();
32 |
33 | Map m();
34 |
35 | Collection c();
36 | }
37 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/CollectionRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.time.Instant;
21 | import java.util.Collection;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | @RecordBuilder
27 | @RecordBuilder.Options(useImmutableCollections = true, addFunctionalMethodsToWith = true)
28 | public record CollectionRecord(List l, Set s, Map m, Collection c)
29 | implements CollectionRecordBuilder.With {
30 | public static void main(String[] args) {
31 | var r = new CollectionRecord<>(List.of("hey"), Set.of("there"), Map.of("one", new Point(10, 20)),
32 | Set.of(new Point(30, 40)));
33 | Instant now = r.map((l1, s1, m1, c1) -> Instant.now());
34 | r.accept((l1, s1, m1, c1) -> {
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/CollectionRecordConflicts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.Collection;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | @RecordBuilder
26 | @RecordBuilder.Options(useImmutableCollections = true)
27 | public record CollectionRecordConflicts(List __list, Set __set, Map __map,
28 | Collection __collection) implements CollectionRecordConflictsBuilder.With {
29 | }
30 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/CustomMethodNames.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import io.soabase.recordbuilder.core.RecordBuilder;
22 | import io.soabase.recordbuilder.test.CustomMethodNamesBuilder.Bean;
23 |
24 | @RecordBuilder
25 | @RecordBuilder.Options(setterPrefix = "set", getterPrefix = "get", booleanPrefix = "is", beanClassName = "Bean")
26 | public record CustomMethodNames(Map kvMap, int theValue, List theList, boolean theBoolean)
27 | implements Bean, CustomMethodNamesBuilder.With {
28 | }
29 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/CustomMethodNamesWithFunctionalMethods.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import io.soabase.recordbuilder.core.RecordBuilder;
22 |
23 | @RecordBuilder
24 | @RecordBuilder.Options(getterPrefix = "get", booleanPrefix = "is", addFunctionalMethodsToWith = true)
25 | public record CustomMethodNamesWithFunctionalMethods(Map kvMap, int theValue, List theList,
26 | boolean theBoolean) implements CustomMethodNamesWithFunctionalMethodsBuilder.With {
27 | }
28 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Customer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import java.time.Instant;
19 |
20 | public interface Customer {
21 | String name();
22 |
23 | String address();
24 |
25 | Instant activeDate();
26 | }
27 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/DuplicateMethodNames.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | @RecordBuilder.Options(builderMode = RecordBuilder.BuilderMode.STANDARD_AND_STAGED, builderMethodName = "notBuilder", buildMethodName = "notBuild", stagedBuilderMethodName = "notStagedBuilder")
22 | public record DuplicateMethodNames(int builder, int build, int from, int stream, int stagedBuilder) {
23 | }
24 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Empty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | public record Empty() implements EmptyBuilder.With {
22 | }
23 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/ExceptionDetails.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import javax.lang.model.type.ErrorType;
21 | import java.util.List;
22 |
23 | @RecordBuilder
24 | public record ExceptionDetails(String internalMessage, String endUserMessage, String httpStatus, ErrorType errorType,
25 | List jsonProblems, Throwable cause) {
26 | @Override
27 | public List jsonProblems() {
28 | if (jsonProblems == null) {
29 | return List.of();
30 | }
31 | return jsonProblems;
32 | }
33 | }
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/FullRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilderFull;
19 |
20 | import javax.validation.constraints.NotNull;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | @RecordBuilderFull
25 | public record FullRecord(@NotNull List numbers, @NotNull Map fullRecords,
26 | @NotNull String justAString) {
27 | }
28 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/HasDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.IgnoreDefaultMethod;
19 | import io.soabase.recordbuilder.core.RecordInterface;
20 |
21 | import java.time.Instant;
22 | import java.util.concurrent.TimeUnit;
23 |
24 | @RecordInterface
25 | public interface HasDefaults {
26 | Instant time();
27 |
28 | default Instant tomorrow() {
29 | return Instant.now().plusMillis(TimeUnit.DAYS.toMillis(1));
30 | }
31 |
32 | @IgnoreDefaultMethod
33 | default void complexMethod(String s1, String s2) {
34 | // do nothing
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/IgnoreAnnotated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import javax.validation.constraints.NotNull;
21 |
22 | @RecordBuilder()
23 | @RecordBuilder.Options(inheritComponentAnnotations = false)
24 | public record IgnoreAnnotated(@NotNull String s) {
25 | }
26 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/IncludeWithOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder.Options(prefixEnclosingClassNames = false)
21 | @RecordBuilder.Include(IncludeWithOption.Hey.class)
22 | public class IncludeWithOption {
23 | public static record Hey(String s) {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Initialized.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import io.soabase.recordbuilder.core.RecordBuilderFull;
20 |
21 | import java.util.Optional;
22 |
23 | @RecordBuilderFull
24 | public record Initialized(@RecordBuilder.Initializer("DEFAULT_NAME") String name,
25 | @RecordBuilder.Initializer("defaultAge") int age, Optional dummy,
26 | @RecordBuilder.Initializer(value = "defaultAltName", source = AltSource.class) Optional altName) {
27 |
28 | public static final String DEFAULT_NAME = "hey";
29 |
30 | public static int defaultAge() {
31 | return 18;
32 | }
33 |
34 | public static class AltSource {
35 | public static Optional defaultAltName() {
36 | return Optional.of("alt");
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/InterfaceTemplateTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | @MyInterfaceTemplate
19 | public interface InterfaceTemplateTest {
20 | String name();
21 |
22 | int age();
23 | }
24 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/MutableCollectionRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.List;
21 |
22 | @RecordBuilder
23 | public record MutableCollectionRecord(List l) implements MutableCollectionRecordBuilder.With {
24 | }
25 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/MyInterfaceTemplate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder.Template(options = @RecordBuilder.Options(fileComment = "This is a test", withClassName = "Com"), asRecordInterface = true)
21 | public @interface MyInterfaceTemplate {
22 | }
23 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/MyTemplate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder.Template(options = @RecordBuilder.Options(fileComment = "This is a test", withClassName = "Com"))
21 | public @interface MyTemplate {
22 | }
23 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Nested.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | public class Nested {
19 | record NestedRecord(int x, int y) {
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/NoBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordInterface;
19 |
20 | import java.math.BigDecimal;
21 | import java.math.BigInteger;
22 |
23 | @RecordInterface(addRecordBuilder = false)
24 | public interface NoBuilder {
25 | BigInteger big();
26 |
27 | BigDecimal decimal();
28 | }
29 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/NoStaticBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | /**
21 | * Copyright 2019 Jordan Zimmerman
22 | *
23 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
24 | * the License. You may obtain a copy of the License at
25 | *
26 | * http://www.apache.org/licenses/LICENSE-2.0
27 | *
28 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
29 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
30 | * specific language governing permissions and limitations under the License.
31 | */
32 | @RecordBuilder.Options(addStaticBuilder = false)
33 | @RecordBuilder
34 | public record NoStaticBuilder(String foo) {
35 | }
36 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/NonspecializedNullabeCollectionRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.Collection;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | /**
26 | * To test that the compilation warning is emitted for this combination of options
27 | */
28 | @RecordBuilder
29 | @RecordBuilder.Options(useImmutableCollections = false, useUnmodifiableCollections = false, allowNullableCollections = true)
30 | public record NonspecializedNullabeCollectionRecord(List l, Set s, Map m,
31 | Collection c) implements CollectionRecordBuilder.With {
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/NullableCollectionRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.Collection;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | @RecordBuilder
26 | @RecordBuilder.Options(useImmutableCollections = true, allowNullableCollections = true)
27 | public record NullableCollectionRecord(List l, Set s, Map m, Collection c)
28 | implements CollectionRecordBuilder.With {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/NullableCollectionRecordInterpretingNotNulls.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import javax.validation.constraints.NotNull;
21 | import java.util.Collection;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | @RecordBuilder
27 | @RecordBuilder.Options(useImmutableCollections = true, allowNullableCollections = true, interpretNotNulls = true)
28 | public record NullableCollectionRecordInterpretingNotNulls(@NotNull List l, Set s,
29 | Map m, @NotNull Collection c) implements CollectionRecordBuilder.With {
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/OnceOnly.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | @RecordBuilder.Options(onceOnlyAssignment = true, builderMode = RecordBuilder.BuilderMode.STANDARD_AND_STAGED)
22 | public record OnceOnly(int a, int b, int c) {
23 | }
24 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Pair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | public record Pair(T t, U u) {
19 | }
20 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Person.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordInterface;
19 |
20 | @RecordInterface
21 | public interface Person {
22 | String name();
23 |
24 | int age();
25 | }
26 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Point.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | public record Point(int x, int y) {
19 | }
20 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/PublicConstructor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | @RecordBuilder.Options(publicBuilderConstructors = true)
22 | public record PublicConstructor(int i, String s) {
23 | }
24 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RecordWithAnR.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | public record RecordWithAnR(int r, String b) {
22 | }
23 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RecordWithDefaultNotNull.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import javax.validation.constraints.Null;
20 |
21 | @RecordBuilder.Options(defaultNotNull = true)
22 | @RecordBuilder
23 | public record RecordWithDefaultNotNull(Integer notNullInteger, String notNullString, @Null String nullString) {
24 | }
25 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RecordWithOptional.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import javax.validation.constraints.NotNull;
19 |
20 | import io.soabase.recordbuilder.core.RecordBuilder;
21 |
22 | import java.util.Optional;
23 | import java.util.OptionalDouble;
24 | import java.util.OptionalInt;
25 | import java.util.OptionalLong;
26 |
27 | @RecordBuilder.Options(emptyDefaultForOptional = true, addConcreteSettersForOptional = true)
28 | @RecordBuilder
29 | public record RecordWithOptional(@NotNull Optional value, Optional raw, OptionalInt i, OptionalLong l,
30 | OptionalDouble d) {
31 | }
32 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RecordWithOptional2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import java.util.Optional;
19 | import java.util.OptionalDouble;
20 | import java.util.OptionalInt;
21 | import java.util.OptionalLong;
22 | import io.soabase.recordbuilder.core.RecordBuilder;
23 |
24 | @RecordBuilder.Options(emptyDefaultForOptional = true)
25 | @RecordBuilder
26 | public record RecordWithOptional2(Optional value, Optional raw, OptionalInt i, OptionalLong l,
27 | OptionalDouble d) {
28 | }
29 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RequestWithValid.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import javax.validation.Valid;
21 | import javax.validation.constraints.NotBlank;
22 | import javax.validation.constraints.NotNull;
23 |
24 | @RecordBuilder
25 | @RecordBuilder.Options(useValidationApi = true)
26 | public record RequestWithValid(@NotNull @Valid @jakarta.validation.Valid Part part)
27 | implements RequestWithValidBuilder.With {
28 | public record Part(@NotBlank String name) {
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RequiredRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import javax.validation.constraints.NotNull;
21 | import java.util.List;
22 |
23 | @RecordBuilder.Options(interpretNotNulls = true)
24 | @RecordBuilder
25 | public record RequiredRecord(@NotNull String hey, @NotNull int i, @NotNull List l)
26 | implements RequiredRecordBuilder.With {
27 | }
28 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/RequiredRecord2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import javax.validation.constraints.NotNull;
21 |
22 | @RecordBuilder.Options(useValidationApi = true)
23 | @RecordBuilder
24 | public record RequiredRecord2(@NotNull String hey, @NotNull int i) implements RequiredRecord2Builder.With {
25 | }
26 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/SimpleGenericRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | public record SimpleGenericRecord(int i, T s) implements SimpleGenericRecordBuilder.With {
22 | }
23 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/SimpleRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | @RecordBuilder.Options(prefixEnclosingClassNames = false)
22 | public record SimpleRecord(int i, String s) {
23 | }
24 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/SingleItems.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.time.Instant;
21 | import java.util.Collection;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | @RecordBuilder
27 | @RecordBuilder.Options(addSingleItemCollectionBuilders = true, singleItemBuilderPrefix = "add1", useImmutableCollections = true, addFunctionalMethodsToWith = true)
28 | public record SingleItems(List strings, Set> sets, Map map, Collection collection)
29 | implements SingleItemsBuilder.With {
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/SpecializedPerson.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordInterface;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 | import java.util.function.Function;
23 | import java.util.function.Supplier;
24 |
25 | @RecordInterface
26 | public interface SpecializedPerson extends Person {
27 | List features();
28 |
29 | Map, Function>> complex();
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/StrippedFeaturesRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | @RecordBuilder
21 | @RecordBuilder.Options(enableGetters = false, enableWither = false)
22 | public record StrippedFeaturesRecord(int aField) {
23 | }
24 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/TemplateTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import java.time.Instant;
19 |
20 | @MyTemplate
21 | public record TemplateTest(String text, Instant date) implements TemplateTestBuilder.Com {
22 | }
23 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Thingy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | public interface Thingy {
19 | T getIt();
20 | }
21 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/UnmodifiableCollectionsRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.Collection;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | @RecordBuilder
26 | @RecordBuilder.Options(useUnmodifiableCollections = true)
27 | record UnmodifiableCollectionsRecord(List aList, Set orderedSet, Map orderedMap,
28 | Collection aCollection) {
29 | }
30 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/Usage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | public class Usage {
19 | public static void main(String[] args) {
20 | var hey = SimpleRecordBuilder.builder().i(10).s("hey").build();
21 | System.out.println(hey);
22 | var hey2 = SimpleRecordBuilder.builder(hey).i(100).build();
23 | System.out.println(hey2);
24 |
25 | var person = new PersonRecord("me", 42);
26 | outputPerson(person);
27 | var aged = PersonRecordBuilder.builder(person).age(100).build();
28 | outputPerson(aged);
29 | }
30 |
31 | private static void outputPerson(Person p) {
32 | System.out.println(p.toString());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/WildcardSingleItems.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.time.Instant;
21 | import java.util.Collection;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | @RecordBuilder
27 | @RecordBuilder.Options(addSingleItemCollectionBuilders = true, useImmutableCollections = true)
28 | public record WildcardSingleItems(List extends String> strings, Set extends List extends T>> sets,
29 | Map extends Instant, ? extends T> map, Collection extends T> collection)
30 | implements WildcardSingleItemsBuilder.With {
31 | }
32 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/ClassWithStaged.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.function.Consumer;
21 | import java.util.function.IntConsumer;
22 |
23 | public class ClassWithStaged {
24 | @RecordBuilder.Deconstructor
25 | @RecordBuilder.Options(builderMode = RecordBuilder.BuilderMode.STAGED)
26 | public void deconstructor(IntConsumer i, Consumer s) {
27 | // notning
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/ComplexClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.DeconstructorFull;
19 |
20 | import java.util.function.Consumer;
21 |
22 | public class ComplexClass> {
23 | private final T t;
24 | private final ComplexClass c;
25 |
26 | public ComplexClass(T t, ComplexClass c) {
27 | this.t = t;
28 | this.c = c;
29 | }
30 |
31 | @DeconstructorFull
32 | public void deconstructor(Consumer t, Consumer> c) {
33 | t.accept(this.t);
34 | c.accept(this.c);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/GenericClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import io.soabase.recordbuilder.core.RecordBuilder.Deconstructor;
20 |
21 | import java.util.function.Consumer;
22 |
23 | public class GenericClass {
24 | private final T t;
25 |
26 | public GenericClass(T t) {
27 | this.t = t;
28 | }
29 |
30 | @Deconstructor
31 | @RecordBuilder.Options(interpretNotNulls = true, useImmutableCollections = true, addSingleItemCollectionBuilders = true, addFunctionalMethodsToWith = true, addClassRetainedGenerated = true)
32 | public void deconstructor(Consumer t) {
33 | t.accept(this.t);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/InterfaceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder.Deconstructor;
19 |
20 | import java.time.Instant;
21 | import java.util.function.Consumer;
22 | import java.util.function.IntConsumer;
23 |
24 | public interface InterfaceTest {
25 | @Deconstructor
26 | void deconstructor1(Consumer string, IntConsumer integer, Consumer instant);
27 |
28 | @Deconstructor(prefix = "MeMeMe")
29 | void deconstructor2(Consumer string);
30 | }
31 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/MyClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 |
20 | import java.util.function.Consumer;
21 | import java.util.function.IntConsumer;
22 |
23 | public class MyClass {
24 | private final int i;
25 | private final String s;
26 |
27 | public MyClass(int i, String s) {
28 | this.i = i;
29 | this.s = s;
30 | }
31 |
32 | @RecordBuilder.Deconstructor
33 | public void deconstructor(IntConsumer i, Consumer s) {
34 | i.accept(this.i);
35 | s.accept(this.s);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/NoRecordBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder.Deconstructor;
19 |
20 | import java.util.function.IntConsumer;
21 |
22 | public class NoRecordBuilder {
23 | @Deconstructor(addRecordBuilder = false)
24 | public void unapply(IntConsumer i) {
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/record-builder-test/src/main/java/io/soabase/recordbuilder/test/deconstructors/UniqueVarNameCheck.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The original author or authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.soabase.recordbuilder.test.deconstructors;
17 |
18 | import io.soabase.recordbuilder.core.RecordBuilder;
19 | import io.soabase.recordbuilder.core.RecordBuilder.Deconstructor;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.function.Consumer;
24 | import java.util.function.IntConsumer;
25 |
26 | public class UniqueVarNameCheck {
27 | @Deconstructor
28 | @RecordBuilder.Options(builderMode = RecordBuilder.BuilderMode.STAGED) // use staged so that deconstructor can't use
29 | // builder
30 | public void unapply(Consumer