From 10368b0fb0a1bde7f8cb0eb2c1b22f9c23c806f4 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Wed, 11 Mar 2026 23:38:10 +0100 Subject: [PATCH 1/3] Fixing test --- .../simple/builders/processor/BuilderProcessorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java b/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java index 1a707c56..72b14834 100644 --- a/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java +++ b/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java @@ -2695,7 +2695,7 @@ void shouldHandleOverloadedSettersForSameFieldWithoutConflicts() { private java.util.List names; public java.util.List getNames() { return names; } - public void setNames(java.util.List names) { this.names = names; } + public void setNames(String[] names) { this.names = names; } public void setNames(String... names) { this.names = java.util.List.of(names); } """); From ad7ea24df57d2a4d4fc318a2e3b505fef76bc115 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Wed, 11 Mar 2026 23:51:52 +0100 Subject: [PATCH 2/3] Disabling test because of missing feature --- .../simple/builders/processor/BuilderProcessorTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java b/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java index 72b14834..62fc1699 100644 --- a/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java +++ b/processor/src/test/java/org/javahelpers/simple/builders/processor/BuilderProcessorTest.java @@ -35,6 +35,7 @@ import javax.tools.JavaFileObject; import org.javahelpers.simple.builders.processor.testing.ProcessorAsserts; import org.javahelpers.simple.builders.processor.testing.ProcessorTestUtils; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** Tests for the {@link BuilderProcessor} class. */ @@ -2681,6 +2682,7 @@ public class InnerClass { } @Test + @Disabled("Missing feature: #131") void shouldHandleOverloadedSettersForSameFieldWithoutConflicts() { // Given String packageName = "test"; From 6616a8c11ff2cd0831fb259883988d2a483c20ec Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Thu, 12 Mar 2026 00:07:27 +0100 Subject: [PATCH 3/3] Removing example builder for conflictExample because this is not stabile in different build environments --- .../example/FieldConflictExample.java | 2 +- .../example/FieldConflictExampleBuilder.java | 239 ------------------ 2 files changed, 1 insertion(+), 240 deletions(-) delete mode 100644 example/target/generated-sources/annotations/org/javahelpers/simple/builders/example/FieldConflictExampleBuilder.java diff --git a/example/src/main/java/org/javahelpers/simple/builders/example/FieldConflictExample.java b/example/src/main/java/org/javahelpers/simple/builders/example/FieldConflictExample.java index 31a76631..0b912f94 100644 --- a/example/src/main/java/org/javahelpers/simple/builders/example/FieldConflictExample.java +++ b/example/src/main/java/org/javahelpers/simple/builders/example/FieldConflictExample.java @@ -43,7 +43,7 @@ * * @see org.javahelpers.simple.builders.core.annotations.IgnoreInBuilder */ -@SimpleBuilder +// @SimpleBuilder - needs to be reactivated after having #132 checked public class FieldConflictExample { private String firstName; private java.util.Optional lastName; diff --git a/example/target/generated-sources/annotations/org/javahelpers/simple/builders/example/FieldConflictExampleBuilder.java b/example/target/generated-sources/annotations/org/javahelpers/simple/builders/example/FieldConflictExampleBuilder.java deleted file mode 100644 index 7a1defe7..00000000 --- a/example/target/generated-sources/annotations/org/javahelpers/simple/builders/example/FieldConflictExampleBuilder.java +++ /dev/null @@ -1,239 +0,0 @@ -package org.javahelpers.simple.builders.example; - -import static org.javahelpers.simple.builders.core.util.TrackedValue.changedValue; -import static org.javahelpers.simple.builders.core.util.TrackedValue.initialValue; -import static org.javahelpers.simple.builders.core.util.TrackedValue.unsetValue; - -import java.util.Optional; -import java.util.function.BooleanSupplier; -import java.util.function.Consumer; -import java.util.function.Supplier; -import javax.annotation.processing.Generated; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.javahelpers.simple.builders.core.annotations.BuilderImplementation; -import org.javahelpers.simple.builders.core.interfaces.IBuilderBase; -import org.javahelpers.simple.builders.core.util.BuilderToStringStyle; -import org.javahelpers.simple.builders.core.util.TrackedValue; - -/** - * Builder for {@code org.javahelpers.simple.builders.example.FieldConflictExample}. - *

- * This builder provides a fluent API for creating instances of org.javahelpers.simple.builders.example.FieldConflictExample with - * method chaining and validation. Use the static {@code create()} method - * to obtain a new builder instance, configure the desired properties using - * the setter methods, and then call {@code build()} to create the final DTO. - */ -@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") -@BuilderImplementation( - forClass = FieldConflictExample.class -) -public class FieldConflictExampleBuilder implements IBuilderBase { - /** - * Tracked value for name: name. - */ - private TrackedValue name = unsetValue(); - - /** - * Tracked value for nameOptional: name. - */ - private TrackedValue> nameOptional = unsetValue(); - - /** - * Empty constructor of builder for {@code org.javahelpers.simple.builders.example.FieldConflictExample}. - */ - public FieldConflictExampleBuilder() { - } - - /** - * Initialisation of builder for {@code org.javahelpers.simple.builders.example.FieldConflictExample} by a instance. - * - * @param instance object instance for initialisiation - */ - public FieldConflictExampleBuilder(FieldConflictExample instance) { - } - - /** - * Creating a new builder for {@code org.javahelpers.simple.builders.example.FieldConflictExample}. - * - * @return builder for {@code org.javahelpers.simple.builders.example.FieldConflictExample} - */ - public static FieldConflictExampleBuilder create() { - return new FieldConflictExampleBuilder(); - } - - /** - * Sets the value for name. - * - * @param name name - * @return current instance of builder - */ - public FieldConflictExampleBuilder name(String name) { - this.name = changedValue(name); - return this; - } - - /** - * Sets the value for name. - * - * @param name name - * @return current instance of builder - */ - public FieldConflictExampleBuilder name(Optional name) { - this.nameOptional = changedValue(name); - return this; - } - - /** - * Sets the value for name by executing the provided consumer. - * - * @param nameStringBuilderConsumer consumer providing an instance of name - * @return current instance of builder - */ - public FieldConflictExampleBuilder name(Consumer nameStringBuilderConsumer) { - StringBuilder builder = new StringBuilder(); - nameStringBuilderConsumer.accept(builder); - this.name = changedValue(builder.toString()); - return this; - } - - /** - * Sets the value for name by invoking the provided supplier. - * - * @param nameSupplier supplier for name - * @return current instance of builder - */ - public FieldConflictExampleBuilder name(Supplier nameSupplier) { - this.name = changedValue(nameSupplier.get()); - return this; - } - - /** - * Sets the String value for name by using String.format(format, args). - * See {@link String#format(String, Object...)} for details. - * - * @param format A format string - * @param args Arguments referenced by the format specifiers in the format string. - * @return current instance of builder - */ - public FieldConflictExampleBuilder name(String format, Object... args) { - this.nameOptional = changedValue(Optional.of(String.format(format, args))); - return this; - } - - /** - * Sets the value for nameOptional by executing the provided consumer. - * - * @param nameOptionalStringBuilderConsumer consumer providing an instance of name - * @return current instance of builder - */ - public FieldConflictExampleBuilder nameOptional( - Consumer nameOptionalStringBuilderConsumer) { - StringBuilder builder = new StringBuilder(); - nameOptionalStringBuilderConsumer.accept(builder); - this.nameOptional = changedValue(Optional.of(builder.toString())); - return this; - } - - /** - * Validates that the name field is not null or empty. - * - * @return this builder instance for chaining - * @throws IllegalArgumentException if name is null or empty - */ - FieldConflictExampleBuilder validateName() { - if (!name.isSet() || name.value().trim().isEmpty()) { - throw new IllegalArgumentException("Name cannot be null or empty"); - } - return this; - } - - /** - * Conditionally applies builder modifications if the condition is true. - * - * @param condition the condition to evaluate - * @param yesCondition the consumer to apply if condition is true - * @return this builder instance - */ - public FieldConflictExampleBuilder conditional(BooleanSupplier condition, - Consumer yesCondition) { - return conditional(condition, yesCondition, null); - } - - /** - * Conditionally applies builder modifications based on a condition evaluation. - * - * @param condition the condition to evaluate - * @param trueCase the consumer to apply if condition is true - * @param falseCase the consumer to apply if condition is false (can be null) - * @return this builder instance - */ - public FieldConflictExampleBuilder conditional(BooleanSupplier condition, - Consumer trueCase, - Consumer falseCase) { - if (condition.getAsBoolean()) { - trueCase.accept(this); - } else if (falseCase != null) { - falseCase.accept(this); - } - return this; - } - - /** - * Builds the configured DTO instance. - */ - @Override - public FieldConflictExample build() { - FieldConflictExample result = new FieldConflictExample(); - this.name.ifSet(result::setName); - this.nameOptional.ifSet(result::setName); - return result; - } - - /** - * Returns a string representation of this builder, including only fields that have been set. - * - * @return string representation of the builder - */ - @Override - public String toString() { - return new ToStringBuilder(this, BuilderToStringStyle.INSTANCE) - .append("name", this.name) - .append("nameOptional", this.nameOptional) - .toString(); - } - - /** - * Interface that can be implemented by the DTO to provide fluent modification methods. - */ - public interface With { - /** - * Initializes a builder from an instance of this class, using methods of this builder to change values and returns the new built object. - * - * @param b the consumer to apply modifications - * @return the modified instance - */ - default FieldConflictExample with(Consumer b) { - FieldConflictExampleBuilder builder; - try { - builder = new FieldConflictExampleBuilder(FieldConflictExample.class.cast(this)); - } catch (ClassCastException ex) { - throw new IllegalArgumentException("The interface 'FieldConflictExampleBuilder.With' should only be implemented by classes, which could be casted to 'FieldConflictExample'", ex); - } - b.accept(builder); - return builder.build(); - } - - /** - * Creates a builder initialized from this instance. - * - * @return a builder initialized with this instance's values - */ - default FieldConflictExampleBuilder with() { - try { - return new FieldConflictExampleBuilder(FieldConflictExample.class.cast(this)); - } catch (ClassCastException ex) { - throw new IllegalArgumentException("The interface 'FieldConflictExampleBuilder.With' should only be implemented by classes, which could be casted to 'FieldConflictExample'", ex); - } - } - } -}