-
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.
chore: add java versions starting from 11 to build pipeline
- Loading branch information
1 parent
6134f81
commit 6a03c33
Showing
11 changed files
with
350 additions
and
54 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
90 changes: 79 additions & 11 deletions
90
processor/src/main/java/io/jonasg/bob/BuildableField.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,29 +1,97 @@ | ||
package io.jonasg.bob; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import javax.lang.model.type.TypeMirror; | ||
|
||
/** | ||
* Represents a field that is buildable | ||
* | ||
* @param name 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 | ||
* {@link BuildableField#name} the name of the field as declared in the type | ||
* that will be built | ||
* {@link BuildableField#isConstructorArgument} indicates if the field can be | ||
* set through the constructor | ||
* {@link BuildableField#setterMethodName} the name of the setter method to | ||
* access the field. | ||
* {@link BuildableField#type} the type of the field | ||
*/ | ||
public record BuildableField( | ||
String name, | ||
boolean isConstructorArgument, | ||
boolean isMandatory, | ||
Optional<String> setterMethodName, | ||
TypeMirror type) { | ||
public final class BuildableField { | ||
private final String name; | ||
private final boolean isConstructorArgument; | ||
private final boolean isMandatory; | ||
private final Optional<String> setterMethodName; | ||
private final TypeMirror type; | ||
|
||
public BuildableField( | ||
String name, | ||
boolean isConstructorArgument, | ||
boolean isMandatory, | ||
Optional<String> setterMethodName, | ||
TypeMirror type) { | ||
this.name = name; | ||
this.isConstructorArgument = isConstructorArgument; | ||
this.isMandatory = isMandatory; | ||
this.setterMethodName = setterMethodName; | ||
this.type = type; | ||
} | ||
|
||
public static BuildableField fromConstructor(String fieldName, TypeMirror type) { | ||
return new BuildableField(fieldName, true, false, Optional.empty(), type); | ||
} | ||
|
||
public static BuildableField fromSetter(String fieldName, boolean fieldIsMandatory, String setterMethodName, TypeMirror type) { | ||
public static BuildableField fromSetter(String fieldName, boolean fieldIsMandatory, String setterMethodName, | ||
TypeMirror type) { | ||
return new BuildableField(fieldName, false, fieldIsMandatory, Optional.of(setterMethodName), type); | ||
} | ||
|
||
public String name() { | ||
return name; | ||
} | ||
|
||
public boolean isConstructorArgument() { | ||
return isConstructorArgument; | ||
} | ||
|
||
public boolean isMandatory() { | ||
return isMandatory; | ||
} | ||
|
||
public Optional<String> setterMethodName() { | ||
return setterMethodName; | ||
} | ||
|
||
public TypeMirror type() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) | ||
return true; | ||
if (obj == null || obj.getClass() != this.getClass()) | ||
return false; | ||
var that = (BuildableField) obj; | ||
return Objects.equals(this.name, that.name) && | ||
this.isConstructorArgument == that.isConstructorArgument && | ||
this.isMandatory == that.isMandatory && | ||
Objects.equals(this.setterMethodName, that.setterMethodName) && | ||
Objects.equals(this.type, that.type); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, isConstructorArgument, isMandatory, setterMethodName, type); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BuildableField[" + | ||
"name=" + name + ", " + | ||
"isConstructorArgument=" + isConstructorArgument + ", " + | ||
"isMandatory=" + isMandatory + ", " + | ||
"setterMethodName=" + setterMethodName + ", " + | ||
"type=" + 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
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
Oops, something went wrong.