Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1eb58be
Renaming BuilderDefinitionDto to GenerationTargetClassDto for general…
AndreasIgel Apr 4, 2026
4c1bf84
Fixing expectations because primitive types do not need a null check …
AndreasIgel Apr 5, 2026
ac1e8e2
1st state of refactoring to have a GenerationTargetClassDto and a bui…
AndreasIgel Apr 6, 2026
1fd07e0
Fixing failing tests
AndreasIgel Apr 6, 2026
9c37416
Switching from javax Modifier to AccessModifier
AndreasIgel Apr 6, 2026
9290bdb
Improving code quality
AndreasIgel Apr 11, 2026
1e8e096
Reintegration of protected enum value for accessModifier
AndreasIgel Apr 11, 2026
207aad5
Removed unneeded switch and boxing
AndreasIgel Apr 11, 2026
95ad771
Adding toString to ClassFieldDto and ConstructorDto
AndreasIgel Apr 11, 2026
9fe1d9f
Improving codequality
AndreasIgel Apr 11, 2026
104bc5e
Replacing usage of named Types by referencing the class
AndreasIgel Apr 11, 2026
3de08d5
Improving codequality
AndreasIgel Apr 11, 2026
dce5ca1
Setting visibility of fields on Private per default
AndreasIgel Apr 11, 2026
c55c636
Improving handling of codeBlockImports in context of constructorDto a…
AndreasIgel Apr 12, 2026
6473fca
Switching import-collecting and sorting into a helper class
AndreasIgel Apr 12, 2026
9cd014d
Fixing issue of missing NonNull import in testclasses
AndreasIgel Apr 12, 2026
b95baab
Implementation of ImportStatement dto to handle static and regular im…
AndreasIgel Apr 12, 2026
4edc00f
Adepting test-expectation of full generation
AndreasIgel Apr 21, 2026
dc6bd45
Adapting handling of imports - GenericTypes should not get directly i…
AndreasIgel Apr 21, 2026
b86e80d
Fixing codesmells from SonarQube
AndreasIgel Apr 22, 2026
8863f3f
separation of imports because of field type and specific field-imports
AndreasIgel Apr 22, 2026
06228e0
Removing unused functions
AndreasIgel Apr 22, 2026
710b66a
Removing unneeded coreMethods field
AndreasIgel Apr 22, 2026
3fa5ce1
Removing sourceDescription from methodDto because it is only needed f…
AndreasIgel Apr 22, 2026
8df92b5
Switching interfaces visibility to use AccessModifier
AndreasIgel Apr 23, 2026
dfe8996
Using flat-map-streams for import collecting
AndreasIgel Apr 23, 2026
8d157bf
Migration generation of JacksonModule into default functionality of R…
AndreasIgel Apr 23, 2026
6567897
Removing unneeded JacksonModuleDefinitionDto
AndreasIgel Apr 23, 2026
9a673b5
Improving code
AndreasIgel Apr 23, 2026
477d928
Removing unused private helper function
AndreasIgel Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public enum AccessModifier {
/** Public access - accessible from anywhere */
PUBLIC("public"),

/** Protected access - accessible from the same package and subclasses */
PROTECTED("protected"),

/** Package-private access (default) - accessible only within the same package */
PACKAGE_PRIVATE(""),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.javahelpers.simple.builders.core.util.BuilderToStringStyle;
import org.javahelpers.simple.builders.core.util.TrackedValue;
Expand Down Expand Up @@ -116,52 +114,20 @@ public BookDtoBuilder() {
public BookDtoBuilder(BookDto instance) {
this.author = initialValue(instance.getAuthor());
this.available = initialValue(instance.isAvailable());
if (this.available.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'available' is marked as non-null but source object has null value");
}
this.category = initialValue(instance.getCategory());
if (this.category.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'category' is marked as non-null but source object has null value");
}
this.discount = initialValue(instance.getDiscount());
if (this.discount.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'discount' is marked as non-null but source object has null value");
}
this.edition = initialValue(instance.getEdition());
if (this.edition.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'edition' is marked as non-null but source object has null value");
}
this.exactPrice = initialValue(instance.getExactPrice());
this.genres = initialValue(instance.getGenres());
this.isbn = initialValue(instance.getIsbn());
this.lastUpdated = initialValue(instance.getLastUpdated());
this.metadata = initialValue(instance.getMetadata());
this.pages = initialValue(instance.getPages());
if (this.pages.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'pages' is marked as non-null but source object has null value");
}
this.price = initialValue(instance.getPrice());
if (this.price.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'price' is marked as non-null but source object has null value");
}
this.publishDate = initialValue(instance.getPublishDate());
this.publisher = initialValue(instance.getPublisher());
this.rating = initialValue(instance.getRating());
if (this.rating.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'rating' is marked as non-null but source object has null value");
}
this.salesCount = initialValue(instance.getSalesCount());
if (this.salesCount.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'salesCount' is marked as non-null but source object has null value");
}
this.subtitle = initialValue(instance.getSubtitle());
this.tags = initialValue(instance.getTags());
this.title = initialValue(instance.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public JacksonIntegrationDtoBuilder() {
public JacksonIntegrationDtoBuilder(JacksonIntegrationDto instance) {
this.name = initialValue(instance.name());
this.age = initialValue(instance.age());
if (this.age.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'age' is marked as non-null but source object has null value");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public ProductRecordBuilder() {
public ProductRecordBuilder(ProductRecord instance) {
this.name = initialValue(instance.name());
this.price = initialValue(instance.price());
if (this.price.value() == null) {
throw new IllegalArgumentException(
"Cannot initialize builder from instance: field 'price' is marked as non-null but source object has null value");
}
this.category = initialValue(instance.category());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

public class SimpleBuildersJacksonModule extends SimpleModule {

@JsonDeserialize(builder = JacksonIntegrationDtoBuilder.class)
private interface JacksonIntegrationDtoMixin {
}

public SimpleBuildersJacksonModule() {
setMixInAnnotation(JacksonIntegrationDto.class, JacksonIntegrationDtoMixin.class);
}

@JsonDeserialize(builder = JacksonIntegrationDtoBuilder.class)
private interface JacksonIntegrationDtoMixin {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.javahelpers.simple.builders.processor.generators.integration.JacksonModuleGenerator;
import org.javahelpers.simple.builders.processor.model.core.BuilderConfiguration;
import org.javahelpers.simple.builders.processor.model.core.BuilderDefinitionDto;
import org.javahelpers.simple.builders.processor.model.core.GenerationTargetClassDto;
import org.javahelpers.simple.builders.processor.processing.BuilderConfigurationReader;
import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsEnum;
import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsReader;
Expand Down Expand Up @@ -107,9 +108,18 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment

// Generate Jackson Module if processing is over and feature is enabled
if (roundEnv.processingOver()) {
var modules = jacksonModuleGenerator.getModuleDefinitions();
for (var module : modules) {
codeGenerator.generateJacksonModule(module);
List<GenerationTargetClassDto> moduleClassDefs =
jacksonModuleGenerator.getModuleDefinitions();
for (GenerationTargetClassDto moduleClassDef : moduleClassDefs) {
String packageName = moduleClassDef.getTypeName().getPackageName();
context.info("Generating Jackson Module in package '%s'", packageName);
try {
codeGenerator.generateClass(moduleClassDef);
} catch (BuilderException e) {
context.warning(
"simple-builders: Error generating Jackson module for package %s: %s",
packageName, e.getMessage());
}
}
// Reset indentation after Jackson module generation as well
context.resetIndentation();
Expand Down Expand Up @@ -199,7 +209,7 @@ private void process(Element annotatedElement, BuilderConfiguration config)
throws BuilderException {
context.initConfigurationForProcessingTarget(config);
BuilderDefinitionDto builderDef = extractFromElement(annotatedElement, context);
codeGenerator.generateBuilder(builderDef);
codeGenerator.generateClass(builderDef);

// Collect info for Jackson Module if enabled
jacksonModuleGenerator.addEntry(builderDef, annotatedElement);
Expand All @@ -209,7 +219,7 @@ private void process(Element annotatedElement, BuilderConfiguration config)
context.debugEndOperation(
"Generated builder with %d fields and %d methods for %s",
builderDef.getAllFieldsForBuilder().size(),
builderDef.getCoreMethods().size(),
builderDef.getMethods().size(),
builderDef.getBuilderTypeName().getClassName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static Modifier mapAccessModifier(AccessModifier accessModifier) {
}
return switch (accessModifier) {
case PUBLIC, DEFAULT -> Modifier.PUBLIC;
case PROTECTED -> Modifier.PROTECTED;
case PRIVATE -> Modifier.PRIVATE;
case PACKAGE_PRIVATE -> null; // Package-private has no explicit modifier
};
Expand Down
Loading
Loading