-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fields to builder that are only mutable through setters
This commit will close issue #2
- Loading branch information
1 parent
1e5a818
commit 8a7ec64
Showing
11 changed files
with
307 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.jonasg.bob; | ||
|
||
import java.util.Optional; | ||
|
||
import javax.lang.model.type.TypeMirror; | ||
|
||
/** | ||
* Represents a field that is buildable | ||
* @param fieldName the name of the field as declared in the type that will be built | ||
* @param isConstructorArgument indicates if the field can be set through the constructor | ||
* @param setterMethodName the name of the setter method to access the field. | ||
* @param type the type of the field | ||
*/ | ||
public record BuildableField( | ||
String fieldName, | ||
boolean isConstructorArgument, | ||
Optional<String> setterMethodName, | ||
TypeMirror type) { | ||
|
||
public static BuildableField fromConstructor(String fieldName, TypeMirror type) { | ||
return new BuildableField(fieldName, true, Optional.empty(), type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
processor/src/main/java/io/jonasg/bob/definitions/MethodDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
package io.jonasg.bob.definitions; | ||
|
||
public class MethodDefinition { | ||
private final String name; | ||
import java.util.List; | ||
|
||
public MethodDefinition(String name) { | ||
this.name = name; | ||
} | ||
import javax.lang.model.type.TypeMirror; | ||
|
||
public String name() { | ||
return name; | ||
} | ||
public record MethodDefinition(String name, | ||
List<TypeMirror> parameters) { | ||
} |
8 changes: 8 additions & 0 deletions
8
processor/src/main/java/io/jonasg/bob/definitions/SetterMethodDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.jonasg.bob.definitions; | ||
|
||
import javax.lang.model.type.TypeMirror; | ||
|
||
public record SetterMethodDefinition(String methodName, | ||
String fieldName, | ||
TypeMirror type) { | ||
} |
Oops, something went wrong.