From 0098d2030f354eec9379000807b5d053bc7c20ad Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 06:28:51 +0000 Subject: [PATCH] fix: disable generateUpdateHelpers in the ElementaryBuilder template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @ElementaryBuilder predates the update-helpers option and documented a setter-only builder, but never disabled generateUpdateHelpers — so @ElementaryBuilder-annotated types got xyzUpdate(UnaryOperator) methods anyway (visible in the committed BookDtoBuilder). Align it with @SimpleMinimalBuilder. Fixes #333 --- .../builders/example/BookDtoBuilder.java | 472 ------------------ .../builders/example/ElementaryBuilder.java | 1 + 2 files changed, 1 insertion(+), 472 deletions(-) diff --git a/example/generated-example-builder/org/javahelpers/simple/builders/example/BookDtoBuilder.java b/example/generated-example-builder/org/javahelpers/simple/builders/example/BookDtoBuilder.java index eacfca38..3de32abf 100644 --- a/example/generated-example-builder/org/javahelpers/simple/builders/example/BookDtoBuilder.java +++ b/example/generated-example-builder/org/javahelpers/simple/builders/example/BookDtoBuilder.java @@ -10,7 +10,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.function.UnaryOperator; import org.apache.commons.lang3.builder.ToStringBuilder; import org.javahelpers.simple.builders.core.util.BuilderToStringStyle; import org.javahelpers.simple.builders.core.util.TrackedValue; @@ -27,35 +26,22 @@ *
{@code
  * BookDto result = BookDtoBuilder.create()
  *     .author("example value")
- *     .authorUpdate(String::trim)
  *     .available(true)
- *     .availableUpdate(value -> !value)
  *     .category('x')
  *     .discount(3.14f)
- *     .discountUpdate(Math::abs)
  *     .exactPrice(BigDecimal.valueOf(3.14))
  *     .genres(Set.of("example value"))
- *     .genresUpdate(TreeSet::new)
  *     .isbn("example value")
- *     .isbnUpdate(String::trim)
  *     .lastUpdated(LocalDateTime.now())
- *     .lastUpdatedUpdate(value -> value.plusDays(1))
  *     .metadata(Map.of("example value", "example value"))
- *     .metadataUpdate(Map::copyOf)
  *     .pages(42)
- *     .pagesUpdate(Math::abs)
  *     .price(3.14)
- *     .priceUpdate(Math::abs)
  *     .publishDate(LocalDate.now())
- *     .publishDateUpdate(value -> value.plusDays(1))
  *     .publisher(PersonDtoBuilder.create().build())
  *     .salesCount(42L)
- *     .salesCountUpdate(Math::abs)
  *     .subtitle(Optional.of("example value"))
  *     .tags(List.of("example value"))
- *     .tagsUpdate(list -> list.stream().sorted().toList())
  *     .title("example value")
- *     .titleUpdate(String::trim)
  *     .build();
  * }
*/ @@ -205,32 +191,6 @@ public BookDtoBuilder author(String author) { return this; } - /** - * Updates the current value of author in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setAuthor(String) setAuthor(String author)} - * - *

Example:

- * - *
{@code
-   * builder.author("example value").authorUpdate(String::trim);
-   * }
- * - * @param authorUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if author has not been set yet - */ - public BookDtoBuilder authorUpdate(UnaryOperator authorUpdater) { - if (!this.author.isSet()) { - throw new IllegalStateException("Cannot update 'author' before it is set"); - } - this.author = changedValue(authorUpdater.apply(this.author.value())); - return this; - } - /** * Sets the value for available. *

@@ -250,32 +210,6 @@ public BookDtoBuilder available(boolean available) { return this; } - /** - * Updates the current value of available in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setAvailable(boolean) setAvailable(boolean available)} - * - *

Example:

- * - *
{@code
-   * builder.available(true).availableUpdate(value -> !value);
-   * }
- * - * @param availableUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if available has not been set yet - */ - public BookDtoBuilder availableUpdate(UnaryOperator availableUpdater) { - if (!this.available.isSet()) { - throw new IllegalStateException("Cannot update 'available' before it is set"); - } - this.available = changedValue(availableUpdater.apply(this.available.value())); - return this; - } - /** * Sets the value for category. *

@@ -295,26 +229,6 @@ public BookDtoBuilder category(char category) { return this; } - /** - * Updates the current value of category in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setCategory(char) setCategory(char category)} - * - * @param categoryUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if category has not been set yet - */ - public BookDtoBuilder categoryUpdate(UnaryOperator categoryUpdater) { - if (!this.category.isSet()) { - throw new IllegalStateException("Cannot update 'category' before it is set"); - } - this.category = changedValue(categoryUpdater.apply(this.category.value())); - return this; - } - /** * Sets the value for discount. *

@@ -334,32 +248,6 @@ public BookDtoBuilder discount(float discount) { return this; } - /** - * Updates the current value of discount in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setDiscount(float) setDiscount(float discount)} - * - *

Example:

- * - *
{@code
-   * builder.discount(3.14f).discountUpdate(Math::abs);
-   * }
- * - * @param discountUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if discount has not been set yet - */ - public BookDtoBuilder discountUpdate(UnaryOperator discountUpdater) { - if (!this.discount.isSet()) { - throw new IllegalStateException("Cannot update 'discount' before it is set"); - } - this.discount = changedValue(discountUpdater.apply(this.discount.value())); - return this; - } - /** * Sets the value for edition. *

@@ -373,26 +261,6 @@ public BookDtoBuilder edition(short edition) { return this; } - /** - * Updates the current value of edition in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setEdition(short) setEdition(short edition)} - * - * @param editionUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if edition has not been set yet - */ - public BookDtoBuilder editionUpdate(UnaryOperator editionUpdater) { - if (!this.edition.isSet()) { - throw new IllegalStateException("Cannot update 'edition' before it is set"); - } - this.edition = changedValue(editionUpdater.apply(this.edition.value())); - return this; - } - /** * Sets the value for exactPrice. *

@@ -412,26 +280,6 @@ public BookDtoBuilder exactPrice(BigDecimal exactPrice) { return this; } - /** - * Updates the current value of exactPrice in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setExactPrice(BigDecimal) setExactPrice(BigDecimal exactPrice)} - * - * @param exactPriceUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if exactPrice has not been set yet - */ - public BookDtoBuilder exactPriceUpdate(UnaryOperator exactPriceUpdater) { - if (!this.exactPrice.isSet()) { - throw new IllegalStateException("Cannot update 'exactPrice' before it is set"); - } - this.exactPrice = changedValue(exactPriceUpdater.apply(this.exactPrice.value())); - return this; - } - /** * Sets the value for genres. *

@@ -451,32 +299,6 @@ public BookDtoBuilder genres(Set genres) { return this; } - /** - * Updates the current value of genres in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setGenres(Set) setGenres(Set genres)} - * - *

Example:

- * - *
{@code
-   * builder.genres(Set.of("example value")).genresUpdate(TreeSet::new);
-   * }
- * - * @param genresUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if genres has not been set yet - */ - public BookDtoBuilder genresUpdate(UnaryOperator> genresUpdater) { - if (!this.genres.isSet()) { - throw new IllegalStateException("Cannot update 'genres' before it is set"); - } - this.genres = changedValue(genresUpdater.apply(this.genres.value())); - return this; - } - /** * Sets the value for isbn. *

@@ -496,32 +318,6 @@ public BookDtoBuilder isbn(String isbn) { return this; } - /** - * Updates the current value of isbn in place by applying the given operator, instead of reading it out, - * changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setIsbn(String) setIsbn(String isbn)} - * - *

Example:

- * - *
{@code
-   * builder.isbn("example value").isbnUpdate(String::trim);
-   * }
- * - * @param isbnUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if isbn has not been set yet - */ - public BookDtoBuilder isbnUpdate(UnaryOperator isbnUpdater) { - if (!this.isbn.isSet()) { - throw new IllegalStateException("Cannot update 'isbn' before it is set"); - } - this.isbn = changedValue(isbnUpdater.apply(this.isbn.value())); - return this; - } - /** * Sets the value for lastUpdated. *

@@ -541,32 +337,6 @@ public BookDtoBuilder lastUpdated(LocalDateTime lastUpdated) { return this; } - /** - * Updates the current value of lastUpdated in place by applying the given operator, instead of reading - * it out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setLastUpdated(LocalDateTime) setLastUpdated(LocalDateTime lastUpdated)} - * - *

Example:

- * - *
{@code
-   * builder.lastUpdated(LocalDateTime.now()).lastUpdatedUpdate(value -> value.plusDays(1));
-   * }
- * - * @param lastUpdatedUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if lastUpdated has not been set yet - */ - public BookDtoBuilder lastUpdatedUpdate(UnaryOperator lastUpdatedUpdater) { - if (!this.lastUpdated.isSet()) { - throw new IllegalStateException("Cannot update 'lastUpdated' before it is set"); - } - this.lastUpdated = changedValue(lastUpdatedUpdater.apply(this.lastUpdated.value())); - return this; - } - /** * Sets the value for metadata. *

@@ -586,32 +356,6 @@ public BookDtoBuilder metadata(Map metadata) { return this; } - /** - * Updates the current value of metadata in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setMetadata(Map) setMetadata(Map metadata)} - * - *

Example:

- * - *
{@code
-   * builder.metadata(Map.of("example value", "example value")).metadataUpdate(Map::copyOf);
-   * }
- * - * @param metadataUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if metadata has not been set yet - */ - public BookDtoBuilder metadataUpdate(UnaryOperator> metadataUpdater) { - if (!this.metadata.isSet()) { - throw new IllegalStateException("Cannot update 'metadata' before it is set"); - } - this.metadata = changedValue(metadataUpdater.apply(this.metadata.value())); - return this; - } - /** * Sets the value for pages. *

@@ -631,32 +375,6 @@ public BookDtoBuilder pages(int pages) { return this; } - /** - * Updates the current value of pages in place by applying the given operator, instead of reading it out, - * changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setPages(int) setPages(int pages)} - * - *

Example:

- * - *
{@code
-   * builder.pages(42).pagesUpdate(Math::abs);
-   * }
- * - * @param pagesUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if pages has not been set yet - */ - public BookDtoBuilder pagesUpdate(UnaryOperator pagesUpdater) { - if (!this.pages.isSet()) { - throw new IllegalStateException("Cannot update 'pages' before it is set"); - } - this.pages = changedValue(pagesUpdater.apply(this.pages.value())); - return this; - } - /** * Sets the value for price. *

@@ -676,32 +394,6 @@ public BookDtoBuilder price(double price) { return this; } - /** - * Updates the current value of price in place by applying the given operator, instead of reading it out, - * changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setPrice(double) setPrice(double price)} - * - *

Example:

- * - *
{@code
-   * builder.price(3.14).priceUpdate(Math::abs);
-   * }
- * - * @param priceUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if price has not been set yet - */ - public BookDtoBuilder priceUpdate(UnaryOperator priceUpdater) { - if (!this.price.isSet()) { - throw new IllegalStateException("Cannot update 'price' before it is set"); - } - this.price = changedValue(priceUpdater.apply(this.price.value())); - return this; - } - /** * Sets the value for publishDate. *

@@ -721,32 +413,6 @@ public BookDtoBuilder publishDate(LocalDate publishDate) { return this; } - /** - * Updates the current value of publishDate in place by applying the given operator, instead of reading - * it out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setPublishDate(LocalDate) setPublishDate(LocalDate publishDate)} - * - *

Example:

- * - *
{@code
-   * builder.publishDate(LocalDate.now()).publishDateUpdate(value -> value.plusDays(1));
-   * }
- * - * @param publishDateUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if publishDate has not been set yet - */ - public BookDtoBuilder publishDateUpdate(UnaryOperator publishDateUpdater) { - if (!this.publishDate.isSet()) { - throw new IllegalStateException("Cannot update 'publishDate' before it is set"); - } - this.publishDate = changedValue(publishDateUpdater.apply(this.publishDate.value())); - return this; - } - /** * Sets the value for publisher. *

@@ -766,26 +432,6 @@ public BookDtoBuilder publisher(PersonDto publisher) { return this; } - /** - * Updates the current value of publisher in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setPublisher(PersonDto) setPublisher(PersonDto publisher)} - * - * @param publisherUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if publisher has not been set yet - */ - public BookDtoBuilder publisherUpdate(UnaryOperator publisherUpdater) { - if (!this.publisher.isSet()) { - throw new IllegalStateException("Cannot update 'publisher' before it is set"); - } - this.publisher = changedValue(publisherUpdater.apply(this.publisher.value())); - return this; - } - /** * Sets the value for rating. *

@@ -799,26 +445,6 @@ public BookDtoBuilder rating(byte rating) { return this; } - /** - * Updates the current value of rating in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setRating(byte) setRating(byte rating)} - * - * @param ratingUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if rating has not been set yet - */ - public BookDtoBuilder ratingUpdate(UnaryOperator ratingUpdater) { - if (!this.rating.isSet()) { - throw new IllegalStateException("Cannot update 'rating' before it is set"); - } - this.rating = changedValue(ratingUpdater.apply(this.rating.value())); - return this; - } - /** * Sets the value for salesCount. *

@@ -838,32 +464,6 @@ public BookDtoBuilder salesCount(long salesCount) { return this; } - /** - * Updates the current value of salesCount in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setSalesCount(long) setSalesCount(long salesCount)} - * - *

Example:

- * - *
{@code
-   * builder.salesCount(42L).salesCountUpdate(Math::abs);
-   * }
- * - * @param salesCountUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if salesCount has not been set yet - */ - public BookDtoBuilder salesCountUpdate(UnaryOperator salesCountUpdater) { - if (!this.salesCount.isSet()) { - throw new IllegalStateException("Cannot update 'salesCount' before it is set"); - } - this.salesCount = changedValue(salesCountUpdater.apply(this.salesCount.value())); - return this; - } - /** * Sets the value for subtitle. *

@@ -883,26 +483,6 @@ public BookDtoBuilder subtitle(Optional subtitle) { return this; } - /** - * Updates the current value of subtitle in place by applying the given operator, instead of reading it - * out, changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setSubtitle(Optional) setSubtitle(Optional subtitle)} - * - * @param subtitleUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if subtitle has not been set yet - */ - public BookDtoBuilder subtitleUpdate(UnaryOperator> subtitleUpdater) { - if (!this.subtitle.isSet()) { - throw new IllegalStateException("Cannot update 'subtitle' before it is set"); - } - this.subtitle = changedValue(subtitleUpdater.apply(this.subtitle.value())); - return this; - } - /** * Sets the value for tags. *

@@ -922,32 +502,6 @@ public BookDtoBuilder tags(List tags) { return this; } - /** - * Updates the current value of tags in place by applying the given operator, instead of reading it out, - * changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setTags(List) setTags(List tags)} - * - *

Example:

- * - *
{@code
-   * builder.tags(List.of("example value")).tagsUpdate(list -> list.stream().sorted().toList());
-   * }
- * - * @param tagsUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if tags has not been set yet - */ - public BookDtoBuilder tagsUpdate(UnaryOperator> tagsUpdater) { - if (!this.tags.isSet()) { - throw new IllegalStateException("Cannot update 'tags' before it is set"); - } - this.tags = changedValue(tagsUpdater.apply(this.tags.value())); - return this; - } - /** * Sets the value for title. *

@@ -967,32 +521,6 @@ public BookDtoBuilder title(String title) { return this; } - /** - * Updates the current value of title in place by applying the given operator, instead of reading it out, - * changing it and setting it again. Useful for adjustments relative to the current value, e.g. trimming, - * upper-casing, clamping or incrementing, and in combination with the With copy-and-modify flow. The - * value must have been set before (directly or via an existing instance). - *

- * Generated from setter {@link BookDto#setTitle(String) setTitle(String title)} - * - *

Example:

- * - *
{@code
-   * builder.title("example value").titleUpdate(String::trim);
-   * }
- * - * @param titleUpdater operator applied to the current value; its result becomes the new value - * @return current instance of builder - * @throws IllegalStateException if title has not been set yet - */ - public BookDtoBuilder titleUpdate(UnaryOperator titleUpdater) { - if (!this.title.isSet()) { - throw new IllegalStateException("Cannot update 'title' before it is set"); - } - this.title = changedValue(titleUpdater.apply(this.title.value())); - return this; - } - /** * Validates that the author field is not null or empty. *

diff --git a/example/src/main/java/org/javahelpers/simple/builders/example/ElementaryBuilder.java b/example/src/main/java/org/javahelpers/simple/builders/example/ElementaryBuilder.java index e48984ce..7b84acee 100644 --- a/example/src/main/java/org/javahelpers/simple/builders/example/ElementaryBuilder.java +++ b/example/src/main/java/org/javahelpers/simple/builders/example/ElementaryBuilder.java @@ -40,6 +40,7 @@ generateConditionalHelper = OptionState.DISABLED, generateVarArgsHelpers = OptionState.DISABLED, generateStringFormatHelpers = OptionState.DISABLED, + generateUpdateHelpers = OptionState.DISABLED, generateAddToCollectionHelpers = OptionState.DISABLED, generateUnboxedOptional = OptionState.DISABLED, copyTypeAnnotations = OptionState.DISABLED,