From 008da5fb73b1ce33984e9583d38a902f12f16535 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Mon, 17 Aug 2026 00:07:55 +0200 Subject: [PATCH 01/35] Adding a module for holding testclasses for performance test --- performance-test/pom.xml | 97 ++++++++++++++++++++++++++++++++++++++++ pom.xml | 6 +++ 2 files changed, 103 insertions(+) create mode 100644 performance-test/pom.xml diff --git a/performance-test/pom.xml b/performance-test/pom.xml new file mode 100644 index 00000000..159b6469 --- /dev/null +++ b/performance-test/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + io.github.java-helpers + simple-builders-performance-test + 0.6.0-SNAPSHOT + jar + + Simple Builders - Performance Test + Performance test module with 1000 DTO classes for measuring builder generation performance. Not part of the default build. + https://github.com/java-helpers/simple-builders + 2026 + + + 17 + UTF-8 + + 3.20.0 + + ${java.version} + ${java.version} + ${java.version} + + + false + false + + 3.15.0 + 3.1.4 + + + + + io.github.java-helpers + simple-builders-core + ${project.version} + + + org.apache.commons + commons-lang3 + ${commons-lang.version} + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + ${plugin.maven.deploy.version} + + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${plugin.maven.compiler.version} + + ${java.version} + ${java.version} + ${java.version} + ${project.basedir}/generated-performance-builder + + + + default-compile + + + + io.github.java-helpers + simple-builders-processor + ${project.version} + + + + -Averbose=${simplebuilder.verbose} + -Asimplebuilder.performanceTracking=${simplebuilder.performanceTracking} + + + + + default-testCompile + + none + + + + + + + diff --git a/pom.xml b/pom.xml index 24235cd6..ec1aeaee 100644 --- a/pom.xml +++ b/pom.xml @@ -172,5 +172,11 @@ + + performance-test + + performance-test + + \ No newline at end of file From 8f7321c7f651d738a19ad13f65b5d24550480d29 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Mon, 17 Aug 2026 00:22:39 +0200 Subject: [PATCH 02/35] Moving ProcessingLogger into package org.javahelpers.simple.builders.processor.processing.logging --- .../simple/builders/processor/BuilderProcessor.java | 2 +- .../processor/classgen/roaster/RoasterCodeGenerator.java | 2 +- .../generators/integration/JacksonModuleGenerator.java | 2 +- .../processor/processing/BuilderConfigurationReader.java | 1 + .../builders/processor/processing/ProcessingContext.java | 1 + .../processor/processing/{ => logging}/ProcessingLogger.java | 4 +++- .../processor/RoasterCodeGeneratorResilienceTest.java | 2 +- 7 files changed, 9 insertions(+), 5 deletions(-) rename processor/src/main/java/org/javahelpers/simple/builders/processor/processing/{ => logging}/ProcessingLogger.java (98%) diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java index d89d43e1..1ae1002c 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java @@ -56,7 +56,7 @@ import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsEnum; import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsReader; import org.javahelpers.simple.builders.processor.processing.ProcessingContext; -import org.javahelpers.simple.builders.processor.processing.ProcessingLogger; +import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; /** * BuilderProcessor is an annotation processor for execution in generate-sources phase. The diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java index 5e3f5df1..49f572ef 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java @@ -58,7 +58,7 @@ import org.javahelpers.simple.builders.processor.model.type.NestedTypeDto; import org.javahelpers.simple.builders.processor.model.type.TypeName; import org.javahelpers.simple.builders.processor.model.type.TypeNameArray; -import org.javahelpers.simple.builders.processor.processing.ProcessingLogger; +import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; import org.javahelpers.simple.builders.processor.util.ImportCollector; import org.jboss.forge.roaster.Roaster; import org.jboss.forge.roaster.model.source.AnnotationSource; diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/integration/JacksonModuleGenerator.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/integration/JacksonModuleGenerator.java index 6c7e96a0..7c4faf17 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/integration/JacksonModuleGenerator.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/integration/JacksonModuleGenerator.java @@ -41,7 +41,7 @@ import org.javahelpers.simple.builders.processor.model.method.MethodCodeDto; import org.javahelpers.simple.builders.processor.model.type.NestedTypeDto; import org.javahelpers.simple.builders.processor.model.type.TypeName; -import org.javahelpers.simple.builders.processor.processing.ProcessingLogger; +import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; /** * Generates Jackson SimpleModules to register all generated builders. diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/BuilderConfigurationReader.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/BuilderConfigurationReader.java index 6abb5259..49398368 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/BuilderConfigurationReader.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/BuilderConfigurationReader.java @@ -39,6 +39,7 @@ import org.javahelpers.simple.builders.core.enums.OptionState; import org.javahelpers.simple.builders.processor.exceptions.BuilderException; import org.javahelpers.simple.builders.processor.model.core.BuilderConfiguration; +import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; /** * Reads builder configuration from annotated elements. diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java index 2886227f..1665a8f9 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java @@ -35,6 +35,7 @@ import org.javahelpers.simple.builders.processor.generators.registry.GeneratorRegistry; import org.javahelpers.simple.builders.processor.model.core.BuilderConfiguration; import org.javahelpers.simple.builders.processor.model.type.TypeName; +import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; /** * Context object that wraps Elements, Types, and logging utilities from annotation processing, diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingLogger.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ProcessingLogger.java similarity index 98% rename from processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingLogger.java rename to processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ProcessingLogger.java index 5be6032e..fa3bf1a5 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingLogger.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ProcessingLogger.java @@ -22,12 +22,14 @@ * SOFTWARE. */ -package org.javahelpers.simple.builders.processor.processing; +package org.javahelpers.simple.builders.processor.processing.logging; import javax.annotation.processing.Messager; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.tools.Diagnostic; +import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsEnum; +import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsReader; /** * Logger for all messages during annotation processing. Providing util-functions for posting diff --git a/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java b/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java index 5a01ba85..168d5976 100644 --- a/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java +++ b/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java @@ -49,7 +49,7 @@ import org.javahelpers.simple.builders.processor.model.method.MethodCodeDto; import org.javahelpers.simple.builders.processor.model.method.MethodCodePlaceholder; import org.javahelpers.simple.builders.processor.model.type.TypeName; -import org.javahelpers.simple.builders.processor.processing.ProcessingLogger; +import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; import org.junit.jupiter.api.Test; /** From 1bf5e03691f9b2c99ee732bb6159ecfc2f93761c Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Mon, 17 Aug 2026 00:24:47 +0200 Subject: [PATCH 03/35] Implementation of first PerformanceTracking algorithm --- .../builders/processor/BuilderProcessor.java | 45 +++- .../registry/GeneratorRegistry.java | 9 + .../processing/CompilerArgumentsEnum.java | 4 + .../processing/ProcessingContext.java | 32 +++ .../logging/ActivePerformanceTracker.java | 226 ++++++++++++++++++ .../logging/NoOpPerformanceTracker.java | 79 ++++++ .../logging/PerformanceTracker.java | 111 +++++++++ 7 files changed, 504 insertions(+), 2 deletions(-) create mode 100644 processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java create mode 100644 processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/NoOpPerformanceTracker.java create mode 100644 processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java index 1ae1002c..44ef28f5 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java @@ -56,6 +56,7 @@ import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsEnum; import org.javahelpers.simple.builders.processor.processing.CompilerArgumentsReader; import org.javahelpers.simple.builders.processor.processing.ProcessingContext; +import org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker; import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; /** @@ -112,6 +113,10 @@ public boolean process(Set annotations, RoundEnvironment // Generate Jackson Module if processing is over and feature is enabled if (roundEnv.processingOver()) { + // Generate performance report at the end of processing + PerformanceTracker tracker = context.getPerformanceTracker(); + tracker.generateReport(context.getLogger()); + List moduleClassDefs = jacksonModuleGenerator.getModuleDefinitions(); for (GenerationTargetClassDto moduleClassDef : moduleClassDefs) { @@ -175,13 +180,17 @@ public boolean process(Set annotations, RoundEnvironment .sorted(Comparator.comparing(element -> element.getSimpleName().toString())) .toList(); + PerformanceTracker tracker = context.getPerformanceTracker(); int successfulGenerations = 0; for (Element annotatedElement : sortedElements) { context.debugStartOperation("Processing element: " + annotatedElement.getSimpleName()); + String className = annotatedElement.getSimpleName().toString(); + tracker.startClass(className); try { - // Resolve configuration per-element to handle all layers - // (defaults, global, template, inline) + // Track Configuration Resolution (actual work happens here) + tracker.startPhase("Configuration Resolution", className); BuilderConfiguration config = reader.resolveConfiguration(annotatedElement); + tracker.endPhase("Configuration Resolution"); context.debug("Configuration resolved: %s", config); process(annotatedElement, config); successfulGenerations++; @@ -225,14 +234,46 @@ public SourceVersion getSupportedSourceVersion() { private void process(Element annotatedElement, BuilderConfiguration config) throws BuilderException { context.initConfigurationForProcessingTarget(config); + PerformanceTracker tracker = context.getPerformanceTracker(); + String className = annotatedElement.getSimpleName().toString(); + + // Track Builder Definition Extraction + tracker.startPhase("Builder Definition Extraction", className); BuilderDefinitionDto builderDef = extractFromElement(annotatedElement, context); + tracker.endPhase("Builder Definition Extraction"); + + // Compute class-level metrics now that the definition is available + int fieldCount = builderDef.getAllFieldsForBuilder().size(); + int collectionCount = + (int) + builderDef.getAllFieldsForBuilder().stream() + .filter( + f -> { + String typeName = f.getFieldType().getFullQualifiedName(); + return typeName.startsWith("java.util.List") + || typeName.startsWith("java.util.Set") + || typeName.startsWith("java.util.Map") + || typeName.startsWith("java.util.Collection"); + }) + .count(); + + // Track DTO Mapping + tracker.startPhase("DTO Mapping", className); GenerationTargetClassDto renderingDto = toRenderingDto(builderDef); + tracker.endPhase("DTO Mapping"); + + // Track Code Generation + tracker.startPhase("Code Generation (Roaster)", className); codeGenerator.generateClass(renderingDto); + tracker.endPhase("Code Generation (Roaster)"); // Collect info for Jackson Module if enabled jacksonModuleGenerator.addEntry(builderDef, annotatedElement); context.debug("Jackson module entry added"); + // End class-level timing (started in caller before config resolution) + tracker.endClass(fieldCount, collectionCount); + // Add summary of what was generated context.debugEndOperation( "Generated builder with %d fields and %d methods for %s", diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/registry/GeneratorRegistry.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/registry/GeneratorRegistry.java index ef0ebce8..9638c47e 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/registry/GeneratorRegistry.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/generators/registry/GeneratorRegistry.java @@ -38,6 +38,7 @@ import org.javahelpers.simple.builders.processor.model.method.BuilderMethodDto; import org.javahelpers.simple.builders.processor.model.type.TypeName; import org.javahelpers.simple.builders.processor.processing.ProcessingContext; +import org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker; /** * Unified registry that manages all generators (both method generators and builder enhancers). @@ -60,6 +61,7 @@ public class GeneratorRegistry { private final List builderEnhancers; private final ProcessingContext context; private final ComponentFilter componentFilter; + private final PerformanceTracker performanceTracker; /** * Creates a new registry and initializes it with built-in and custom generators. @@ -72,6 +74,7 @@ public GeneratorRegistry(ProcessingContext context, ProcessingEnvironment proces this.methodGenerators = new ArrayList<>(); this.builderEnhancers = new ArrayList<>(); this.componentFilter = new ComponentFilter(processingEnv); + this.performanceTracker = context.getPerformanceTracker(); loadAllGenerators(); sortGeneratorsByPriority(); @@ -102,8 +105,11 @@ public List generateAllMethods( "Applying: %s (priority: %d)", generator.getClass().getSimpleName(), generator.getPriority()); + String genName = generator.getClass().getSimpleName(); + performanceTracker.startGenerator(genName); List generatedMethods = generator.generateMethods(field, builderType, context); + performanceTracker.endGenerator(genName); if (CollectionUtils.isNotEmpty(generatedMethods)) { allMethods.addAll(generatedMethods); @@ -136,7 +142,10 @@ public void enhanceBuilder(BuilderDefinitionDto builderDto, TypeName dtoType) { "Applying: %s (priority: %d)", enhancer.getClass().getSimpleName(), enhancer.getPriority()); + String enhName = enhancer.getClass().getSimpleName(); + performanceTracker.startEnhancer(enhName); enhancer.enhanceBuilder(builderDto, context); + performanceTracker.endEnhancer(enhName); appliedEnhancers++; } catch (Exception e) { context.error( diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java index cf40d714..4703b5b0 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java @@ -133,6 +133,10 @@ public enum CompilerArgumentsEnum { /** Option for verbose logging output. */ VERBOSE("verbose"), + // === Performance Tracking === + /** Option for performance tracking during annotation processing. */ + PERFORMANCE_TRACKING("performanceTracking"), + // === Error Handling === /** * Option for strict/fail-fast generation mode. When enabled, builder (and Jackson module) diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java index 1665a8f9..ca2c832d 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java @@ -35,6 +35,9 @@ import org.javahelpers.simple.builders.processor.generators.registry.GeneratorRegistry; import org.javahelpers.simple.builders.processor.model.core.BuilderConfiguration; import org.javahelpers.simple.builders.processor.model.type.TypeName; +import org.javahelpers.simple.builders.processor.processing.logging.ActivePerformanceTracker; +import org.javahelpers.simple.builders.processor.processing.logging.NoOpPerformanceTracker; +import org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker; import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; /** @@ -49,6 +52,7 @@ public final class ProcessingContext { private final ProcessingLogger logger; private final BuilderConfigurationReader configurationReader; private final ProcessingEnvironment processingEnv; + private final PerformanceTracker performanceTracker; private GeneratorRegistry generatorRegistry; private BuilderConfiguration configurationForProcessingTarget; @@ -69,6 +73,12 @@ public ProcessingContext( this.processingEnv = processingEnv; this.configurationReader = new BuilderConfigurationReader(globalConfiguration, logger, elementUtils); + // Initialize performance tracker based on compiler argument + CompilerArgumentsReader argReader = new CompilerArgumentsReader(processingEnv); + boolean perfTrackingEnabled = + argReader.readBooleanValue(CompilerArgumentsEnum.PERFORMANCE_TRACKING); + this.performanceTracker = + perfTrackingEnabled ? new ActivePerformanceTracker() : new NoOpPerformanceTracker(); // GeneratorRegistry will be lazily initialized on first access } @@ -114,6 +124,19 @@ public GeneratorRegistry getGeneratorRegistry() { return generatorRegistry; } + /** + * Gets the performance tracker for this processing context. + * + *

When performance tracking is disabled, returns a {@link NoOpPerformanceTracker} that has + * zero overhead. When enabled via {@code -Asimplebuilder.performanceTracking=true}, returns an + * {@link ActivePerformanceTracker} that measures execution times. + * + * @return the performance tracker instance + */ + public PerformanceTracker getPerformanceTracker() { + return performanceTracker; + } + /** * Get the TypeElement for a given qualified class name. * @@ -230,6 +253,15 @@ public java.util.List directSupertypes(TypeMirror typeMirr return typeUtils.directSupertypes(typeMirror); } + /** + * Gets the processing logger for this context. + * + * @return the processing logger + */ + public ProcessingLogger getLogger() { + return logger; + } + /** * Logs an info-level message that appears in normal Maven output. * diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java new file mode 100644 index 00000000..421838d7 --- /dev/null +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java @@ -0,0 +1,226 @@ +/* + * MIT License + * + * Copyright (c) 2026 Andreas Igel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.javahelpers.simple.builders.processor.processing.logging; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Active implementation of {@link PerformanceTracker} that measures execution times using {@link + * System#nanoTime()} and aggregates results for a summary report. + * + *

This tracker maintains: + * + *

    + *
  • Per-phase total time (Configuration Resolution, Builder Definition Extraction, DTO Mapping, + * Code Generation) + *
  • Per-generator total time and call count (for MethodGenerators) + *
  • Per-enhancer total time and call count (for BuilderEnhancers) + *
  • Per-class total time with field count and collection count + *
+ */ +public final class ActivePerformanceTracker implements PerformanceTracker { + + private final Map phaseTimes = new LinkedHashMap<>(); + private final Map generatorTimes = new LinkedHashMap<>(); + private final Map generatorCalls = new LinkedHashMap<>(); + private final Map enhancerTimes = new LinkedHashMap<>(); + private final Map enhancerCalls = new LinkedHashMap<>(); + private final List classMetrics = new ArrayList<>(); + + private final ThreadLocal> phaseStartStack = ThreadLocal.withInitial(ArrayList::new); + private final ThreadLocal> generatorStartStack = + ThreadLocal.withInitial(ArrayList::new); + private final ThreadLocal> enhancerStartStack = + ThreadLocal.withInitial(ArrayList::new); + + private long totalStartTime; + private int totalClasses = 0; + + private String currentClassName; + private long classStartTime; + + /** Creates a new ActivePerformanceTracker and records the overall start time. */ + public ActivePerformanceTracker() { + this.totalStartTime = System.nanoTime(); + } + + @Override + public void startPhase(String phase, String className) { + phaseStartStack.get().add(System.nanoTime()); + } + + @Override + public void endPhase(String phase) { + List stack = phaseStartStack.get(); + if (stack.isEmpty()) { + return; + } + long start = stack.remove(stack.size() - 1); + long elapsed = System.nanoTime() - start; + phaseTimes.merge(phase, elapsed, Long::sum); + } + + @Override + public void startGenerator(String generatorName) { + generatorStartStack.get().add(System.nanoTime()); + } + + @Override + public void endGenerator(String generatorName) { + List stack = generatorStartStack.get(); + if (stack.isEmpty()) { + return; + } + long start = stack.remove(stack.size() - 1); + long elapsed = System.nanoTime() - start; + generatorTimes.merge(generatorName, elapsed, Long::sum); + generatorCalls.merge(generatorName, 1, Integer::sum); + } + + @Override + public void startEnhancer(String enhancerName) { + enhancerStartStack.get().add(System.nanoTime()); + } + + @Override + public void endEnhancer(String enhancerName) { + List stack = enhancerStartStack.get(); + if (stack.isEmpty()) { + return; + } + long start = stack.remove(stack.size() - 1); + long elapsed = System.nanoTime() - start; + enhancerTimes.merge(enhancerName, elapsed, Long::sum); + enhancerCalls.merge(enhancerName, 1, Integer::sum); + } + + @Override + public void startClass(String className) { + this.currentClassName = className; + this.classStartTime = System.nanoTime(); + } + + @Override + public void endClass(int fieldCount, int collectionCount) { + if (currentClassName == null) { + return; + } + long elapsed = System.nanoTime() - classStartTime; + classMetrics.add(new ClassMetric(currentClassName, elapsed, fieldCount, collectionCount)); + totalClasses++; + currentClassName = null; + } + + @Override + public void generateReport(ProcessingLogger logger) { + long totalTime = System.nanoTime() - totalStartTime; + double totalSeconds = totalTime / 1_000_000_000.0; + + logger.info("simple-builders: PERFORMANCE REPORT"); + logger.info("================================"); + logger.info("Total classes processed: %d", totalClasses); + logger.info("Total processing time: %.1fs", totalSeconds); + logger.info(""); + + // Phase breakdown + logger.info("Phase breakdown:"); + Map phaseSeconds = new LinkedHashMap<>(); + for (Map.Entry entry : phaseTimes.entrySet()) { + phaseSeconds.put(entry.getKey(), entry.getValue() / 1_000_000_000.0); + } + for (Map.Entry entry : phaseSeconds.entrySet()) { + double phaseTime = entry.getValue(); + double percentage = totalSeconds > 0 ? (phaseTime / totalSeconds) * 100 : 0; + logger.info(" %s: %.1fs (%.1f%%)", entry.getKey(), phaseTime, percentage); + } + logger.info(""); + + // Average per class + if (totalClasses > 0) { + double avgPerClass = (totalTime / 1_000_000.0) / totalClasses; + logger.info("Average per class: %.1fms", avgPerClass); + logger.info(""); + } + + // Top 5 slowest classes + List topClasses = new ArrayList<>(classMetrics); + topClasses.sort(Comparator.comparingLong(ClassMetric::elapsedNanos).reversed()); + int classLimit = Math.min(5, topClasses.size()); + if (classLimit > 0) { + logger.info("Top %d slowest classes:", classLimit); + for (int i = 0; i < classLimit; i++) { + ClassMetric cm = topClasses.get(i); + double ms = cm.elapsedNanos() / 1_000_000.0; + logger.info( + " %d. %s - %.0fms (%d fields, %d collections)", + i + 1, cm.className(), ms, cm.fieldCount(), cm.collectionCount()); + } + logger.info(""); + } + + // Top 5 slowest MethodGenerators + List> topGenerators = new ArrayList<>(generatorTimes.entrySet()); + topGenerators.sort(Map.Entry.comparingByValue().reversed()); + int genLimit = Math.min(5, topGenerators.size()); + if (genLimit > 0) { + logger.info("Top %d slowest MethodGenerators:", genLimit); + for (int i = 0; i < genLimit; i++) { + Map.Entry entry = topGenerators.get(i); + double seconds = entry.getValue() / 1_000_000_000.0; + int calls = generatorCalls.getOrDefault(entry.getKey(), 0); + double avgMs = calls > 0 ? (entry.getValue() / 1_000_000.0) / calls : 0; + logger.info( + " %d. %s - %.1fs (%d calls, %.2fms/call)", + i + 1, entry.getKey(), seconds, calls, avgMs); + } + logger.info(""); + } + + // Top 5 slowest BuilderEnhancers + List> topEnhancers = new ArrayList<>(enhancerTimes.entrySet()); + topEnhancers.sort(Map.Entry.comparingByValue().reversed()); + int enhLimit = Math.min(5, topEnhancers.size()); + if (enhLimit > 0) { + logger.info("Top %d slowest BuilderEnhancers:", enhLimit); + for (int i = 0; i < enhLimit; i++) { + Map.Entry entry = topEnhancers.get(i); + double seconds = entry.getValue() / 1_000_000_000.0; + int calls = enhancerCalls.getOrDefault(entry.getKey(), 0); + double avgMs = calls > 0 ? (entry.getValue() / 1_000_000.0) / calls : 0; + logger.info( + " %d. %s - %.1fs (%d calls, %.2fms/call)", + i + 1, entry.getKey(), seconds, calls, avgMs); + } + } + } + + /** Record for per-class performance metrics. */ + private record ClassMetric( + String className, long elapsedNanos, int fieldCount, int collectionCount) {} +} diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/NoOpPerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/NoOpPerformanceTracker.java new file mode 100644 index 00000000..6a771d4a --- /dev/null +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/NoOpPerformanceTracker.java @@ -0,0 +1,79 @@ +/* + * MIT License + * + * Copyright (c) 2026 Andreas Igel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.javahelpers.simple.builders.processor.processing.logging; + +/** + * No-operation implementation of {@link PerformanceTracker} that does nothing. + * + *

All methods are empty, so the JIT compiler can eliminate them entirely when the tracker is + * fixed at construction time. This ensures zero overhead when performance tracking is disabled. + */ +public final class NoOpPerformanceTracker implements PerformanceTracker { + + @Override + public void startPhase(String phase, String className) { + // No-op + } + + @Override + public void endPhase(String phase) { + // No-op + } + + @Override + public void startGenerator(String generatorName) { + // No-op + } + + @Override + public void endGenerator(String generatorName) { + // No-op + } + + @Override + public void startEnhancer(String enhancerName) { + // No-op + } + + @Override + public void endEnhancer(String enhancerName) { + // No-op + } + + @Override + public void startClass(String className) { + // No-op + } + + @Override + public void endClass(int fieldCount, int collectionCount) { + // No-op + } + + @Override + public void generateReport(ProcessingLogger logger) { + // No-op + } +} diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java new file mode 100644 index 00000000..ddee9eb2 --- /dev/null +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java @@ -0,0 +1,111 @@ +/* + * MIT License + * + * Copyright (c) 2026 Andreas Igel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.javahelpers.simple.builders.processor.processing.logging; + +/** + * Interface for tracking performance metrics during annotation processing. + * + *

Implementations: + * + *

    + *
  • {@link NoOpPerformanceTracker} - all methods are no-ops, zero overhead (default) + *
  • {@link ActivePerformanceTracker} - actual measurement with nanoTime and aggregation + *
+ * + *

The No-Op pattern ensures that when performance tracking is disabled, the JIT compiler can + * eliminate all tracking calls entirely, as the receiver type is fixed at construction time and all + * methods are empty. + */ +public interface PerformanceTracker { + + /** + * Starts tracking a processing phase for a specific class. + * + * @param phase the phase identifier (e.g., "Configuration Resolution", "Builder Definition + * Extraction") + * @param className the simple name of the class being processed + */ + void startPhase(String phase, String className); + + /** + * Ends tracking a processing phase. + * + * @param phase the phase identifier that was started + */ + void endPhase(String phase); + + /** + * Starts tracking an individual method generator invocation. + * + * @param generatorName the simple class name of the method generator + */ + void startGenerator(String generatorName); + + /** + * Ends tracking an individual method generator invocation. + * + * @param generatorName the simple class name of the method generator that was started + */ + void endGenerator(String generatorName); + + /** + * Starts tracking an individual builder enhancer invocation. + * + * @param enhancerName the simple class name of the builder enhancer + */ + void startEnhancer(String enhancerName); + + /** + * Ends tracking an individual builder enhancer invocation. + * + * @param enhancerName the simple class name of the builder enhancer that was started + */ + void endEnhancer(String enhancerName); + + /** + * Records the start of processing for a specific class. + * + *

Call this before any work begins for the class. Field and collection counts are not yet + * known at this point; they are passed to {@link #endClass(int, int)} after extraction. + * + * @param className the simple name of the class being processed + */ + void startClass(String className); + + /** + * Records the end of processing for the current class. + * + * @param fieldCount the number of fields in the class + * @param collectionCount the number of collection-type fields + */ + void endClass(int fieldCount, int collectionCount); + + /** + * Generates and logs the performance report. + * + * @param logger the processing logger to output the report + */ + void generateReport(ProcessingLogger logger); +} From 0dcec37ea49a638e40137c2bc43e06b41737e053 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Mon, 17 Aug 2026 01:06:29 +0200 Subject: [PATCH 04/35] Refactoring of performance tracker and integration in build process t add processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java && GIT_EDITOR=true git rebase --continue t add processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java sdft status --short t status --short t status --- .../builders/processor/BuilderProcessor.java | 25 ++-- .../roaster/RoasterCodeGenerator.java | 83 ++++++++---- .../logging/ActivePerformanceTracker.java | 120 +++++++++++++++--- .../logging/PerformanceTracker.java | 24 ++++ .../RoasterCodeGeneratorResilienceTest.java | 4 +- 5 files changed, 196 insertions(+), 60 deletions(-) diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java index 44ef28f5..8ebb3266 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/BuilderProcessor.java @@ -26,6 +26,10 @@ import static org.javahelpers.simple.builders.processor.model.core.BuilderToGenerationTypeMapper.toRenderingDto; import static org.javahelpers.simple.builders.processor.processing.BuilderDefinitionCreator.extractFromElement; +import static org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker.PHASE_BUILDER_DEFINITION_EXTRACTION; +import static org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker.PHASE_CODE_GENERATION; +import static org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker.PHASE_CONFIGURATION_RESOLUTION; +import static org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker.PHASE_DTO_MAPPING; import com.google.auto.service.AutoService; import java.util.ArrayList; @@ -84,7 +88,8 @@ public synchronized void init(ProcessingEnvironment processingEnv) { logger.debug("Loaded global configuration from compiler arguments: %s", globalConfig); this.context = new ProcessingContext(logger, globalConfig, processingEnv); - this.codeGenerator = new RoasterCodeGenerator(processingEnv, logger); + this.codeGenerator = + new RoasterCodeGenerator(processingEnv, logger, context.getPerformanceTracker()); this.jacksonModuleGenerator = new JacksonModuleGenerator(processingEnv, logger); // Initialize GeneratorRegistry once during processor initialization @@ -188,9 +193,9 @@ public boolean process(Set annotations, RoundEnvironment tracker.startClass(className); try { // Track Configuration Resolution (actual work happens here) - tracker.startPhase("Configuration Resolution", className); + tracker.startPhase(PHASE_CONFIGURATION_RESOLUTION, className); BuilderConfiguration config = reader.resolveConfiguration(annotatedElement); - tracker.endPhase("Configuration Resolution"); + tracker.endPhase(PHASE_CONFIGURATION_RESOLUTION); context.debug("Configuration resolved: %s", config); process(annotatedElement, config); successfulGenerations++; @@ -238,9 +243,9 @@ private void process(Element annotatedElement, BuilderConfiguration config) String className = annotatedElement.getSimpleName().toString(); // Track Builder Definition Extraction - tracker.startPhase("Builder Definition Extraction", className); + tracker.startPhase(PHASE_BUILDER_DEFINITION_EXTRACTION, className); BuilderDefinitionDto builderDef = extractFromElement(annotatedElement, context); - tracker.endPhase("Builder Definition Extraction"); + tracker.endPhase(PHASE_BUILDER_DEFINITION_EXTRACTION); // Compute class-level metrics now that the definition is available int fieldCount = builderDef.getAllFieldsForBuilder().size(); @@ -258,14 +263,14 @@ private void process(Element annotatedElement, BuilderConfiguration config) .count(); // Track DTO Mapping - tracker.startPhase("DTO Mapping", className); + tracker.startPhase(PHASE_DTO_MAPPING, className); GenerationTargetClassDto renderingDto = toRenderingDto(builderDef); - tracker.endPhase("DTO Mapping"); + tracker.endPhase(PHASE_DTO_MAPPING); - // Track Code Generation - tracker.startPhase("Code Generation (Roaster)", className); + // Track Code Generation (parent phase; sub-phases tracked inside RoasterCodeGenerator) + tracker.startPhase(PHASE_CODE_GENERATION, className); codeGenerator.generateClass(renderingDto); - tracker.endPhase("Code Generation (Roaster)"); + tracker.endPhase(PHASE_CODE_GENERATION); // Collect info for Jackson Module if enabled jacksonModuleGenerator.addEntry(builderDef, annotatedElement); diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java index 49f572ef..be4d9e44 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/classgen/roaster/RoasterCodeGenerator.java @@ -26,6 +26,7 @@ import static org.javahelpers.simple.builders.processor.classgen.roaster.RoasterMapper.mapType; import static org.javahelpers.simple.builders.processor.classgen.roaster.RoasterMapper.resolveCodeTemplate; +import static org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker.*; import java.io.IOException; import java.io.InputStream; @@ -58,6 +59,7 @@ import org.javahelpers.simple.builders.processor.model.type.NestedTypeDto; import org.javahelpers.simple.builders.processor.model.type.TypeName; import org.javahelpers.simple.builders.processor.model.type.TypeNameArray; +import org.javahelpers.simple.builders.processor.processing.logging.PerformanceTracker; import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; import org.javahelpers.simple.builders.processor.util.ImportCollector; import org.jboss.forge.roaster.Roaster; @@ -81,6 +83,9 @@ public class RoasterCodeGenerator { /** Logger for debug output during code generation. */ private final ProcessingLogger logger; + /** Performance tracker for sub-phase timing (Source Construction, File Writing). */ + private final PerformanceTracker performanceTracker; + private final Properties formatterProperties; /** @@ -89,9 +94,11 @@ public class RoasterCodeGenerator { * @param processingEnv Processing environment for accessing filer and element utilities * @param logger Logger for debug output */ - public RoasterCodeGenerator(ProcessingEnvironment processingEnv, ProcessingLogger logger) { + public RoasterCodeGenerator( + ProcessingEnvironment processingEnv, ProcessingLogger logger, PerformanceTracker tracker) { this.processingEnv = processingEnv; this.logger = logger; + this.performanceTracker = tracker; this.formatterProperties = loadFormatterProperties(); } @@ -107,20 +114,38 @@ public void generateClass(GenerationTargetClassDto classDef) throws BuilderExcep String sourceCode; try { - sourceCode = createClassSource(classDef); + String className = classDef.getTypeName().getClassName(); + performanceTracker.startPhase(PHASE_SOURCE_CONSTRUCTION, className); + JavaClassSource source = buildClassSource(classDef); + performanceTracker.startPhase(PHASE_STRING_GENERATION, className); + String unformatted = source.toUnformattedString(); + performanceTracker.endPhase(PHASE_STRING_GENERATION); + performanceTracker.startPhase(PHASE_FORMATTING, className); + sourceCode = formatSource(unformatted); + // Roaster renders some java.lang annotations (e.g. @SuppressWarnings, @Deprecated with + // members) with their FQN (@java.lang.SuppressWarnings) even though java.lang types don't + // need qualification. Fix this by replacing @java.lang.Xxx with @Xxx for known annotations. + sourceCode = sourceCode.replace("@java.lang.SuppressWarnings", "@SuppressWarnings"); + sourceCode = sourceCode.replace("@java.lang.Deprecated", "@Deprecated"); + performanceTracker.endPhase(PHASE_FORMATTING); + performanceTracker.endPhase(PHASE_SOURCE_CONSTRUCTION); } catch (RuntimeException ex) { // Rendering failures (e.g. RoasterMapperException) are RuntimeExceptions. Convert them into // a BuilderException so callers can isolate the failure to this single class and keep // generating the remaining builders instead of aborting the whole processing round. throw new BuilderException(null, ex); } + performanceTracker.startPhase(PHASE_FILE_WRITING, classDef.getTypeName().getClassName()); writeClassToFile(sourceCode, classDef); + performanceTracker.endPhase(PHASE_FILE_WRITING); logger.debugEndOperation( "Successfully generated class: %s", classDef.getTypeName().getClassName()); } - private String createClassSource(GenerationTargetClassDto classDef) { + private JavaClassSource buildClassSource(GenerationTargetClassDto classDef) { + String className = classDef.getTypeName().getClassName(); + performanceTracker.startPhase(PHASE_ELEMENT_BUILDING, className); JavaClassSource source = createJavaClassSource(classDef); addClassMetadata(source, classDef); appendFields(source, classDef); @@ -128,19 +153,22 @@ private String createClassSource(GenerationTargetClassDto classDef) { appendMethods(source, classDef); appendNestedTypes(source, classDef); applyClassAnnotations(source, classDef); - return renderClassSource(source); + performanceTracker.endPhase(PHASE_ELEMENT_BUILDING); + return source; } private void applyClassAnnotations(JavaClassSource source, GenerationTargetClassDto classDef) { - if (CollectionUtils.isEmpty(classDef.getClassAnnotations())) { - return; + performanceTracker.startPhase(PHASE_CLASS_ANNOTATIONS, classDef.getTypeName().getClassName()); + if (CollectionUtils.isNotEmpty(classDef.getClassAnnotations())) { + // Adding class annotations + applyAnnotations(source, classDef.getClassAnnotations()); + logger.debug("Class-level annotations added"); } - // Adding class annotations - applyAnnotations(source, classDef.getClassAnnotations()); - logger.debug("Class-level annotations added"); + performanceTracker.endPhase(PHASE_CLASS_ANNOTATIONS); } private JavaClassSource createJavaClassSource(GenerationTargetClassDto classDef) { + performanceTracker.startPhase(PHASE_CLASS_CREATION, classDef.getTypeName().getClassName()); if (CollectionUtils.isNotEmpty(classDef.getGenerics())) { logger.debug("Class has %d generic type parameter(s)", classDef.getGenerics().size()); } @@ -166,10 +194,12 @@ private JavaClassSource createJavaClassSource(GenerationTargetClassDto classDef) } logger.debug("JavaClassSource created"); + performanceTracker.endPhase(PHASE_CLASS_CREATION); return source; } private void addClassMetadata(JavaClassSource source, GenerationTargetClassDto classDef) { + performanceTracker.startPhase(PHASE_CLASS_METADATA, classDef.getTypeName().getClassName()); applyJavadoc(source, classDef.getClassJavadoc()); applyVisibility(source, classDef.getClassAccessModifier()); applySuperType(source, classDef.getSuperType()); @@ -180,20 +210,11 @@ private void addClassMetadata(JavaClassSource source, GenerationTargetClassDto c } logger.debug("Class metadata added"); - } - - private String renderClassSource(JavaClassSource source) { - String rendered = source.toUnformattedString(); - String formatted = formatSource(rendered); - // Roaster renders some java.lang annotations (e.g. @SuppressWarnings, @Deprecated with - // members) with their FQN (@java.lang.SuppressWarnings) even though java.lang types don't - // need qualification. Fix this by replacing @java.lang.Xxx with @Xxx for known annotations. - formatted = formatted.replace("@java.lang.SuppressWarnings", "@SuppressWarnings"); - formatted = formatted.replace("@java.lang.Deprecated", "@Deprecated"); - return formatted; + performanceTracker.endPhase(PHASE_CLASS_METADATA); } private void appendFields(JavaClassSource source, GenerationTargetClassDto classDef) { + performanceTracker.startPhase(PHASE_FIELDS, classDef.getTypeName().getClassName()); logger.debugStartOperation("Generating %d fields", classDef.getClassFields().size()); for (ClassFieldDto fieldDto : classDef.getClassFields()) { @@ -201,6 +222,7 @@ private void appendFields(JavaClassSource source, GenerationTargetClassDto class } logger.debugEndOperation("Fields added: %d fields", source.getFields().size()); + performanceTracker.endPhase(PHASE_FIELDS); } private void appendField(JavaClassSource source, ClassFieldDto fieldDto) { @@ -213,6 +235,7 @@ private void appendField(JavaClassSource source, ClassFieldDto fieldDto) { } private void appendConstructors(JavaClassSource source, GenerationTargetClassDto classDef) { + performanceTracker.startPhase(PHASE_CONSTRUCTORS, classDef.getTypeName().getClassName()); logger.debugStartOperation("Generating %d constructors", classDef.getConstructors().size()); for (ConstructorDto constructor : classDef.getConstructors()) { @@ -220,6 +243,7 @@ private void appendConstructors(JavaClassSource source, GenerationTargetClassDto } logger.debugEndOperation("Constructors added: %d", classDef.getConstructors().size()); + performanceTracker.endPhase(PHASE_CONSTRUCTORS); } private void appendConstructor(JavaClassSource source, ConstructorDto constructor) { @@ -235,6 +259,7 @@ private void appendConstructor(JavaClassSource source, ConstructorDto constructo } private void appendMethods(JavaClassSource source, GenerationTargetClassDto classDef) { + performanceTracker.startPhase(PHASE_METHODS, classDef.getTypeName().getClassName()); logger.debugStartOperation("Generating %d method candidates", classDef.getMethods().size()); // Resolve method conflicts by signature and priority @@ -246,6 +271,7 @@ private void appendMethods(JavaClassSource source, GenerationTargetClassDto clas } logger.debugEndOperation("Methods added: %d", resolvedMethods.size()); + performanceTracker.endPhase(PHASE_METHODS); } /** @@ -297,15 +323,16 @@ private void appendMethod( } private void appendNestedTypes(JavaClassSource source, GenerationTargetClassDto classDef) { - if (CollectionUtils.isEmpty(classDef.getNestedTypes())) { - return; - } - logger.debugStartOperation("Generating %d nested type(s)", classDef.getNestedTypes().size()); - for (NestedTypeDto nestedType : classDef.getNestedTypes()) { - appendNestedType(source, nestedType); - logger.debug("Generated nested type: %s", nestedType.getTypeName()); + performanceTracker.startPhase(PHASE_NESTED_TYPES, classDef.getTypeName().getClassName()); + if (CollectionUtils.isNotEmpty(classDef.getNestedTypes())) { + logger.debugStartOperation("Generating %d nested type(s)", classDef.getNestedTypes().size()); + for (NestedTypeDto nestedType : classDef.getNestedTypes()) { + appendNestedType(source, nestedType); + logger.debug("Generated nested type: %s", nestedType.getTypeName()); + } + logger.debugEndOperation("Nested types added"); } - logger.debugEndOperation("Nested types added"); + performanceTracker.endPhase(PHASE_NESTED_TYPES); } private void appendNestedType(JavaClassSource source, NestedTypeDto nestedType) { diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java index 421838d7..53a4d419 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java @@ -28,6 +28,7 @@ import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -37,8 +38,26 @@ *

This tracker maintains: * *

    - *
  • Per-phase total time (Configuration Resolution, Builder Definition Extraction, DTO Mapping, - * Code Generation) + *
  • Per-phase total time with a hardcoded hierarchy for display: + *
    + *       Configuration Resolution
    + *       Builder Definition Extraction
    + *       DTO Mapping
    + *       Code Generation
    + *       ├─ Source Construction
    + *       │  ├─ Element Building
    + *       │  │  ├─ Class Creation
    + *       │  │  ├─ Class Metadata
    + *       │  │  ├─ Fields
    + *       │  │  ├─ Constructors
    + *       │  │  ├─ Methods
    + *       │  │  ├─ Nested Types
    + *       │  │  └─ Class Annotations
    + *       │  ├─ String Generation
    + *       │  └─ Formatting
    + *       └─ File Writing
    + *       
    + * Percentages are calculated relative to the parent phase. *
  • Per-generator total time and call count (for MethodGenerators) *
  • Per-enhancer total time and call count (for BuilderEnhancers) *
  • Per-class total time with field count and collection count @@ -46,6 +65,34 @@ */ public final class ActivePerformanceTracker implements PerformanceTracker { + /** Hardcoded phase hierarchy for report display. Order defines display order. */ + private static final List TOP_LEVEL_PHASES = + List.of( + PHASE_CONFIGURATION_RESOLUTION, + PHASE_BUILDER_DEFINITION_EXTRACTION, + PHASE_DTO_MAPPING, + PHASE_CODE_GENERATION); + + private static final Map> PHASE_CHILDREN = new LinkedHashMap<>(); + + static { + PHASE_CHILDREN.put( + PHASE_CODE_GENERATION, List.of(PHASE_SOURCE_CONSTRUCTION, PHASE_FILE_WRITING)); + PHASE_CHILDREN.put( + PHASE_SOURCE_CONSTRUCTION, + List.of(PHASE_ELEMENT_BUILDING, PHASE_STRING_GENERATION, PHASE_FORMATTING)); + PHASE_CHILDREN.put( + PHASE_ELEMENT_BUILDING, + List.of( + PHASE_CLASS_CREATION, + PHASE_CLASS_METADATA, + PHASE_FIELDS, + PHASE_CONSTRUCTORS, + PHASE_METHODS, + PHASE_NESTED_TYPES, + PHASE_CLASS_ANNOTATIONS)); + } + private final Map phaseTimes = new LinkedHashMap<>(); private final Map generatorTimes = new LinkedHashMap<>(); private final Map generatorCalls = new LinkedHashMap<>(); @@ -145,41 +192,42 @@ public void generateReport(ProcessingLogger logger) { logger.info("simple-builders: PERFORMANCE REPORT"); logger.info("================================"); logger.info("Total classes processed: %d", totalClasses); - logger.info("Total processing time: %.1fs", totalSeconds); + logger.info(String.format(Locale.US, "Total processing time: %.1fs", totalSeconds)); logger.info(""); - // Phase breakdown + // Phase breakdown (hierarchical, using hardcoded hierarchy) logger.info("Phase breakdown:"); - Map phaseSeconds = new LinkedHashMap<>(); - for (Map.Entry entry : phaseTimes.entrySet()) { - phaseSeconds.put(entry.getKey(), entry.getValue() / 1_000_000_000.0); - } - for (Map.Entry entry : phaseSeconds.entrySet()) { - double phaseTime = entry.getValue(); - double percentage = totalSeconds > 0 ? (phaseTime / totalSeconds) * 100 : 0; - logger.info(" %s: %.1fs (%.1f%%)", entry.getKey(), phaseTime, percentage); + for (int i = 0; i < TOP_LEVEL_PHASES.size(); i++) { + reportPhase( + logger, TOP_LEVEL_PHASES.get(i), totalSeconds, "", i == TOP_LEVEL_PHASES.size() - 1); } logger.info(""); // Average per class if (totalClasses > 0) { double avgPerClass = (totalTime / 1_000_000.0) / totalClasses; - logger.info("Average per class: %.1fms", avgPerClass); + logger.info(String.format(Locale.US, "Average per class: %.1fms", avgPerClass)); logger.info(""); } - // Top 5 slowest classes + // Top 20 slowest classes List topClasses = new ArrayList<>(classMetrics); topClasses.sort(Comparator.comparingLong(ClassMetric::elapsedNanos).reversed()); - int classLimit = Math.min(5, topClasses.size()); + int classLimit = Math.min(20, topClasses.size()); if (classLimit > 0) { logger.info("Top %d slowest classes:", classLimit); for (int i = 0; i < classLimit; i++) { ClassMetric cm = topClasses.get(i); double ms = cm.elapsedNanos() / 1_000_000.0; logger.info( - " %d. %s - %.0fms (%d fields, %d collections)", - i + 1, cm.className(), ms, cm.fieldCount(), cm.collectionCount()); + String.format( + Locale.US, + " %d. %s - %.1fms (%d fields, %d collections)", + i + 1, + cm.className(), + ms, + cm.fieldCount(), + cm.collectionCount())); } logger.info(""); } @@ -196,8 +244,14 @@ public void generateReport(ProcessingLogger logger) { int calls = generatorCalls.getOrDefault(entry.getKey(), 0); double avgMs = calls > 0 ? (entry.getValue() / 1_000_000.0) / calls : 0; logger.info( - " %d. %s - %.1fs (%d calls, %.2fms/call)", - i + 1, entry.getKey(), seconds, calls, avgMs); + String.format( + Locale.US, + " %d. %s - %.1fs (%d calls, %.2fms/call)", + i + 1, + entry.getKey(), + seconds, + calls, + avgMs)); } logger.info(""); } @@ -214,8 +268,14 @@ public void generateReport(ProcessingLogger logger) { int calls = enhancerCalls.getOrDefault(entry.getKey(), 0); double avgMs = calls > 0 ? (entry.getValue() / 1_000_000.0) / calls : 0; logger.info( - " %d. %s - %.1fs (%d calls, %.2fms/call)", - i + 1, entry.getKey(), seconds, calls, avgMs); + String.format( + Locale.US, + " %d. %s - %.1fs (%d calls, %.2fms/call)", + i + 1, + entry.getKey(), + seconds, + calls, + avgMs)); } } } @@ -223,4 +283,22 @@ public void generateReport(ProcessingLogger logger) { /** Record for per-class performance metrics. */ private record ClassMetric( String className, long elapsedNanos, int fieldCount, int collectionCount) {} + + private void reportPhase( + ProcessingLogger logger, String phase, double parentSeconds, String prefix, boolean isLast) { + long nanos = phaseTimes.getOrDefault(phase, 0L); + double seconds = nanos / 1_000_000_000.0; + double percentage = parentSeconds > 0 ? (seconds / parentSeconds) * 100 : 0; + String connector = isLast ? "└─ " : "├─ "; + logger.info( + String.format( + Locale.US, "%s%s%s: %.1fs (%.1f%%)", prefix, connector, phase, seconds, percentage)); + List children = PHASE_CHILDREN.get(phase); + if (children != null) { + String childPrefix = prefix + (isLast ? " " : "│ "); + for (int i = 0; i < children.size(); i++) { + reportPhase(logger, children.get(i), seconds, childPrefix, i == children.size() - 1); + } + } + } } diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java index ddee9eb2..7d154778 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/PerformanceTracker.java @@ -40,6 +40,30 @@ */ public interface PerformanceTracker { + // Top-level phases + String PHASE_CONFIGURATION_RESOLUTION = "Configuration Resolution"; + String PHASE_BUILDER_DEFINITION_EXTRACTION = "Builder Definition Extraction"; + String PHASE_DTO_MAPPING = "DTO Mapping"; + String PHASE_CODE_GENERATION = "Code Generation"; + + // Code Generation children + String PHASE_SOURCE_CONSTRUCTION = "Source Construction"; + String PHASE_FILE_WRITING = "File Writing"; + + // Source Construction children + String PHASE_ELEMENT_BUILDING = "Element Building"; + String PHASE_STRING_GENERATION = "String Generation"; + String PHASE_FORMATTING = "Formatting"; + + // Element Building children + String PHASE_CLASS_CREATION = "Class Creation"; + String PHASE_CLASS_METADATA = "Class Metadata"; + String PHASE_FIELDS = "Fields"; + String PHASE_CONSTRUCTORS = "Constructors"; + String PHASE_METHODS = "Methods"; + String PHASE_NESTED_TYPES = "Nested Types"; + String PHASE_CLASS_ANNOTATIONS = "Class Annotations"; + /** * Starts tracking a processing phase for a specific class. * diff --git a/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java b/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java index 168d5976..cd9caa34 100644 --- a/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java +++ b/processor/src/test/java/org/javahelpers/simple/builders/processor/RoasterCodeGeneratorResilienceTest.java @@ -49,6 +49,7 @@ import org.javahelpers.simple.builders.processor.model.method.MethodCodeDto; import org.javahelpers.simple.builders.processor.model.method.MethodCodePlaceholder; import org.javahelpers.simple.builders.processor.model.type.TypeName; +import org.javahelpers.simple.builders.processor.processing.logging.NoOpPerformanceTracker; import org.javahelpers.simple.builders.processor.processing.logging.ProcessingLogger; import org.junit.jupiter.api.Test; @@ -85,7 +86,8 @@ void shouldWrapRenderingRuntimeExceptionInBuilderException() { classDef.addConstructor(constructor); ProcessingEnvironment env = new NoopProcessingEnvironment(); - RoasterCodeGenerator generator = new RoasterCodeGenerator(env, new ProcessingLogger(env)); + RoasterCodeGenerator generator = + new RoasterCodeGenerator(env, new ProcessingLogger(env), new NoOpPerformanceTracker()); BuilderException thrown = assertThrows(BuilderException.class, () -> generator.generateClass(classDef)); From 9578186a86a90fc48a5c33b0f0789cbd0bd204be Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 14:31:36 +0200 Subject: [PATCH 05/35] Adding a python script for class creation --- performance-test/scripts/generate_classes.py | 728 +++++++++++++++++++ 1 file changed, 728 insertions(+) create mode 100755 performance-test/scripts/generate_classes.py diff --git a/performance-test/scripts/generate_classes.py b/performance-test/scripts/generate_classes.py new file mode 100755 index 00000000..9db6a6a4 --- /dev/null +++ b/performance-test/scripts/generate_classes.py @@ -0,0 +1,728 @@ +#!/usr/bin/env python3 +""" +Generate Java class/record source files from library-class-catalog.json. + +The JSON blueprint defines all classes for the performance-test module. This +script reads the JSON and produces one .java file per class entry under +performance-test/src/main/java/... following the package layout from the plan: + + org.javahelpers.simple.builders.performance_test.library.. + +Only the classes defined in the JSON's ``packages..classes`` arrays are +generated. The fixed infrastructure (LibraryEntity, the 5 enums, and the 5 +intermediate classes) is NOT generated by this script — create those by hand. + +Usage: + python3 generate_classes.py # generate all classes + python3 generate_classes.py --limit 5 # generate only the first 5 classes (test mode) + python3 generate_classes.py --dry-run # print what would be written, write nothing + python3 generate_classes.py --json other.json # use an alternate JSON file + python3 generate_classes.py --out other/dir # use an alternate output root + python3 generate_classes.py --force # overwrite existing .java files + +JSON schema (expected by this script): + { + "topic": "...", # ignored + "totalClasses": , # ignored (computed from packages) + "packages": { + "": { # subPackage -> Java sub-package name + "intermediateClass": "", # ignored if per-class "extends" is set + "classes": [ + { + "name": "", # required, must be a valid Java identifier + "kind": "class" | "record", # required + "extends": "" | null, # superclass for classes; ignored for records + "properties": [ + { + "name": "", # required, valid Java identifier + "type": "", # required, e.g. "String", "List", "int[]" + "default": "", # optional -> @Default("value") + "ignore": true # optional -> @IgnoreInBuilder on setter + } + ] + } + ] + } + } + } + +Project-specific assumptions (hardcoded — edit the constants below to reuse +this script for a different project): + - BASE_PACKAGE: the generated classes live under + org.javahelpers.simple.builders.performance_test.library. + - COPYRIGHT_YEAR / COPYRIGHT_HOLDER: the MIT license header in every file + - ANNOTATION_IMPORTS: uses org.javahelpers.simple.builders.core.annotations + (@SimpleBuilder, @Default, @IgnoreInBuilder) + - Records get `implements Builder.With` (simple-builders convention) + - ENUM_PACKAGE: enum types are expected in .enums + - STANDARD_IMPORTS: a closed list of 12 Java standard types. Any property + type that is NOT a primitive, NOT in STANDARD_IMPORTS, and NOT a class + declared in the JSON is assumed to be an enum and imported from + ENUM_PACKAGE. If you use a Java type not in STANDARD_IMPORTS (e.g. + `Instant`, `ZonedDateTime`, `Collection`), add it to STANDARD_IMPORTS or + it will be misclassified as an enum. +""" + +from __future__ import annotations + +import argparse +import json +import os +import re +import sys +import tempfile +from pathlib import Path +from typing import Iterable + +# --------------------------------------------------------------------------- +# Constants +# --------------------------------------------------------------------------- + +SCRIPT_DIR = Path(__file__).resolve().parent +DEFAULT_JSON = SCRIPT_DIR.parent / "docs" / "library-class-catalog.json" +DEFAULT_OUT_ROOT = SCRIPT_DIR.parent / "src" / "main" / "java" + +BASE_PACKAGE = "org.javahelpers.simple.builders.performance_test.library" +COPYRIGHT_YEAR = 2026 +COPYRIGHT_HOLDER = "Andreas Igel" + +# Java standard/3rd-party types that need imports, mapped to their fully +# qualified names. Only the simple name appears in the JSON. +STANDARD_IMPORTS: dict[str, str] = { + "LocalDate": "java.time.LocalDate", + "LocalTime": "java.time.LocalTime", + "LocalDateTime": "java.time.LocalDateTime", + "Duration": "java.time.Duration", + "BigDecimal": "java.math.BigDecimal", + "BigInteger": "java.math.BigInteger", + "UUID": "java.util.UUID", + "List": "java.util.List", + "Set": "java.util.Set", + "Map": "java.util.Map", + "Optional": "java.util.Optional", + "Date": "java.util.Date", +} + +# Package where hand-written enum types live (fixed by the plan). Enum names +# themselves are NOT hardcoded — any property type that is neither a primitive, +# a standard Java type, nor a class declared in the JSON is assumed to be an +# enum imported from this package. This keeps the script JSON-driven: adding a +# new enum to the catalog only requires using it as a property type. +ENUM_PACKAGE = f"{BASE_PACKAGE}.enums" + +# Annotation imports +ANNOTATION_IMPORTS: dict[str, str] = { + "SimpleBuilder": "org.javahelpers.simple.builders.core.annotations.SimpleBuilder", + "Default": "org.javahelpers.simple.builders.core.annotations.Default", + "IgnoreInBuilder": "org.javahelpers.simple.builders.core.annotations.IgnoreInBuilder", +} + +# Primitive types (no import needed, no wrapper logic for getters). +PRIMITIVES = {"int", "long", "double", "float", "boolean", "char", "byte", "short"} + +# Valid ``kind`` values in the JSON. +VALID_KINDS = {"class", "record"} + +# Regex for valid Java identifiers (JLS §3.8). Covers the ASCII subset, which +# is all we expect in this catalog. Keywords are technically valid identifiers +# but would produce non-compiling Java — we reject them separately below. +_JAVA_IDENTIFIER_RE = re.compile(r"^[A-Za-z_$][A-Za-z0-9_$]*$") + +# Java keywords that must not be used as identifiers (JLS §3.9). +JAVA_KEYWORDS = { + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", + "class", "const", "continue", "default", "do", "double", "else", "enum", + "extends", "final", "finally", "float", "for", "goto", "if", "implements", + "import", "instanceof", "int", "interface", "long", "native", "new", + "package", "private", "protected", "public", "return", "short", "static", + "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", + "transient", "try", "void", "volatile", "while", "true", "false", "null", + "record", "sealed", "permits", "var", "yield", +} + + +# --------------------------------------------------------------------------- +# Validation helpers +# --------------------------------------------------------------------------- + + +class ValidationError(ValueError): + """Raised when a JSON entry fails validation.""" + + +def validate_identifier(name: str, label: str) -> None: + """ + Validate that ``name`` is a safe Java identifier. + + This serves two purposes: + 1. Prevents path traversal — a name like ``../../etc/passwd`` would be + used directly in a file path without this check. + 2. Ensures the generated Java compiles — ``int`` or ``123abc`` would not. + + Raises ``ValidationError`` if the name is not a valid Java identifier or + is a Java keyword. + """ + if not name: + raise ValidationError(f"{label} is empty") + if not _JAVA_IDENTIFIER_RE.match(name): + raise ValidationError( + f"{label} {name!r} is not a valid Java identifier " + f"(contains illegal characters or starts with a digit)" + ) + if name in JAVA_KEYWORDS: + raise ValidationError(f"{label} {name!r} is a Java keyword and cannot be used as an identifier") + + +def validate_type_string(type_str: str, label: str) -> None: + """ + Validate that ``type_str`` is a plausible Java type expression. + + This is a lightweight check — it rejects characters that have no business + in a type expression (path separators, semicolons, etc.) and ensures every + token within it is a valid Java identifier. It does NOT fully parse Java + generics syntax. + """ + if not type_str: + raise ValidationError(f"{label} type is empty") + # Reject characters that could be used for path traversal or injection. + forbidden = {";", "/", "\\", ".."} + for ch in forbidden: + if ch in type_str: + raise ValidationError(f"{label} type {type_str!r} contains forbidden character {ch!r}") + # Every token must be a valid identifier (after stripping < > , [ ] spaces). + for token in extract_simple_types(type_str): + if token not in PRIMITIVES and token not in JAVA_KEYWORDS: + if not _JAVA_IDENTIFIER_RE.match(token): + raise ValidationError( + f"{label} type {type_str!r} contains invalid token {token!r}" + ) + + +def escape_java_string_literal(value: str) -> str: + """ + Escape a string so it can be safely embedded inside a Java double-quoted + string literal (e.g. for ``@Default("...")``). + + Escapes backslash, double quote, and common control characters. + """ + result = [] + for ch in value: + if ch == "\\": + result.append("\\\\") + elif ch == '"': + result.append('\\"') + elif ch == "\n": + result.append("\\n") + elif ch == "\r": + result.append("\\r") + elif ch == "\t": + result.append("\\t") + else: + result.append(ch) + return "".join(result) + + +# --------------------------------------------------------------------------- +# Helpers +# --------------------------------------------------------------------------- + + +def license_header() -> str: + """Return the MIT license header used across the project.""" + return f"""/* + * MIT License + * + * Copyright (c) {COPYRIGHT_YEAR} {COPYRIGHT_HOLDER} + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */""" + + +def capitalize(name: str) -> str: + """Capitalize the first letter of ``name``.""" + return name[0].upper() + name[1:] if name else name + + +def extract_simple_types(type_str: str) -> set[str]: + """ + Extract all simple type names referenced in a Java type string. + + Examples: + "String" -> {"String"} + "List" -> {"List", "String"} + "Map" -> {"Map", "String", "OtherDto"} + "Optional>" -> {"Optional", "List", "Author"} + "int[]" -> {"int"} + """ + # Strip array brackets + cleaned = type_str.replace("[]", "") + # Split on anything that is not a Java identifier character + tokens = re.split(r"[<>,\s]+", cleaned) + return {t for t in tokens if t and t not in {"?", "extends", "super", "var"}} + + +def getter_name(field_name: str, field_type: str) -> str: + """Return the getter method name following the JavaBeans convention.""" + cap = capitalize(field_name) + return f"is{cap}" if field_type == "boolean" else f"get{cap}" + + +def setter_name(field_name: str) -> str: + """Return the setter method name following the JavaBeans convention.""" + return f"set{capitalize(field_name)}" + + +def collect_class_index(data: dict) -> dict[str, str]: + """ + Build a mapping ``class_name -> sub_package`` for every class defined in + the JSON. Used to resolve cross-package imports for reference types. + + Raises ``ValidationError`` if duplicate class names are found. + """ + index: dict[str, str] = {} + for pkg_name, pkg in data.get("packages", {}).items(): + for cls in pkg.get("classes", []): + name = cls.get("name") + if not name: + continue + if name in index: + raise ValidationError( + f"duplicate class name {name!r} found in package {pkg_name!r} " + f"(already defined in package {index[name]!r})" + ) + index[name] = pkg_name + return index + + +def resolve_imports( + class_entry: dict, + sub_package: str, + class_index: dict[str, str], +) -> list[str]: + """ + Determine the sorted list of import statements needed for a class/record. + + Rules: + - Standard Java types (List, LocalDate, ...) -> java.* imports + - Classes found in the JSON -> cross-package import, but only when the + referenced class lives in a different sub-package (same-package types + need no import). + - Any other non-primitive, non-String type -> assumed to be an enum in + .library.enums and imported from there. This avoids hardcoding enum + names; the trade-off is that a genuinely unknown reference would also + produce an (incorrect) enum import. + - Primitives and String -> no import + """ + needed: set[str] = set() + uses_default = False + uses_ignore = False + + for prop in class_entry.get("properties", []): + prop_type = prop.get("type", "") + for simple in extract_simple_types(prop_type): + if simple in PRIMITIVES or simple == "String": + continue + if simple in STANDARD_IMPORTS: + needed.add(STANDARD_IMPORTS[simple]) + elif simple in class_index: + if class_index[simple] != sub_package: + ref_pkg = class_index[simple] + needed.add(f"{BASE_PACKAGE}.{ref_pkg}.{simple}") + # same sub-package: no import needed + else: + # Not a primitive, not a standard Java type, not a JSON class: + # assume it is an enum in the .library.enums package. + needed.add(f"{ENUM_PACKAGE}.{simple}") + if "default" in prop: + uses_default = True + if prop.get("ignore"): + uses_ignore = True + + # @SimpleBuilder is always used + needed.add(ANNOTATION_IMPORTS["SimpleBuilder"]) + if uses_default: + needed.add(ANNOTATION_IMPORTS["Default"]) + if uses_ignore: + needed.add(ANNOTATION_IMPORTS["IgnoreInBuilder"]) + + return sorted(needed) + + +# --------------------------------------------------------------------------- +# Source generation +# --------------------------------------------------------------------------- + + +def generate_class_source( + class_entry: dict, + intermediate_class: str, + sub_package: str, + class_index: dict[str, str], +) -> str: + """ + Generate the full Java source for a ``kind: "class"`` entry. + + The ``extends`` clause uses the per-class ``extends`` field from the JSON. + If it is null or absent, the class has no superclass. If it is set, that + value is used (typically the package's intermediate class). + """ + name = class_entry["name"] + props = class_entry.get("properties", []) + imports = resolve_imports(class_entry, sub_package, class_index) + package_decl = f"{BASE_PACKAGE}.{sub_package}" + + # Determine extends clause from the per-class field. + extends_value = class_entry.get("extends") + extends_clause = f" extends {extends_value}" if extends_value else "" + + lines: list[str] = [] + lines.append(license_header()) + lines.append("") + lines.append(f"package {package_decl};") + lines.append("") + if imports: + for imp in imports: + lines.append(f"import {imp};") + lines.append("") + lines.append("@SimpleBuilder") + lines.append(f"public class {name}{extends_clause} {{") + lines.append("") + + # Fields + for prop in props: + field_name = prop["name"] + field_type = prop["type"] + annotations: list[str] = [] + if "default" in prop: + escaped = escape_java_string_literal(str(prop["default"])) + annotations.append(f'@Default("{escaped}")') + # NOTE: @IgnoreInBuilder targets METHOD/PARAMETER, not FIELD, so it is + # placed on the setter below, not here. + indent = " " + for ann in annotations: + lines.append(f"{indent}{ann}") + lines.append(f"{indent}private {field_type} {field_name};") + lines.append("") + + # Getters and setters + for prop in props: + field_name = prop["name"] + field_type = prop["type"] + getter = getter_name(field_name, field_type) + setter = setter_name(field_name) + indent = " " + + # Getter + lines.append(f"{indent}public {field_type} {getter}() {{") + lines.append(f"{indent} return {field_name};") + lines.append(f"{indent}}}") + lines.append("") + + # Setter (with @IgnoreInBuilder if flagged) + if prop.get("ignore"): + lines.append(f"{indent}@IgnoreInBuilder") + lines.append(f"{indent}public void {setter}({field_type} {field_name}) {{") + lines.append(f"{indent} this.{field_name} = {field_name};") + lines.append(f"{indent}}}") + lines.append("") + + lines.append("}") + lines.append("") + return "\n".join(lines) + + +def generate_record_source( + class_entry: dict, + sub_package: str, + class_index: dict[str, str], +) -> str: + """Generate the full Java source for a ``kind: "record"`` entry.""" + name = class_entry["name"] + props = class_entry.get("properties", []) + imports = resolve_imports(class_entry, sub_package, class_index) + package_decl = f"{BASE_PACKAGE}.{sub_package}" + + lines: list[str] = [] + lines.append(license_header()) + lines.append("") + lines.append(f"package {package_decl};") + lines.append("") + if imports: + for imp in imports: + lines.append(f"import {imp};") + lines.append("") + lines.append("@SimpleBuilder") + lines.append(f"public record {name}(") + + # Record components + for i, prop in enumerate(props): + field_name = prop["name"] + field_type = prop["type"] + annotations: list[str] = [] + if "default" in prop: + escaped = escape_java_string_literal(str(prop["default"])) + annotations.append(f'@Default("{escaped}")') + if prop.get("ignore"): + annotations.append("@IgnoreInBuilder") + prefix = " " + if annotations: + ann_str = "\n".join(f"{prefix}{a}" for a in annotations) + "\n" + prefix + else: + ann_str = prefix + comma = "," if i < len(props) - 1 else "" + lines.append(f"{ann_str}{field_type} {field_name}{comma}") + + lines.append(f") implements {name}Builder.With {{") + lines.append("}") + lines.append("") + return "\n".join(lines) + + +def generate_source( + class_entry: dict, + intermediate_class: str, + sub_package: str, + class_index: dict[str, str], +) -> str: + """Dispatch to the correct generator based on ``kind``.""" + kind = class_entry.get("kind", "class") + if kind == "record": + return generate_record_source(class_entry, sub_package, class_index) + return generate_class_source(class_entry, intermediate_class, sub_package, class_index) + + +# --------------------------------------------------------------------------- +# Main +# --------------------------------------------------------------------------- + + +def iter_classes(data: dict) -> Iterable[tuple[str, str, dict]]: + """ + Yield ``(sub_package, intermediate_class, class_entry)`` tuples in JSON + order: items, persons, organizations, locations, events, and within each + package the classes in array order. + """ + for pkg_name, pkg in data.get("packages", {}).items(): + intermediate = pkg.get("intermediateClass", "") + for cls in pkg.get("classes", []): + yield pkg_name, intermediate, cls + + +def atomic_write(path: Path, content: str) -> None: + """ + Write ``content`` to ``path`` atomically. + + Writes to a temporary file in the same directory, then renames it to the + target. This ensures that if the process is interrupted, the target file + is either the old version or the complete new version — never a partial + write. + """ + path.parent.mkdir(parents=True, exist_ok=True) + # Use the same directory as the target so the rename is atomic on the same + # filesystem. NamedTemporaryFile handles the unique-name and cleanup-on- + # error logic. + with tempfile.NamedTemporaryFile( + mode="w", + encoding="utf-8", + dir=path.parent, + prefix=f".{path.stem}.", + suffix=".tmp", + delete=False, + ) as tmp: + tmp.write(content) + tmp.flush() + os.fsync(tmp.fileno()) + tmp_path = Path(tmp.name) + # os.replace is atomic on POSIX and Windows (Python 3.3+). + os.replace(tmp_path, path) + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser( + description="Generate Java class files from library-class-catalog.json.", + ) + parser.add_argument( + "--json", + type=Path, + default=DEFAULT_JSON, + help=f"Path to the catalog JSON (default: {DEFAULT_JSON})", + ) + parser.add_argument( + "--out", + type=Path, + default=DEFAULT_OUT_ROOT, + help=f"Output root directory (default: {DEFAULT_OUT_ROOT})", + ) + parser.add_argument( + "--limit", + type=int, + default=None, + help="Only generate the first N classes (test mode, e.g. --limit 5).", + ) + parser.add_argument( + "--dry-run", + action="store_true", + help="Print the paths that would be written without writing any files.", + ) + parser.add_argument( + "--force", + action="store_true", + help="Overwrite existing .java files (default: skip them).", + ) + args = parser.parse_args(argv) + + json_path: Path = args.json + out_root: Path = args.out + limit: int | None = args.limit + + if limit is not None and limit < 0: + print("error: --limit must be >= 0", file=sys.stderr) + return 2 + + if not json_path.is_file(): + print(f"error: JSON file not found: {json_path}", file=sys.stderr) + return 2 + + try: + with json_path.open("r", encoding="utf-8") as f: + data = json.load(f) + except json.JSONDecodeError as e: + print(f"error: invalid JSON in {json_path}: {e}", file=sys.stderr) + return 2 + + # Build class index and validate uniqueness. + try: + class_index = collect_class_index(data) + except ValidationError as e: + print(f"error: {e}", file=sys.stderr) + return 2 + + total_in_json = sum(len(p.get("classes", [])) for p in data.get("packages", {}).values()) + n_to_generate = min(limit, total_in_json) if limit is not None else total_in_json + + print(f"JSON: {json_path}") + print(f"Output: {out_root}") + print(f"Classes in JSON: {total_in_json}") + if limit is not None: + print(f"Limit: first {n_to_generate} class(es) (test mode)") + print() + + written = 0 + skipped = 0 + errors: list[str] = [] + + for idx, (sub_package, intermediate, cls) in enumerate(iter_classes(data)): + if limit is not None and idx >= limit: + break + + # --- Validate the entry before generating anything --- + try: + name = cls.get("name") + if not name: + raise ValidationError(f"class entry at index {idx} has no name") + validate_identifier(name, f"class name (index {idx})") + validate_identifier(sub_package, f"package name (index {idx})") + + kind = cls.get("kind", "class") + if kind not in VALID_KINDS: + raise ValidationError( + f"class {name!r} has invalid kind {kind!r}; " + f"expected one of {sorted(VALID_KINDS)}" + ) + + # Validate extends if present. + extends_value = cls.get("extends") + if extends_value is not None: + validate_identifier(str(extends_value), f"extends in class {name!r}") + + # Validate each property. + for prop in cls.get("properties", []): + prop_name = prop.get("name") + if not prop_name: + raise ValidationError(f"class {name!r} has a property without a name") + validate_identifier(prop_name, f"property name in class {name!r}") + prop_type = prop.get("type") + if prop_type is None: + raise ValidationError( + f"property {prop_name!r} in class {name!r} has no type" + ) + validate_type_string(str(prop_type), f"property {prop_name!r} in class {name!r}") + + except ValidationError as e: + errors.append(str(e)) + print(f" ERROR: {e}", file=sys.stderr) + continue + + # --- Generate source --- + try: + source = generate_source(cls, intermediate, sub_package, class_index) + except (KeyError, TypeError) as e: + msg = f"failed to generate source for class {name!r}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + + rel_path = Path(*BASE_PACKAGE.split(".")) / sub_package / f"{name}.java" + out_file = out_root / rel_path + + # Safety: ensure the resolved path is still under out_root (defense in + # depth, even though identifiers are validated above). + try: + out_file.resolve().relative_to(out_root.resolve()) + except ValueError: + msg = f"refusing to write outside output root: {out_file}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + + if args.dry_run: + print(f" [dry-run] {out_file} ({len(source)} bytes)") + continue + + if out_file.exists() and not args.force: + print(f" skip (exists): {out_file}") + skipped += 1 + continue + + try: + atomic_write(out_file, source) + except OSError as e: + msg = f"failed to write {out_file}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + + print(f" wrote: {out_file}") + written += 1 + + print() + if args.dry_run: + print(f"Dry run complete — {n_to_generate} class(es) would be generated.") + else: + print(f"Done — wrote {written} file(s), skipped {skipped} existing file(s).") + if errors: + print(f"\n{len(errors)} error(s) occurred:", file=sys.stderr) + for err in errors: + print(f" - {err}", file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From ae10229ebd0c5e248ccbef5bd7c677dca1f91798 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 14:31:58 +0200 Subject: [PATCH 06/35] Adding a first draft of a json file for class generation --- .../docs/library-class-catalog.json | 13753 ++++++++++++++++ 1 file changed, 13753 insertions(+) create mode 100644 performance-test/docs/library-class-catalog.json diff --git a/performance-test/docs/library-class-catalog.json b/performance-test/docs/library-class-catalog.json new file mode 100644 index 00000000..9e09e3a5 --- /dev/null +++ b/performance-test/docs/library-class-catalog.json @@ -0,0 +1,13753 @@ +{ + "topic": "Library System", + "totalClasses": 1000, + "packages": { + "items": { + "intermediateClass": "LibraryItem", + "classes": [ + { + "name": "HardcoverBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "weightGrams", "type": "double"}, + {"name": "illustrated", "type": "boolean"}, + {"name": "shelfCode", "type": "char"}, + {"name": "chapters", "type": "List"}, + {"name": "keywords", "type": "Set"}, + {"name": "acquisitionDate", "type": "LocalDate"}, + {"name": "price", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "primaryAuthor", "type": "Author"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"}, + {"name": "internalNotes", "type": "String", "ignore": true} + ] + }, + { + "name": "PaperbackBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "coverThickness", "type": "double"}, + {"name": "waterproof", "type": "boolean"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "price", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LeatherBoundVolume", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "bindingDate", "type": "LocalDate"}, + {"name": "leatherType", "type": "String"}, + {"name": "gildedEdges", "type": "boolean"}, + {"name": "ribbedSpine", "type": "boolean"}, + {"name": "marbledEndpapers", "type": "boolean"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "appraisalDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"}, + {"name": "restorationNotes", "type": "String", "ignore": true} + ] + }, + { + "name": "CollectorEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editionNumber", "type": "int"}, + {"name": "totalEditions", "type": "int"}, + {"name": "certificateOfAuthenticity", "type": "boolean"}, + {"name": "signedByAuthor", "type": "boolean"}, + {"name": "slipcaseIncluded", "type": "boolean"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "acquisitionDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "previousOwner", "type": "AdultMember"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "Encyclopedia", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "volumeCount", "type": "int"}, + {"name": "volumeNumber", "type": "int"}, + {"name": "subjectArea", "type": "String"}, + {"name": "entries", "type": "List"}, + {"name": "indexTerms", "type": "Set"}, + {"name": "publicationYear", "type": "int"}, + {"name": "publisher", "type": "AcademicPress"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"}, + {"name": "replacementCost", "type": "BigDecimal"} + ] + }, + { + "name": "AudiobookCd", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "narratorName", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "trackCount", "type": "int"}, + {"name": "isAbridged", "type": "boolean"}, + {"name": "discCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "lendingLibrary", "type": "PublicLibrary"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "RareBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "printingYear", "type": "int"}, + {"name": "printingLocation", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "appraisalDate", "type": "LocalDate"}, + {"name": "provenance", "type": "List"}, + {"name": "exhibitionHistory", "type": "Set"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "storageLocation", "type": "RareBookVault"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"}, + {"name": "accessRestrictions", "type": "String", "ignore": true} + ] + }, + { + "name": "PocketBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "pocketSize", "type": "String"}, + {"name": "flexibleCover", "type": "boolean"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "price", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LimitedEditionPrint", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "printNumber", "type": "int"}, + {"name": "totalPrints", "type": "int"}, + {"name": "printDate", "type": "LocalDate"}, + {"name": "signedByAuthor", "type": "boolean"}, + {"name": "certificateNumber", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "FacsimileEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "sourceDocument", "type": "String"}, + {"name": "reproductionDate", "type": "LocalDate"}, + {"name": "fidelityRating", "type": "String"}, + {"name": "colorReproduced", "type": "boolean"}, + {"name": "scaleRatio", "type": "String"}, + {"name": "pages", "type": "int"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "UniversityPress"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "CriticalEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editorName", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "annotations", "type": "List"}, + {"name": "footnotes", "type": "List"}, + {"name": "appendices", "type": "Set"}, + {"name": "bibliography", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "AcademicPress"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AnnotatedEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "annotator", "type": "String"}, + {"name": "annotationCount", "type": "int"}, + {"name": "annotationDate", "type": "LocalDate"}, + {"name": "marginalia", "type": "boolean"}, + {"name": "notes", "type": "List"}, + {"name": "crossReferences", "type": "Set"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "IllustratedEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "illustrator", "type": "String"}, + {"name": "illustrationCount", "type": "int"}, + {"name": "colorIllustrations", "type": "boolean"}, + {"name": "illustrationStyle", "type": "String"}, + {"name": "plates", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "BilingualEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "primaryLanguage", "type": "String"}, + {"name": "secondaryLanguage", "type": "String"}, + {"name": "translator", "type": "String"}, + {"name": "parallelText", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "language", "type": "String", "default": "EN"} + ] + }, + { + "name": "LargePrintBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "fontSize", "type": "String"}, + {"name": "lineSpacing", "type": "double"}, + {"name": "pageCount", "type": "int"}, + {"name": "authorName", "type": "String"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "BrailleBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "brailleGrade", "type": "String"}, + {"name": "volumes", "type": "int"}, + {"name": "doubleSided", "type": "boolean"}, + {"name": "tactileDiagrams", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "transcriber", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "TalkingBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "narrator", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "format", "type": "String"}, + {"name": "chapters", "type": "List"}, + {"name": "unabridged", "type": "boolean"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "BoardBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "targetAgeMin", "type": "int"}, + {"name": "targetAgeMax", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "roundedCorners", "type": "boolean"}, + {"name": "tearResistant", "type": "boolean"}, + {"name": "illustrations", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "PopUpBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "popUpCount", "type": "int"}, + {"name": "paperEngineer", "type": "String"}, + {"name": "interactiveElements", "type": "boolean"}, + {"name": "targetAgeMin", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "illustrations", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LiftTheFlapBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "flapCount", "type": "int"}, + {"name": "targetAgeMin", "type": "int"}, + {"name": "targetAgeMax", "type": "int"}, + {"name": "interactiveElements", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "illustrations", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ChapterBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "chapterCount", "type": "int"}, + {"name": "targetAgeMin", "type": "int"}, + {"name": "targetAgeMax", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "PictureBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "illustrator", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "targetAgeMin", "type": "int"}, + {"name": "targetAgeMax", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "wordCount", "type": "int"}, + {"name": "awards", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "EarlyReader", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "readingLevel", "type": "String"}, + {"name": "sightWords", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "illustrations", "type": "boolean"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "MiddleGradeNovel", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "protagonistName", "type": "String"}, + {"name": "setting", "type": "String"}, + {"name": "themes", "type": "Set"}, + {"name": "pageCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "YoungAdultNovel", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "protagonistName", "type": "String"}, + {"name": "themes", "type": "Set"}, + {"name": "pageCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "awards", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "GraphicNovel", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "illustrator", "type": "String"}, + {"name": "colorist", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "color", "type": "boolean"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ComicBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "illustrator", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "seriesName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "color", "type": "boolean"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "MangaVolume", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "illustrator", "type": "String"}, + {"name": "volumeNumber", "type": "int"}, + {"name": "seriesName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "readDirection", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ArtBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "artworkCount", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "colorPlates", "type": "boolean"}, + {"name": "gallery", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "CoffeeTableBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "topic", "type": "String"}, + {"name": "photographer", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "illustrations", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "ExhibitionCatalog", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "exhibitionName", "type": "String"}, + {"name": "curator", "type": "String"}, + {"name": "exhibitionDates", "type": "String"}, + {"name": "artworkCount", "type": "int"}, + {"name": "essays", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "hostMuseum", "type": "ArtMuseum"} + ] + }, + { + "name": "MuseumGuide", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "museumName", "type": "String"}, + {"name": "galleries", "type": "List"}, + {"name": "highlights", "type": "Set"}, + {"name": "pageCount", "type": "int"}, + {"name": "floorPlan", "type": "boolean"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "hostMuseum", "type": "ArtMuseum"} + ] + }, + { + "name": "TravelGuide", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "destination", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "mapsIncluded", "type": "boolean"}, + {"name": "attractions", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Cookbook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "recipeCount", "type": "int"}, + {"name": "cuisineType", "type": "String"}, + {"name": "hasPhotos", "type": "boolean"}, + {"name": "recipes", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Textbook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "gradeLevel", "type": "String"}, + {"name": "edition", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "exercises", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "EducationalPublisher"} + ] + }, + { + "name": "Workbook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "gradeLevel", "type": "String"}, + {"name": "exerciseCount", "type": "int"}, + {"name": "answerKeyIncluded", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "TeacherManual", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "gradeLevel", "type": "String"}, + {"name": "lessonPlans", "type": "List"}, + {"name": "assessmentTools", "type": "Set"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "EducationalPublisher"} + ] + }, + { + "name": "StudyGuide", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "summaryPoints", "type": "List"}, + {"name": "practiceQuestions", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "RevisionGuide", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "examBoard", "type": "String"}, + {"name": "keyTopics", "type": "List"}, + {"name": "practicePapers", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Dictionary", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editorName", "type": "String"}, + {"name": "language", "type": "String"}, + {"name": "entryCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "edition", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Thesaurus", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editorName", "type": "String"}, + {"name": "language", "type": "String"}, + {"name": "entryCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Almanac", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "year", "type": "int"}, + {"name": "publisher", "type": "String"}, + {"name": "topics", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Yearbook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "year", "type": "int"}, + {"name": "institution", "type": "String"}, + {"name": "photosIncluded", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "sections", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AnnualReport", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "organization", "type": "String"}, + {"name": "fiscalYear", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "financialHighlights", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Compendium", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editorName", "type": "String"}, + {"name": "topic", "type": "String"}, + {"name": "sectionCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "contributors", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Handbook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "ProfessionalPublisher"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ReferenceVolume", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "field", "type": "String"}, + {"name": "editorName", "type": "String"}, + {"name": "volumeNumber", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "entries", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Bibliography", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "compiler", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "entryCount", "type": "int"}, + {"name": "entries", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Concordance", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "sourceWork", "type": "String"}, + {"name": "entryCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Gazetteer", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "region", "type": "String"}, + {"name": "editorName", "type": "String"}, + {"name": "placeCount", "type": "int"}, + {"name": "mapsIncluded", "type": "boolean"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Directory", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "category", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "entryCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "CatalogRaisonne", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "compiler", "type": "String"}, + {"name": "workCount", "type": "int"}, + {"name": "illustrations", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "hostMuseum", "type": "ArtMuseum"} + ] + }, + { + "name": "Chronicle", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "period", "type": "String"}, + {"name": "events", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Anthology", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editorName", "type": "String"}, + {"name": "theme", "type": "String"}, + {"name": "selections", "type": "List"}, + {"name": "contributorCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "CollectedWorks", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "editorName", "type": "String"}, + {"name": "volumeCount", "type": "int"}, + {"name": "works", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "AcademicPress"} + ] + }, + { + "name": "ShortStoryCollection", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "storyCount", "type": "int"}, + {"name": "stories", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "EssayCollection", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "editorName", "type": "String"}, + {"name": "essayCount", "type": "int"}, + {"name": "topics", "type": "Set"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LetterCollection", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "correspondent", "type": "String"}, + {"name": "letterCount", "type": "int"}, + {"name": "dateRange", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Diary", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "dateRange", "type": "String"}, + {"name": "entries", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Memoir", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "period", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Biography", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subjectName", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "awards", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Autobiography", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "OralHistory", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "interviewer", "type": "String"}, + {"name": "intervieweeCount", "type": "int"}, + {"name": "transcripts", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "FieldNotebook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "researcher", "type": "String"}, + {"name": "fieldSite", "type": "String"}, + {"name": "entryCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "dateRange", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "WeeklyMagazine", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "issueNumber", "type": "int"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "coverStory", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "MonthlyMagazine", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "issueNumber", "type": "int"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "coverStory", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "QuarterlyMagazine", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "volumeNumber", "type": "int"}, + {"name": "issueNumber", "type": "int"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AcademicJournal", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "journalName", "type": "String"}, + {"name": "volume", "type": "int"}, + {"name": "issue", "type": "int"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "publisher", "type": "UniversityPress"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ScientificJournal", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "journalName", "type": "String"}, + {"name": "volume", "type": "int"}, + {"name": "issue", "type": "int"}, + {"name": "field", "type": "String"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "PeerReviewedJournal", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "journalName", "type": "String"}, + {"name": "volume", "type": "int"}, + {"name": "issue", "type": "int"}, + {"name": "field", "type": "String"}, + {"name": "reviewerCount", "type": "int"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"} + ] + }, + { + "name": "OpenAccessJournal", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "journalName", "type": "String"}, + {"name": "volume", "type": "int"}, + {"name": "issue", "type": "int"}, + {"name": "url", "type": "String"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "TradePublication", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "industry", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ProfessionalNewsletter", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "organization", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "DailyNewspaper", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "newspaperName", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "sections", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "headline", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "WeeklyNewspaper", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "newspaperName", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "sections", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "headline", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "SundayEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "newspaperName", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "sections", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "supplements", "type": "boolean"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "CampusNewspaper", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "universityName", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "sections", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "editorName", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LocalGazette", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "locality", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "notices", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AlumniMagazine", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "institution", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "articles", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Bulletin", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "organization", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "announcements", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Pamphlet", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "topic", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Brochure", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "topic", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "illustrated", "type": "boolean"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Leaflet", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "topic", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ProgramBooklet", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "eventName", "type": "String"}, + {"name": "eventDate", "type": "LocalDate"}, + {"name": "pageCount", "type": "int"}, + {"name": "schedule", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "PressRelease", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "organization", "type": "String"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "headline", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "WhitePaper", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "TechnicalReport", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "reportNumber", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "institution", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ResearchReport", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "reportNumber", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ConferencePaper", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "conferenceName", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "presentationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AudiobookMp3", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "narrator", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "fileSizeMB", "type": "double"}, + {"name": "unabridged", "type": "boolean"}, + {"name": "chapters", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "MusicCd", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "trackCount", "type": "int"}, + {"name": "totalDuration", "type": "int"}, + {"name": "genre", "type": "String"}, + {"name": "tracks", "type": "List"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "VinylRecord", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "rpm", "type": "int"}, + {"name": "trackCount", "type": "int"}, + {"name": "genre", "type": "String"}, + {"name": "tracks", "type": "List"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "CassetteTape", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "trackCount", "type": "int"}, + {"name": "totalDuration", "type": "int"}, + {"name": "genre", "type": "String"}, + {"name": "tracks", "type": "List"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "DvdMovie", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "director", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "rating", "type": "String"}, + {"name": "actors", "type": "List"}, + {"name": "subtitles", "type": "Set"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "BluRayDisc", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "director", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "rating", "type": "String"}, + {"name": "resolution", "type": "String"}, + {"name": "actors", "type": "List"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "DocumentaryDvd", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "topic", "type": "String"}, + {"name": "director", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "narrator", "type": "String"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "EducationalVideo", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "presenter", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "level", "type": "String"}, + {"name": "segments", "type": "List"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LectureRecording", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "lecturer", "type": "String"}, + {"name": "topic", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "institution", "type": "String"}, + {"name": "recordingDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "InterviewRecording", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "interviewer", "type": "String"}, + {"name": "interviewee", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "topic", "type": "String"}, + {"name": "recordingDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "OralHistoryRecording", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "interviewee", "type": "String"}, + {"name": "interviewer", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "transcriptAvailable", "type": "boolean"}, + {"name": "recordingDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "LanguageCourse", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "language", "type": "String"}, + {"name": "level", "type": "String"}, + {"name": "lessonCount", "type": "int"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "components", "type": "List"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "MusicScore", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "composer", "type": "String"}, + {"name": "genre", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "instrumentation", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "SheetMusic", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "composer", "type": "String"}, + {"name": "title", "type": "String"}, + {"name": "instrument", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "difficulty", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ChoralScore", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "composer", "type": "String"}, + {"name": "title", "type": "String"}, + {"name": "voiceParts", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "language", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "OrchestralScore", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "composer", "type": "String"}, + {"name": "title", "type": "String"}, + {"name": "instruments", "type": "List"}, + {"name": "pageCount", "type": "int"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "OperaScore", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "composer", "type": "String"}, + {"name": "title", "type": "String"}, + {"name": "librettist", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "acts", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "PianoScore", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "composer", "type": "String"}, + {"name": "title", "type": "String"}, + {"name": "difficulty", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AntiqueBook", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "printingYear", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "provenance", "type": "List"}, + {"name": "appraisalDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "storageLocation", "type": "RareBookVault"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"}, + {"name": "accessRestrictions", "type": "String", "ignore": true} + ] + }, + { + "name": "FirstEdition", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "printingYear", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "printingLocation", "type": "String"}, + {"name": "provenance", "type": "List"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "SignedCopy", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "signingDate", "type": "LocalDate"}, + {"name": "signingLocation", "type": "String"}, + {"name": "inscription", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "InscribedCopy", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "inscriber", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "inscriptionText", "type": "String"}, + {"name": "inscriptionDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AuthorManuscript", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "pageCount", "type": "int"}, + {"name": "drafts", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "MedievalManuscript", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "creationCentury", "type": "int"}, + {"name": "origin", "type": "String"}, + {"name": "script", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "storageLocation", "type": "RareBookVault"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "IlluminatedManuscript", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "creationCentury", "type": "int"}, + {"name": "origin", "type": "String"}, + {"name": "illuminationType", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "miniatures", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "storageLocation", "type": "RareBookVault"} + ] + }, + { + "name": "VellumDocument", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "creationDate", "type": "LocalDate"}, + {"name": "origin", "type": "String"}, + {"name": "script", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "PapyrusFragment", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "origin", "type": "String"}, + {"name": "creationCentury", "type": "int"}, + {"name": "fragmentSize", "type": "String"}, + {"name": "textContent", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "POOR"} + ] + }, + { + "name": "Scroll", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "origin", "type": "String"}, + {"name": "creationCentury", "type": "int"}, + {"name": "length", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "Codex", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "origin", "type": "String"}, + {"name": "creationCentury", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "binding", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "Incunabulum", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "printingYear", "type": "int"}, + {"name": "printer", "type": "String"}, + {"name": "printingLocation", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "storageLocation", "type": "RareBookVault"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "Broadside", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "printingYear", "type": "int"}, + {"name": "printer", "type": "String"}, + {"name": "topic", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "EphemeraItem", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "category", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "PostcardItem", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "imageSubject", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"}, + {"name": "publisher", "type": "String"}, + {"name": "postmarked", "type": "boolean"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "WorldMap", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "projection", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "CityMap", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "cityName", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "TopographicMap", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "region", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "contourInterval", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "NauticalChart", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "waterBody", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "depthUnits", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "AerialPhotograph", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "location", "type": "String"}, + {"name": "captureDate", "type": "LocalDate"}, + {"name": "altitude", "type": "double"}, + {"name": "dimensions", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "SatelliteImage", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "location", "type": "String"}, + {"name": "captureDate", "type": "LocalDate"}, + {"name": "resolution", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "NEW"} + ] + }, + { + "name": "Globe", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "diameter", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "productionYear", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ReliefMap", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "region", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "material", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "HistoricalMap", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "region", "type": "String"}, + {"name": "creationYear", "type": "int"}, + {"name": "cartographer", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "ThematicMap", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "theme", "type": "String"}, + {"name": "region", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ArchitecturalDrawing", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "buildingName", "type": "String"}, + {"name": "architect", "type": "String"}, + {"name": "drawingType", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Blueprint", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "projectName", "type": "String"}, + {"name": "architect", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "ArtPrint", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "printTechnique", "type": "String"}, + {"name": "editionNumber", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Engraving", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Etching", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Lithograph", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Woodcut", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Serigraph", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "artist", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "editionSize", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Photograph", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "photographer", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "captureDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Daguerreotype", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "photographer", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "Stereograph", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "PhotoAlbum", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "compiler", "type": "String"}, + {"name": "photoCount", "type": "int"}, + {"name": "dateRange", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Microfilm", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "contentDescription", "type": "String"}, + {"name": "frameCount", "type": "int"}, + {"name": "reductionRatio", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Microfiche", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "contentDescription", "type": "String"}, + {"name": "frameCount", "type": "int"}, + {"name": "reductionRatio", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Artifact", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "origin", "type": "String"}, + {"name": "creationPeriod", "type": "String"}, + {"name": "material", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "FAIR"} + ] + }, + { + "name": "Coin", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "denomination", "type": "String"}, + {"name": "mintYear", "type": "int"}, + {"name": "mintLocation", "type": "String"}, + {"name": "material", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Medal", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "issuer", "type": "String"}, + {"name": "issueYear", "type": "int"}, + {"name": "material", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "Bookplate", + "kind": "class", + "extends": "LibraryItem", + "properties": [ + {"name": "ownerName", "type": "String"}, + {"name": "artist", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "catalogId", "type": "UUID"}, + {"name": "curator", "type": "Curator"}, + {"name": "condition", "type": "ItemCondition", "default": "GOOD"} + ] + }, + { + "name": "BookRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "available", "type": "boolean"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "isbn", "type": "UUID"}, + {"name": "language", "type": "String", "default": "EN"}, + {"name": "publisherName", "type": "String"} + ] + }, + { + "name": "NovelRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "genre", "type": "String"}, + {"name": "wordCount", "type": "long"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "available", "type": "boolean"}, + {"name": "language", "type": "String", "default": "EN"} + ] + }, + { + "name": "PoetryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "poetName", "type": "String"}, + {"name": "poemCount", "type": "int"}, + {"name": "form", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "isbn", "type": "UUID"}, + {"name": "language", "type": "String", "default": "EN"} + ] + }, + { + "name": "NovellaRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "wordCount", "type": "long"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "available", "type": "boolean"}, + {"name": "language", "type": "String", "default": "EN"} + ] + }, + { + "name": "ShortStoryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "wordCount", "type": "int"}, + {"name": "genre", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "available", "type": "boolean"} + ] + }, + { + "name": "DramaRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "playwright", "type": "String"}, + {"name": "actCount", "type": "int"}, + {"name": "characterCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "language", "type": "String", "default": "EN"} + ] + }, + { + "name": "EssayRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "wordCount", "type": "int"}, + {"name": "topic", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "FestschriftRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "honoree", "type": "String"}, + {"name": "editorName", "type": "String"}, + {"name": "essayCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "ProceedingsRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "conferenceName", "type": "String"}, + {"name": "editorName", "type": "String"}, + {"name": "paperCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "TransactionsRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "organization", "type": "String"}, + {"name": "volume", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "MonographRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "field", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "TreatiseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "DissertationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "university", "type": "String"}, + {"name": "degree", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "defenseDate", "type": "LocalDate"} + ] + }, + { + "name": "ThesisRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "university", "type": "String"}, + {"name": "degreeLevel", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "submissionDate", "type": "LocalDate"} + ] + }, + { + "name": "HabilitationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "university", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "defenseDate", "type": "LocalDate"} + ] + }, + { + "name": "LectureNotesRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "courseTitle", "type": "String"}, + {"name": "lecturer", "type": "String"}, + {"name": "lectureCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "semester", "type": "String"} + ] + }, + { + "name": "SyllabusRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "courseTitle", "type": "String"}, + {"name": "instructor", "type": "String"}, + {"name": "creditHours", "type": "int"}, + {"name": "weekCount", "type": "int"}, + {"name": "semester", "type": "String"} + ] + }, + { + "name": "CurriculumRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "programName", "type": "String"}, + {"name": "institution", "type": "String"}, + {"name": "courseCount", "type": "int"}, + {"name": "creditHours", "type": "int"}, + {"name": "effectiveDate", "type": "LocalDate"} + ] + }, + { + "name": "LessonPlanRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "teacher", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "objectives", "type": "List"}, + {"name": "materials", "type": "List"} + ] + }, + { + "name": "ExamPaperRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "examTitle", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "questionCount", "type": "int"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "examDate", "type": "LocalDate"} + ] + }, + { + "name": "WorksheetRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "gradeLevel", "type": "String"}, + {"name": "exerciseCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "FlashcardRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "cardCount", "type": "int"}, + {"name": "level", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "MapRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "region", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "AtlasRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "mapCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "GazetteerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "region", "type": "String"}, + {"name": "placeCount", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "CartographyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "cartographer", "type": "String"}, + {"name": "mapCount", "type": "int"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "ChartRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "chartType", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "DiagramRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "diagramType", "type": "String"}, + {"name": "subject", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "BlueprintRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "projectName", "type": "String"}, + {"name": "architect", "type": "String"}, + {"name": "scale", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "PhotographRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "photographer", "type": "String"}, + {"name": "captureDate", "type": "LocalDate"}, + {"name": "dimensions", "type": "String"} + ] + }, + { + "name": "NegativeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "photographer", "type": "String"}, + {"name": "format", "type": "String"}, + {"name": "captureDate", "type": "LocalDate"} + ] + }, + { + "name": "SlideRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "photographer", "type": "String"}, + {"name": "format", "type": "String"}, + {"name": "captureDate", "type": "LocalDate"} + ] + }, + { + "name": "TransparencyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "creator", "type": "String"}, + {"name": "format", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "PosterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "creator", "type": "String"}, + {"name": "dimensions", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"} + ] + }, + { + "name": "BrochureRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "productionDate", "type": "LocalDate"} + ] + }, + { + "name": "PamphletRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "FlyerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "productionDate", "type": "LocalDate"} + ] + }, + { + "name": "BookletRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "PressReleaseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "headline", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "pageCount", "type": "int"} + ] + }, + { + "name": "NewsletterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "publisher", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "BulletinRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "CircularRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "issuer", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "issueDate", "type": "LocalDate"} + ] + }, + { + "name": "MemorandumRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "from", "type": "String"}, + {"name": "to", "type": "String"}, + {"name": "date", "type": "LocalDate"}, + {"name": "pageCount", "type": "int"} + ] + }, + { + "name": "CorrespondenceRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sender", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "date", "type": "LocalDate"}, + {"name": "pageCount", "type": "int"}, + {"name": "subject", "type": "String"} + ] + }, + { + "name": "LetterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sender", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "date", "type": "LocalDate"}, + {"name": "pageCount", "type": "int"} + ] + }, + { + "name": "PostcardRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subject", "type": "String"}, + {"name": "sender", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "postmarkDate", "type": "LocalDate"} + ] + }, + { + "name": "TelegramRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sender", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "date", "type": "LocalDate"}, + {"name": "wordCount", "type": "int"} + ] + }, + { + "name": "CableRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sender", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "date", "type": "LocalDate"}, + {"name": "wordCount", "type": "int"} + ] + }, + { + "name": "ManuscriptRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "draftNumber", "type": "int"} + ] + }, + { + "name": "TypescriptRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "creationDate", "type": "LocalDate"} + ] + }, + { + "name": "FolioRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "QuartoRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "OctavoRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "DuodecimoRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "dimensions", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "ZineRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "creator", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "productionDate", "type": "LocalDate"} + ] + }, + { + "name": "ComicRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "issueNumber", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "GraphicNovelRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "illustrator", "type": "String"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "MangaRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "authorName", "type": "String"}, + {"name": "volumeNumber", "type": "int"}, + {"name": "pageCount", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "AudiobookRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "title", "type": "String"}, + {"name": "narrator", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "publicationDate", "type": "LocalDate"} + ] + }, + { + "name": "MicroformRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "contentDescription", "type": "String"}, + {"name": "frameCount", "type": "int"}, + {"name": "format", "type": "String"}, + {"name": "productionDate", "type": "LocalDate"} + ] + } + ] + }, + "persons": { + "intermediateClass": "LibraryPerson", + "classes": [ + { + "name": "Librarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "hireDate", "type": "LocalDate"}, + {"name": "salaryGrade", "type": "int"}, + {"name": "specialization", "type": "String"}, + {"name": "languages", "type": "List"}, + {"name": "certifications", "type": "Set"}, + {"name": "officeLocation", "type": "StaffOffice"}, + {"name": "supervisor", "type": "SeniorLibrarian"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SeniorLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "hireDate", "type": "LocalDate"}, + {"name": "yearsOfService", "type": "int"}, + {"name": "department", "type": "String"}, + {"name": "managedStaff", "type": "List"}, + {"name": "budgetAuthority", "type": "BigDecimal"}, + {"name": "officeLocation", "type": "DirectorOffice"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Archivist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "collectionsManaged", "type": "List"}, + {"name": "processingQueue", "type": "Set"}, + {"name": "certificationDate", "type": "LocalDate"}, + {"name": "archive", "type": "NationalArchive"}, + {"name": "supervisor", "type": "SeniorLibrarian"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Curator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "areaOfExpertise", "type": "String"}, + {"name": "exhibitionsCurated", "type": "int"}, + {"name": "currentExhibitions", "type": "List"}, + {"name": "museum", "type": "ArtMuseum"}, + {"name": "officeLocation", "type": "StaffOffice"}, + {"name": "status", "type": "String", "default": "ACTIVE"}, + {"name": "researchNotes", "type": "String", "ignore": true} + ] + }, + { + "name": "AdultMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "membershipLevel", "type": "MembershipLevel", "default": "BASIC"}, + {"name": "itemsBorrowed", "type": "List"}, + {"name": "readingPreferences", "type": "Set"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "accountBalance", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Author", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "penName", "type": "String"}, + {"name": "genre", "type": "String"}, + {"name": "publishedWorks", "type": "List"}, + {"name": "awards", "type": "Set"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "agent", "type": "LiteraryAgent"}, + {"name": "biography", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryDirector", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "reportsSubmitted", "type": "int"}, + {"name": "strategicGoals", "type": "List"}, + {"name": "boardMembers", "type": "Set"}, + {"name": "mainLibrary", "type": "PublicLibrary"}, + {"name": "officeLocation", "type": "DirectorOffice"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "JuniorLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "hireDate", "type": "LocalDate"}, + {"name": "trainingProgress", "type": "int"}, + {"name": "mentor", "type": "SeniorLibrarian"}, + {"name": "assignedTasks", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ReferenceLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "dailyInquiries", "type": "int"}, + {"name": "researchGuides", "type": "List"}, + {"name": "databaseAccess", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CatalogLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "recordsCreated", "type": "int"}, + {"name": "classificationSystem", "type": "String"}, + {"name": "languages", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AcquisitionsLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "vendors", "type": "List"}, + {"name": "pendingOrders", "type": "int"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SerialsLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "activeSubscriptions", "type": "int"}, + {"name": "journalTitles", "type": "List"}, + {"name": "renewalDates", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ElectronicResourcesLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "databaseCount", "type": "int"}, + {"name": "managedResources", "type": "List"}, + {"name": "accessMethods", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SystemsLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "systemsManaged", "type": "List"}, + {"name": "serverCount", "type": "int"}, + {"name": "uptimePercentage", "type": "double"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DataLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "datasetsManaged", "type": "int"}, + {"name": "dataSources", "type": "List"}, + {"name": "cleaningProtocols", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitalInitiativesLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "projectCount", "type": "int"}, + {"name": "activeProjects", "type": "List"}, + {"name": "collaborators", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SubjectSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "subjectArea", "type": "String"}, + {"name": "collectionSize", "type": "int"}, + {"name": "researchGuides", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Bibliographer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "specialtyField", "type": "String"}, + {"name": "bibliographiesCompiled", "type": "int"}, + {"name": "publications", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CollectionDevelopmentLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "budgetAllocated", "type": "BigDecimal"}, + {"name": "collectionAreas", "type": "List"}, + {"name": "selectionCriteria", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PreservationLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "itemsPreserved", "type": "int"}, + {"name": "techniques", "type": "List"}, + {"name": "environmentalControls", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ConservationSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "itemsRestored", "type": "int"}, + {"name": "treatmentMethods", "type": "List"}, + {"name": "certifications", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ProcessingArchivist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "collectionsProcessed", "type": "int"}, + {"name": "findingAidsCreated", "type": "List"}, + {"name": "processingPriority", "type": "String"}, + {"name": "archive", "type": "NationalArchive"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ReferenceArchivist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "dailyInquiries", "type": "int"}, + {"name": "researchAreas", "type": "List"}, + {"name": "accessPolicies", "type": "Set"}, + {"name": "archive", "type": "NationalArchive"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitalArchivist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "digitalCollections", "type": "int"}, + {"name": "fileFormats", "type": "List"}, + {"name": "preservationProtocols", "type": "Set"}, + {"name": "archive", "type": "NationalArchive"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "RecordsManager", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "recordsManaged", "type": "int"}, + {"name": "retentionPolicies", "type": "List"}, + {"name": "complianceAreas", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AssociateCurator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "areaOfExpertise", "type": "String"}, + {"name": "exhibitionsCurated", "type": "int"}, + {"name": "researchProjects", "type": "List"}, + {"name": "museum", "type": "ArtMuseum"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AssistantCurator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "assignedArea", "type": "String"}, + {"name": "catalogEntries", "type": "int"}, + {"name": "assistedExhibitions", "type": "List"}, + {"name": "museum", "type": "ArtMuseum"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MuseumRegistrar", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "accessionsProcessed", "type": "int"}, + {"name": "loanAgreements", "type": "List"}, + {"name": "insurancePolicies", "type": "Set"}, + {"name": "museum", "type": "ArtMuseum"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ExhibitionCoordinator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "activeExhibitions", "type": "int"}, + {"name": "upcomingShows", "type": "List"}, + {"name": "vendorContacts", "type": "Set"}, + {"name": "museum", "type": "ArtMuseum"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CollectionsManager", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "collectionSize", "type": "int"}, + {"name": "storageLocations", "type": "List"}, + {"name": "inventorySchedule", "type": "String"}, + {"name": "museum", "type": "ArtMuseum"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SpecialCollectionsLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "collectionAreas", "type": "List"}, + {"name": "rareItemCount", "type": "int"}, + {"name": "accessRestrictions", "type": "Set"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "RareBooksLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "rareBookCount", "type": "int"}, + {"name": "specializedAreas", "type": "List"}, + {"name": "appraisalExperience", "type": "int"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ManuscriptsLibrarian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "manuscriptCount", "type": "int"}, + {"name": "collectionLanguages", "type": "List"}, + {"name": "preservationNotes", "type": "String", "ignore": true}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AssociateDirector", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "managedDepartments", "type": "List"}, + {"name": "budgetOversight", "type": "BigDecimal"}, + {"name": "mainLibrary", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AssistantDirector", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "responsibilities", "type": "List"}, + {"name": "reportsTo", "type": "LibraryDirector"}, + {"name": "mainLibrary", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DepartmentHead", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "departmentBudget", "type": "BigDecimal"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BranchManager", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "branchName", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TeamLeader", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "teamSize", "type": "int"}, + {"name": "teamFocus", "type": "String"}, + {"name": "currentProjects", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Supervisor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "supervisedStaff", "type": "int"}, + {"name": "shiftSchedule", "type": "String"}, + {"name": "responsibilities", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Coordinator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "coordinationArea", "type": "String"}, + {"name": "programsManaged", "type": "int"}, + {"name": "partnerOrganizations", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ProjectManager", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "activeProjects", "type": "int"}, + {"name": "projectBudgets", "type": "BigDecimal"}, + {"name": "deadlines", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryAssistant", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "hireDate", "type": "LocalDate"}, + {"name": "assignedTasks", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryTechnician", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "technicalSkills", "type": "List"}, + {"name": "equipmentMaintained", "type": "int"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryClerk", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "duties", "type": "List"}, + {"name": "hoursPerWeek", "type": "int"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CirculationAssistant", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "dailyTransactions", "type": "int"}, + {"name": "assignedDesk", "type": "String"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ShelvingAssistant", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "itemsShelvedDaily", "type": "int"}, + {"name": "assignedSections", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Page", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "hoursPerWeek", "type": "int"}, + {"name": "shelvingAccuracy", "type": "double"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Volunteer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "volunteerId", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "hoursPerMonth", "type": "int"}, + {"name": "assignedTasks", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Intern", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "internId", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "learningGoals", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StudentWorker", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "university", "type": "String"}, + {"name": "hoursPerWeek", "type": "int"}, + {"name": "assignedTasks", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GraduateAssistant", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "program", "type": "String"}, + {"name": "researchArea", "type": "String"}, + {"name": "assignedTasks", "type": "List"}, + {"name": "branch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TeenMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "gradeLevel", "type": "String"}, + {"name": "readingPreferences", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ChildMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "ageGroup", "type": "String"}, + {"name": "parentGuardian", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SeniorMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "retirementStatus", "type": "boolean"}, + {"name": "readingPreferences", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StudentMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "institution", "type": "String"}, + {"name": "major", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FacultyMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "department", "type": "String"}, + {"name": "researchAreas", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AlumniMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "graduationYear", "type": "int"}, + {"name": "almaMater", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommunityMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "neighborhood", "type": "String"}, + {"name": "interests", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Visitor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "visitorId", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "purpose", "type": "String"}, + {"name": "hostLibrary", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DayPassVisitor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "passId", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "validUntil", "type": "LocalDate"}, + {"name": "hostLibrary", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Researcher", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "researcherId", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "currentProject", "type": "String"}, + {"name": "affiliatedInstitution", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "VisitingScholar", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "scholarId", "type": "String"}, + {"name": "homeInstitution", "type": "String"}, + {"name": "visitStartDate", "type": "LocalDate"}, + {"name": "visitEndDate", "type": "LocalDate"}, + {"name": "researchTopic", "type": "String"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GenealogyResearcher", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "researcherId", "type": "String"}, + {"name": "familyNames", "type": "List"}, + {"name": "geographicFocus", "type": "String"}, + {"name": "timePeriod", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LocalHistorian", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "historianId", "type": "String"}, + {"name": "areaOfFocus", "type": "String"}, + {"name": "publications", "type": "List"}, + {"name": "archivalSources", "type": "Set"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Journalist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "pressId", "type": "String"}, + {"name": "publication", "type": "String"}, + {"name": "beat", "type": "String"}, + {"name": "articlesPublished", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Illustrator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "portfolioUrl", "type": "String"}, + {"name": "medium", "type": "String"}, + {"name": "publishedWorks", "type": "List"}, + {"name": "awards", "type": "Set"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Translator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "translatorId", "type": "String"}, + {"name": "sourceLanguages", "type": "List"}, + {"name": "targetLanguages", "type": "List"}, + {"name": "translatedWorks", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Editor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "editorId", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "editedWorks", "type": "int"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Contributor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "contributorId", "type": "String"}, + {"name": "contributionType", "type": "String"}, + {"name": "contributedWorks", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Reviewer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "reviewerId", "type": "String"}, + {"name": "expertiseArea", "type": "String"}, + {"name": "reviewsCompleted", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PeerReviewer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "reviewerId", "type": "String"}, + {"name": "academicField", "type": "String"}, + {"name": "journalsReviewed", "type": "List"}, + {"name": "reviewsCompleted", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EditorInChief", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "publication", "type": "String"}, + {"name": "editorialPolicies", "type": "List"}, + {"name": "managingEditors", "type": "int"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ManagingEditor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "publication", "type": "String"}, + {"name": "manuscriptsInReview", "type": "int"}, + {"name": "productionSchedule", "type": "String"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CopyEditor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "manuscriptsEdited", "type": "int"}, + {"name": "styleGuide", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Proofreader", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "pagesPerHour", "type": "int"}, + {"name": "languages", "type": "List"}, + {"name": "accuracyRate", "type": "double"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Typesetter", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "softwareUsed", "type": "List"}, + {"name": "pagesPerDay", "type": "int"}, + {"name": "specialization", "type": "String"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BookDesigner", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "designsCreated", "type": "int"}, + {"name": "designTools", "type": "List"}, + {"name": "specialization", "type": "String"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CoverArtist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "artistId", "type": "String"}, + {"name": "coversDesigned", "type": "int"}, + {"name": "medium", "type": "String"}, + {"name": "portfolio", "type": "List"}, + {"name": "publisher", "type": "CommercialPublisher"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Bookbinder", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "craftsmanId", "type": "String"}, + {"name": "bindingTypes", "type": "List"}, + {"name": "booksBound", "type": "int"}, + {"name": "materials", "type": "Set"}, + {"name": "specialization", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Printer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "printerId", "type": "String"}, + {"name": "printingMethods", "type": "List"}, + {"name": "capacityPerDay", "type": "int"}, + {"name": "specialization", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LiteraryAgent", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "agentId", "type": "String"}, + {"name": "agency", "type": "String"}, + {"name": "representedAuthors", "type": "List"}, + {"name": "specialization", "type": "String"}, + {"name": "commissionRate", "type": "double"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Bookseller", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "sellerId", "type": "String"}, + {"name": "storeName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "inventorySize", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Distributor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "distributorId", "type": "String"}, + {"name": "distributionNetwork", "type": "List"}, + {"name": "warehouses", "type": "int"}, + {"name": "territory", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "WholesaleAgent", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "wholesalerId", "type": "String"}, + {"name": "supplierNetwork", "type": "List"}, + {"name": "discountRate", "type": "double"}, + {"name": "minimumOrder", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SupplierRepresentative", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "supplierId", "type": "String"}, + {"name": "productCategories", "type": "List"}, + {"name": "clientLibraries", "type": "int"}, + {"name": "contractTerms", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SubscriptionAgent", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "agentId", "type": "String"}, + {"name": "journalTitles", "type": "int"}, + {"name": "clientLibraries", "type": "List"}, + {"name": "renewalRate", "type": "double"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DatabaseProvider", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "providerId", "type": "String"}, + {"name": "databasesOffered", "type": "List"}, + {"name": "clientLibraries", "type": "int"}, + {"name": "pricingModel", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Benefactor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "benefactorId", "type": "String"}, + {"name": "totalDonations", "type": "BigDecimal"}, + {"name": "donationHistory", "type": "List"}, + {"name": "preferredCauses", "type": "Set"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Philanthropist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "philanthropistId", "type": "String"}, + {"name": "totalGiven", "type": "BigDecimal"}, + {"name": "causesSupported", "type": "List"}, + {"name": "foundation", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Donor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "donorId", "type": "String"}, + {"name": "itemsDonated", "type": "int"}, + {"name": "donationValue", "type": "BigDecimal"}, + {"name": "donationDate", "type": "LocalDate"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MemorialDonor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "donorId", "type": "String"}, + {"name": "memorialName", "type": "String"}, + {"name": "itemsDonated", "type": "int"}, + {"name": "dedicationDate", "type": "LocalDate"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EndowmentDonor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "donorId", "type": "String"}, + {"name": "endowmentName", "type": "String"}, + {"name": "endowmentAmount", "type": "BigDecimal"}, + {"name": "establishmentDate", "type": "LocalDate"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CorporateSponsor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "sponsorId", "type": "String"}, + {"name": "companyName", "type": "String"}, + {"name": "sponsorshipLevel", "type": "String"}, + {"name": "totalContributed", "type": "BigDecimal"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FoundationGrantor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "grantorId", "type": "String"}, + {"name": "foundationName", "type": "String"}, + {"name": "grantsAwarded", "type": "int"}, + {"name": "totalGranted", "type": "BigDecimal"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GovernmentFunder", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "funderId", "type": "String"}, + {"name": "agency", "type": "String"}, + {"name": "fundingProgram", "type": "String"}, + {"name": "annualAllocation", "type": "BigDecimal"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FriendOfLibrary", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "memberId", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "volunteerHours", "type": "int"}, + {"name": "fundraisingEvents", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PatronOfArts", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "patronId", "type": "String"}, + {"name": "artFormsSupported", "type": "List"}, + {"name": "eventsSponsored", "type": "int"}, + {"name": "totalContributed", "type": "BigDecimal"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Professor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "researchAreas", "type": "List"}, + {"name": "publications", "type": "int"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AssociateProfessor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "tenureYear", "type": "int"}, + {"name": "researchAreas", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AssistantProfessor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "hireDate", "type": "LocalDate"}, + {"name": "researchAreas", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Lecturer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "courses", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AdjunctInstructor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "courses", "type": "List"}, + {"name": "hoursPerWeek", "type": "int"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TeachingAssistant", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "assignedCourses", "type": "List"}, + {"name": "hoursPerWeek", "type": "int"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchAssistant", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "researchProject", "type": "String"}, + {"name": "principalInvestigator", "type": "String"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PostdoctoralResearcher", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "researcherId", "type": "String"}, + {"name": "researchField", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DoctoralCandidate", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "program", "type": "String"}, + {"name": "dissertationTitle", "type": "String"}, + {"name": "advisor", "type": "String"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MastersStudent", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "program", "type": "String"}, + {"name": "thesisTitle", "type": "String"}, + {"name": "expectedGraduation", "type": "LocalDate"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "UndergraduateStudent", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "studentId", "type": "String"}, + {"name": "major", "type": "String"}, + {"name": "year", "type": "String"}, + {"name": "enrolledCourses", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "VisitingProfessor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "professorId", "type": "String"}, + {"name": "homeInstitution", "type": "String"}, + {"name": "visitStart", "type": "LocalDate"}, + {"name": "visitEnd", "type": "LocalDate"}, + {"name": "hostUniversity", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EmeritusProfessor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "professorId", "type": "String"}, + {"name": "retirementYear", "type": "int"}, + {"name": "department", "type": "String"}, + {"name": "ongoingResearch", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DepartmentChair", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "termStart", "type": "LocalDate"}, + {"name": "termEnd", "type": "LocalDate"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Dean", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "school", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "managedDepartments", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Provost", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "academicPrograms", "type": "List"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Chancellor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "campus", "type": "String"}, + {"name": "university", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "InformationScientist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "scientistId", "type": "String"}, + {"name": "researchArea", "type": "String"}, + {"name": "publications", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "KnowledgeManager", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "knowledgeSystems", "type": "List"}, + {"name": "managedRepositories", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DataScientist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "scientistId", "type": "String"}, + {"name": "toolsUsed", "type": "List"}, + {"name": "modelsBuilt", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MetadataSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "metadataSchemas", "type": "List"}, + {"name": "recordsCreated", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Taxonomist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "taxonomiesManaged", "type": "List"}, + {"name": "classificationSystems", "type": "Set"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Ontologist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "ontologiesDeveloped", "type": "List"}, + {"name": "linkedDataProjects", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Indexer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "worksIndexed", "type": "int"}, + {"name": "specialization", "type": "String"}, + {"name": "indexingLanguages", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Abstractor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "abstractsWritten", "type": "int"}, + {"name": "subjectAreas", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Classifier", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "itemsClassified", "type": "int"}, + {"name": "classificationSystem", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Cataloger", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "recordsCreated", "type": "int"}, + {"name": "catalogingRules", "type": "String"}, + {"name": "languages", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "OriginalCataloger", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "originalRecords", "type": "int"}, + {"name": "classificationSystem", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CopyCataloger", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "recordsCopied", "type": "int"}, + {"name": "sourceDatabases", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AuthorityControlSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "authorityRecords", "type": "int"}, + {"name": "vocabularySources", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LinkedDataSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "linkedDatasets", "type": "int"}, + {"name": "vocabularies", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitalHumanitiesSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "projects", "type": "List"}, + {"name": "tools", "type": "Set"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DataCurationSpecialist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "datasetsCurated", "type": "int"}, + {"name": "curationStandards", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchDataManager", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "managedDatasets", "type": "int"}, + {"name": "dataManagementPlans", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ScholarlyCommunicationOfficer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "openAccessPolicies", "type": "List"}, + {"name": "institutionalRepository", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CopyrightOfficer", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "licensesManaged", "type": "int"}, + {"name": "copyrightAreas", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EventCoordinator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "eventsPerYear", "type": "int"}, + {"name": "upcomingEvents", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "WorkshopInstructor", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "workshopsTaught", "type": "int"}, + {"name": "topics", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TourGuide", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "employeeId", "type": "String"}, + {"name": "toursGiven", "type": "int"}, + {"name": "languages", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GuestSpeaker", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "speakerId", "type": "String"}, + {"name": "expertise", "type": "String"}, + {"name": "pastEngagements", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "KeynoteSpeaker", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "speakerId", "type": "String"}, + {"name": "keynotesDelivered", "type": "int"}, + {"name": "topics", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Panelist", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "panelistId", "type": "String"}, + {"name": "panelsParticipated", "type": "int"}, + {"name": "areasOfExpertise", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Moderator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "moderatorId", "type": "String"}, + {"name": "sessionsModerated", "type": "int"}, + {"name": "topics", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Facilitator", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "facilitatorId", "type": "String"}, + {"name": "sessionsFacilitated", "type": "int"}, + {"name": "facilitationMethods", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DiscussionLeader", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "leaderId", "type": "String"}, + {"name": "discussionsLed", "type": "int"}, + {"name": "topics", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BookClubLeader", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "leaderId", "type": "String"}, + {"name": "clubName", "type": "String"}, + {"name": "booksDiscussed", "type": "int"}, + {"name": "meetingSchedule", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Trustee", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "trusteeId", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "termEnd", "type": "LocalDate"}, + {"name": "committees", "type": "List"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BoardChair", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "boardMemberId", "type": "String"}, + {"name": "boardName", "type": "String"}, + {"name": "termStart", "type": "LocalDate"}, + {"name": "termEnd", "type": "LocalDate"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BoardMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "boardMemberId", "type": "String"}, + {"name": "boardName", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AdvisoryBoardMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "memberId", "type": "String"}, + {"name": "boardName", "type": "String"}, + {"name": "expertise", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommitteeMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "memberId", "type": "String"}, + {"name": "committeeName", "type": "String"}, + {"name": "role", "type": "String"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FoundationBoardMember", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "memberId", "type": "String"}, + {"name": "foundationName", "type": "String"}, + {"name": "termStart", "type": "LocalDate"}, + {"name": "fundraisingTarget", "type": "BigDecimal"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FriendsGroupPresident", + "kind": "class", + "extends": "LibraryPerson", + "properties": [ + {"name": "memberId", "type": "String"}, + {"name": "groupName", "type": "String"}, + {"name": "termStart", "type": "LocalDate"}, + {"name": "membersCount", "type": "int"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PatronRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "membershipId", "type": "String"}, + {"name": "fullName", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "itemsCheckedOut", "type": "int"}, + {"name": "finesOwed", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MemberRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "memberId", "type": "UUID"}, + {"name": "firstName", "type": "String"}, + {"name": "lastName", "type": "String"}, + {"name": "email", "type": "String"}, + {"name": "level", "type": "MembershipLevel", "default": "BASIC"}, + {"name": "renewalDate", "type": "LocalDate"} + ] + }, + { + "name": "VisitorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "visitorId", "type": "UUID"}, + {"name": "visitorName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "purpose", "type": "String"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "hostLibrary", "type": "String"} + ] + }, + { + "name": "GuestRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "guestId", "type": "UUID"}, + {"name": "guestName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "hostLibrary", "type": "String"}, + {"name": "purpose", "type": "String"} + ] + }, + { + "name": "ScholarRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "scholarId", "type": "UUID"}, + {"name": "scholarName", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "institution", "type": "String"}, + {"name": "publications", "type": "int"} + ] + }, + { + "name": "FellowRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "fellowId", "type": "UUID"}, + {"name": "fellowName", "type": "String"}, + {"name": "fellowshipType", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"} + ] + }, + { + "name": "ResidentRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "residentId", "type": "UUID"}, + {"name": "residentName", "type": "String"}, + {"name": "program", "type": "String"}, + {"name": "year", "type": "int"}, + {"name": "specialization", "type": "String"} + ] + }, + { + "name": "InternRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "internId", "type": "UUID"}, + {"name": "internName", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"} + ] + }, + { + "name": "ApprenticeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "apprenticeId", "type": "UUID"}, + {"name": "apprenticeName", "type": "String"}, + {"name": "trade", "type": "String"}, + {"name": "mentorName", "type": "String"}, + {"name": "durationMonths", "type": "int"} + ] + }, + { + "name": "TraineeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "traineeId", "type": "UUID"}, + {"name": "traineeName", "type": "String"}, + {"name": "program", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "completedModules", "type": "int"} + ] + }, + { + "name": "MentorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "mentorId", "type": "UUID"}, + {"name": "mentorName", "type": "String"}, + {"name": "expertiseArea", "type": "String"}, + {"name": "menteesCount", "type": "int"}, + {"name": "yearsExperience", "type": "int"} + ] + }, + { + "name": "SupervisorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "supervisorId", "type": "UUID"}, + {"name": "supervisorName", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "teamSize", "type": "int"}, + {"name": "shift", "type": "String"} + ] + }, + { + "name": "ManagerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "managerId", "type": "UUID"}, + {"name": "managerName", "type": "String"}, + {"name": "department", "type": "String"}, + {"name": "reportsCount", "type": "int"}, + {"name": "budget", "type": "BigDecimal"} + ] + }, + { + "name": "DirectorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "directorId", "type": "UUID"}, + {"name": "directorName", "type": "String"}, + {"name": "title", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"}, + {"name": "annualBudget", "type": "BigDecimal"} + ] + }, + { + "name": "TrusteeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "trusteeId", "type": "UUID"}, + {"name": "trusteeName", "type": "String"}, + {"name": "boardName", "type": "String"}, + {"name": "termStart", "type": "LocalDate"}, + {"name": "termEnd", "type": "LocalDate"} + ] + }, + { + "name": "OfficerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "officerId", "type": "UUID"}, + {"name": "officerName", "type": "String"}, + {"name": "role", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "CoordinatorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "coordinatorId", "type": "UUID"}, + {"name": "coordinatorName", "type": "String"}, + {"name": "area", "type": "String"}, + {"name": "programsManaged", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "AssistantRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "assistantId", "type": "UUID"}, + {"name": "assistantName", "type": "String"}, + {"name": "assignedTo", "type": "String"}, + {"name": "tasks", "type": "List"}, + {"name": "hoursPerWeek", "type": "int"} + ] + }, + { + "name": "SpecialistRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "specialistId", "type": "UUID"}, + {"name": "specialistName", "type": "String"}, + {"name": "specialty", "type": "String"}, + {"name": "certifications", "type": "List"}, + {"name": "yearsExperience", "type": "int"} + ] + }, + { + "name": "ConsultantRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "consultantId", "type": "UUID"}, + {"name": "consultantName", "type": "String"}, + {"name": "expertise", "type": "String"}, + {"name": "clientCount", "type": "int"}, + {"name": "hourlyRate", "type": "BigDecimal"} + ] + }, + { + "name": "AdvisorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "advisorId", "type": "UUID"}, + {"name": "advisorName", "type": "String"}, + {"name": "advisoryArea", "type": "String"}, + {"name": "appointments", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "LiaisonRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "liaisonId", "type": "UUID"}, + {"name": "liaisonName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "partnerOrganizations", "type": "List"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "RepresentativeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "representativeId", "type": "UUID"}, + {"name": "representativeName", "type": "String"}, + {"name": "constituency", "type": "String"}, + {"name": "termStart", "type": "LocalDate"}, + {"name": "termEnd", "type": "LocalDate"} + ] + }, + { + "name": "DelegateRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "delegateId", "type": "UUID"}, + {"name": "delegateName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "conference", "type": "String"}, + {"name": "year", "type": "int"} + ] + }, + { + "name": "AmbassadorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "ambassadorId", "type": "UUID"}, + {"name": "ambassadorName", "type": "String"}, + {"name": "country", "type": "String"}, + {"name": "hostCountry", "type": "String"}, + {"name": "appointmentDate", "type": "LocalDate"} + ] + }, + { + "name": "VolunteerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "volunteerId", "type": "UUID"}, + {"name": "volunteerName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "hoursPerMonth", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "DonorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "donorId", "type": "UUID"}, + {"name": "donorName", "type": "String"}, + {"name": "totalDonated", "type": "BigDecimal"}, + {"name": "donationCount", "type": "int"}, + {"name": "firstDonationDate", "type": "LocalDate"} + ] + }, + { + "name": "SponsorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sponsorId", "type": "UUID"}, + {"name": "sponsorName", "type": "String"}, + {"name": "sponsorshipLevel", "type": "String"}, + {"name": "totalContributed", "type": "BigDecimal"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "BenefactorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "benefactorId", "type": "UUID"}, + {"name": "benefactorName", "type": "String"}, + {"name": "totalGiven", "type": "BigDecimal"}, + {"name": "causesSupported", "type": "List"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "PatronOfArtsRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "patronId", "type": "UUID"}, + {"name": "patronName", "type": "String"}, + {"name": "artFormsSupported", "type": "List"}, + {"name": "totalContributed", "type": "BigDecimal"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "AuthorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "authorId", "type": "UUID"}, + {"name": "authorName", "type": "String"}, + {"name": "publishedWorks", "type": "int"}, + {"name": "genres", "type": "List"}, + {"name": "awards", "type": "int"} + ] + }, + { + "name": "EditorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "editorId", "type": "UUID"}, + {"name": "editorName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "editedWorks", "type": "int"}, + {"name": "publisher", "type": "String"} + ] + }, + { + "name": "IllustratorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "illustratorId", "type": "UUID"}, + {"name": "illustratorName", "type": "String"}, + {"name": "medium", "type": "String"}, + {"name": "publishedWorks", "type": "int"}, + {"name": "awards", "type": "int"} + ] + }, + { + "name": "TranslatorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "translatorId", "type": "UUID"}, + {"name": "translatorName", "type": "String"}, + {"name": "sourceLanguages", "type": "List"}, + {"name": "targetLanguages", "type": "List"}, + {"name": "translatedWorks", "type": "int"} + ] + }, + { + "name": "ContributorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "contributorId", "type": "UUID"}, + {"name": "contributorName", "type": "String"}, + {"name": "contributionType", "type": "String"}, + {"name": "contributedWorks", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "ReviewerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "reviewerId", "type": "UUID"}, + {"name": "reviewerName", "type": "String"}, + {"name": "expertiseArea", "type": "String"}, + {"name": "reviewsCompleted", "type": "int"}, + {"name": "rating", "type": "double"} + ] + }, + { + "name": "RefereeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "refereeId", "type": "UUID"}, + {"name": "refereeName", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "papersReviewed", "type": "int"}, + {"name": "journals", "type": "List"} + ] + }, + { + "name": "ExaminerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "examinerId", "type": "UUID"}, + {"name": "examinerName", "type": "String"}, + {"name": "subjectArea", "type": "String"}, + {"name": "examinationsConducted", "type": "int"}, + {"name": "institution", "type": "String"} + ] + }, + { + "name": "AssessorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "assessorId", "type": "UUID"}, + {"name": "assessorName", "type": "String"}, + {"name": "assessmentArea", "type": "String"}, + {"name": "assessmentsCompleted", "type": "int"}, + {"name": "certification", "type": "String"} + ] + }, + { + "name": "EvaluatorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "evaluatorId", "type": "UUID"}, + {"name": "evaluatorName", "type": "String"}, + {"name": "evaluationDomain", "type": "String"}, + {"name": "evaluationsCompleted", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "AuditorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "auditorId", "type": "UUID"}, + {"name": "auditorName", "type": "String"}, + {"name": "auditType", "type": "String"}, + {"name": "auditsConducted", "type": "int"}, + {"name": "certification", "type": "String"} + ] + }, + { + "name": "InspectorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "inspectorId", "type": "UUID"}, + {"name": "inspectorName", "type": "String"}, + {"name": "inspectionArea", "type": "String"}, + {"name": "inspectionsCompleted", "type": "int"}, + {"name": "region", "type": "String"} + ] + }, + { + "name": "InvestigatorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "investigatorId", "type": "UUID"}, + {"name": "investigatorName", "type": "String"}, + {"name": "researchField", "type": "String"}, + {"name": "investigationsLed", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "ResearcherRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "researcherId", "type": "UUID"}, + {"name": "researcherName", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "publications", "type": "int"}, + {"name": "institution", "type": "String"} + ] + }, + { + "name": "AnalystRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "analystId", "type": "UUID"}, + {"name": "analystName", "type": "String"}, + {"name": "analysisType", "type": "String"}, + {"name": "reportsGenerated", "type": "int"}, + {"name": "tools", "type": "List"} + ] + }, + { + "name": "StatisticianRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "statisticianId", "type": "UUID"}, + {"name": "statisticianName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "modelsDeveloped", "type": "int"}, + {"name": "softwareUsed", "type": "List"} + ] + }, + { + "name": "DemographerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "demographerId", "type": "UUID"}, + {"name": "demographerName", "type": "String"}, + {"name": "regionOfStudy", "type": "String"}, + {"name": "studiesCompleted", "type": "int"}, + {"name": "publications", "type": "int"} + ] + }, + { + "name": "HistorianRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "historianId", "type": "UUID"}, + {"name": "historianName", "type": "String"}, + {"name": "era", "type": "String"}, + {"name": "publications", "type": "int"}, + {"name": "specialization", "type": "String"} + ] + }, + { + "name": "ArchivistRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "archivistId", "type": "UUID"}, + {"name": "archivistName", "type": "String"}, + {"name": "collectionArea", "type": "String"}, + {"name": "recordsProcessed", "type": "int"}, + {"name": "institution", "type": "String"} + ] + }, + { + "name": "CuratorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "curatorId", "type": "UUID"}, + {"name": "curatorName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "exhibitionsCurated", "type": "int"}, + {"name": "institution", "type": "String"} + ] + }, + { + "name": "ConservatorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "conservatorId", "type": "UUID"}, + {"name": "conservatorName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "itemsTreated", "type": "int"}, + {"name": "techniques", "type": "List"} + ] + }, + { + "name": "RestorerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "restorerId", "type": "UUID"}, + {"name": "restorerName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "itemsRestored", "type": "int"}, + {"name": "yearsExperience", "type": "int"} + ] + }, + { + "name": "TechnicianRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "technicianId", "type": "UUID"}, + {"name": "technicianName", "type": "String"}, + {"name": "technicalField", "type": "String"}, + {"name": "equipmentMaintained", "type": "int"}, + {"name": "certifications", "type": "List"} + ] + }, + { + "name": "OperatorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "operatorId", "type": "UUID"}, + {"name": "operatorName", "type": "String"}, + {"name": "machineType", "type": "String"}, + {"name": "yearsExperience", "type": "int"}, + {"name": "shift", "type": "String"} + ] + }, + { + "name": "EngineerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "engineerId", "type": "UUID"}, + {"name": "engineerName", "type": "String"}, + {"name": "engineeringField", "type": "String"}, + {"name": "projectsCompleted", "type": "int"}, + {"name": "license", "type": "String"} + ] + }, + { + "name": "DeveloperRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "developerId", "type": "UUID"}, + {"name": "developerName", "type": "String"}, + {"name": "languages", "type": "List"}, + {"name": "projectsCompleted", "type": "int"}, + {"name": "experienceYears", "type": "int"} + ] + }, + { + "name": "DesignerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "designerId", "type": "UUID"}, + {"name": "designerName", "type": "String"}, + {"name": "designField", "type": "String"}, + {"name": "projectsCompleted", "type": "int"}, + {"name": "tools", "type": "List"} + ] + }, + { + "name": "ArchitectRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "architectId", "type": "UUID"}, + {"name": "architectName", "type": "String"}, + {"name": "specialization", "type": "String"}, + {"name": "projectsCompleted", "type": "int"}, + {"name": "license", "type": "String"} + ] + }, + { + "name": "PlannerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "plannerId", "type": "UUID"}, + {"name": "plannerName", "type": "String"}, + {"name": "planningArea", "type": "String"}, + {"name": "plansCreated", "type": "int"}, + {"name": "region", "type": "String"} + ] + }, + { + "name": "StrategistRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "strategistId", "type": "UUID"}, + {"name": "strategistName", "type": "String"}, + {"name": "strategyArea", "type": "String"}, + {"name": "strategiesDeveloped", "type": "int"}, + {"name": "experienceYears", "type": "int"} + ] + } + ] + }, + "organizations": { + "intermediateClass": "LibraryOrganization", + "classes": [ + { + "name": "UniversityPress", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "publicationsPerYear", "type": "int"}, + {"name": "catalogTitles", "type": "List"}, + {"name": "distributedPresses", "type": "Set"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "director", "type": "LibraryDirector"}, + {"name": "annualRevenue", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommercialPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "imprints", "type": "List"}, + {"name": "bestsellingTitles", "type": "Set"}, + {"name": "annualRevenue", "type": "BigDecimal"}, + {"name": "headquartersCity", "type": "String"}, + {"name": "contracts", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PublicLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "branchCount", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "operatingHours", "type": "String"}, + {"name": "director", "type": "LibraryDirector"}, + {"name": "staffMembers", "type": "List"}, + {"name": "registeredMembers", "type": "Set"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AcademicLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "affiliatedInstitution", "type": "University"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "digitalResources", "type": "int"}, + {"name": "subjectAreas", "type": "List"}, + {"name": "headLibrarian", "type": "SeniorLibrarian"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArtMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "collectionSize", "type": "int"}, + {"name": "currentExhibitions", "type": "List"}, + {"name": "permanentGalleries", "type": "Set"}, + {"name": "curator", "type": "Curator"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "admissionFee", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "NationalArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "long"}, + {"name": "oldestDocumentYear", "type": "int"}, + {"name": "archivalCollections", "type": "List"}, + {"name": "restrictedAccessAreas", "type": "Set"}, + {"name": "headArchivist", "type": "Archivist"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "University", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "facultyCount", "type": "int"}, + {"name": "departments", "type": "List"}, + {"name": "degreePrograms", "type": "Set"}, + {"name": "campusLibrary", "type": "AcademicLibrary"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AcademicPress", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "publicationsPerYear", "type": "int"}, + {"name": "peerReviewedJournals", "type": "List"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TradePublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualTitles", "type": "int"}, + {"name": "genres", "type": "List"}, + {"name": "bestsellingAuthors", "type": "Set"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "IndependentPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualTitles", "type": "int"}, + {"name": "specialty", "type": "String"}, + {"name": "distributionNetwork", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SmallPress", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualTitles", "type": "int"}, + {"name": "focusArea", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SelfPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "platformName", "type": "String"}, + {"name": "registeredAuthors", "type": "int"}, + {"name": "annualPublications", "type": "int"}, + {"name": "servicesOffered", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "HybridPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "traditionalTitles", "type": "int"}, + {"name": "openAccessTitles", "type": "int"}, + {"name": "revenueModel", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PublishingServiceProvider", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "serviceName", "type": "String"}, + {"name": "servicesOffered", "type": "List"}, + {"name": "clientPublishers", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ScholarlyPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "journalCount", "type": "int"}, + {"name": "bookSeries", "type": "List"}, + {"name": "peerReviewProcess", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EducationalPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "textbookTitles", "type": "int"}, + {"name": "subjectAreas", "type": "List"}, + {"name": "gradeLevels", "type": "Set"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ProfessionalPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "professionalFields", "type": "List"}, + {"name": "annualTitles", "type": "int"}, + {"name": "certificationPrograms", "type": "Set"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "RegionalPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "region", "type": "String"}, + {"name": "localAuthors", "type": "int"}, + {"name": "annualTitles", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ChildrensPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualTitles", "type": "int"}, + {"name": "ageGroups", "type": "List"}, + {"name": "illustratedBooks", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PoetryPress", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "poetsPublished", "type": "int"}, + {"name": "annualCollections", "type": "int"}, + {"name": "awardsWon", "type": "Set"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LiteraryPress", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualTitles", "type": "int"}, + {"name": "literaryAwards", "type": "Set"}, + {"name": "translatedWorks", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArtPress", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "artBooksPublished", "type": "int"}, + {"name": "featuredArtists", "type": "List"}, + {"name": "exhibitionCatalogs", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MusicPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "composersPublished", "type": "int"}, + {"name": "catalogTitles", "type": "List"}, + {"name": "royaltySystem", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MapPublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "mapTitles", "type": "int"}, + {"name": "coverageRegions", "type": "List"}, + {"name": "digitalMaps", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "UniversityLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "digitalResources", "type": "int"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CollegeLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "affiliatedCollege", "type": "University"}, + {"name": "subjectAreas", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SchoolLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "int"}, + {"name": "gradeLevels", "type": "List"}, + {"name": "schoolName", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SpecialLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "specialization", "type": "String"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "accessPolicy", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LawLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "legalVolumes", "type": "long"}, + {"name": "jurisdictions", "type": "List"}, + {"name": "affiliatedInstitution", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MedicalLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "medicalVolumes", "type": "long"}, + {"name": "journalSubscriptions", "type": "int"}, + {"name": "affiliatedHospital", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CorporateLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "int"}, + {"name": "companyName", "type": "String"}, + {"name": "industry", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GovernmentLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "agency", "type": "String"}, + {"name": "classificationLevel", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "NationalLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "country", "type": "String"}, + {"name": "legalDeposit", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StateLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "state", "type": "String"}, + {"name": "regionalCollections", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MunicipalLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "city", "type": "String"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CountyLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "county", "type": "String"}, + {"name": "branchCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "RegionalLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "region", "type": "String"}, + {"name": "memberLibraries", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommunityLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "int"}, + {"name": "communityName", "type": "String"}, + {"name": "volunteerCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BranchLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalVolumes", "type": "int"}, + {"name": "branchName", "type": "String"}, + {"name": "mainLibrary", "type": "PublicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BookmobileLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "vehicleCount", "type": "int"}, + {"name": "stopsPerWeek", "type": "int"}, + {"name": "collectionSize", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitalLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "digitalTitles", "type": "long"}, + {"name": "dailyVisitors", "type": "int"}, + {"name": "downloadLimit", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "VirtualLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "onlineResources", "type": "long"}, + {"name": "registeredUsers", "type": "int"}, + {"name": "platform", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StateArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "long"}, + {"name": "state", "type": "String"}, + {"name": "accessPolicy", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MunicipalArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "long"}, + {"name": "city", "type": "String"}, + {"name": "collections", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CorporateArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "long"}, + {"name": "companyName", "type": "String"}, + {"name": "accessLevel", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TheaterArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "performanceCount", "type": "int"}, + {"name": "theaterName", "type": "String"}, + {"name": "mediaFormats", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "UniversityArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "long"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "collections", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FamilyArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "int"}, + {"name": "familyName", "type": "String"}, + {"name": "generations", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PhotographyArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "photoCount", "type": "long"}, + {"name": "dateRange", "type": "String"}, + {"name": "formats", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FilmArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "filmCount", "type": "int"}, + {"name": "formats", "type": "List"}, + {"name": "restorationProjects", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BusinessArchive", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "documentCount", "type": "long"}, + {"name": "industry", "type": "String"}, + {"name": "corporateRecords", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "HistoryMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "collectionSize", "type": "int"}, + {"name": "timePeriods", "type": "List"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "NaturalHistoryMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "specimenCount", "type": "long"}, + {"name": "researchAreas", "type": "List"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ScienceMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "interactiveDisplays", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ChildrensMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "ageRange", "type": "String"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DesignMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "collectionSize", "type": "int"}, + {"name": "designFields", "type": "List"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MaritimeMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "collectionSize", "type": "int"}, + {"name": "vesselCount", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AviationMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "aircraftCount", "type": "int"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "RailwayMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "locomotiveCount", "type": "int"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AgriculturalMuseum", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "farmEquipment", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchInstitute", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "researchFields", "type": "List"}, + {"name": "researcherCount", "type": "int"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ThinkTank", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "focusAreas", "type": "List"}, + {"name": "publicationsPerYear", "type": "int"}, + {"name": "staffCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchCenter", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "specialization", "type": "String"}, + {"name": "ongoingProjects", "type": "int"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchLaboratory", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "labType", "type": "String"}, + {"name": "equipmentCount", "type": "int"}, + {"name": "researcherCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FieldStation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "location", "type": "String"}, + {"name": "researchArea", "type": "String"}, + {"name": "seasonalOperation", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Observatory", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "telescopeCount", "type": "int"}, + {"name": "researchArea", "type": "String"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BotanicalGarden", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "plantSpecies", "type": "int"}, + {"name": "gardenArea", "type": "double"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Zoo", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "animalSpecies", "type": "int"}, + {"name": "totalAnimals", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Aquarium", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "marineSpecies", "type": "int"}, + {"name": "tankCount", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Planetarium", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "showsPerWeek", "type": "int"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "College", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "departments", "type": "List"}, + {"name": "campusLibrary", "type": "AcademicLibrary"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommunityCollege", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "programsOffered", "type": "List"}, + {"name": "campusCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "VocationalSchool", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "trades", "type": "List"}, + {"name": "certificationPrograms", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MusicSchool", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "instruments", "type": "List"}, + {"name": "performanceSpaces", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchUniversity", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "researchExpenditure", "type": "BigDecimal"}, + {"name": "doctoralPrograms", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LiberalArtsCollege", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "departments", "type": "List"}, + {"name": "studentFacultyRatio", "type": "double"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TechnicalInstitute", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "technicalFields", "type": "List"}, + {"name": "labCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ProfessionalSchool", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "professionalField", "type": "String"}, + {"name": "accreditation", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GraduateSchool", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "degreePrograms", "type": "List"}, + {"name": "facultyCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryAssociation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "activities", "type": "List"}, + {"name": "annualConference", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArchivalAssociation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "focusAreas", "type": "List"}, + {"name": "publications", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MuseumAssociation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberMuseums", "type": "int"}, + {"name": "exhibitionPrograms", "type": "List"}, + {"name": "accreditationProgram", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PublishersAssociation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberPublishers", "type": "int"}, + {"name": "industryStandards", "type": "List"}, + {"name": "annualReport", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BooksellersAssociation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberBooksellers", "type": "int"}, + {"name": "advocacyAreas", "type": "List"}, + {"name": "annualTradeShow", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AuthorsGuild", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "legalServices", "type": "List"}, + {"name": "advocacyIssues", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchAssociation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "researchAreas", "type": "List"}, + {"name": "grantsAwarded", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "HistoricalSociety", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "focusEra", "type": "String"}, + {"name": "publications", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GenealogicalSociety", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "databases", "type": "List"}, + {"name": "regionalFocus", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FriendsOfLibrary", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "fundraisingEvents", "type": "List"}, + {"name": "annualContribution", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Bookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "inventorySize", "type": "int"}, + {"name": "specialty", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ChainBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeCount", "type": "int"}, + {"name": "chainName", "type": "String"}, + {"name": "totalInventory", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "IndependentBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "inventorySize", "type": "int"}, + {"name": "specialty", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "UsedBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "inventorySize", "type": "int"}, + {"name": "acquisitionPolicy", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AntiqueBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "rareBookCount", "type": "int"}, + {"name": "oldestBookYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "OnlineBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "digitalCatalog", "type": "long"}, + {"name": "dailyOrders", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "UniversityBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "textbookInventory", "type": "int"}, + {"name": "merchandise", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SpecialtyBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "specialty", "type": "String"}, + {"name": "inventorySize", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AcademicBookstore", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "storeName", "type": "String"}, + {"name": "academicTitles", "type": "int"}, + {"name": "disciplines", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibrarySupplier", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "clientLibraries", "type": "int"}, + {"name": "productCategories", "type": "List"}, + {"name": "annualRevenue", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "BookDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "publisherClients", "type": "int"}, + {"name": "warehouseCount", "type": "int"}, + {"name": "dailyShipments", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Wholesaler", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "supplierCount", "type": "int"}, + {"name": "retailerClients", "type": "int"}, + {"name": "inventorySize", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "libraryClients", "type": "int"}, + {"name": "catalogTitles", "type": "long"}, + {"name": "distributionRegions", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "JournalDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "journalTitles", "type": "int"}, + {"name": "subscriberCount", "type": "int"}, + {"name": "frequency", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MusicDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "labelClients", "type": "int"}, + {"name": "formats", "type": "List"}, + {"name": "dailyShipments", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "FilmDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "studioClients", "type": "int"}, + {"name": "titlesDistributed", "type": "int"}, + {"name": "formats", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArtDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "artistClients", "type": "int"}, + {"name": "galleryClients", "type": "int"}, + {"name": "artworkTypes", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EducationalDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "schoolClients", "type": "int"}, + {"name": "educationalMaterials", "type": "long"}, + {"name": "gradeLevels", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "InternationalDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "countriesServed", "type": "int"}, + {"name": "dailyShipments", "type": "int"}, + {"name": "languagesSupported", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "RegionalDistributor", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "region", "type": "String"}, + {"name": "clientCount", "type": "int"}, + {"name": "warehouseCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SubscriptionAgency", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "journalTitles", "type": "int"}, + {"name": "libraryClients", "type": "int"}, + {"name": "renewalRate", "type": "double"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "JournalSubscriptionService", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "availableJournals", "type": "int"}, + {"name": "activeSubscriptions", "type": "int"}, + {"name": "platform", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DatabaseSubscriptionService", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "availableDatabases", "type": "int"}, + {"name": "activeSubscriptions", "type": "int"}, + {"name": "concurrentUsers", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EBookSubscriptionService", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "ebookTitles", "type": "long"}, + {"name": "activeSubscriptions", "type": "int"}, + {"name": "downloadLimit", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StreamingService", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "availableTitles", "type": "long"}, + {"name": "activeUsers", "type": "int"}, + {"name": "contentTypes", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ContentProvider", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "contentTypes", "type": "List"}, + {"name": "clientCount", "type": "int"}, + {"name": "dailyContent", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MediaProvider", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "mediaTypes", "type": "List"}, + {"name": "availableTitles", "type": "long"}, + {"name": "clientCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitalContentProvider", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "digitalAssets", "type": "long"}, + {"name": "platform", "type": "String"}, + {"name": "dailyDownloads", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "OpenAccessRepository", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "depositedPapers", "type": "long"}, + {"name": "monthlyDownloads", "type": "int"}, + {"name": "affiliatedUniversity", "type": "University"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "InstitutionalRepository", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "depositedItems", "type": "long"}, + {"name": "affiliatedInstitution", "type": "String"}, + {"name": "itemTypes", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "endowment", "type": "BigDecimal"}, + {"name": "grantsAwarded", "type": "int"}, + {"name": "beneficiaryLibraries", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CharitableFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "annualGiving", "type": "BigDecimal"}, + {"name": "focusAreas", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EducationalFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "scholarshipsOffered", "type": "int"}, + {"name": "beneficiarySchools", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CulturalFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "culturalPrograms", "type": "List"}, + {"name": "annualGrants", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "researchGrants", "type": "int"}, + {"name": "researchAreas", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "EndowmentFund", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "fundValue", "type": "BigDecimal"}, + {"name": "annualPayout", "type": "BigDecimal"}, + {"name": "beneficiaryCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MemorialFund", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "fundValue", "type": "BigDecimal"}, + {"name": "memorialName", "type": "String"}, + {"name": "annualDistribution", "type": "BigDecimal"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ScholarshipFund", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "fundValue", "type": "BigDecimal"}, + {"name": "scholarshipsAwarded", "type": "int"}, + {"name": "eligibilityCriteria", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GrantMakingFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualGrants", "type": "int"}, + {"name": "totalGrantValue", "type": "BigDecimal"}, + {"name": "grantAreas", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommunityFoundation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "communityPrograms", "type": "List"}, + {"name": "donorCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MinistryOfCulture", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "country", "type": "String"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "culturalPrograms", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DepartmentOfEducation", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "schoolCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryCommission", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "commissionerCount", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "oversightAreas", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StateLibraryAgency", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "state", "type": "String"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "supportedLibraries", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MunicipalCulturalOffice", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "city", "type": "String"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "culturalInitiatives", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "NationalEndowment", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "country", "type": "String"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "grantsAwarded", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArtsCouncil", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "grantsAwarded", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "HeritageCouncil", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "heritageSites", "type": "int"}, + {"name": "preservationGrants", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArchivesCommission", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "overseenArchives", "type": "int"}, + {"name": "policies", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PreservationOffice", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "preservationProjects", "type": "int"}, + {"name": "guidelines", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "StandardsOrganization", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "standardsPublished", "type": "int"}, + {"name": "memberOrganizations", "type": "int"}, + {"name": "focusAreas", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "MetadataStandardsBody", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "standardsDeveloped", "type": "List"}, + {"name": "memberCount", "type": "int"}, + {"name": "workingGroups", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CatalogingCodeBody", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "codeName", "type": "String"}, + {"name": "revisions", "type": "int"}, + {"name": "memberOrganizations", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ClassificationAuthority", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "classificationSystem", "type": "String"}, + {"name": "categories", "type": "int"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "AuthorityFilePublisher", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "authorityRecords", "type": "long"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "subscriberCount", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "SubjectHeadingAuthority", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "headingCount", "type": "long"}, + {"name": "languagesSupported", "type": "List"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "NameAuthority", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "nameRecords", "type": "long"}, + {"name": "variantsPerRecord", "type": "double"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GenreFormAuthority", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "genreTerms", "type": "int"}, + {"name": "formTerms", "type": "int"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LanguageAuthority", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "languageCodes", "type": "int"}, + {"name": "dialects", "type": "int"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "GeographicAuthority", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "geographicCodes", "type": "long"}, + {"name": "regionsCovered", "type": "List"}, + {"name": "updatesPerYear", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "LibraryConsortium", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberLibraries", "type": "int"}, + {"name": "sharedCatalog", "type": "boolean"}, + {"name": "jointPurchasing", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitalConsortium", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "sharedPlatforms", "type": "List"}, + {"name": "digitalResources", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResearchConsortium", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberInstitutions", "type": "int"}, + {"name": "sharedResources", "type": "List"}, + {"name": "jointProjects", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PurchasingConsortium", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "annualPurchasingVolume", "type": "BigDecimal"}, + {"name": "vendorAgreements", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ResourceSharingNetwork", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberLibraries", "type": "int"}, + {"name": "annualTransactions", "type": "long"}, + {"name": "averageDeliveryDays", "type": "double"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "InterlibraryLoanNetwork", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberLibraries", "type": "int"}, + {"name": "annualLoans", "type": "long"}, + {"name": "averageTurnaroundDays", "type": "double"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CatalogingNetwork", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberLibraries", "type": "int"}, + {"name": "sharedRecords", "type": "long"}, + {"name": "platform", "type": "String"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PreservationNetwork", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberInstitutions", "type": "int"}, + {"name": "preservationProjects", "type": "int"}, + {"name": "sharedFacilities", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "DigitizationNetwork", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberInstitutions", "type": "int"}, + {"name": "itemsDigitized", "type": "long"}, + {"name": "sharedEquipment", "type": "boolean"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "TrainingNetwork", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "memberCount", "type": "int"}, + {"name": "annualWorkshops", "type": "int"}, + {"name": "certificationPrograms", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CulturalCenter", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "annualEvents", "type": "int"}, + {"name": "facilities", "type": "List"}, + {"name": "annualVisitors", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "ArtsCenter", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "performanceSpaces", "type": "int"}, + {"name": "studioCount", "type": "int"}, + {"name": "annualEvents", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CommunityCenter", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "roomCount", "type": "int"}, + {"name": "programsOffered", "type": "List"}, + {"name": "annualParticipants", "type": "long"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "CulturalHeritageInstitution", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "collectionSize", "type": "long"}, + {"name": "heritageSites", "type": "int"}, + {"name": "preservationPrograms", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PerformingArtsCenter", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "annualPerformances", "type": "int"}, + {"name": "residentCompanies", "type": "List"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "Cinema", + "kind": "class", + "extends": "LibraryOrganization", + "properties": [ + {"name": "foundedYear", "type": "int"}, + {"name": "screenCount", "type": "int"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "weeklyShowings", "type": "int"}, + {"name": "status", "type": "String", "default": "ACTIVE"} + ] + }, + { + "name": "PressRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "pressName", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "totalTitles", "type": "int"}, + {"name": "headquarters", "type": "String"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "PublisherRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "publisherName", "type": "String"}, + {"name": "establishedDate", "type": "LocalDate"}, + {"name": "imprintCount", "type": "int"}, + {"name": "annualOutput", "type": "int"}, + {"name": "country", "type": "String"} + ] + }, + { + "name": "BranchRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "branchName", "type": "String"}, + {"name": "address", "type": "String"}, + {"name": "openingDate", "type": "LocalDate"}, + {"name": "staffCount", "type": "int"}, + {"name": "collectionSize", "type": "long"}, + {"name": "status", "type": "String", "default": "OPEN"} + ] + }, + { + "name": "ImprintRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "imprintName", "type": "String"}, + {"name": "parentPublisher", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "activeTitles", "type": "int"}, + {"name": "specialty", "type": "String"} + ] + }, + { + "name": "DivisionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "divisionName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "headCount", "type": "int"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "establishedDate", "type": "LocalDate"} + ] + }, + { + "name": "SubsidiaryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "subsidiaryName", "type": "String"}, + {"name": "parentCompany", "type": "String"}, + {"name": "ownershipPercent", "type": "double"}, + {"name": "country", "type": "String"}, + {"name": "establishedDate", "type": "LocalDate"} + ] + }, + { + "name": "AffiliateRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "affiliateName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "relationshipType", "type": "String"}, + {"name": "agreementDate", "type": "LocalDate"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "ChapterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "chapterName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "region", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "SectionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sectionName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "focusArea", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "DepartmentRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "departmentName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "headName", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "budget", "type": "BigDecimal"} + ] + }, + { + "name": "FacultyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "facultyName", "type": "String"}, + {"name": "university", "type": "String"}, + {"name": "professorCount", "type": "int"}, + {"name": "studentCount", "type": "int"}, + {"name": "researchAreas", "type": "List"} + ] + }, + { + "name": "SchoolRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "schoolName", "type": "String"}, + {"name": "district", "type": "String"}, + {"name": "studentCount", "type": "int"}, + {"name": "teacherCount", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "InstituteRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "instituteName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "researcherCount", "type": "int"}, + {"name": "focusAreas", "type": "List"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "CenterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "centerName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "directorName", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "LaboratoryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "labName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "equipmentCount", "type": "int"}, + {"name": "researcherCount", "type": "int"}, + {"name": "specialization", "type": "String"} + ] + }, + { + "name": "UnitRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "unitName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "function", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "establishedDate", "type": "LocalDate"} + ] + }, + { + "name": "BureauRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "bureauName", "type": "String"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "annualBudget", "type": "BigDecimal"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "AgencyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "agencyName", "type": "String"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "function", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "CommissionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "commissionName", "type": "String"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "commissionerCount", "type": "int"}, + {"name": "mandate", "type": "String"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "CommitteeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "committeeName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "chairName", "type": "String"}, + {"name": "establishedDate", "type": "LocalDate"} + ] + }, + { + "name": "CouncilRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "councilName", "type": "String"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "function", "type": "String"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "BoardRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "boardName", "type": "String"}, + {"name": "parentOrganization", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "chairName", "type": "String"}, + {"name": "termStart", "type": "LocalDate"} + ] + }, + { + "name": "TrustRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "trustName", "type": "String"}, + {"name": "trustType", "type": "String"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "beneficiaries", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "EndowmentRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "endowmentName", "type": "String"}, + {"name": "fundValue", "type": "BigDecimal"}, + {"name": "annualPayout", "type": "BigDecimal"}, + {"name": "beneficiaryCount", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "FundRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "fundName", "type": "String"}, + {"name": "fundType", "type": "String"}, + {"name": "totalValue", "type": "BigDecimal"}, + {"name": "annualDistribution", "type": "BigDecimal"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "GrantRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "grantId", "type": "UUID"}, + {"name": "grantName", "type": "String"}, + {"name": "grantAmount", "type": "BigDecimal"}, + {"name": "recipient", "type": "String"}, + {"name": "awardDate", "type": "LocalDate"} + ] + }, + { + "name": "ScholarshipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "scholarshipName", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "eligibility", "type": "String"}, + {"name": "awardsPerYear", "type": "int"}, + {"name": "foundedYear", "type": "int"} + ] + }, + { + "name": "FellowshipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "fellowshipName", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "duration", "type": "String"}, + {"name": "field", "type": "String"}, + {"name": "awardsPerYear", "type": "int"} + ] + }, + { + "name": "SponsorshipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sponsorName", "type": "String"}, + {"name": "beneficiary", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"} + ] + }, + { + "name": "DonationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "donorName", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "date", "type": "LocalDate"}, + {"name": "purpose", "type": "String"} + ] + }, + { + "name": "BequestRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "bequestName", "type": "String"}, + {"name": "testator", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "beneficiary", "type": "String"}, + {"name": "executionDate", "type": "LocalDate"} + ] + }, + { + "name": "CharterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "charterName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "charterDate", "type": "LocalDate"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "LicenseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "licenseName", "type": "String"}, + {"name": "licenseType", "type": "String"}, + {"name": "issuer", "type": "String"}, + {"name": "validFrom", "type": "LocalDate"}, + {"name": "validUntil", "type": "LocalDate"} + ] + }, + { + "name": "PermitRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "permitName", "type": "String"}, + {"name": "permitType", "type": "String"}, + {"name": "issuer", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "expiryDate", "type": "LocalDate"} + ] + }, + { + "name": "CertificateRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "certificateName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "issuingBody", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "valid", "type": "boolean", "default": "true"} + ] + }, + { + "name": "AccreditationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "accreditationName", "type": "String"}, + {"name": "institution", "type": "String"}, + {"name": "accreditingBody", "type": "String"}, + {"name": "grantedDate", "type": "LocalDate"}, + {"name": "expiryDate", "type": "LocalDate"} + ] + }, + { + "name": "MembershipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "memberName", "type": "String"}, + {"name": "organization", "type": "String"}, + {"name": "memberType", "type": "String"}, + {"name": "joinDate", "type": "LocalDate"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "PartnershipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "partnershipName", "type": "String"}, + {"name": "partnerA", "type": "String"}, + {"name": "partnerB", "type": "String"}, + {"name": "agreementDate", "type": "LocalDate"}, + {"name": "duration", "type": "String"} + ] + }, + { + "name": "AllianceRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "allianceName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "focusArea", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "CoalitionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "coalitionName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "cause", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "FederationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "federationName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "jurisdiction", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "NetworkRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "networkName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "focusArea", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "ConsortiumRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "consortiumName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "sharedResources", "type": "boolean", "default": "true"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "AssociationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "associationName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "focusArea", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "annualDues", "type": "BigDecimal"} + ] + }, + { + "name": "SocietyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "societyName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "field", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "annualFee", "type": "BigDecimal"} + ] + }, + { + "name": "GuildRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "guildName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "profession", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "UnionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "unionName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "industry", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "SyndicateRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "syndicateName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "activity", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "CooperativeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "cooperativeName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "purpose", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "CollectiveRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "collectiveName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "focusArea", "type": "String"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "FoundationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "foundationName", "type": "String"}, + {"name": "totalAssets", "type": "BigDecimal"}, + {"name": "annualGiving", "type": "BigDecimal"}, + {"name": "foundedYear", "type": "int"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "InstituteRecord2", + "kind": "record", + "extends": null, + "properties": [ + {"name": "instituteName", "type": "String"}, + {"name": "researchArea", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "foundedYear", "type": "int"}, + {"name": "annualBudget", "type": "BigDecimal"} + ] + }, + { + "name": "InitiativeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "initiativeName", "type": "String"}, + {"name": "leadOrganization", "type": "String"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"} + ] + }, + { + "name": "ProgramRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "programName", "type": "String"}, + {"name": "organizingBody", "type": "String"}, + {"name": "participantCount", "type": "int"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "active", "type": "boolean", "default": "true"} + ] + }, + { + "name": "ProjectRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "projectName", "type": "String"}, + {"name": "leadOrganization", "type": "String"}, + {"name": "budget", "type": "BigDecimal"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"} + ] + }, + { + "name": "CampaignRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "campaignName", "type": "String"}, + {"name": "organizingBody", "type": "String"}, + {"name": "targetAmount", "type": "BigDecimal"}, + {"name": "raisedAmount", "type": "BigDecimal"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "RegistryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "registryName", "type": "String"}, + {"name": "entriesCount", "type": "long"}, + {"name": "maintainedBy", "type": "String"}, + {"name": "lastUpdated", "type": "LocalDate"}, + {"name": "accessLevel", "type": "String"} + ] + } + ] + }, + "locations": { + "intermediateClass": "LibraryLocation", + "classes": [ + { + "name": "QuietReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasNaturalLight", "type": "boolean"}, + {"name": "noiseLevelDb", "type": "double"}, + {"name": "availableSeats", "type": "int"}, + {"name": "amenities", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "GroupStudyRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasWhiteboard", "type": "boolean"}, + {"name": "hasProjector", "type": "boolean"}, + {"name": "bookingRequired", "type": "boolean"}, + {"name": "maxBookingHours", "type": "int"}, + {"name": "equipment", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "RareBookVault", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "temperatureCelsius", "type": "double"}, + {"name": "humidityPercent", "type": "double"}, + {"name": "capacity", "type": "int"}, + {"name": "securityLevel", "type": "String"}, + {"name": "accessRequired", "type": "boolean"}, + {"name": "storedItems", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "RARE_BOOKS"}, + {"name": "alarmCode", "type": "String", "ignore": true} + ] + }, + { + "name": "StaffOffice", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "occupantName", "type": "String"}, + {"name": "hasWindow", "type": "boolean"}, + {"name": "deskCount", "type": "int"}, + {"name": "phoneExtension", "type": "String"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "DirectorOffice", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "occupantName", "type": "String"}, + {"name": "hasMeetingArea", "type": "boolean"}, + {"name": "hasPrivateEntrance", "type": "boolean"}, + {"name": "floorNumber", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "CirculationDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "staffOnDuty", "type": "int"}, + {"name": "selfCheckoutAvailable", "type": "boolean"}, + {"name": "queueLength", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Auditorium", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasStage", "type": "boolean"}, + {"name": "hasSoundSystem", "type": "boolean"}, + {"name": "hasLightingSystem", "type": "boolean"}, + {"name": "scheduledEvents", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "IndividualStudyCarrel", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "carrelNumber", "type": "int"}, + {"name": "hasPowerOutlet", "type": "boolean"}, + {"name": "hasEthernet", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "LoungeArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasCoffeeTable", "type": "boolean"}, + {"name": "magazineRackCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "NewspaperReadingArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "newspaperRackCount", "type": "int"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "internationalPapers", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "PeriodicalReadingArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "journalDisplayCount", "type": "int"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "currentSubscriptions", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ReferenceReadingDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "deskCount", "type": "int"}, + {"name": "hasPowerOutlet", "type": "boolean"}, + {"name": "assignedLibrarian", "type": "String"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "MicroformReadingStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "machineCount", "type": "int"}, + {"name": "hasPrinter", "type": "boolean"}, + {"name": "availableMicrofilm", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ComputerWorkstation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasInternetAccess", "type": "boolean"}, + {"name": "hasPrinter", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "LaptopSeatingArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "powerOutletsPerSeat", "type": "int"}, + {"name": "hasWiFi", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "StandingReadingDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "deskCount", "type": "int"}, + {"name": "deskHeightCm", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "WindowSeat", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatCount", "type": "int"}, + {"name": "hasCushion", "type": "boolean"}, + {"name": "naturalLightLevel", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "FireplaceNook", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasFunctionalFireplace", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "GardenReadingPavilion", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasShade", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "RooftopReadingTerrace", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasShadeStructure", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "BasementReadingNook", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasArtificialLight", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "MezzanineReadingLevel", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "floorNumber", "type": "int"}, + {"name": "hasBalconyView", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "GalleryReadingCorridor", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "corridorLengthMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "AtriumReadingSpace", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasSkylight", "type": "boolean"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "CourtyardReadingArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasWaterFeature", "type": "boolean"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ChildrenReadingNook", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasColorfulDecor", "type": "boolean"}, + {"name": "bookDisplayCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "CHILDREN"} + ] + }, + { + "name": "TeenZone", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasGamingConsoles", "type": "boolean"}, + {"name": "hasComputers", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "TEEN"} + ] + }, + { + "name": "LocalHistoryReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "archivalDocuments", "type": "int"}, + {"name": "microfilmAvailable", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "LOCAL_HISTORY"} + ] + }, + { + "name": "YoungAdultArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasComputers", "type": "boolean"}, + {"name": "hasStudyRooms", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "TEEN"} + ] + }, + { + "name": "SeniorReadingArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasComfortableSeating", "type": "boolean"}, + {"name": "hasMagnifiers", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "AccessibilityReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasAdjustableDesks", "type": "boolean"}, + {"name": "hasScreenReaders", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "ACCESSIBLE"} + ] + }, + { + "name": "BrailleReadingStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stationCount", "type": "int"}, + {"name": "hasBraillePrinter", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "ACCESSIBLE"} + ] + }, + { + "name": "AssistiveTechnologyRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "availableTechnologies", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "ACCESSIBLE"} + ] + }, + { + "name": "SensoryFriendlyRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasDimmableLights", "type": "boolean"}, + {"name": "hasSoundProofing", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "ACCESSIBLE"} + ] + }, + { + "name": "MultilingualReadingCorner", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "languagesAvailable", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "OpenStacks", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "subjectAreas", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "ClosedStacks", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "retrievalRequired", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "CompactShelving", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfUnits", "type": "int"}, + {"name": "isMotorized", "type": "boolean"}, + {"name": "totalVolumes", "type": "long"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "HighDensityStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "storageUnits", "type": "int"}, + {"name": "totalCapacity", "type": "long"}, + {"name": "climateControlled", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "OffSiteStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "facilityName", "type": "String"}, + {"name": "totalCapacity", "type": "long"}, + {"name": "distanceKm", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "ColdStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "temperatureCelsius", "type": "double"}, + {"name": "capacity", "type": "int"}, + {"name": "humidityPercent", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "ClimateControlledVault", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "temperatureCelsius", "type": "double"}, + {"name": "humidityPercent", "type": "double"}, + {"name": "capacity", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "ManuscriptVault", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "temperatureCelsius", "type": "double"}, + {"name": "humidityPercent", "type": "double"}, + {"name": "manuscriptCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "RARE_BOOKS"} + ] + }, + { + "name": "MapCabinet", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "drawerCount", "type": "int"}, + {"name": "mapCount", "type": "int"}, + {"name": "largestMapSize", "type": "String"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "PrintStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "drawerCount", "type": "int"}, + {"name": "printCount", "type": "int"}, + {"name": "hasFramingStorage", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "SlideCabinet", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "drawerCount", "type": "int"}, + {"name": "slideCount", "type": "int"}, + {"name": "hasLightTable", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "MicrofilmCabinet", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "drawerCount", "type": "int"}, + {"name": "reelCount", "type": "int"}, + {"name": "hasReaderAvailable", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "NegativeStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "drawerCount", "type": "int"}, + {"name": "negativeCount", "type": "int"}, + {"name": "climateControlled", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "FlatFileStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "drawerCount", "type": "int"}, + {"name": "fileCount", "type": "int"}, + {"name": "largestSize", "type": "String"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "RolledStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "slotCount", "type": "int"}, + {"name": "rolledItemCount", "type": "int"}, + {"name": "hasVerticalRacks", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "OversizedStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "itemCount", "type": "int"}, + {"name": "maxDimensions", "type": "String"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "FolioShelf", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "folioCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "QuartoShelf", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "quartoCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "PamphletBox", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "boxCount", "type": "int"}, + {"name": "pamphletCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "DepartmentOffice", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "departmentName", "type": "String"}, + {"name": "staffCount", "type": "int"}, + {"name": "hasMeetingArea", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "ConferenceRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasProjector", "type": "boolean"}, + {"name": "hasVideoConferencing", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "MeetingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasWhiteboard", "type": "boolean"}, + {"name": "bookingRequired", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "BreakRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasRefrigerator", "type": "boolean"}, + {"name": "hasMicrowave", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "StaffKitchen", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasStove", "type": "boolean"}, + {"name": "hasDishwasher", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "MailRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "mailboxCount", "type": "int"}, + {"name": "hasSortingArea", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "SupplyRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "hasLockedCabinet", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "Workroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasLargeTable", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "AudioRecordingStudio", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasSoundProofing", "type": "boolean"}, + {"name": "equipmentCount", "type": "int"}, + {"name": "hasMixingConsole", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "CatalogingWorkroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasSortingArea", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "AcquisitionsWorkroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasUnpackingArea", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "PreservationLab", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasFumigationChamber", "type": "boolean"}, + {"name": "equipmentCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "ConservationLab", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasDeacidificationEquipment", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "BindingWorkshop", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasBindingPress", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "RepairStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasBookRepairTools", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "DigitizationLab", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "scannerCount", "type": "int"}, + {"name": "hasOversizedScanner", "type": "boolean"}, + {"name": "hasBookScanner", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "ScanningStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "scannerCount", "type": "int"}, + {"name": "hasFeederScanner", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "PhotographyStudio", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasLightingKit", "type": "boolean"}, + {"name": "hasCopyStand", "type": "boolean"}, + {"name": "cameraCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "ReferenceDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "staffOnDuty", "type": "int"}, + {"name": "hasComputer", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "InformationDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "staffOnDuty", "type": "int"}, + {"name": "hasMapDisplay", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ReceptionDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "staffOnDuty", "type": "int"}, + {"name": "hasVisitorLog", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "SelfCheckoutStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stationCount", "type": "int"}, + {"name": "hasRFIDReader", "type": "boolean"}, + {"name": "hasReceiptPrinter", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ReturnDropBox", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "boxCount", "type": "int"}, + {"name": "isAccessible24h", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "BookReturnChute", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "chuteCount", "type": "int"}, + {"name": "hasSortingConveyor", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "HoldsShelf", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "holdsCapacity", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ReservesDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "staffOnDuty", "type": "int"}, + {"name": "reserveItemsCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "InterlibraryLoanDesk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "staffOnDuty", "type": "int"}, + {"name": "pendingRequests", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ComputerLab", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasProjector", "type": "boolean"}, + {"name": "hasPrinter", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "MakerSpace", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "availableEquipment", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "ThreeDPrintingStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "printerCount", "type": "int"}, + {"name": "availableFilaments", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "MediaLab", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "availableSoftware", "type": "List"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "VideoEditingSuite", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasVideoMixingConsole", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "AudioEditingSuite", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasAudioMixingConsole", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "DesignStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "workstationCount", "type": "int"}, + {"name": "hasDrawingTablet", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "VirtualRealityStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stationCount", "type": "int"}, + {"name": "hasVRHeadsets", "type": "boolean"}, + {"name": "availableExperiences", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "GamingStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stationCount", "type": "int"}, + {"name": "hasConsoles", "type": "boolean"}, + {"name": "availableGames", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "ProjectionRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasProjector", "type": "boolean"}, + {"name": "hasFilmReels", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "LectureHall", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasProjector", "type": "boolean"}, + {"name": "hasMicrophone", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "SeminarRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasWhiteboard", "type": "boolean"}, + {"name": "hasProjector", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Classroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasWhiteboard", "type": "boolean"}, + {"name": "hasComputers", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "PanelDiscussionRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasPanelTable", "type": "boolean"}, + {"name": "hasMicrophones", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ExhibitionGallery", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "displayWallLength", "type": "double"}, + {"name": "currentExhibits", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "EXHIBITION"} + ] + }, + { + "name": "DisplayCase", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "caseCount", "type": "int"}, + {"name": "hasLockingGlass", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "EXHIBITION"} + ] + }, + { + "name": "DisplayWall", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "wallLengthMeters", "type": "double"}, + {"name": "hasLighting", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "EXHIBITION"} + ] + }, + { + "name": "Vitrine", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "vitrineCount", "type": "int"}, + {"name": "hasClimateControl", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "EXHIBITION"} + ] + }, + { + "name": "Pedestal", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "pedestalCount", "type": "int"}, + {"name": "hasGlassCover", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "EXHIBITION"} + ] + }, + { + "name": "Easel", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "easelCount", "type": "int"}, + {"name": "maxDisplaySize", "type": "String"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "EXHIBITION"} + ] + }, + { + "name": "BulletinBoard", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "boardCount", "type": "int"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "DigitalDisplay", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "displayCount", "type": "int"}, + {"name": "hasTouchCapability", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "InteractiveKiosk", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "kioskCount", "type": "int"}, + {"name": "hasTouchscreen", "type": "boolean"}, + {"name": "hasPrinter", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "TouchscreenDisplay", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "displayCount", "type": "int"}, + {"name": "screenSizeInches", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "MainEntrance", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasSecurityGates", "type": "boolean"}, + {"name": "hasAutomaticDoors", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "SideEntrance", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasSecurityGates", "type": "boolean"}, + {"name": "isAccessibleAfterHours", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "ServiceEntrance", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasLoadingDock", "type": "boolean"}, + {"name": "hasFreightElevator", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "Lobby", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasInformationDesk", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Foyer", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasCoatCheck", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Atrium", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasSkylight", "type": "boolean"}, + {"name": "hasSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Mezzanine", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "floorNumber", "type": "int"}, + {"name": "hasBalconyRail", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Balcony", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Terrace", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasOutdoorSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Courtyard", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasGarden", "type": "boolean"}, + {"name": "hasSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "MainStaircase", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stepCount", "type": "int"}, + {"name": "hasHandrail", "type": "boolean"}, + {"name": "hasWheelchairLift", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "EmergencyStaircase", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stepCount", "type": "int"}, + {"name": "hasEmergencyLighting", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Elevator", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "capacityPersons", "type": "int"}, + {"name": "floorCount", "type": "int"}, + {"name": "hasBrailleButtons", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "FreightElevator", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "capacityKg", "type": "double"}, + {"name": "floorCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "Escalator", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "floorCount", "type": "int"}, + {"name": "hasEmergencyStop", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Corridor", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "lengthMeters", "type": "double"}, + {"name": "widthMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Hallway", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "lengthMeters", "type": "double"}, + {"name": "hasDisplayCases", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "Aisle", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "lengthMeters", "type": "double"}, + {"name": "widthMeters", "type": "double"}, + {"name": "shelfCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "CrossAisle", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "lengthMeters", "type": "double"}, + {"name": "widthMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "BrowsingAisle", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "lengthMeters", "type": "double"}, + {"name": "hasSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STACKS"} + ] + }, + { + "name": "Restroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stallCount", "type": "int"}, + {"name": "hasChangingTable", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "AccessibleRestroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stallCount", "type": "int"}, + {"name": "hasGrabBars", "type": "boolean"}, + {"name": "hasEmergencyCord", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "ACCESSIBLE"} + ] + }, + { + "name": "FamilyRestroom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "stallCount", "type": "int"}, + {"name": "hasChangingTable", "type": "boolean"}, + {"name": "hasNursingChair", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "NursingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasComfortableSeating", "type": "boolean"}, + {"name": "hasSink", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "FirstAidStation", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasDefibrillator", "type": "boolean"}, + {"name": "hasFirstAidKit", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "LostAndFound", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "itemCount", "type": "int"}, + {"name": "hasLockedStorage", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "LockerRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "lockerCount", "type": "int"}, + {"name": "hasChangingArea", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "CoatCheck", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hookCount", "type": "int"}, + {"name": "hasAttendant", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "BagCheck", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "storageCapacity", "type": "int"}, + {"name": "hasAttendant", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "SecurityCheckpoint", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasMetalDetector", "type": "boolean"}, + {"name": "hasBagScanner", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "LibraryCafe", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasEspressoMachine", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "CoffeeCorner", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasVendingMachine", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "VendingArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "machineCount", "type": "int"}, + {"name": "hasSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "SnackLounge", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasMicrowave", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "WaterFountain", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "fountainCount", "type": "int"}, + {"name": "hasBottleFiller", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "PicnicArea", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasTables", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "GardenPatio", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasShade", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "OutdoorSeating", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasUmbrellas", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "IndoorGarden", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "plantCount", "type": "int"}, + {"name": "hasSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "WinterGarden", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasGlassRoof", "type": "boolean"}, + {"name": "hasSeating", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "BoilerRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasHeatingSystem", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "MechanicalRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasHVACControls", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "ElectricalRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasMainPanel", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "ServerRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "serverRackCount", "type": "int"}, + {"name": "hasCoolingSystem", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "TelecommunicationsRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasNetworkEquipment", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "JanitorialCloset", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "hasSink", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "StorageCloset", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STAFF"} + ] + }, + { + "name": "ArchiveStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "boxCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "FurnitureStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "areaSquareMeters", "type": "double"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "EquipmentStorage", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "shelfCount", "type": "int"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "STORAGE"} + ] + }, + { + "name": "RareBookReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasSurveillanceCameras", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "RARE_BOOKS"} + ] + }, + { + "name": "ManuscriptReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasBookCradles", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "RARE_BOOKS"} + ] + }, + { + "name": "ArchivesReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasFindingAids", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "ARCHIVES"} + ] + }, + { + "name": "MapReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasLargeTables", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "MusicReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasListeningStations", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "FilmViewingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasProjector", "type": "boolean"}, + {"name": "hasScreen", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "AudioListeningRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasHeadphoneJacks", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "MEDIA"} + ] + }, + { + "name": "MicroformReadingRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "machineCount", "type": "int"}, + {"name": "hasPrinter", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "GENERAL"} + ] + }, + { + "name": "GenealogyRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasMicrofilmReaders", "type": "boolean"}, + {"name": "hasComputerAccess", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "LOCAL_HISTORY"} + ] + }, + { + "name": "LocalHistoryRoom", + "kind": "class", + "extends": "LibraryLocation", + "properties": [ + {"name": "seatingCapacity", "type": "int"}, + {"name": "hasArchivalMaterials", "type": "boolean"}, + {"name": "hasDisplayArea", "type": "boolean"}, + {"name": "assignedLibrary", "type": "PublicLibrary"}, + {"name": "zone", "type": "LocationZone", "default": "LOCAL_HISTORY"} + ] + }, + { + "name": "RoomRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "roomNumber", "type": "String"}, + {"name": "roomName", "type": "String"}, + {"name": "capacity", "type": "int"}, + {"name": "floor", "type": "int"}, + {"name": "accessible", "type": "boolean", "default": "true"} + ] + }, + { + "name": "ChamberRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "chamberId", "type": "UUID"}, + {"name": "designation", "type": "String"}, + {"name": "volume", "type": "double"}, + {"name": "temperature", "type": "double"}, + {"name": "secured", "type": "boolean"} + ] + }, + { + "name": "HallRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "hallName", "type": "String"}, + {"name": "building", "type": "String"}, + {"name": "capacity", "type": "int"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "CorridorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "corridorName", "type": "String"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "widthMeters", "type": "double"}, + {"name": "floorLevel", "type": "int"}, + {"name": "hasHandrail", "type": "boolean", "default": "true"} + ] + }, + { + "name": "PassageRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "passageName", "type": "String"}, + {"name": "connectsFrom", "type": "String"}, + {"name": "connectsTo", "type": "String"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "accessLevel", "type": "String"} + ] + }, + { + "name": "GalleryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "galleryName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "hasLighting", "type": "boolean", "default": "true"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "BalconyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "balconyName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "floorLevel", "type": "int"}, + {"name": "hasRail", "type": "boolean", "default": "true"} + ] + }, + { + "name": "TerraceRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "terraceName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasSeating", "type": "boolean", "default": "true"}, + {"name": "hasShade", "type": "boolean"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "PatioRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "patioName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasGarden", "type": "boolean"}, + {"name": "hasSeating", "type": "boolean", "default": "true"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "VerandaRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "verandaName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasRoof", "type": "boolean", "default": "true"}, + {"name": "hasSeating", "type": "boolean", "default": "true"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "PorchRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "porchName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasRoof", "type": "boolean", "default": "true"}, + {"name": "hasScreens", "type": "boolean"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "DeckRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "deckName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "hasRail", "type": "boolean", "default": "true"}, + {"name": "floorLevel", "type": "int"} + ] + }, + { + "name": "PlatformRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "platformName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasRamp", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "StageRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "stageName", "type": "String"}, + {"name": "areaSquareMeters", "type": "double"}, + {"name": "hasCurtains", "type": "boolean"}, + {"name": "hasLighting", "type": "boolean"}, + {"name": "capacity", "type": "int"} + ] + }, + { + "name": "PodiumRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "podiumName", "type": "String"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasMicrophone", "type": "boolean"}, + {"name": "hasLectern", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "DeskRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "deskName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "depthCm", "type": "double"}, + {"name": "hasDrawers", "type": "boolean", "default": "true"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "TableRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "tableName", "type": "String"}, + {"name": "seatingCapacity", "type": "int"}, + {"name": "widthCm", "type": "double"}, + {"name": "depthCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "CounterRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "counterName", "type": "String"}, + {"name": "lengthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasDisplayCase", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "ShelfRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "shelfName", "type": "String"}, + {"name": "shelfCount", "type": "int"}, + {"name": "capacityPerShelf", "type": "int"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "RackRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "rackName", "type": "String"}, + {"name": "shelfLevels", "type": "int"}, + {"name": "capacityPerLevel", "type": "int"}, + {"name": "hasWheels", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "CabinetRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "cabinetName", "type": "String"}, + {"name": "drawerCount", "type": "int"}, + {"name": "hasLock", "type": "boolean"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "DrawerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "drawerName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "depthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasLock", "type": "boolean"} + ] + }, + { + "name": "BinRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "binName", "type": "String"}, + {"name": "capacityLiters", "type": "double"}, + {"name": "hasLid", "type": "boolean", "default": "true"}, + {"name": "material", "type": "String"}, + {"name": "color", "type": "String"} + ] + }, + { + "name": "BoxRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "boxName", "type": "String"}, + {"name": "lengthCm", "type": "double"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "CrateRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "crateName", "type": "String"}, + {"name": "lengthCm", "type": "double"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "CaseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "caseName", "type": "String"}, + {"name": "hasGlassFront", "type": "boolean"}, + {"name": "hasLock", "type": "boolean"}, + {"name": "itemCount", "type": "int"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "FrameRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "frameName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "hasGlass", "type": "boolean", "default": "true"} + ] + }, + { + "name": "MountRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "mountName", "type": "String"}, + {"name": "mountType", "type": "String"}, + {"name": "weightCapacityKg", "type": "double"}, + {"name": "hasSwivel", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "StandRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "standName", "type": "String"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasAdjustableHeight", "type": "boolean"}, + {"name": "baseDiameterCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "BaseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "baseName", "type": "String"}, + {"name": "diameterCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "weightKg", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "PedestalRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "pedestalName", "type": "String"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasGlassCover", "type": "boolean"}, + {"name": "hasLighting", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "PlinthRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "plinthName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "depthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "PanelRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "panelName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "thicknessCm", "type": "double"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "SignageRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "signageName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasCorkSurface", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "ScreenRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "screenName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "isFolding", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "PartitionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "partitionName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "isMovable", "type": "boolean", "default": "true"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "DividerRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "dividerName", "type": "String"}, + {"name": "lengthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "isAdjustable", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "BarrierRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "barrierName", "type": "String"}, + {"name": "lengthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "isRemovable", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "GateRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "gateName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasLock", "type": "boolean", "default": "true"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "DoorRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "doorName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasAutoClose", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "WindowRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "windowName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "canOpen", "type": "boolean", "default": "true"}, + {"name": "hasBlinds", "type": "boolean"} + ] + }, + { + "name": "SkylightRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "skylightName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "lengthCm", "type": "double"}, + {"name": "hasBlinds", "type": "boolean"}, + {"name": "isOperable", "type": "boolean", "default": "true"} + ] + }, + { + "name": "VentRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "ventName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasAdjustableLouvers", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "DuctRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "ductName", "type": "String"}, + {"name": "diameterCm", "type": "double"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "hasInsulation", "type": "boolean"} + ] + }, + { + "name": "PipeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "pipeName", "type": "String"}, + {"name": "diameterCm", "type": "double"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "hasInsulation", "type": "boolean"} + ] + }, + { + "name": "WireRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "wireName", "type": "String"}, + {"name": "gauge", "type": "String"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "ratedVoltage", "type": "int"} + ] + }, + { + "name": "ConduitRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "conduitName", "type": "String"}, + {"name": "conductorCount", "type": "int"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "ratedVoltage", "type": "int"}, + {"name": "hasShielding", "type": "boolean"} + ] + }, + { + "name": "SocketRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "socketName", "type": "String"}, + {"name": "socketType", "type": "String"}, + {"name": "ratedVoltage", "type": "int"}, + {"name": "hasCover", "type": "boolean", "default": "true"}, + {"name": "isGrounded", "type": "boolean", "default": "true"} + ] + }, + { + "name": "SwitchRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "switchName", "type": "String"}, + {"name": "switchType", "type": "String"}, + {"name": "ratedAmperage", "type": "int"}, + {"name": "isDimmable", "type": "boolean"}, + {"name": "hasIndicator", "type": "boolean"} + ] + }, + { + "name": "LampRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "lampName", "type": "String"}, + {"name": "wattage", "type": "int"}, + {"name": "bulbType", "type": "String"}, + {"name": "hasDimmer", "type": "boolean"}, + {"name": "color", "type": "String"} + ] + }, + { + "name": "FixtureRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "fixtureName", "type": "String"}, + {"name": "fixtureType", "type": "String"}, + {"name": "mountType", "type": "String"}, + {"name": "hasBulb", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "FittingRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "fittingName", "type": "String"}, + {"name": "fittingType", "type": "String"}, + {"name": "diameterCm", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "hasGasket", "type": "boolean"} + ] + }, + { + "name": "HandleRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "handleName", "type": "String"}, + {"name": "handleType", "type": "String"}, + {"name": "lengthCm", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "hasLock", "type": "boolean"} + ] + }, + { + "name": "LockRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "lockName", "type": "String"}, + {"name": "lockType", "type": "String"}, + {"name": "hasKey", "type": "boolean", "default": "true"}, + {"name": "isElectronic", "type": "boolean"}, + {"name": "material", "type": "String"} + ] + }, + { + "name": "HingeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "hingeName", "type": "String"}, + {"name": "hingeType", "type": "String"}, + {"name": "hasSelfClosing", "type": "boolean"}, + {"name": "material", "type": "String"}, + {"name": "finishColor", "type": "String"} + ] + }, + { + "name": "SealRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sealName", "type": "String"}, + {"name": "sealType", "type": "String"}, + {"name": "lengthMeters", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "isWeatherproof", "type": "boolean", "default": "true"} + ] + }, + { + "name": "GasketRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "gasketName", "type": "String"}, + {"name": "gasketType", "type": "String"}, + {"name": "thicknessMm", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "isHeatResistant", "type": "boolean"} + ] + }, + { + "name": "InsulationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "insulationName", "type": "String"}, + {"name": "insulationType", "type": "String"}, + {"name": "thicknessCm", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "rValue", "type": "double"} + ] + }, + { + "name": "TileRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "tileName", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "material", "type": "String"}, + {"name": "finishType", "type": "String"} + ] + }, + { + "name": "AcousticPanelRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "panelName", "type": "String"}, + {"name": "panelType", "type": "String"}, + {"name": "widthCm", "type": "double"}, + {"name": "heightCm", "type": "double"}, + {"name": "hasAcousticProperties", "type": "boolean"} + ] + } + ] + }, + "events": { + "intermediateClass": "LibraryEvent", + "classes": [ + { + "name": "BookCheckout", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "loanId", "type": "UUID"}, + {"name": "borrowerName", "type": "String"}, + {"name": "dueDate", "type": "LocalDate"}, + {"name": "renewalCount", "type": "int"}, + {"name": "lateFee", "type": "BigDecimal"}, + {"name": "overdue", "type": "boolean"}, + {"name": "itemIsbns", "type": "List"}, + {"name": "borrower", "type": "AdultMember"}, + {"name": "loanedItem", "type": "HardcoverBook"}, + {"name": "status", "type": "LoanStatus", "default": "ACTIVE"}, + {"name": "internalNotes", "type": "String", "ignore": true} + ] + }, + { + "name": "BookReturn", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "loanId", "type": "UUID"}, + {"name": "returnDate", "type": "LocalDate"}, + {"name": "daysLate", "type": "int"}, + {"name": "lateFeePaid", "type": "BigDecimal"}, + {"name": "itemCondition", "type": "ItemCondition"}, + {"name": "returnedBy", "type": "AdultMember"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "status", "type": "LoanStatus", "default": "RETURNED"} + ] + }, + { + "name": "BookRenewal", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "loanId", "type": "UUID"}, + {"name": "renewalDate", "type": "LocalDate"}, + {"name": "newDueDate", "type": "LocalDate"}, + {"name": "renewalCount", "type": "int"}, + {"name": "maxRenewals", "type": "int"}, + {"name": "renewedBy", "type": "AdultMember"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "status", "type": "LoanStatus", "default": "ACTIVE"} + ] + }, + { + "name": "AuthorReading", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "authorName", "type": "String"}, + {"name": "bookTitle", "type": "String"}, + {"name": "seatsReserved", "type": "int"}, + {"name": "seatsAvailable", "type": "int"}, + {"name": "registrationRequired", "type": "boolean"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "featuredAuthor", "type": "Author"}, + {"name": "eventType", "type": "EventType", "default": "READING"} + ] + }, + { + "name": "BookClubMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "clubName", "type": "String"}, + {"name": "bookDiscussed", "type": "String"}, + {"name": "attendees", "type": "List"}, + {"name": "discussionTopics", "type": "Set"}, + {"name": "venue", "type": "GroupStudyRoom"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ArtExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionTitle", "type": "String"}, + {"name": "artistName", "type": "String"}, + {"name": "artworkCount", "type": "int"}, + {"name": "exhibitedWorks", "type": "List"}, + {"name": "sponsors", "type": "Set"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "hostMuseum", "type": "ArtMuseum"}, + {"name": "curator", "type": "Curator"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "WritingWorkshop", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "workshopTitle", "type": "String"}, + {"name": "instructor", "type": "Author"}, + {"name": "maxParticipants", "type": "int"}, + {"name": "registeredParticipants", "type": "int"}, + {"name": "materials", "type": "List"}, + {"name": "venue", "type": "GroupStudyRoom"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "OverdueNotice", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "loanId", "type": "UUID"}, + {"name": "borrowerName", "type": "String"}, + {"name": "itemTitle", "type": "String"}, + {"name": "dueDate", "type": "LocalDate"}, + {"name": "daysOverdue", "type": "int"}, + {"name": "fineAmount", "type": "BigDecimal"}, + {"name": "noticeCount", "type": "int"}, + {"name": "borrower", "type": "AdultMember"}, + {"name": "loanedItem", "type": "HardcoverBook"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "FinePayment", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "paymentId", "type": "UUID"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "paymentDate", "type": "LocalDate"}, + {"name": "paymentMethod", "type": "String"}, + {"name": "receiptNumber", "type": "String"}, + {"name": "payer", "type": "AdultMember"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "LostItemClaim", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "claimId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "replacementCost", "type": "BigDecimal"}, + {"name": "claimDate", "type": "LocalDate"}, + {"name": "resolved", "type": "boolean"}, + {"name": "claimant", "type": "AdultMember"}, + {"name": "lostItem", "type": "HardcoverBook"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "DamagedItemReport", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "reportId", "type": "UUID"}, + {"name": "damageDescription", "type": "String"}, + {"name": "severityLevel", "type": "String"}, + {"name": "reportDate", "type": "LocalDate"}, + {"name": "repairEstimate", "type": "BigDecimal"}, + {"name": "reportedBy", "type": "Librarian"}, + {"name": "damagedItem", "type": "HardcoverBook"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "ReplacementOrder", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "orderId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "supplier", "type": "String"}, + {"name": "orderDate", "type": "LocalDate"}, + {"name": "cost", "type": "BigDecimal"}, + {"name": "quantity", "type": "int"}, + {"name": "approvedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "WaiverRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "reason", "type": "String"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "approved", "type": "boolean"}, + {"name": "requester", "type": "AdultMember"}, + {"name": "reviewedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "BillingNotice", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "noticeId", "type": "UUID"}, + {"name": "amountDue", "type": "BigDecimal"}, + {"name": "billingDate", "type": "LocalDate"}, + {"name": "dueDate", "type": "LocalDate"}, + {"name": "description", "type": "String"}, + {"name": "recipient", "type": "AdultMember"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "InterlibraryLoanRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "requestedTitle", "type": "String"}, + {"name": "requestingLibrary", "type": "String"}, + {"name": "lendingLibrary", "type": "String"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "neededByDate", "type": "LocalDate"}, + {"name": "requester", "type": "AdultMember"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "InterlibraryLoanReceipt", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "receiptId", "type": "UUID"}, + {"name": "receivedTitle", "type": "String"}, + {"name": "sourceLibrary", "type": "String"}, + {"name": "receiptDate", "type": "LocalDate"}, + {"name": "returnDate", "type": "LocalDate"}, + {"name": "conditionOnArrival", "type": "String"}, + {"name": "recipient", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "InterlibraryLoanReturn", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "returnId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "destinationLibrary", "type": "String"}, + {"name": "returnDate", "type": "LocalDate"}, + {"name": "shippingMethod", "type": "String"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "InterlibraryLoanShipping", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "shippingId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "carrier", "type": "String"}, + {"name": "trackingNumber", "type": "String"}, + {"name": "shipDate", "type": "LocalDate"}, + {"name": "estimatedDelivery", "type": "LocalDate"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "InterlibraryLoanInvoice", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "invoiceId", "type": "UUID"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "invoiceDate", "type": "LocalDate"}, + {"name": "billingPeriod", "type": "String"}, + {"name": "lendingLibrary", "type": "String"}, + {"name": "paid", "type": "boolean"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "DocumentDeliveryRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "documentTitle", "type": "String"}, + {"name": "deliveryFormat", "type": "String"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "deliveryDeadline", "type": "LocalDate"}, + {"name": "requester", "type": "AdultMember"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "DocumentDeliveryReceipt", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "receiptId", "type": "UUID"}, + {"name": "documentTitle", "type": "String"}, + {"name": "deliveryMethod", "type": "String"}, + {"name": "deliveryDate", "type": "LocalDate"}, + {"name": "deliveredTo", "type": "AdultMember"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "ScanRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "documentTitle", "type": "String"}, + {"name": "pageRange", "type": "String"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "resolution", "type": "String"}, + {"name": "requester", "type": "AdultMember"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "DigitizationRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "format", "type": "String"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "priority", "type": "String"}, + {"name": "requestedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "ReproductionRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "reproductionType", "type": "String"}, + {"name": "quantity", "type": "int"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "requester", "type": "AdultMember"}, + {"name": "eventType", "type": "EventType", "default": "LOAN"} + ] + }, + { + "name": "PurchaseOrder", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "orderId", "type": "UUID"}, + {"name": "supplier", "type": "String"}, + {"name": "totalAmount", "type": "BigDecimal"}, + {"name": "orderDate", "type": "LocalDate"}, + {"name": "itemCount", "type": "int"}, + {"name": "approvedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "GiftAcceptance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "acceptanceId", "type": "UUID"}, + {"name": "donorName", "type": "String"}, + {"name": "itemCount", "type": "int"}, + {"name": "acceptanceDate", "type": "LocalDate"}, + {"name": "estimatedValue", "type": "BigDecimal"}, + {"name": "acceptedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "DonationReceipt", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "receiptId", "type": "UUID"}, + {"name": "donorName", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "receiptDate", "type": "LocalDate"}, + {"name": "purpose", "type": "String"}, + {"name": "issuedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "ExchangeAgreement", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "agreementId", "type": "UUID"}, + {"name": "partnerLibrary", "type": "String"}, + {"name": "itemsSent", "type": "int"}, + {"name": "itemsReceived", "type": "int"}, + {"name": "agreementDate", "type": "LocalDate"}, + {"name": "expiryDate", "type": "LocalDate"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "TransferRecord", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "transferId", "type": "UUID"}, + {"name": "fromBranch", "type": "String"}, + {"name": "toBranch", "type": "String"}, + {"name": "transferDate", "type": "LocalDate"}, + {"name": "itemCount", "type": "int"}, + {"name": "authorizedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "DepositAgreement", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "agreementId", "type": "UUID"}, + {"name": "depositorName", "type": "String"}, + {"name": "depositDate", "type": "LocalDate"}, + {"name": "itemCount", "type": "int"}, + {"name": "terms", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "AcquisitionProposal", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "proposalId", "type": "UUID"}, + {"name": "proposedTitle", "type": "String"}, + {"name": "proposedBy", "type": "String"}, + {"name": "proposalDate", "type": "LocalDate"}, + {"name": "estimatedCost", "type": "BigDecimal"}, + {"name": "justification", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "CollectionEvaluation", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "evaluationId", "type": "UUID"}, + {"name": "sectionName", "type": "String"}, + {"name": "evaluationDate", "type": "LocalDate"}, + {"name": "itemsReviewed", "type": "int"}, + {"name": "itemsRecommendedForRemoval", "type": "int"}, + {"name": "evaluatedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "WeedingNotice", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "noticeId", "type": "UUID"}, + {"name": "sectionName", "type": "String"}, + {"name": "itemsMarkedForRemoval", "type": "int"}, + {"name": "noticeDate", "type": "LocalDate"}, + {"name": "reason", "type": "String"}, + {"name": "issuedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "WithdrawalRecord", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "withdrawalId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "withdrawalDate", "type": "LocalDate"}, + {"name": "reason", "type": "String"}, + {"name": "disposalMethod", "type": "String"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "OriginalCataloging", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "catalogingId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "cataloger", "type": "String"}, + {"name": "catalogingDate", "type": "LocalDate"}, + {"name": "classificationNumber", "type": "String"}, + {"name": "subjectHeadings", "type": "List"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "CopyCataloging", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "catalogingId", "type": "UUID"}, + {"name": "sourceRecord", "type": "String"}, + {"name": "copiedItem", "type": "String"}, + {"name": "copyDate", "type": "LocalDate"}, + {"name": "modifiedFields", "type": "List"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "Recataloging", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "recatalogingId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "reason", "type": "String"}, + {"name": "recatalogingDate", "type": "LocalDate"}, + {"name": "previousClassification", "type": "String"}, + {"name": "newClassification", "type": "String"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "AuthorityRecord", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "authorityId", "type": "UUID"}, + {"name": "authorityType", "type": "String"}, + {"name": "heading", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "sourceFile", "type": "String"}, + {"name": "createdBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "ClassificationAssignment", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "assignmentId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "classificationScheme", "type": "String"}, + {"name": "assignedNumber", "type": "String"}, + {"name": "assignmentDate", "type": "LocalDate"}, + {"name": "assignedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "SubjectHeadingAssignment", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "assignmentId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "subjectHeadings", "type": "List"}, + {"name": "vocabularySource", "type": "String"}, + {"name": "assignmentDate", "type": "LocalDate"}, + {"name": "assignedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "MetadataCreation", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "metadataId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "metadataFormat", "type": "String"}, + {"name": "creationDate", "type": "LocalDate"}, + {"name": "metadataFields", "type": "Map"}, + {"name": "createdBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "MetadataModification", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "modificationId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "modifiedFields", "type": "List"}, + {"name": "modificationDate", "type": "LocalDate"}, + {"name": "reason", "type": "String"}, + {"name": "modifiedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "RecordMerge", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "mergeId", "type": "UUID"}, + {"name": "sourceRecordIds", "type": "List"}, + {"name": "targetRecordId", "type": "UUID"}, + {"name": "mergeDate", "type": "LocalDate"}, + {"name": "mergedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "RecordSplit", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "splitId", "type": "UUID"}, + {"name": "sourceRecordId", "type": "UUID"}, + {"name": "newRecordIds", "type": "List"}, + {"name": "splitDate", "type": "LocalDate"}, + {"name": "splitReason", "type": "String"}, + {"name": "splitBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "ACQUISITION"} + ] + }, + { + "name": "ConservationTreatment", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "treatmentId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "treatmentType", "type": "String"}, + {"name": "treatmentDate", "type": "LocalDate"}, + {"name": "cost", "type": "BigDecimal"}, + {"name": "conservator", "type": "String"}, + {"name": "treatedItem", "type": "HardcoverBook"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BindingOrder", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "orderId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "bindingType", "type": "String"}, + {"name": "orderDate", "type": "LocalDate"}, + {"name": "cost", "type": "BigDecimal"}, + {"name": "vendor", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "RepairRequest", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "requestId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "damageType", "type": "String"}, + {"name": "requestDate", "type": "LocalDate"}, + {"name": "estimatedCost", "type": "BigDecimal"}, + {"name": "requestedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "DeacidificationTreatment", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "treatmentId", "type": "UUID"}, + {"name": "itemCount", "type": "int"}, + {"name": "treatmentDate", "type": "LocalDate"}, + {"name": "method", "type": "String"}, + {"name": "batchNumber", "type": "String"}, + {"name": "processedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "EncapsulationOrder", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "orderId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "material", "type": "String"}, + {"name": "orderDate", "type": "LocalDate"}, + {"name": "cost", "type": "BigDecimal"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BoxMakingOrder", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "orderId", "type": "UUID"}, + {"name": "itemTitle", "type": "String"}, + {"name": "boxDimensions", "type": "String"}, + {"name": "orderDate", "type": "LocalDate"}, + {"name": "material", "type": "String"}, + {"name": "cost", "type": "BigDecimal"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "ClimateMonitoring", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "monitoringId", "type": "UUID"}, + {"name": "location", "type": "String"}, + {"name": "temperature", "type": "double"}, + {"name": "humidity", "type": "double"}, + {"name": "readingDate", "type": "LocalDate"}, + {"name": "monitoredBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "PestInspection", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "inspectionId", "type": "UUID"}, + {"name": "areaInspected", "type": "String"}, + {"name": "inspectionDate", "type": "LocalDate"}, + {"name": "pestsFound", "type": "boolean"}, + {"name": "treatmentRequired", "type": "boolean"}, + {"name": "inspectedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "MoldRemediation", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "remediationId", "type": "UUID"}, + {"name": "affectedArea", "type": "String"}, + {"name": "remediationDate", "type": "LocalDate"}, + {"name": "method", "type": "String"}, + {"name": "itemsAffected", "type": "int"}, + {"name": "remediatedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "DisasterResponse", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "responseId", "type": "UUID"}, + {"name": "disasterType", "type": "String"}, + {"name": "responseDate", "type": "LocalDate"}, + {"name": "itemsDamaged", "type": "int"}, + {"name": "itemsLost", "type": "int"}, + {"name": "estimatedLoss", "type": "BigDecimal"}, + {"name": "responseTeam", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "AuthorTalk", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "talkId", "type": "UUID"}, + {"name": "talkTitle", "type": "String"}, + {"name": "featuredAuthor", "type": "Author"}, + {"name": "talkDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BookSigning", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "signingId", "type": "UUID"}, + {"name": "bookTitle", "type": "String"}, + {"name": "featuredAuthor", "type": "Author"}, + {"name": "signingDate", "type": "LocalDate"}, + {"name": "booksAvailable", "type": "int"}, + {"name": "booksSigned", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "PoetryReading", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "readingId", "type": "UUID"}, + {"name": "poetName", "type": "String"}, + {"name": "readingDate", "type": "LocalDate"}, + {"name": "poemsRead", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "hostLibrary", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "StoryTimeSession", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "sessionTitle", "type": "String"}, + {"name": "storyteller", "type": "Librarian"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "childCount", "type": "int"}, + {"name": "ageRange", "type": "String"}, + {"name": "venue", "type": "QuietReadingRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ToddlerStoryTime", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "storyteller", "type": "Librarian"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "toddlerCount", "type": "int"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "venue", "type": "QuietReadingRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BabyStoryTime", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "storyteller", "type": "Librarian"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "babyCount", "type": "int"}, + {"name": "parentCount", "type": "int"}, + {"name": "venue", "type": "QuietReadingRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "FamilyStoryTime", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "storyteller", "type": "Librarian"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "familyCount", "type": "int"}, + {"name": "totalAttendees", "type": "int"}, + {"name": "venue", "type": "QuietReadingRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "InformationLiteracyClass", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "classId", "type": "UUID"}, + {"name": "classTitle", "type": "String"}, + {"name": "instructor", "type": "Librarian"}, + {"name": "classDate", "type": "LocalDate"}, + {"name": "enrolledCount", "type": "int"}, + {"name": "skillLevel", "type": "String"}, + {"name": "venue", "type": "GroupStudyRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ResearchSkillsWorkshop", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "workshopId", "type": "UUID"}, + {"name": "workshopTitle", "type": "String"}, + {"name": "instructor", "type": "Librarian"}, + {"name": "workshopDate", "type": "LocalDate"}, + {"name": "maxParticipants", "type": "int"}, + {"name": "researchArea", "type": "String"}, + {"name": "venue", "type": "GroupStudyRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "CitationWorkshop", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "workshopId", "type": "UUID"}, + {"name": "citationStyle", "type": "String"}, + {"name": "instructor", "type": "Librarian"}, + {"name": "workshopDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "GroupStudyRoom"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "DatabaseTraining", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "trainingId", "type": "UUID"}, + {"name": "databaseName", "type": "String"}, + {"name": "trainer", "type": "Librarian"}, + {"name": "trainingDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "durationHours", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "InternetSafetyClass", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "classId", "type": "UUID"}, + {"name": "instructor", "type": "Librarian"}, + {"name": "classDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "targetAudience", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "GenealogyWorkshop", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "workshopId", "type": "UUID"}, + {"name": "instructor", "type": "Librarian"}, + {"name": "workshopDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "resourcesUsed", "type": "List"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "LocalHistoryLecture", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "lectureId", "type": "UUID"}, + {"name": "lecturer", "type": "String"}, + {"name": "lectureDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "topic", "type": "String"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "DigitalLiteracyClass", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "classId", "type": "UUID"}, + {"name": "instructor", "type": "Librarian"}, + {"name": "classDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "skillLevel", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ConversationGroup", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "groupId", "type": "UUID"}, + {"name": "language", "type": "String"}, + {"name": "facilitator", "type": "Librarian"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "proficiencyLevel", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "LanguageClass", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "classId", "type": "UUID"}, + {"name": "language", "type": "String"}, + {"name": "instructor", "type": "String"}, + {"name": "classDate", "type": "LocalDate"}, + {"name": "enrolledCount", "type": "int"}, + {"name": "level", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "PhotographyExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "photographer", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "photographCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "HistoryExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "artifactCount", "type": "int"}, + {"name": "curator", "type": "Curator"}, + {"name": "venue", "type": "ArtMuseum"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "ScienceExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "exhibitCount", "type": "int"}, + {"name": "targetAgeGroup", "type": "String"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BookArtsExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "exhibitedWorks", "type": "List"}, + {"name": "curator", "type": "Curator"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "PosterExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "posterCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "TravelExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "destination", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "photographCount", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "CommunityArtShow", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "showId", "type": "UUID"}, + {"name": "showTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "artistCount", "type": "int"}, + {"name": "artworkCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "StudentArtShow", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "showId", "type": "UUID"}, + {"name": "showTitle", "type": "String"}, + {"name": "schoolName", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "artworkCount", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "PermanentExhibition", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionTitle", "type": "String"}, + {"name": "installationDate", "type": "LocalDate"}, + {"name": "itemCount", "type": "int"}, + {"name": "curator", "type": "Curator"}, + {"name": "venue", "type": "ArtMuseum"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "ConcertPerformance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "performanceId", "type": "UUID"}, + {"name": "performerName", "type": "String"}, + {"name": "performanceDate", "type": "LocalDate"}, + {"name": "ticketCount", "type": "int"}, + {"name": "genre", "type": "String"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "RecitalPerformance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "performanceId", "type": "UUID"}, + {"name": "performerName", "type": "String"}, + {"name": "performanceDate", "type": "LocalDate"}, + {"name": "instrumentCount", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "ChamberMusicConcert", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "concertId", "type": "UUID"}, + {"name": "ensembleName", "type": "String"}, + {"name": "concertDate", "type": "LocalDate"}, + {"name": "performerCount", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "JazzPerformance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "performanceId", "type": "UUID"}, + {"name": "performerName", "type": "String"}, + {"name": "performanceDate", "type": "LocalDate"}, + {"name": "bandSize", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "FolkMusicPerformance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "performanceId", "type": "UUID"}, + {"name": "performerName", "type": "String"}, + {"name": "performanceDate", "type": "LocalDate"}, + {"name": "tradition", "type": "String"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "PoetrySlam", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "slamId", "type": "UUID"}, + {"name": "slamTitle", "type": "String"}, + {"name": "slamDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "audienceCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "TheaterPerformance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "performanceId", "type": "UUID"}, + {"name": "playTitle", "type": "String"}, + {"name": "performanceDate", "type": "LocalDate"}, + {"name": "castSize", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "PuppetShow", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "showId", "type": "UUID"}, + {"name": "showTitle", "type": "String"}, + {"name": "showDate", "type": "LocalDate"}, + {"name": "puppeteerCount", "type": "int"}, + {"name": "childCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "FilmScreening", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "screeningId", "type": "UUID"}, + {"name": "filmTitle", "type": "String"}, + {"name": "screeningDate", "type": "LocalDate"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "Auditorium"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "DocumentaryScreening", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "screeningId", "type": "UUID"}, + {"name": "documentaryTitle", "type": "String"}, + {"name": "screeningDate", "type": "LocalDate"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "discussionLeader", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BookLaunch", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "launchId", "type": "UUID"}, + {"name": "bookTitle", "type": "String"}, + {"name": "featuredAuthor", "type": "Author"}, + {"name": "launchDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BookSale", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "saleId", "type": "UUID"}, + {"name": "saleTitle", "type": "String"}, + {"name": "saleDate", "type": "LocalDate"}, + {"name": "bookCount", "type": "int"}, + {"name": "totalRevenue", "type": "BigDecimal"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BookSwap", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "swapId", "type": "UUID"}, + {"name": "swapDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "booksSwapped", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "BlindDateWithBook", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "eventId", "type": "UUID"}, + {"name": "eventDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "booksWrapped", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "SummerReadingProgram", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "programId", "type": "UUID"}, + {"name": "programTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "enrolledCount", "type": "int"}, + {"name": "booksRead", "type": "int"}, + {"name": "coordinator", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "WinterReadingChallenge", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "challengeId", "type": "UUID"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "targetBooks", "type": "int"}, + {"name": "coordinator", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ReadingMarathon", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "marathonId", "type": "UUID"}, + {"name": "marathonDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "totalPagesRead", "type": "int"}, + {"name": "durationHours", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "LibraryCardSignUp", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "eventId", "type": "UUID"}, + {"name": "eventDate", "type": "LocalDate"}, + {"name": "newCardsIssued", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "coordinator", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "OpenHouse", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "eventId", "type": "UUID"}, + {"name": "eventDate", "type": "LocalDate"}, + {"name": "visitorCount", "type": "int"}, + {"name": "toursConducted", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "coordinator", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "AnniversaryCelebration", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "celebrationId", "type": "UUID"}, + {"name": "anniversaryYear", "type": "int"}, + {"name": "celebrationDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "coordinator", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "SchoolVisit", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "visitId", "type": "UUID"}, + {"name": "schoolName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "studentCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ClassroomVisit", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "visitId", "type": "UUID"}, + {"name": "schoolName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "studentCount", "type": "int"}, + {"name": "presenter", "type": "Librarian"}, + {"name": "topic", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "SeniorCenterVisit", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "visitId", "type": "UUID"}, + {"name": "centerName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "presenter", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "HospitalVisit", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "visitId", "type": "UUID"}, + {"name": "hospitalName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "patientCount", "type": "int"}, + {"name": "presenter", "type": "Librarian"}, + {"name": "booksDelivered", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "RemoteLibraryVisit", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "visitId", "type": "UUID"}, + {"name": "locationName", "type": "String"}, + {"name": "visitDate", "type": "LocalDate"}, + {"name": "visitorCount", "type": "int"}, + {"name": "servicesProvided", "type": "List"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BookmobileStop", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "stopId", "type": "UUID"}, + {"name": "locationName", "type": "String"}, + {"name": "stopDate", "type": "LocalDate"}, + {"name": "visitorsCount", "type": "int"}, + {"name": "itemsCheckedOut", "type": "int"}, + {"name": "driver", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "CommunityFairBooth", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "boothId", "type": "UUID"}, + {"name": "fairName", "type": "String"}, + {"name": "fairDate", "type": "LocalDate"}, + {"name": "visitorsCount", "type": "int"}, + {"name": "newSignups", "type": "int"}, + {"name": "staffedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "FarmersMarketTable", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tableId", "type": "UUID"}, + {"name": "marketName", "type": "String"}, + {"name": "marketDate", "type": "LocalDate"}, + {"name": "visitorsCount", "type": "int"}, + {"name": "brochuresDistributed", "type": "int"}, + {"name": "staffedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "StreetFestivalBooth", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "boothId", "type": "UUID"}, + {"name": "festivalName", "type": "String"}, + {"name": "festivalDate", "type": "LocalDate"}, + {"name": "visitorsCount", "type": "int"}, + {"name": "activitiesOffered", "type": "List"}, + {"name": "staffedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "NeighborhoodOutreach", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "outreachId", "type": "UUID"}, + {"name": "neighborhoodName", "type": "String"}, + {"name": "outreachDate", "type": "LocalDate"}, + {"name": "householdsVisited", "type": "int"}, + {"name": "newMembers", "type": "int"}, + {"name": "conductedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BuildingTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "SpecialCollectionsTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Curator"}, + {"name": "itemsShown", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ArchitectureTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "highlights", "type": "List"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "GardenTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "gardenArea", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BehindTheScenesTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "areasVisited", "type": "List"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ConservationLabTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Curator"}, + {"name": "demonstrationsShown", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "StackTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "floorsVisited", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "DigitalLabTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "equipmentDemonstrated", "type": "List"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "GroupTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "groupSize", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "SchoolGroupTour", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "tourId", "type": "UUID"}, + {"name": "schoolName", "type": "String"}, + {"name": "tourDate", "type": "LocalDate"}, + {"name": "studentCount", "type": "int"}, + {"name": "guide", "type": "Librarian"}, + {"name": "gradeLevel", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "LibraryConference", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "conferenceId", "type": "UUID"}, + {"name": "conferenceName", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "sessionCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ProfessionalWorkshop", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "workshopId", "type": "UUID"}, + {"name": "workshopTitle", "type": "String"}, + {"name": "workshopDate", "type": "LocalDate"}, + {"name": "instructor", "type": "String"}, + {"name": "participantCount", "type": "int"}, + {"name": "durationHours", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "StaffTrainingSession", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "sessionTitle", "type": "String"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "trainer", "type": "String"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "durationHours", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ContinuingEducationCourse", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "courseId", "type": "UUID"}, + {"name": "courseTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "enrolledCount", "type": "int"}, + {"name": "instructor", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "WebinarAttendance", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "webinarId", "type": "UUID"}, + {"name": "webinarTitle", "type": "String"}, + {"name": "webinarDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "provider", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "ConferencePresentation", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "presentationId", "type": "UUID"}, + {"name": "presentationTitle", "type": "String"}, + {"name": "presentationDate", "type": "LocalDate"}, + {"name": "presenter", "type": "String"}, + {"name": "audienceCount", "type": "int"}, + {"name": "conferenceName", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "PosterSession", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "sessionTitle", "type": "String"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "presenter", "type": "String"}, + {"name": "posterCount", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "PanelDiscussion", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "panelId", "type": "UUID"}, + {"name": "panelTitle", "type": "String"}, + {"name": "panelDate", "type": "LocalDate"}, + {"name": "panelistCount", "type": "int"}, + {"name": "audienceCount", "type": "int"}, + {"name": "moderator", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "RoundtableDiscussion", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "discussionId", "type": "UUID"}, + {"name": "topic", "type": "String"}, + {"name": "discussionDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "facilitator", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "NetworkingEvent", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "eventId", "type": "UUID"}, + {"name": "eventTitle", "type": "String"}, + {"name": "eventDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "GalaDinner", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "galaId", "type": "UUID"}, + {"name": "galaTitle", "type": "String"}, + {"name": "galaDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "ticketPrice", "type": "BigDecimal"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "SilentAuction", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "auctionId", "type": "UUID"}, + {"name": "auctionDate", "type": "LocalDate"}, + {"name": "itemCount", "type": "int"}, + {"name": "totalRaised", "type": "BigDecimal"}, + {"name": "venue", "type": "PublicLibrary"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "RaffleDrawing", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "raffleId", "type": "UUID"}, + {"name": "raffleDate", "type": "LocalDate"}, + {"name": "ticketCount", "type": "int"}, + {"name": "prizeCount", "type": "int"}, + {"name": "totalRaised", "type": "BigDecimal"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "FundraisingAppeal", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "appealId", "type": "UUID"}, + {"name": "appealTitle", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "targetAmount", "type": "BigDecimal"}, + {"name": "raisedAmount", "type": "BigDecimal"}, + {"name": "coordinator", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "CapitalCampaign", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "campaignId", "type": "UUID"}, + {"name": "campaignName", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "targetAmount", "type": "BigDecimal"}, + {"name": "raisedAmount", "type": "BigDecimal"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "EndowmentCampaign", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "campaignId", "type": "UUID"}, + {"name": "campaignName", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "targetAmount", "type": "BigDecimal"}, + {"name": "raisedAmount", "type": "BigDecimal"}, + {"name": "coordinator", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "MemorialDonation", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "donationId", "type": "UUID"}, + {"name": "donorName", "type": "String"}, + {"name": "memorialName", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "donationDate", "type": "LocalDate"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "TributeDonation", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "donationId", "type": "UUID"}, + {"name": "donorName", "type": "String"}, + {"name": "honoreeName", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "donationDate", "type": "LocalDate"}, + {"name": "occasion", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "MatchingGiftCampaign", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "campaignId", "type": "UUID"}, + {"name": "campaignName", "type": "String"}, + {"name": "matchingSponsor", "type": "String"}, + {"name": "matchRatio", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "CrowdfundingCampaign", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "campaignId", "type": "UUID"}, + {"name": "campaignTitle", "type": "String"}, + {"name": "platform", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "targetAmount", "type": "BigDecimal"}, + {"name": "raisedAmount", "type": "BigDecimal"}, + {"name": "backerCount", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "EXHIBITION"} + ] + }, + { + "name": "StrategicPlanningSession", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "facilitator", "type": "LibraryDirector"}, + {"name": "topicsCovered", "type": "List"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BudgetReviewMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "budgetPeriod", "type": "String"}, + {"name": "totalBudget", "type": "BigDecimal"}, + {"name": "chairedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "AnnualReportMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "reportingYear", "type": "int"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "participantCount", "type": "int"}, + {"name": "presentedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "BoardMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "boardMemberCount", "type": "int"}, + {"name": "agendaItems", "type": "int"}, + {"name": "chairedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "CommitteeMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "committeeName", "type": "String"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "memberCount", "type": "int"}, + {"name": "chairedBy", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "StaffMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "agendaItems", "type": "List"}, + {"name": "chairedBy", "type": "LibraryDirector"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "DepartmentMeeting", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "departmentName", "type": "String"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "chairedBy", "type": "Librarian"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "PerformanceReview", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "reviewId", "type": "UUID"}, + {"name": "reviewDate", "type": "LocalDate"}, + {"name": "revieweeName", "type": "String"}, + {"name": "reviewerName", "type": "String"}, + {"name": "rating", "type": "String"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "JobInterview", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "interviewId", "type": "UUID"}, + {"name": "candidateName", "type": "String"}, + {"name": "position", "type": "String"}, + {"name": "interviewDate", "type": "LocalDate"}, + {"name": "interviewerCount", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "OrientationSession", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "sessionDate", "type": "LocalDate"}, + {"name": "newHireCount", "type": "int"}, + {"name": "presenter", "type": "Librarian"}, + {"name": "durationHours", "type": "int"}, + {"name": "eventType", "type": "EventType", "default": "WORKSHOP"} + ] + }, + { + "name": "EventRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "eventId", "type": "UUID"}, + {"name": "eventName", "type": "String"}, + {"name": "eventDate", "type": "LocalDate"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "eventType", "type": "String"} + ] + }, + { + "name": "SessionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "sessionId", "type": "UUID"}, + {"name": "sessionTitle", "type": "String"}, + {"name": "startTime", "type": "LocalTime"}, + {"name": "endTime", "type": "LocalTime"}, + {"name": "attendeeCount", "type": "int"} + ] + }, + { + "name": "MeetingRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "meetingId", "type": "UUID"}, + {"name": "meetingTitle", "type": "String"}, + {"name": "meetingDate", "type": "LocalDate"}, + {"name": "organizer", "type": "String"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "status", "type": "String", "default": "SCHEDULED"} + ] + }, + { + "name": "GatheringRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "gatheringId", "type": "UUID"}, + {"name": "gatheringName", "type": "String"}, + {"name": "location", "type": "String"}, + {"name": "participantCount", "type": "int"} + ] + }, + { + "name": "AssemblyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "assemblyId", "type": "UUID"}, + {"name": "assemblyTitle", "type": "String"}, + {"name": "assemblyDate", "type": "LocalDate"}, + {"name": "speakerCount", "type": "int"}, + {"name": "topic", "type": "String"} + ] + }, + { + "name": "ConventionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "conventionId", "type": "UUID"}, + {"name": "conventionName", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "expectedAttendance", "type": "int"} + ] + }, + { + "name": "ConferenceRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "conferenceId", "type": "UUID"}, + {"name": "conferenceName", "type": "String"}, + {"name": "venue", "type": "String"}, + {"name": "sessionCount", "type": "int"}, + {"name": "keynoteSpeaker", "type": "String"} + ] + }, + { + "name": "SymposiumRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "symposiumId", "type": "UUID"}, + {"name": "symposiumTitle", "type": "String"}, + {"name": "symposiumDate", "type": "LocalDate"}, + {"name": "panelCount", "type": "int"}, + {"name": "theme", "type": "String"} + ] + }, + { + "name": "ColloquiumRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "colloquiumId", "type": "UUID"}, + {"name": "colloquiumTitle", "type": "String"}, + {"name": "presenter", "type": "String"}, + {"name": "attendeeLimit", "type": "int"}, + {"name": "subjectArea", "type": "String"} + ] + }, + { + "name": "SeminarRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "seminarId", "type": "UUID"}, + {"name": "seminarTitle", "type": "String"}, + {"name": "seminarDate", "type": "LocalDate"}, + {"name": "durationHours", "type": "int"}, + {"name": "instructor", "type": "String"} + ] + }, + { + "name": "WorkshopRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "workshopId", "type": "UUID"}, + {"name": "workshopName", "type": "String"}, + {"name": "workshopDate", "type": "LocalDate"}, + {"name": "maxParticipants", "type": "int"}, + {"name": "materials", "type": "List"} + ] + }, + { + "name": "ClassRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "classId", "type": "UUID"}, + {"name": "className", "type": "String"}, + {"name": "instructor", "type": "String"}, + {"name": "enrolledCount", "type": "int"}, + {"name": "roomNumber", "type": "String"} + ] + }, + { + "name": "LessonRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "lessonId", "type": "UUID"}, + {"name": "lessonTitle", "type": "String"}, + {"name": "lessonDate", "type": "LocalDate"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "subject", "type": "String"} + ] + }, + { + "name": "LectureRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "lectureId", "type": "UUID"}, + {"name": "lectureTitle", "type": "String"}, + {"name": "lecturer", "type": "String"}, + {"name": "attendeeCount", "type": "int"}, + {"name": "lectureDate", "type": "LocalDate"} + ] + }, + { + "name": "TalkRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "talkId", "type": "UUID"}, + {"name": "talkTitle", "type": "String"}, + {"name": "speaker", "type": "String"}, + {"name": "talkDate", "type": "LocalDate"}, + {"name": "audienceSize", "type": "int"} + ] + }, + { + "name": "PresentationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "presentationId", "type": "UUID"}, + {"name": "presentationTitle", "type": "String"}, + {"name": "presenter", "type": "String"}, + {"name": "slideCount", "type": "int"}, + {"name": "presentationDate", "type": "LocalDate"} + ] + }, + { + "name": "DemonstrationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "demonstrationId", "type": "UUID"}, + {"name": "demonstrationName", "type": "String"}, + {"name": "demonstrator", "type": "String"}, + {"name": "observerCount", "type": "int"}, + {"name": "topic", "type": "String"} + ] + }, + { + "name": "ExhibitionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "exhibitionId", "type": "UUID"}, + {"name": "exhibitionName", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"}, + {"name": "itemCount", "type": "int"} + ] + }, + { + "name": "DisplayRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "displayId", "type": "UUID"}, + {"name": "displayName", "type": "String"}, + {"name": "location", "type": "String"}, + {"name": "displayDate", "type": "LocalDate"}, + {"name": "curator", "type": "String"} + ] + }, + { + "name": "ShowRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "showId", "type": "UUID"}, + {"name": "showName", "type": "String"}, + {"name": "showDate", "type": "LocalDate"}, + {"name": "ticketCount", "type": "int"}, + {"name": "venue", "type": "String"} + ] + }, + { + "name": "PerformanceRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "performanceId", "type": "UUID"}, + {"name": "performanceTitle", "type": "String"}, + {"name": "performer", "type": "String"}, + {"name": "performanceDate", "type": "LocalDate"}, + {"name": "durationMinutes", "type": "int"} + ] + }, + { + "name": "ConcertRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "concertId", "type": "UUID"}, + {"name": "concertName", "type": "String"}, + {"name": "concertDate", "type": "LocalDate"}, + {"name": "performerCount", "type": "int"}, + {"name": "genre", "type": "String"} + ] + }, + { + "name": "RecitalRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "recitalId", "type": "UUID"}, + {"name": "recitalTitle", "type": "String"}, + {"name": "performer", "type": "String"}, + {"name": "recitalDate", "type": "LocalDate"}, + {"name": "instrumentCount", "type": "int"} + ] + }, + { + "name": "ReadingRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "readingId", "type": "UUID"}, + {"name": "readingTitle", "type": "String"}, + {"name": "reader", "type": "String"}, + {"name": "readingDate", "type": "LocalDate"}, + {"name": "audienceCount", "type": "int"} + ] + }, + { + "name": "ScreeningRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "screeningId", "type": "UUID"}, + {"name": "screeningTitle", "type": "String"}, + {"name": "screeningDate", "type": "LocalDate"}, + {"name": "durationMinutes", "type": "int"}, + {"name": "format", "type": "String"} + ] + }, + { + "name": "BroadcastRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "broadcastId", "type": "UUID"}, + {"name": "broadcastTitle", "type": "String"}, + {"name": "broadcastDate", "type": "LocalDate"}, + {"name": "channel", "type": "String"}, + {"name": "viewerCount", "type": "int"} + ] + }, + { + "name": "WebcastRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "webcastId", "type": "UUID"}, + {"name": "webcastTitle", "type": "String"}, + {"name": "webcastDate", "type": "LocalDate"}, + {"name": "url", "type": "String"}, + {"name": "viewerCount", "type": "int"} + ] + }, + { + "name": "PodcastRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "podcastId", "type": "UUID"}, + {"name": "podcastTitle", "type": "String"}, + {"name": "host", "type": "String"}, + {"name": "episodeNumber", "type": "int"}, + {"name": "durationMinutes", "type": "int"} + ] + }, + { + "name": "WebinarRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "webinarId", "type": "UUID"}, + {"name": "webinarTitle", "type": "String"}, + {"name": "presenter", "type": "String"}, + {"name": "webinarDate", "type": "LocalDate"}, + {"name": "registrantCount", "type": "int"} + ] + }, + { + "name": "TelecastRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "telecastId", "type": "UUID"}, + {"name": "telecastTitle", "type": "String"}, + {"name": "telecastDate", "type": "LocalDate"}, + {"name": "network", "type": "String"}, + {"name": "audienceRating", "type": "String"} + ] + }, + { + "name": "TransmissionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "transmissionId", "type": "UUID"}, + {"name": "transmissionTitle", "type": "String"}, + {"name": "transmissionDate", "type": "LocalDate"}, + {"name": "frequency", "type": "String"}, + {"name": "signalStrength", "type": "double"} + ] + }, + { + "name": "PublicationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "publicationId", "type": "UUID"}, + {"name": "publicationTitle", "type": "String"}, + {"name": "publicationDate", "type": "LocalDate"}, + {"name": "publisher", "type": "String"}, + {"name": "issn", "type": "String"} + ] + }, + { + "name": "ReleaseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "releaseId", "type": "UUID"}, + {"name": "releaseTitle", "type": "String"}, + {"name": "releaseDate", "type": "LocalDate"}, + {"name": "version", "type": "String"}, + {"name": "platform", "type": "String"} + ] + }, + { + "name": "LaunchRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "launchId", "type": "UUID"}, + {"name": "launchName", "type": "String"}, + {"name": "launchDate", "type": "LocalDate"}, + {"name": "budgetAllocated", "type": "BigDecimal"}, + {"name": "targetAudience", "type": "String"} + ] + }, + { + "name": "DebutRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "debutId", "type": "UUID"}, + {"name": "debutTitle", "type": "String"}, + {"name": "debutDate", "type": "LocalDate"}, + {"name": "performer", "type": "String"}, + {"name": "venueCapacity", "type": "int"} + ] + }, + { + "name": "PremiereRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "premiereId", "type": "UUID"}, + {"name": "premiereTitle", "type": "String"}, + {"name": "premiereDate", "type": "LocalDate"}, + {"name": "director", "type": "String"}, + {"name": "guestCount", "type": "int"} + ] + }, + { + "name": "OpeningRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "openingId", "type": "UUID"}, + {"name": "openingName", "type": "String"}, + {"name": "openingDate", "type": "LocalDate"}, + {"name": "openingTime", "type": "LocalTime"}, + {"name": "expectedGuests", "type": "int"} + ] + }, + { + "name": "ClosingRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "closingId", "type": "UUID"}, + {"name": "closingName", "type": "String"}, + {"name": "closingDate", "type": "LocalDate"}, + {"name": "closingTime", "type": "LocalTime"}, + {"name": "finalAttendance", "type": "int"} + ] + }, + { + "name": "AwardRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "awardId", "type": "UUID"}, + {"name": "awardName", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "awardDate", "type": "LocalDate"}, + {"name": "category", "type": "String"} + ] + }, + { + "name": "PrizeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "prizeId", "type": "UUID"}, + {"name": "prizeName", "type": "String"}, + {"name": "winner", "type": "String"}, + {"name": "prizeDate", "type": "LocalDate"}, + {"name": "prizeValue", "type": "BigDecimal"} + ] + }, + { + "name": "CredentialRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "certificateId", "type": "UUID"}, + {"name": "certificateType", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "issuer", "type": "String"} + ] + }, + { + "name": "DiplomaRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "diplomaId", "type": "UUID"}, + {"name": "diplomaTitle", "type": "String"}, + {"name": "graduate", "type": "String"}, + {"name": "conferralDate", "type": "LocalDate"}, + {"name": "institution", "type": "String"} + ] + }, + { + "name": "DegreeRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "degreeId", "type": "UUID"}, + {"name": "degreeTitle", "type": "String"}, + {"name": "holder", "type": "String"}, + {"name": "completionDate", "type": "LocalDate"}, + {"name": "fieldOfStudy", "type": "String"} + ] + }, + { + "name": "FundingRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "grantId", "type": "UUID"}, + {"name": "grantTitle", "type": "String"}, + {"name": "recipient", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "grantDate", "type": "LocalDate"} + ] + }, + { + "name": "BursaryRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "scholarshipId", "type": "UUID"}, + {"name": "scholarshipName", "type": "String"}, + {"name": "scholar", "type": "String"}, + {"name": "amount", "type": "BigDecimal"}, + {"name": "academicYear", "type": "String"} + ] + }, + { + "name": "StipendRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "fellowshipId", "type": "UUID"}, + {"name": "fellowshipName", "type": "String"}, + {"name": "fellow", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "endDate", "type": "LocalDate"} + ] + }, + { + "name": "ResidencyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "residencyId", "type": "UUID"}, + {"name": "residencyName", "type": "String"}, + {"name": "resident", "type": "String"}, + {"name": "durationMonths", "type": "int"}, + {"name": "program", "type": "String"} + ] + }, + { + "name": "InternshipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "internshipId", "type": "UUID"}, + {"name": "internshipTitle", "type": "String"}, + {"name": "intern", "type": "String"}, + {"name": "startDate", "type": "LocalDate"}, + {"name": "supervisor", "type": "String"} + ] + }, + { + "name": "ApprenticeshipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "apprenticeshipId", "type": "UUID"}, + {"name": "apprenticeshipName", "type": "String"}, + {"name": "apprentice", "type": "String"}, + {"name": "trade", "type": "String"}, + {"name": "durationYears", "type": "int"} + ] + }, + { + "name": "MentorshipRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "mentorshipId", "type": "UUID"}, + {"name": "mentorshipName", "type": "String"}, + {"name": "mentor", "type": "String"}, + {"name": "mentee", "type": "String"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "CollaborationAgreementRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "partnershipId", "type": "UUID"}, + {"name": "partnershipName", "type": "String"}, + {"name": "partnerA", "type": "String"}, + {"name": "partnerB", "type": "String"}, + {"name": "establishedDate", "type": "LocalDate"} + ] + }, + { + "name": "CollaborationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "collaborationId", "type": "UUID"}, + {"name": "collaborationTitle", "type": "String"}, + {"name": "leadOrganization", "type": "String"}, + {"name": "participantCount", "type": "int"}, + {"name": "startDate", "type": "LocalDate"} + ] + }, + { + "name": "FactionRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "allianceId", "type": "UUID"}, + {"name": "allianceName", "type": "String"}, + {"name": "memberCount", "type": "int"}, + {"name": "formedDate", "type": "LocalDate"}, + {"name": "headquarters", "type": "String"} + ] + }, + { + "name": "TreatyRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "treatyId", "type": "UUID"}, + {"name": "treatyName", "type": "String"}, + {"name": "signatoryCount", "type": "int"}, + {"name": "signedDate", "type": "LocalDate"}, + {"name": "jurisdiction", "type": "String"} + ] + }, + { + "name": "AgreementRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "agreementId", "type": "UUID"}, + {"name": "agreementTitle", "type": "String"}, + {"name": "partyA", "type": "String"}, + {"name": "partyB", "type": "String"}, + {"name": "effectiveDate", "type": "LocalDate"} + ] + }, + { + "name": "ContractRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "contractId", "type": "UUID"}, + {"name": "contractTitle", "type": "String"}, + {"name": "contractor", "type": "String"}, + {"name": "value", "type": "BigDecimal"}, + {"name": "expiryDate", "type": "LocalDate"} + ] + }, + { + "name": "LeaseRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "leaseId", "type": "UUID"}, + {"name": "leaseTitle", "type": "String"}, + {"name": "lessee", "type": "String"}, + {"name": "monthlyRate", "type": "BigDecimal"}, + {"name": "leaseEndDate", "type": "LocalDate"} + ] + }, + { + "name": "AuthorizationRecord", + "kind": "record", + "extends": null, + "properties": [ + {"name": "licenseId", "type": "UUID"}, + {"name": "licenseType", "type": "String"}, + {"name": "licensee", "type": "String"}, + {"name": "issueDate", "type": "LocalDate"}, + {"name": "expirationDate", "type": "LocalDate"} + ] + }, + { + "name": "SimpleTypesBenchmark", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "eventCount", "type": "int"}, + {"name": "eventIdentifier", "type": "long"}, + {"name": "durationMeasurement", "type": "double"}, + {"name": "attendanceRatio", "type": "float"}, + {"name": "isActive", "type": "boolean"}, + {"name": "statusCode", "type": "char"}, + {"name": "priorityLevel", "type": "byte"}, + {"name": "seatIndex", "type": "short"}, + {"name": "participantCount", "type": "int"}, + {"name": "sessionIdentifier", "type": "long"}, + {"name": "scoreMeasurement", "type": "double"}, + {"name": "costRatio", "type": "float"}, + {"name": "isPublic", "type": "boolean"}, + {"name": "categoryCode", "type": "char"}, + {"name": "urgencyLevel", "type": "byte"}, + {"name": "waitlistIndex", "type": "short"}, + {"name": "ticketCount", "type": "int"}, + {"name": "bookingIdentifier", "type": "long"}, + {"name": "revenueMeasurement", "type": "double"}, + {"name": "discountRatio", "type": "float"} + ] + }, + { + "name": "ComplexTypesBenchmark", + "kind": "class", + "extends": "LibraryEvent", + "properties": [ + {"name": "title", "type": "String"}, + {"name": "description", "type": "String"}, + {"name": "tags", "type": "List"}, + {"name": "categories", "type": "Set"}, + {"name": "metadata", "type": "Map"}, + {"name": "authors", "type": "List"}, + {"name": "relatedBooks", "type": "Set"}, + {"name": "branchMap", "type": "Map"}, + {"name": "primaryAuthor", "type": "Author"}, + {"name": "homeBranch", "type": "PublicLibrary"}, + {"name": "featuredItem", "type": "HardcoverBook"}, + {"name": "manager", "type": "LibraryDirector"}, + {"name": "optionalNote", "type": "Optional"}, + {"name": "optionalAuthor", "type": "Optional"}, + {"name": "keywords", "type": "String[]"}, + {"name": "scores", "type": "int[]"}, + {"name": "items", "type": "List"}, + {"name": "authorBookMap", "type": "Map"}, + {"name": "directors", "type": "Set"}, + {"name": "foundedDate", "type": "LocalDate"} + ] + } + ] + } + } +} From 0dfc498bb0b4b62993219a1359837fca3299bff8 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 14:41:45 +0200 Subject: [PATCH 07/35] Removing unneeded properties form generation json --- .../docs/library-class-catalog.json | 7 +----- performance-test/scripts/generate_classes.py | 23 ++++++++----------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/performance-test/docs/library-class-catalog.json b/performance-test/docs/library-class-catalog.json index 9e09e3a5..f5c28d4a 100644 --- a/performance-test/docs/library-class-catalog.json +++ b/performance-test/docs/library-class-catalog.json @@ -1,9 +1,8 @@ { "topic": "Library System", - "totalClasses": 1000, + "designNotes": "Classes are grouped into packages (items, persons, organizations, locations, events). Each package maps to a Java sub-package under org.javahelpers.simple.builders.performance_test.library.. Each class entry has: name (Java identifier), kind ('class' or 'record'), extends (superclass name or null; ignored for records), and properties. Each property has: name, type (Java type string, e.g. 'String', 'List', 'int[]'), optional default (generates @Default annotation), and optional ignore:true (generates @IgnoreInBuilder on setter). Property types that are not primitives, not in the script's STANDARD_IMPORTS list, and not declared as classes in this JSON are assumed to be enums from the .enums sub-package. The fixed infrastructure (LibraryEntity, the 5 enums, and the 5 intermediate base classes) is hand-written and NOT generated by the script. Records get 'implements Builder.With' per the simple-builders convention.", "packages": { "items": { - "intermediateClass": "LibraryItem", "classes": [ { "name": "HardcoverBook", @@ -2930,7 +2929,6 @@ ] }, "persons": { - "intermediateClass": "LibraryPerson", "classes": [ { "name": "Librarian", @@ -5581,7 +5579,6 @@ ] }, "organizations": { - "intermediateClass": "LibraryOrganization", "classes": [ { "name": "UniversityPress", @@ -8270,7 +8267,6 @@ ] }, "locations": { - "intermediateClass": "LibraryLocation", "classes": [ { "name": "QuietReadingRoom", @@ -10892,7 +10888,6 @@ ] }, "events": { - "intermediateClass": "LibraryEvent", "classes": [ { "name": "BookCheckout", diff --git a/performance-test/scripts/generate_classes.py b/performance-test/scripts/generate_classes.py index 9db6a6a4..1455b478 100755 --- a/performance-test/scripts/generate_classes.py +++ b/performance-test/scripts/generate_classes.py @@ -23,10 +23,9 @@ JSON schema (expected by this script): { "topic": "...", # ignored - "totalClasses": , # ignored (computed from packages) + "designNotes": "...", # ignored (human-readable documentation) "packages": { "": { # subPackage -> Java sub-package name - "intermediateClass": "", # ignored if per-class "extends" is set "classes": [ { "name": "", # required, must be a valid Java identifier @@ -371,7 +370,6 @@ def resolve_imports( def generate_class_source( class_entry: dict, - intermediate_class: str, sub_package: str, class_index: dict[str, str], ) -> str: @@ -379,8 +377,7 @@ def generate_class_source( Generate the full Java source for a ``kind: "class"`` entry. The ``extends`` clause uses the per-class ``extends`` field from the JSON. - If it is null or absent, the class has no superclass. If it is set, that - value is used (typically the package's intermediate class). + If it is null or absent, the class has no superclass. """ name = class_entry["name"] props = class_entry.get("properties", []) @@ -496,7 +493,6 @@ def generate_record_source( def generate_source( class_entry: dict, - intermediate_class: str, sub_package: str, class_index: dict[str, str], ) -> str: @@ -504,7 +500,7 @@ def generate_source( kind = class_entry.get("kind", "class") if kind == "record": return generate_record_source(class_entry, sub_package, class_index) - return generate_class_source(class_entry, intermediate_class, sub_package, class_index) + return generate_class_source(class_entry, sub_package, class_index) # --------------------------------------------------------------------------- @@ -512,16 +508,15 @@ def generate_source( # --------------------------------------------------------------------------- -def iter_classes(data: dict) -> Iterable[tuple[str, str, dict]]: +def iter_classes(data: dict) -> Iterable[tuple[str, dict]]: """ - Yield ``(sub_package, intermediate_class, class_entry)`` tuples in JSON - order: items, persons, organizations, locations, events, and within each + Yield ``(sub_package, class_entry)`` tuples in JSON order: + items, persons, organizations, locations, events, and within each package the classes in array order. """ for pkg_name, pkg in data.get("packages", {}).items(): - intermediate = pkg.get("intermediateClass", "") for cls in pkg.get("classes", []): - yield pkg_name, intermediate, cls + yield pkg_name, cls def atomic_write(path: Path, content: str) -> None: @@ -627,7 +622,7 @@ def main(argv: list[str] | None = None) -> int: skipped = 0 errors: list[str] = [] - for idx, (sub_package, intermediate, cls) in enumerate(iter_classes(data)): + for idx, (sub_package, cls) in enumerate(iter_classes(data)): if limit is not None and idx >= limit: break @@ -671,7 +666,7 @@ def main(argv: list[str] | None = None) -> int: # --- Generate source --- try: - source = generate_source(cls, intermediate, sub_package, class_index) + source = generate_source(cls, sub_package, class_index) except (KeyError, TypeError) as e: msg = f"failed to generate source for class {name!r}: {e}" errors.append(msg) From c0d616339cede03c704dfcd5edc1ae5e9c67f5a9 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 15:13:15 +0200 Subject: [PATCH 08/35] Adepting class names so that it is not offensive --- performance-test/docs/library-class-catalog.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/performance-test/docs/library-class-catalog.json b/performance-test/docs/library-class-catalog.json index f5c28d4a..ef3d976f 100644 --- a/performance-test/docs/library-class-catalog.json +++ b/performance-test/docs/library-class-catalog.json @@ -7949,7 +7949,7 @@ {"name": "testator", "type": "String"}, {"name": "amount", "type": "BigDecimal"}, {"name": "beneficiary", "type": "String"}, - {"name": "executionDate", "type": "LocalDate"} + {"name": "fulfillmentDate", "type": "LocalDate"} ] }, { @@ -8145,11 +8145,11 @@ ] }, { - "name": "SyndicateRecord", + "name": "ConsortiumPartnerRecord", "kind": "record", "extends": null, "properties": [ - {"name": "syndicateName", "type": "String"}, + {"name": "consortiumPartnerName", "type": "String"}, {"name": "memberCount", "type": "int"}, {"name": "activity", "type": "String"}, {"name": "foundedYear", "type": "int"}, @@ -8193,7 +8193,7 @@ ] }, { - "name": "InstituteRecord2", + "name": "ResearchInstituteRecord", "kind": "record", "extends": null, "properties": [ @@ -12219,7 +12219,7 @@ ] }, { - "name": "BlindDateWithBook", + "name": "MysteryDateWithBook", "kind": "class", "extends": "LibraryEvent", "properties": [ From 808cf0b77428ad3cb0b79298f0416cd598bf8e07 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 16:46:31 +0200 Subject: [PATCH 09/35] Improving json-structure and generation-python to generate enums and baseclasses too --- .../docs/library-class-catalog.json | 29 +- performance-test/scripts/generate_classes.py | 256 +++++++++++++++++- 2 files changed, 273 insertions(+), 12 deletions(-) diff --git a/performance-test/docs/library-class-catalog.json b/performance-test/docs/library-class-catalog.json index ef3d976f..6fc403ed 100644 --- a/performance-test/docs/library-class-catalog.json +++ b/performance-test/docs/library-class-catalog.json @@ -1,6 +1,33 @@ { "topic": "Library System", - "designNotes": "Classes are grouped into packages (items, persons, organizations, locations, events). Each package maps to a Java sub-package under org.javahelpers.simple.builders.performance_test.library.. Each class entry has: name (Java identifier), kind ('class' or 'record'), extends (superclass name or null; ignored for records), and properties. Each property has: name, type (Java type string, e.g. 'String', 'List', 'int[]'), optional default (generates @Default annotation), and optional ignore:true (generates @IgnoreInBuilder on setter). Property types that are not primitives, not in the script's STANDARD_IMPORTS list, and not declared as classes in this JSON are assumed to be enums from the .enums sub-package. The fixed infrastructure (LibraryEntity, the 5 enums, and the 5 intermediate base classes) is hand-written and NOT generated by the script. Records get 'implements Builder.With' per the simple-builders convention.", + "designNotes": "Classes are grouped into packages (items, persons, organizations, locations, events). Each package maps to a Java sub-package under org.javahelpers.simple.builders.performance_test.library.. Each class entry has: name (Java identifier), kind ('class' or 'record'), extends (superclass name or null; ignored for records), and properties. Each property has: name, type (Java type string, e.g. 'String', 'List', 'int[]'), optional default (generates @Default annotation), and optional ignore:true (generates @IgnoreInBuilder on setter). Property types that are not primitives, not in the script's STANDARD_IMPORTS list, and not declared as classes in this JSON are assumed to be enums from the .enums sub-package. The enums section defines enum types generated into the .enums sub-package. The baseClasses section defines the root entity class and intermediate base classes (one per package) that generated classes extend. Records get 'implements Builder.With' per the simple-builders convention.", + "enums": { + "types": [ + {"name": "EventType", "values": ["ACQUISITION", "EXHIBITION", "LOAN", "READING", "WORKSHOP"]}, + {"name": "ItemCondition", "values": ["NEW", "GOOD", "FAIR", "POOR"]}, + {"name": "LoanStatus", "values": ["ACTIVE", "RETURNED"]}, + {"name": "LocationZone", "values": ["GENERAL", "STACKS", "RARE_BOOKS", "ARCHIVES", "CHILDREN", "TEEN", "MEDIA", "LOCAL_HISTORY", "STAFF", "STORAGE", "EXHIBITION", "ACCESSIBLE"]}, + {"name": "MembershipLevel", "values": ["BASIC", "STANDARD", "PREMIUM"]} + ] + }, + "baseClasses": { + "rootEntity": { + "name": "LibraryEntity", + "package": "", + "properties": [ + {"name": "id", "type": "UUID"}, + {"name": "name", "type": "String"}, + {"name": "createdAt", "type": "LocalDate"} + ] + }, + "intermediateClasses": [ + {"name": "LibraryItem", "package": "items", "extends": "LibraryEntity"}, + {"name": "LibraryPerson", "package": "persons", "extends": "LibraryEntity"}, + {"name": "LibraryOrganization", "package": "organizations", "extends": "LibraryEntity"}, + {"name": "LibraryLocation", "package": "locations", "extends": "LibraryEntity"}, + {"name": "LibraryEvent", "package": "events", "extends": "LibraryEntity"} + ] + }, "packages": { "items": { "classes": [ diff --git a/performance-test/scripts/generate_classes.py b/performance-test/scripts/generate_classes.py index 1455b478..6a13f04f 100755 --- a/performance-test/scripts/generate_classes.py +++ b/performance-test/scripts/generate_classes.py @@ -8,9 +8,11 @@ org.javahelpers.simple.builders.performance_test.library.. -Only the classes defined in the JSON's ``packages..classes`` arrays are -generated. The fixed infrastructure (LibraryEntity, the 5 enums, and the 5 -intermediate classes) is NOT generated by this script — create those by hand. +The script generates three categories of Java source files: + 1. Enums — from the top-level ``enums.types`` array (into the .enums sub-package). + 2. Base classes — from the top-level ``baseClasses`` section: one root entity + class (LibraryEntity) and one intermediate base class per package. + 3. DTO classes/records — from the ``packages..classes`` arrays. Usage: python3 generate_classes.py # generate all classes @@ -24,6 +26,28 @@ { "topic": "...", # ignored "designNotes": "...", # ignored (human-readable documentation) + "enums": { # optional: enum types to generate + "types": [ + { + "name": "", # required, valid Java identifier + "values": ["VAL1", "VAL2", ...] # required, list of enum constant names + } + ] + }, + "baseClasses": { # optional: infrastructure base classes + "rootEntity": { # the root entity class (e.g. LibraryEntity) + "name": "", # required + "package": "" | "", # sub-package ("" = base package, no sub-package) + "properties": [ ... ] # same property format as DTO classes + }, + "intermediateClasses": [ # one intermediate base class per package + { + "name": "", # required + "package": "", # which sub-package this class lives in + "extends": "" # typically the root entity name + } + ] + }, "packages": { "": { # subPackage -> Java sub-package name "classes": [ @@ -53,13 +77,12 @@ - ANNOTATION_IMPORTS: uses org.javahelpers.simple.builders.core.annotations (@SimpleBuilder, @Default, @IgnoreInBuilder) - Records get `implements Builder.With` (simple-builders convention) - - ENUM_PACKAGE: enum types are expected in .enums - - STANDARD_IMPORTS: a closed list of 12 Java standard types. Any property - type that is NOT a primitive, NOT in STANDARD_IMPORTS, and NOT a class - declared in the JSON is assumed to be an enum and imported from - ENUM_PACKAGE. If you use a Java type not in STANDARD_IMPORTS (e.g. - `Instant`, `ZonedDateTime`, `Collection`), add it to STANDARD_IMPORTS or - it will be misclassified as an enum. + - ENUM_PACKAGE: enum types are generated in .enums from the + JSON's ``enums.types`` array. Any property type that is NOT a primitive, + NOT in STANDARD_IMPORTS, and NOT a class declared in the JSON is assumed + to be an enum and imported from ENUM_PACKAGE. + - BASE_CLASSES: the root entity class and intermediate base classes are + generated from the JSON's ``baseClasses`` section before the DTO classes. """ from __future__ import annotations @@ -491,6 +514,94 @@ def generate_record_source( return "\n".join(lines) +def generate_enum_source(enum_entry: dict) -> str: + """ + Generate the full Java source for an enum type. + + The enum is placed in the ``.enums`` sub-package and contains only the + constants listed in the ``values`` array — no fields, constructors, or + methods. + """ + name = enum_entry["name"] + values = enum_entry["values"] + + lines: list[str] = [] + lines.append(license_header()) + lines.append("") + lines.append(f"package {ENUM_PACKAGE};") + lines.append("") + lines.append(f"public enum {name} {{") + for i, val in enumerate(values): + comma = "," if i < len(values) - 1 else "" + lines.append(f" {val}{comma}") + lines.append("}") + lines.append("") + return "\n".join(lines) + + +def generate_base_class_source( + name: str, + sub_package: str, + extends_value: str | None, + props: list[dict], + class_index: dict[str, str], +) -> str: + """ + Generate a base infrastructure class (root entity or intermediate base). + + These classes are plain POJOs with fields, getters, and setters — no + @SimpleBuilder annotation. They use the same import resolution as DTO + classes so that enum and cross-package references are handled correctly. + """ + package_decl = f"{BASE_PACKAGE}.{sub_package}" if sub_package else BASE_PACKAGE + + # Build a minimal class_entry for resolve_imports + class_entry: dict = {"properties": props} + imports = resolve_imports(class_entry, sub_package, class_index) + # Remove @SimpleBuilder from imports — base classes are not annotated + imports = [i for i in imports if not i.endswith(".SimpleBuilder")] + + extends_clause = f" extends {extends_value}" if extends_value else "" + + lines: list[str] = [] + lines.append(license_header()) + lines.append("") + lines.append(f"package {package_decl};") + lines.append("") + if imports: + for imp in imports: + lines.append(f"import {imp};") + lines.append("") + lines.append(f"public class {name}{extends_clause} {{") + lines.append("") + + # Fields + for prop in props: + field_name = prop["name"] + field_type = prop["type"] + lines.append(f" private {field_type} {field_name};") + lines.append("") + + # Getters and setters + for prop in props: + field_name = prop["name"] + field_type = prop["type"] + getter = getter_name(field_name, field_type) + setter = setter_name(field_name) + lines.append(f" public {field_type} {getter}() {{") + lines.append(f" return {field_name};") + lines.append(" }") + lines.append("") + lines.append(f" public void {setter}({field_type} {field_name}) {{") + lines.append(f" this.{field_name} = {field_name};") + lines.append(" }") + lines.append("") + + lines.append("}") + lines.append("") + return "\n".join(lines) + + def generate_source( class_entry: dict, sub_package: str, @@ -611,8 +722,17 @@ def main(argv: list[str] | None = None) -> int: total_in_json = sum(len(p.get("classes", [])) for p in data.get("packages", {}).values()) n_to_generate = min(limit, total_in_json) if limit is not None else total_in_json + # Count enums and base classes for display + enums_data = data.get("enums", {}) + enum_types = enums_data.get("types", []) + base_classes_data = data.get("baseClasses", {}) + root_entity = base_classes_data.get("rootEntity") + intermediate_classes = base_classes_data.get("intermediateClasses", []) + print(f"JSON: {json_path}") print(f"Output: {out_root}") + print(f"Enums: {len(enum_types)}") + print(f"Base classes: {1 + len(intermediate_classes) if root_entity else len(intermediate_classes)}") print(f"Classes in JSON: {total_in_json}") if limit is not None: print(f"Limit: first {n_to_generate} class(es) (test mode)") @@ -622,6 +742,118 @@ def main(argv: list[str] | None = None) -> int: skipped = 0 errors: list[str] = [] + # --- Generate enums --- + for enum_entry in enum_types: + try: + enum_name = enum_entry.get("name") + if not enum_name: + raise ValidationError("enum entry has no name") + validate_identifier(enum_name, f"enum name {enum_name!r}") + for val in enum_entry.get("values", []): + validate_identifier(val, f"enum constant {val!r} in enum {enum_name!r}") + except ValidationError as e: + errors.append(str(e)) + print(f" ERROR: {e}", file=sys.stderr) + continue + + try: + source = generate_enum_source(enum_entry) + except (KeyError, TypeError) as e: + msg = f"failed to generate source for enum {enum_name!r}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + + enum_rel = Path(*ENUM_PACKAGE.split(".")) / f"{enum_name}.java" + out_file = out_root / enum_rel + + if args.dry_run: + print(f" [dry-run] {out_file} ({len(source)} bytes)") + continue + if out_file.exists() and not args.force: + print(f" skip (exists): {out_file}") + skipped += 1 + continue + try: + atomic_write(out_file, source) + except OSError as e: + msg = f"failed to write {out_file}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + print(f" wrote: {out_file}") + written += 1 + + # --- Generate base classes --- + # Root entity class + if root_entity: + root_name = root_entity.get("name", "LibraryEntity") + root_pkg = root_entity.get("package", "") + root_props = root_entity.get("properties", []) + try: + validate_identifier(root_name, f"root entity name {root_name!r}") + source = generate_base_class_source( + root_name, root_pkg, None, root_props, class_index, + ) + except (ValidationError, KeyError, TypeError) as e: + msg = f"failed to generate root entity {root_name!r}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + else: + root_rel_parts = BASE_PACKAGE.split(".") if not root_pkg else [*BASE_PACKAGE.split("."), root_pkg] + root_rel = Path(*root_rel_parts) / f"{root_name}.java" + out_file = out_root / root_rel + if args.dry_run: + print(f" [dry-run] {out_file} ({len(source)} bytes)") + elif out_file.exists() and not args.force: + print(f" skip (exists): {out_file}") + skipped += 1 + else: + try: + atomic_write(out_file, source) + print(f" wrote: {out_file}") + written += 1 + except OSError as e: + msg = f"failed to write {out_file}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + + # Intermediate base classes + for inter in intermediate_classes: + inter_name = inter.get("name") + inter_pkg = inter.get("package", "") + inter_extends = inter.get("extends") + try: + validate_identifier(inter_name, f"intermediate base class name {inter_name!r}") + source = generate_base_class_source( + inter_name, inter_pkg, inter_extends, [], class_index, + ) + except (ValidationError, KeyError, TypeError) as e: + msg = f"failed to generate base class {inter_name!r}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + + inter_rel = Path(*BASE_PACKAGE.split(".")) / inter_pkg / f"{inter_name}.java" + out_file = out_root / inter_rel + if args.dry_run: + print(f" [dry-run] {out_file} ({len(source)} bytes)") + continue + if out_file.exists() and not args.force: + print(f" skip (exists): {out_file}") + skipped += 1 + continue + try: + atomic_write(out_file, source) + except OSError as e: + msg = f"failed to write {out_file}: {e}" + errors.append(msg) + print(f" ERROR: {msg}", file=sys.stderr) + continue + print(f" wrote: {out_file}") + written += 1 + + # --- Generate DTO classes/records --- for idx, (sub_package, cls) in enumerate(iter_classes(data)): if limit is not None and idx >= limit: break @@ -708,7 +940,9 @@ def main(argv: list[str] | None = None) -> int: print() if args.dry_run: - print(f"Dry run complete — {n_to_generate} class(es) would be generated.") + total = len(enum_types) + (1 if root_entity else 0) + len(intermediate_classes) + n_to_generate + print(f"Dry run complete — {total} file(s) would be generated " + f"({len(enum_types)} enums, {1 + len(intermediate_classes) if root_entity else len(intermediate_classes)} base classes, {n_to_generate} DTO classes).") else: print(f"Done — wrote {written} file(s), skipped {skipped} existing file(s).") if errors: From d286a2fb37595fa022b82a10e408eee86a80c2ba Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 17:39:19 +0200 Subject: [PATCH 10/35] Adding code for exporting analysis data to json --- docs/CONFIGURATION.md | 70 + .../library/events/MeetingRecordBuilder.java | 617 ++++++++ .../events/MentorshipRecordBuilder.java | 559 +++++++ .../library/events/OpeningRecordBuilder.java | 471 ++++++ .../events/PerformanceRecordBuilder.java | 520 +++++++ .../library/events/PodcastRecordBuilder.java | 509 +++++++ .../library/events/PremiereRecordBuilder.java | 504 +++++++ .../events/PresentationRecordBuilder.java | 520 +++++++ .../library/events/PrizeRecordBuilder.java | 496 +++++++ .../events/PublicationRecordBuilder.java | 562 +++++++ .../library/events/ReadingRecordBuilder.java | 501 +++++++ .../library/events/RecitalRecordBuilder.java | 504 +++++++ .../library/events/ReleaseRecordBuilder.java | 541 +++++++ .../events/ResidencyRecordBuilder.java | 546 +++++++ .../events/ScreeningRecordBuilder.java | 518 +++++++ .../library/events/SeminarRecordBuilder.java | 504 +++++++ .../library/events/SessionRecordBuilder.java | 455 ++++++ .../library/events/ShowRecordBuilder.java | 501 +++++++ .../events/SimpleTypesBenchmarkBuilder.java | 1309 +++++++++++++++++ .../library/events/StipendRecordBuilder.java | 509 +++++++ .../events/SymposiumRecordBuilder.java | 515 +++++++ .../library/events/TalkRecordBuilder.java | 501 +++++++ .../library/events/TelecastRecordBuilder.java | 560 +++++++ .../events/TransmissionRecordBuilder.java | 520 +++++++ .../library/events/TreatyRecordBuilder.java | 504 +++++++ .../library/events/WebcastRecordBuilder.java | 501 +++++++ .../library/events/WebinarRecordBuilder.java | 504 +++++++ .../library/events/WorkshopRecordBuilder.java | 550 +++++++ .../library/items/MangaRecordBuilder.java | 509 +++++++ .../items/ManuscriptRecordBuilder.java | 521 +++++++ .../library/items/MapRecordBuilder.java | 493 +++++++ .../items/MemorandumRecordBuilder.java | 563 +++++++ .../library/items/MicroformRecordBuilder.java | 455 ++++++ .../library/items/MonographRecordBuilder.java | 562 +++++++ .../library/items/NegativeRecordBuilder.java | 494 +++++++ .../items/NewsletterRecordBuilder.java | 524 +++++++ .../library/items/NovelRecordBuilder.java | 721 +++++++++ .../library/items/NovellaRecordBuilder.java | 622 ++++++++ .../library/items/OctavoRecordBuilder.java | 454 ++++++ .../library/items/PamphletRecordBuilder.java | 454 ++++++ .../items/PeerReviewedJournalBuilder.java | 948 ++++++++++++ .../items/PhotographRecordBuilder.java | 495 +++++++ .../library/items/PoetryRecordBuilder.java | 716 +++++++++ .../library/items/PostcardRecordBuilder.java | 494 +++++++ .../library/items/PosterRecordBuilder.java | 494 +++++++ .../items/PressReleaseRecordBuilder.java | 468 ++++++ .../items/ProceedingsRecordBuilder.java | 525 +++++++ .../library/items/QuartoRecordBuilder.java | 454 ++++++ .../items/ShortStoryRecordBuilder.java | 623 ++++++++ .../library/items/SlideRecordBuilder.java | 494 +++++++ .../library/items/SyllabusRecordBuilder.java | 551 +++++++ .../library/items/TeacherManualBuilder.java | 993 +++++++++++++ .../library/items/TelegramRecordBuilder.java | 454 ++++++ .../library/items/TextbookBuilder.java | 1060 +++++++++++++ .../library/items/ThesisRecordBuilder.java | 664 +++++++++ .../items/TransactionsRecordBuilder.java | 416 ++++++ .../items/TransparencyRecordBuilder.java | 510 +++++++ .../library/items/TreatiseRecordBuilder.java | 562 +++++++ .../items/TypescriptRecordBuilder.java | 455 ++++++ .../library/items/WorksheetRecordBuilder.java | 509 +++++++ .../library/items/ZineRecordBuilder.java | 505 +++++++ .../library/locations/MountRecordBuilder.java | 551 +++++++ .../library/locations/PanelRecordBuilder.java | 511 +++++++ .../locations/PartitionRecordBuilder.java | 520 +++++++ .../locations/PassageRecordBuilder.java | 595 ++++++++ .../library/locations/PatioRecordBuilder.java | 468 ++++++ .../locations/PedestalRecordBuilder.java | 526 +++++++ .../library/locations/PipeRecordBuilder.java | 514 +++++++ .../locations/PlatformRecordBuilder.java | 526 +++++++ .../locations/PlinthRecordBuilder.java | 511 +++++++ .../locations/PodiumRecordBuilder.java | 511 +++++++ .../library/locations/PorchRecordBuilder.java | 468 ++++++ .../library/locations/RackRecordBuilder.java | 514 +++++++ .../library/locations/RoomRecordBuilder.java | 505 +++++++ .../locations/ScreenRecordBuilder.java | 511 +++++++ .../library/locations/SealRecordBuilder.java | 548 +++++++ .../library/locations/ShelfRecordBuilder.java | 511 +++++++ .../locations/SignageRecordBuilder.java | 512 +++++++ .../locations/SkylightRecordBuilder.java | 478 ++++++ .../locations/SocketRecordBuilder.java | 502 +++++++ .../library/locations/StageRecordBuilder.java | 474 ++++++ .../library/locations/StandRecordBuilder.java | 528 +++++++ .../locations/SwitchRecordBuilder.java | 514 +++++++ .../library/locations/TableRecordBuilder.java | 511 +++++++ .../locations/TerraceRecordBuilder.java | 469 ++++++ .../library/locations/TileRecordBuilder.java | 551 +++++++ .../library/locations/VentRecordBuilder.java | 514 +++++++ .../locations/VerandaRecordBuilder.java | 463 ++++++ .../locations/WindowRecordBuilder.java | 465 ++++++ .../library/locations/WireRecordBuilder.java | 551 +++++++ .../organizations/MapPublisherBuilder.java | 715 +++++++++ .../organizations/MaritimeMuseumBuilder.java | 639 ++++++++ .../organizations/MediaProviderBuilder.java | 710 +++++++++ .../organizations/MedicalLibraryBuilder.java | 687 +++++++++ .../MembershipRecordBuilder.java | 558 +++++++ .../organizations/MemorialFundBuilder.java | 678 +++++++++ .../MetadataStandardsBodyBuilder.java | 718 +++++++++ .../MinistryOfCultureBuilder.java | 756 ++++++++++ .../MunicipalArchiveBuilder.java | 752 ++++++++++ .../MunicipalCulturalOfficeBuilder.java | 758 ++++++++++ .../MunicipalLibraryBuilder.java | 681 +++++++++ .../MuseumAssociationBuilder.java | 721 +++++++++ .../MusicDistributorBuilder.java | 711 +++++++++ .../organizations/MusicPublisherBuilder.java | 753 ++++++++++ .../organizations/MusicSchoolBuilder.java | 710 +++++++++ .../organizations/NameAuthorityBuilder.java | 641 ++++++++ .../NationalEndowmentBuilder.java | 682 +++++++++ .../organizations/NationalLibraryBuilder.java | 680 +++++++++ .../NaturalHistoryMuseumBuilder.java | 717 +++++++++ .../organizations/NetworkRecordBuilder.java | 509 +++++++ .../organizations/OnlineBookstoreBuilder.java | 680 +++++++++ .../PartnershipRecordBuilder.java | 607 ++++++++ .../PerformingArtsCenterBuilder.java | 721 +++++++++ .../organizations/PermitRecordBuilder.java | 557 +++++++ .../PhotographyArchiveBuilder.java | 753 ++++++++++ .../organizations/PlanetariumBuilder.java | 639 ++++++++ .../organizations/PoetryPressBuilder.java | 710 +++++++++ .../PreservationNetworkBuilder.java | 647 ++++++++ .../PreservationOfficeBuilder.java | 755 ++++++++++ .../organizations/PressRecordBuilder.java | 509 +++++++ .../ProfessionalPublisherBuilder.java | 795 ++++++++++ .../ProfessionalSchoolBuilder.java | 727 +++++++++ .../organizations/ProgramRecordBuilder.java | 518 +++++++ .../organizations/ProjectRecordBuilder.java | 510 +++++++ .../organizations/PublisherRecordBuilder.java | 524 +++++++ .../PublishersAssociationBuilder.java | 761 ++++++++++ .../PublishingServiceProviderBuilder.java | 712 +++++++++ .../PurchasingConsortiumBuilder.java | 644 ++++++++ .../organizations/RailwayMuseumBuilder.java | 639 ++++++++ .../RegionalDistributorBuilder.java | 682 +++++++++ .../organizations/RegionalLibraryBuilder.java | 680 +++++++++ .../RegionalPublisherBuilder.java | 682 +++++++++ .../organizations/RegistryRecordBuilder.java | 566 +++++++ .../ResearchAssociationBuilder.java | 717 +++++++++ .../ResearchConsortiumBuilder.java | 719 +++++++++ .../ResearchFoundationBuilder.java | 715 +++++++++ .../ResearchInstituteBuilder.java | 717 +++++++++ .../ResearchInstituteRecordBuilder.java | 541 +++++++ .../ResearchLaboratoryBuilder.java | 682 +++++++++ .../ResearchUniversityBuilder.java | 641 ++++++++ .../ResourceSharingNetworkBuilder.java | 649 ++++++++ .../ScholarlyPublisherBuilder.java | 757 ++++++++++ .../organizations/ScholarshipFundBuilder.java | 684 +++++++++ .../ScholarshipRecordBuilder.java | 523 +++++++ .../organizations/SchoolLibraryBuilder.java | 751 ++++++++++ .../organizations/SchoolRecordBuilder.java | 515 +++++++ .../organizations/ScienceMuseumBuilder.java | 641 ++++++++ .../organizations/SectionRecordBuilder.java | 555 +++++++ .../organizations/SelfPublisherBuilder.java | 759 ++++++++++ .../organizations/SmallPressBuilder.java | 680 +++++++++ .../organizations/SocietyRecordBuilder.java | 507 +++++++ .../organizations/SpecialLibraryBuilder.java | 721 +++++++++ .../SpecialtyBookstoreBuilder.java | 723 +++++++++ .../SponsorshipRecordBuilder.java | 526 +++++++ .../StandardsOrganizationBuilder.java | 716 +++++++++ .../organizations/StateArchiveBuilder.java | 721 +++++++++ .../StateLibraryAgencyBuilder.java | 682 +++++++++ .../organizations/StateLibraryBuilder.java | 757 ++++++++++ .../StreamingServiceBuilder.java | 711 +++++++++ .../SubjectHeadingAuthorityBuilder.java | 719 +++++++++ .../SubscriptionAgencyBuilder.java | 641 ++++++++ .../SubsidiaryRecordBuilder.java | 567 +++++++ .../TechnicalInstituteBuilder.java | 717 +++++++++ .../organizations/TheaterArchiveBuilder.java | 751 ++++++++++ .../organizations/ThinkTankBuilder.java | 710 +++++++++ .../organizations/TradePublisherBuilder.java | 786 ++++++++++ .../organizations/TrainingNetworkBuilder.java | 716 +++++++++ .../organizations/TrustRecordBuilder.java | 510 +++++++ .../organizations/UnionRecordBuilder.java | 506 +++++++ .../organizations/UnitRecordBuilder.java | 550 +++++++ .../organizations/UsedBookstoreBuilder.java | 725 +++++++++ .../organizations/VirtualLibraryBuilder.java | 680 +++++++++ .../VocationalSchoolBuilder.java | 715 +++++++++ .../organizations/WholesalerBuilder.java | 639 ++++++++ .../library/organizations/ZooBuilder.java | 638 ++++++++ .../persons/ManagingEditorBuilder.java | 843 +++++++++++ .../library/persons/MentorRecordBuilder.java | 509 +++++++ .../library/persons/OfficerRecordBuilder.java | 541 +++++++ .../persons/OperatorRecordBuilder.java | 549 +++++++ .../persons/PatronOfArtsRecordBuilder.java | 548 +++++++ .../library/persons/PatronRecordBuilder.java | 617 ++++++++ .../library/persons/PlannerRecordBuilder.java | 546 +++++++ .../library/persons/PrinterBuilder.java | 790 ++++++++++ .../library/persons/ProofreaderBuilder.java | 826 +++++++++++ .../library/persons/RefereeRecordBuilder.java | 577 ++++++++ .../persons/RepresentativeRecordBuilder.java | 529 +++++++ .../persons/ResearcherRecordBuilder.java | 548 +++++++ .../persons/ResidentRecordBuilder.java | 546 +++++++ .../persons/RestorerRecordBuilder.java | 523 +++++++ .../persons/ReviewerRecordBuilder.java | 509 +++++++ .../library/persons/ScholarRecordBuilder.java | 546 +++++++ .../persons/SpecialistRecordBuilder.java | 599 ++++++++ .../library/persons/SponsorRecordBuilder.java | 513 +++++++ .../persons/StatisticianRecordBuilder.java | 599 ++++++++ .../persons/StrategistRecordBuilder.java | 525 +++++++ .../persons/SubscriptionAgentBuilder.java | 757 ++++++++++ .../persons/SupervisorRecordBuilder.java | 548 +++++++ .../SupplierRepresentativeBuilder.java | 805 ++++++++++ .../persons/TechnicianRecordBuilder.java | 599 ++++++++ .../library/persons/TraineeRecordBuilder.java | 504 +++++++ .../persons/TranslatorRecordBuilder.java | 628 ++++++++ .../library/persons/TrusteeRecordBuilder.java | 509 +++++++ .../library/persons/TypesetterBuilder.java | 867 +++++++++++ .../library/persons/VisitorBuilder.java | 757 ++++++++++ .../library/persons/VisitorRecordBuilder.java | 617 ++++++++ .../persons/VolunteerRecordBuilder.java | 519 +++++++ .../persons/WholesaleAgentBuilder.java | 755 ++++++++++ .../scripts/run_performance_analysis.py | 248 ++++ .../processing/CompilerArgumentsEnum.java | 3 + .../processing/ProcessingContext.java | 5 +- .../logging/ActivePerformanceTracker.java | 253 +++- 211 files changed, 125283 insertions(+), 3 deletions(-) create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MeetingRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MentorshipRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/OpeningRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PerformanceRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PodcastRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PremiereRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PresentationRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PrizeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PublicationRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReadingRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/RecitalRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReleaseRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ResidencyRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ScreeningRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SeminarRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SessionRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ShowRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SimpleTypesBenchmarkBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/StipendRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SymposiumRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TalkRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TelecastRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TransmissionRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TreatyRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebcastRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebinarRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WorkshopRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MangaRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ManuscriptRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MapRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MemorandumRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MicroformRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MonographRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NegativeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NewsletterRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovelRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovellaRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/OctavoRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PamphletRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PeerReviewedJournalBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PhotographRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PoetryRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PostcardRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PosterRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PressReleaseRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ProceedingsRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/QuartoRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ShortStoryRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SlideRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SyllabusRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TeacherManualBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TelegramRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TextbookBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ThesisRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransactionsRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransparencyRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TreatiseRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TypescriptRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/WorksheetRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ZineRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/MountRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PanelRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PartitionRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PassageRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PatioRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PedestalRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PipeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlatformRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlinthRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PodiumRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PorchRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RackRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RoomRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ScreenRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SealRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ShelfRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SignageRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SkylightRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SocketRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StageRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StandRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SwitchRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TableRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TerraceRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TileRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VentRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VerandaRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WindowRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WireRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MapPublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MaritimeMuseumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MediaProviderBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MedicalLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MembershipRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MemorialFundBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MetadataStandardsBodyBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MinistryOfCultureBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalArchiveBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalCulturalOfficeBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MuseumAssociationBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicDistributorBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicPublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicSchoolBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NameAuthorityBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalEndowmentBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NaturalHistoryMuseumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NetworkRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/OnlineBookstoreBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PartnershipRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PerformingArtsCenterBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PermitRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PhotographyArchiveBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PlanetariumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PoetryPressBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationNetworkBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationOfficeBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PressRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalPublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalSchoolBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProgramRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProjectRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublisherRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishersAssociationBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishingServiceProviderBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PurchasingConsortiumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RailwayMuseumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalDistributorBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalPublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegistryRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchAssociationBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchConsortiumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchFoundationBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchLaboratoryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchUniversityBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResourceSharingNetworkBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarlyPublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipFundBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScienceMuseumBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SectionRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SelfPublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SmallPressBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SocietyRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialtyBookstoreBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SponsorshipRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StandardsOrganizationBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateArchiveBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryAgencyBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StreamingServiceBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubjectHeadingAuthorityBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubscriptionAgencyBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubsidiaryRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TechnicalInstituteBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TheaterArchiveBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ThinkTankBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TradePublisherBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrainingNetworkBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrustRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnionRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnitRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UsedBookstoreBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VirtualLibraryBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VocationalSchoolBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/WholesalerBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ZooBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ManagingEditorBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/MentorRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OfficerRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OperatorRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronOfArtsRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PlannerRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PrinterBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ProofreaderBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RefereeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RepresentativeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResearcherRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResidentRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RestorerRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ReviewerRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ScholarRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SpecialistRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SponsorRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StatisticianRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StrategistRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SubscriptionAgentBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupervisorRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupplierRepresentativeBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TechnicianRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TraineeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TranslatorRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TrusteeRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TypesetterBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VolunteerRecordBuilder.java create mode 100644 performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/WholesaleAgentBuilder.java create mode 100644 performance-test/scripts/run_performance_analysis.py diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 624b14ec..04d3981a 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -20,6 +20,7 @@ Simple-builders supports fine-grained configuration through the `@SimpleBuilder. - [Component Filtering](#component-filtering) - [Integration](#integration) - [Reliability](#reliability) + - [Performance Tracking](#performance-tracking) - [Examples](#examples) - [Minimal Builder](#minimal-builder) - [Internal API Builder](#internal-api-builder) @@ -901,6 +902,71 @@ When enabled, builder and Jackson-module generation failures are promoted from c to errors that fail the build. By default, strict mode is disabled and generation failures are reported as warnings so compilation can continue. +--- + +### Performance Tracking + +#### `performanceTracking` + +**Default**: `false` | **Compiler Option**: `-Asimplebuilder.performanceTracking=true|false` + +Enables performance tracking during annotation processing. When enabled, the processor measures +execution times for each processing phase, method generator, builder enhancer, and per-class +processing. A summary report is logged to the compiler output at the end of processing. + +**When enabled**: A hierarchical performance report is printed to the compiler log, including: +- Total processing time and average time per class +- Phase breakdown (Configuration Resolution, Builder Definition Extraction, DTO Mapping, Code Generation) +- Top 20 slowest classes with field and collection counts +- Top 5 slowest MethodGenerators and BuilderEnhancers + +**When disabled** (default): No performance tracking occurs. The `NoOpPerformanceTracker` is used, +which has zero overhead as the JIT compiler eliminates all tracking calls. + +**Example**: +```bash +# Maven +mvn compile -Dsimplebuilder.performanceTracking=true + +# Or via compiler arg +-Asimplebuilder.performanceTracking=true +``` + +--- + +#### `performanceOutputFile` + +**Default**: *(empty, no file output)* | **Compiler Option**: `-Asimplebuilder.performanceOutputFile=path/to/report.json` + +Specifies a file path where the performance report is written as structured JSON. This is useful +for automated performance analysis and comparison across multiple runs. + +**When set**: In addition to the log output, a JSON file is written containing: +- `timestamp` — ISO-8601 timestamp of the report +- `totalClasses` — number of classes processed +- `totalProcessingTimeNanos` / `totalProcessingTimeSeconds` — total processing time +- `averagePerClassMs` — average processing time per class +- `phaseBreakdown` — hierarchical phase timings with elapsed nanos, seconds, and percentages +- `classMetrics` — per-class metrics (name, elapsed nanos/ms, field count, collection count), sorted by elapsed time descending +- `generatorStats` — per-generator stats (name, elapsed nanos, call count, avg ms/call) +- `enhancerStats` — per-enhancer stats (name, elapsed nanos, call count, avg ms/call) + +**When not set** (default): Only the log report is generated; no JSON file is written. + +**Example**: +```bash +# Maven +mvn compile \ + -Dsimplebuilder.performanceTracking=true \ + -Dsimplebuilder.performanceOutputFile=target/performance-report.json + +# Or via compiler arg +-Asimplebuilder.performanceTracking=true +-Asimplebuilder.performanceOutputFile=target/performance-report.json +``` + +**Note**: `performanceTracking` must be enabled for `performanceOutputFile` to have any effect. + ## Examples ### Minimal Builder @@ -1277,6 +1343,10 @@ methodAccess = AccessModifier.PRIVATE # Reliability -Asimplebuilder.strict=ENABLED|DISABLED + +# Performance Tracking +-Asimplebuilder.performanceTracking=true|false +-Asimplebuilder.performanceOutputFile=path/to/report.json ``` ### Complete Options Example diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MeetingRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MeetingRecordBuilder.java new file mode 100644 index 00000000..12fe3904 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MeetingRecordBuilder.java @@ -0,0 +1,617 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.MeetingRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.MeetingRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MeetingRecord result = MeetingRecordBuilder.create()
    + *     .meetingId(UUID.randomUUID())
    + *     .meetingId(() -> UUID.randomUUID())
    + *     .meetingTitle("example value")
    + *     .meetingTitle("Hello %s", "World")
    + *     .meetingTitle(() -> "example value")
    + *     .meetingTitle(sb -> sb.append("text"))
    + *     .meetingDate(LocalDate.now())
    + *     .meetingDate(() -> LocalDate.now())
    + *     .organizer("example value")
    + *     .organizer("Hello %s", "World")
    + *     .organizer(() -> "example value")
    + *     .organizer(sb -> sb.append("text"))
    + *     .attendeeCount(42)
    + *     .attendeeCount(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MeetingRecord.class) +public class MeetingRecordBuilder implements IBuilderBase { + + /** + * Tracked value for meetingId: meetingId. + */ + private TrackedValue meetingId = unsetValue(); + /** + * Tracked value for meetingTitle: meetingTitle. + */ + private TrackedValue meetingTitle = unsetValue(); + /** + * Tracked value for meetingDate: meetingDate. + */ + private TrackedValue meetingDate = unsetValue(); + /** + * Tracked value for organizer: organizer. + */ + private TrackedValue organizer = unsetValue(); + /** + * Tracked value for attendeeCount: attendeeCount. + */ + private TrackedValue attendeeCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.MeetingRecord}. + */ + public MeetingRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.MeetingRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public MeetingRecordBuilder(MeetingRecord instance) { + this.meetingId = initialValue(instance.meetingId()); + this.meetingTitle = initialValue(instance.meetingTitle()); + this.meetingDate = initialValue(instance.meetingDate()); + this.organizer = initialValue(instance.organizer()); + this.attendeeCount = initialValue(instance.attendeeCount()); + this.status = initialValue(instance.status()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.MeetingRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MeetingRecordBuilder builder = MeetingRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.MeetingRecord} + */ + public static MeetingRecordBuilder create() { + return new MeetingRecordBuilder(); + } + + /** + * Sets the value for attendeeCount. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.attendeeCount(42);
    +   * }
    + * + * @param attendeeCount attendeeCount + * @return current instance of builder + */ + public MeetingRecordBuilder attendeeCount(int attendeeCount) { + this.attendeeCount = changedValue(attendeeCount); + return this; + } + + /** + * Sets the value for attendeeCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.attendeeCount(() -> 42);
    +   * }
    + * + * @param attendeeCountSupplier supplier for attendeeCount + * @return current instance of builder + */ + public MeetingRecordBuilder attendeeCount(Supplier attendeeCountSupplier) { + this.attendeeCount = changedValue(attendeeCountSupplier.get()); + return this; + } + + /** + * Sets the value for meetingDate. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingDate(LocalDate.now());
    +   * }
    + * + * @param meetingDate meetingDate + * @return current instance of builder + */ + public MeetingRecordBuilder meetingDate(LocalDate meetingDate) { + this.meetingDate = changedValue(meetingDate); + return this; + } + + /** + * Sets the value for meetingDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingDate(() -> LocalDate.now());
    +   * }
    + * + * @param meetingDateSupplier supplier for meetingDate + * @return current instance of builder + */ + public MeetingRecordBuilder meetingDate(Supplier meetingDateSupplier) { + this.meetingDate = changedValue(meetingDateSupplier.get()); + return this; + } + + /** + * Sets the value for meetingId. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingId(UUID.randomUUID());
    +   * }
    + * + * @param meetingId meetingId + * @return current instance of builder + */ + public MeetingRecordBuilder meetingId(UUID meetingId) { + this.meetingId = changedValue(meetingId); + return this; + } + + /** + * Sets the value for meetingId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingId(() -> UUID.randomUUID());
    +   * }
    + * + * @param meetingIdSupplier supplier for meetingId + * @return current instance of builder + */ + public MeetingRecordBuilder meetingId(Supplier meetingIdSupplier) { + this.meetingId = changedValue(meetingIdSupplier.get()); + return this; + } + + /** + * Sets the value for meetingTitle. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingTitle("example value");
    +   * }
    + * + * @param meetingTitle meetingTitle + * @return current instance of builder + */ + public MeetingRecordBuilder meetingTitle(String meetingTitle) { + this.meetingTitle = changedValue(meetingTitle); + return this; + } + + /** + * Sets the value for meetingTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param meetingTitleStringBuilderConsumer consumer providing an instance of meetingTitle + * @return current instance of builder + */ + public MeetingRecordBuilder meetingTitle(Consumer meetingTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + meetingTitleStringBuilderConsumer.accept(builder); + this.meetingTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for meetingTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingTitle(() -> "example value");
    +   * }
    + * + * @param meetingTitleSupplier supplier for meetingTitle + * @return current instance of builder + */ + public MeetingRecordBuilder meetingTitle(Supplier meetingTitleSupplier) { + this.meetingTitle = changedValue(meetingTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for meetingTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.meetingTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MeetingRecordBuilder meetingTitle(String format, Object... args) { + this.meetingTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for organizer. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizer("example value");
    +   * }
    + * + * @param organizer organizer + * @return current instance of builder + */ + public MeetingRecordBuilder organizer(String organizer) { + this.organizer = changedValue(organizer); + return this; + } + + /** + * Sets the value for organizer by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizer(sb -> sb.append("text"));
    +   * }
    + * + * @param organizerStringBuilderConsumer consumer providing an instance of organizer + * @return current instance of builder + */ + public MeetingRecordBuilder organizer(Consumer organizerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizerStringBuilderConsumer.accept(builder); + this.organizer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organizer by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizer(() -> "example value");
    +   * }
    + * + * @param organizerSupplier supplier for organizer + * @return current instance of builder + */ + public MeetingRecordBuilder organizer(Supplier organizerSupplier) { + this.organizer = changedValue(organizerSupplier.get()); + return this; + } + + /** + * Sets the String value for organizer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MeetingRecordBuilder organizer(String format, Object... args) { + this.organizer = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MeetingRecordBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MeetingRecordBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MeetingRecordBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MeetingRecord#MeetingRecord(UUID, String, LocalDate, String, int, String) MeetingRecord(UUID meetingId, + * String meetingTitle, LocalDate meetingDate, String organizer, int attendeeCount, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MeetingRecordBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MeetingRecordBuilder 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 MeetingRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MeetingRecord result = builder.build();
    +   * }
    + */ + @Override + public MeetingRecord build() { + if (!this.attendeeCount.isSet()) { + throw new IllegalStateException("Required field 'attendeeCount' must be set before calling build()"); + } + if (this.attendeeCount.value() == null) { + throw new IllegalStateException("Field 'attendeeCount' is marked as non-null but null value was provided"); + } + MeetingRecord result = new MeetingRecord(this.meetingId.value(), + this.meetingTitle.value(), + this.meetingDate.value(), + this.organizer.value(), + this.attendeeCount.value(), + this.status.valueOr("SCHEDULED")); + 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("meetingId", this.meetingId) + .append("meetingTitle", this.meetingTitle) + .append("meetingDate", this.meetingDate) + .append("organizer", this.organizer) + .append("attendeeCount", this.attendeeCount) + .append("status", this.status) + .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 MeetingRecord with(Consumer b) { + MeetingRecordBuilder builder; + try { + builder = new MeetingRecordBuilder(MeetingRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MeetingRecordBuilder.With' should only be implemented by classes, which could be casted to 'MeetingRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MeetingRecordBuilder with() { + try { + return new MeetingRecordBuilder(MeetingRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MeetingRecordBuilder.With' should only be implemented by classes, which could be casted to 'MeetingRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MentorshipRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MentorshipRecordBuilder.java new file mode 100644 index 00000000..630ff36f --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/MentorshipRecordBuilder.java @@ -0,0 +1,559 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.MentorshipRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.MentorshipRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MentorshipRecord result = MentorshipRecordBuilder.create()
    + *     .mentorshipId(UUID.randomUUID())
    + *     .mentorshipId(() -> UUID.randomUUID())
    + *     .mentorshipName("example value")
    + *     .mentorshipName("Hello %s", "World")
    + *     .mentorshipName(() -> "example value")
    + *     .mentorshipName(sb -> sb.append("text"))
    + *     .mentor("example value")
    + *     .mentor("Hello %s", "World")
    + *     .mentor(() -> "example value")
    + *     .mentor(sb -> sb.append("text"))
    + *     .mentee("example value")
    + *     .mentee("Hello %s", "World")
    + *     .mentee(() -> "example value")
    + *     .mentee(sb -> sb.append("text"))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MentorshipRecord.class) +public class MentorshipRecordBuilder implements IBuilderBase { + + /** + * Tracked value for mentorshipId: mentorshipId. + */ + private TrackedValue mentorshipId = unsetValue(); + /** + * Tracked value for mentorshipName: mentorshipName. + */ + private TrackedValue mentorshipName = unsetValue(); + /** + * Tracked value for mentor: mentor. + */ + private TrackedValue mentor = unsetValue(); + /** + * Tracked value for mentee: mentee. + */ + private TrackedValue mentee = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.MentorshipRecord}. + */ + public MentorshipRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.MentorshipRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public MentorshipRecordBuilder(MentorshipRecord instance) { + this.mentorshipId = initialValue(instance.mentorshipId()); + this.mentorshipName = initialValue(instance.mentorshipName()); + this.mentor = initialValue(instance.mentor()); + this.mentee = initialValue(instance.mentee()); + this.startDate = initialValue(instance.startDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.MentorshipRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MentorshipRecordBuilder builder = MentorshipRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.MentorshipRecord} + */ + public static MentorshipRecordBuilder create() { + return new MentorshipRecordBuilder(); + } + + /** + * Sets the value for mentee. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentee("example value");
    +   * }
    + * + * @param mentee mentee + * @return current instance of builder + */ + public MentorshipRecordBuilder mentee(String mentee) { + this.mentee = changedValue(mentee); + return this; + } + + /** + * Sets the value for mentee by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentee(sb -> sb.append("text"));
    +   * }
    + * + * @param menteeStringBuilderConsumer consumer providing an instance of mentee + * @return current instance of builder + */ + public MentorshipRecordBuilder mentee(Consumer menteeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + menteeStringBuilderConsumer.accept(builder); + this.mentee = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for mentee by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentee(() -> "example value");
    +   * }
    + * + * @param menteeSupplier supplier for mentee + * @return current instance of builder + */ + public MentorshipRecordBuilder mentee(Supplier menteeSupplier) { + this.mentee = changedValue(menteeSupplier.get()); + return this; + } + + /** + * Sets the String value for mentee by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentee("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MentorshipRecordBuilder mentee(String format, Object... args) { + this.mentee = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for mentor. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentor("example value");
    +   * }
    + * + * @param mentor mentor + * @return current instance of builder + */ + public MentorshipRecordBuilder mentor(String mentor) { + this.mentor = changedValue(mentor); + return this; + } + + /** + * Sets the value for mentor by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentor(sb -> sb.append("text"));
    +   * }
    + * + * @param mentorStringBuilderConsumer consumer providing an instance of mentor + * @return current instance of builder + */ + public MentorshipRecordBuilder mentor(Consumer mentorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + mentorStringBuilderConsumer.accept(builder); + this.mentor = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for mentor by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentor(() -> "example value");
    +   * }
    + * + * @param mentorSupplier supplier for mentor + * @return current instance of builder + */ + public MentorshipRecordBuilder mentor(Supplier mentorSupplier) { + this.mentor = changedValue(mentorSupplier.get()); + return this; + } + + /** + * Sets the String value for mentor by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentor("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MentorshipRecordBuilder mentor(String format, Object... args) { + this.mentor = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for mentorshipId. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorshipId(UUID.randomUUID());
    +   * }
    + * + * @param mentorshipId mentorshipId + * @return current instance of builder + */ + public MentorshipRecordBuilder mentorshipId(UUID mentorshipId) { + this.mentorshipId = changedValue(mentorshipId); + return this; + } + + /** + * Sets the value for mentorshipId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorshipId(() -> UUID.randomUUID());
    +   * }
    + * + * @param mentorshipIdSupplier supplier for mentorshipId + * @return current instance of builder + */ + public MentorshipRecordBuilder mentorshipId(Supplier mentorshipIdSupplier) { + this.mentorshipId = changedValue(mentorshipIdSupplier.get()); + return this; + } + + /** + * Sets the value for mentorshipName. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorshipName("example value");
    +   * }
    + * + * @param mentorshipName mentorshipName + * @return current instance of builder + */ + public MentorshipRecordBuilder mentorshipName(String mentorshipName) { + this.mentorshipName = changedValue(mentorshipName); + return this; + } + + /** + * Sets the value for mentorshipName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorshipName(sb -> sb.append("text"));
    +   * }
    + * + * @param mentorshipNameStringBuilderConsumer consumer providing an instance of mentorshipName + * @return current instance of builder + */ + public MentorshipRecordBuilder mentorshipName(Consumer mentorshipNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + mentorshipNameStringBuilderConsumer.accept(builder); + this.mentorshipName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for mentorshipName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorshipName(() -> "example value");
    +   * }
    + * + * @param mentorshipNameSupplier supplier for mentorshipName + * @return current instance of builder + */ + public MentorshipRecordBuilder mentorshipName(Supplier mentorshipNameSupplier) { + this.mentorshipName = changedValue(mentorshipNameSupplier.get()); + return this; + } + + /** + * Sets the String value for mentorshipName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorshipName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MentorshipRecordBuilder mentorshipName(String format, Object... args) { + this.mentorshipName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public MentorshipRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MentorshipRecord#MentorshipRecord(UUID, String, String, String, LocalDate) MentorshipRecord(UUID + * mentorshipId, String mentorshipName, String mentor, String mentee, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public MentorshipRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + 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 MentorshipRecordBuilder 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 MentorshipRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MentorshipRecord result = builder.build();
    +   * }
    + */ + @Override + public MentorshipRecord build() { + MentorshipRecord result = new MentorshipRecord(this.mentorshipId + .value(), this.mentorshipName.value(), this.mentor.value(), this.mentee.value(), this.startDate.value()); + 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("mentorshipId", this.mentorshipId) + .append("mentorshipName", this.mentorshipName) + .append("mentor", this.mentor) + .append("mentee", this.mentee) + .append("startDate", this.startDate) + .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 MentorshipRecord with(Consumer b) { + MentorshipRecordBuilder builder; + try { + builder = new MentorshipRecordBuilder(MentorshipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MentorshipRecordBuilder.With' should only be implemented by classes, which could be casted to 'MentorshipRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MentorshipRecordBuilder with() { + try { + return new MentorshipRecordBuilder(MentorshipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MentorshipRecordBuilder.With' should only be implemented by classes, which could be casted to 'MentorshipRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/OpeningRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/OpeningRecordBuilder.java new file mode 100644 index 00000000..72ae207a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/OpeningRecordBuilder.java @@ -0,0 +1,471 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.time.LocalTime; +import java.util.UUID; +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.performance_test.library.events.OpeningRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.OpeningRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * OpeningRecord result = OpeningRecordBuilder.create()
    + *     .openingId(UUID.randomUUID())
    + *     .openingId(() -> UUID.randomUUID())
    + *     .openingName("example value")
    + *     .openingName("Hello %s", "World")
    + *     .openingName(() -> "example value")
    + *     .openingName(sb -> sb.append("text"))
    + *     .openingDate(LocalDate.now())
    + *     .openingDate(() -> LocalDate.now())
    + *     .openingTime(LocalTime.now())
    + *     .openingTime(() -> LocalTime.now())
    + *     .expectedGuests(42)
    + *     .expectedGuests(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = OpeningRecord.class) +public class OpeningRecordBuilder implements IBuilderBase { + + /** + * Tracked value for openingId: openingId. + */ + private TrackedValue openingId = unsetValue(); + /** + * Tracked value for openingName: openingName. + */ + private TrackedValue openingName = unsetValue(); + /** + * Tracked value for openingDate: openingDate. + */ + private TrackedValue openingDate = unsetValue(); + /** + * Tracked value for openingTime: openingTime. + */ + private TrackedValue openingTime = unsetValue(); + /** + * Tracked value for expectedGuests: expectedGuests. + */ + private TrackedValue expectedGuests = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.OpeningRecord}. + */ + public OpeningRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.OpeningRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public OpeningRecordBuilder(OpeningRecord instance) { + this.openingId = initialValue(instance.openingId()); + this.openingName = initialValue(instance.openingName()); + this.openingDate = initialValue(instance.openingDate()); + this.openingTime = initialValue(instance.openingTime()); + this.expectedGuests = initialValue(instance.expectedGuests()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.OpeningRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * OpeningRecordBuilder builder = OpeningRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.OpeningRecord} + */ + public static OpeningRecordBuilder create() { + return new OpeningRecordBuilder(); + } + + /** + * Sets the value for expectedGuests. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expectedGuests(42);
    +   * }
    + * + * @param expectedGuests expectedGuests + * @return current instance of builder + */ + public OpeningRecordBuilder expectedGuests(int expectedGuests) { + this.expectedGuests = changedValue(expectedGuests); + return this; + } + + /** + * Sets the value for expectedGuests by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expectedGuests(() -> 42);
    +   * }
    + * + * @param expectedGuestsSupplier supplier for expectedGuests + * @return current instance of builder + */ + public OpeningRecordBuilder expectedGuests(Supplier expectedGuestsSupplier) { + this.expectedGuests = changedValue(expectedGuestsSupplier.get()); + return this; + } + + /** + * Sets the value for openingDate. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingDate(LocalDate.now());
    +   * }
    + * + * @param openingDate openingDate + * @return current instance of builder + */ + public OpeningRecordBuilder openingDate(LocalDate openingDate) { + this.openingDate = changedValue(openingDate); + return this; + } + + /** + * Sets the value for openingDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingDate(() -> LocalDate.now());
    +   * }
    + * + * @param openingDateSupplier supplier for openingDate + * @return current instance of builder + */ + public OpeningRecordBuilder openingDate(Supplier openingDateSupplier) { + this.openingDate = changedValue(openingDateSupplier.get()); + return this; + } + + /** + * Sets the value for openingId. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingId(UUID.randomUUID());
    +   * }
    + * + * @param openingId openingId + * @return current instance of builder + */ + public OpeningRecordBuilder openingId(UUID openingId) { + this.openingId = changedValue(openingId); + return this; + } + + /** + * Sets the value for openingId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingId(() -> UUID.randomUUID());
    +   * }
    + * + * @param openingIdSupplier supplier for openingId + * @return current instance of builder + */ + public OpeningRecordBuilder openingId(Supplier openingIdSupplier) { + this.openingId = changedValue(openingIdSupplier.get()); + return this; + } + + /** + * Sets the value for openingName. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingName("example value");
    +   * }
    + * + * @param openingName openingName + * @return current instance of builder + */ + public OpeningRecordBuilder openingName(String openingName) { + this.openingName = changedValue(openingName); + return this; + } + + /** + * Sets the value for openingName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingName(sb -> sb.append("text"));
    +   * }
    + * + * @param openingNameStringBuilderConsumer consumer providing an instance of openingName + * @return current instance of builder + */ + public OpeningRecordBuilder openingName(Consumer openingNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + openingNameStringBuilderConsumer.accept(builder); + this.openingName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for openingName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingName(() -> "example value");
    +   * }
    + * + * @param openingNameSupplier supplier for openingName + * @return current instance of builder + */ + public OpeningRecordBuilder openingName(Supplier openingNameSupplier) { + this.openingName = changedValue(openingNameSupplier.get()); + return this; + } + + /** + * Sets the String value for openingName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OpeningRecordBuilder openingName(String format, Object... args) { + this.openingName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for openingTime. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingTime(LocalTime.now());
    +   * }
    + * + * @param openingTime openingTime + * @return current instance of builder + */ + public OpeningRecordBuilder openingTime(LocalTime openingTime) { + this.openingTime = changedValue(openingTime); + return this; + } + + /** + * Sets the value for openingTime by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OpeningRecord#OpeningRecord(UUID, String, LocalDate, LocalTime, int) + * OpeningRecord(UUID openingId, String openingName, LocalDate openingDate, LocalTime openingTime, int + * expectedGuests)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.openingTime(() -> LocalTime.now());
    +   * }
    + * + * @param openingTimeSupplier supplier for openingTime + * @return current instance of builder + */ + public OpeningRecordBuilder openingTime(Supplier openingTimeSupplier) { + this.openingTime = changedValue(openingTimeSupplier.get()); + 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 OpeningRecordBuilder 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 OpeningRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * OpeningRecord result = builder.build();
    +   * }
    + */ + @Override + public OpeningRecord build() { + if (!this.expectedGuests.isSet()) { + throw new IllegalStateException("Required field 'expectedGuests' must be set before calling build()"); + } + if (this.expectedGuests.value() == null) { + throw new IllegalStateException("Field 'expectedGuests' is marked as non-null but null value was provided"); + } + OpeningRecord result = new OpeningRecord(this.openingId.value(), + this.openingName.value(), + this.openingDate.value(), + this.openingTime.value(), + this.expectedGuests.value()); + 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("openingId", this.openingId) + .append("openingName", this.openingName) + .append("openingDate", this.openingDate) + .append("openingTime", this.openingTime) + .append("expectedGuests", this.expectedGuests) + .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 OpeningRecord with(Consumer b) { + OpeningRecordBuilder builder; + try { + builder = new OpeningRecordBuilder(OpeningRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OpeningRecordBuilder.With' should only be implemented by classes, which could be casted to 'OpeningRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default OpeningRecordBuilder with() { + try { + return new OpeningRecordBuilder(OpeningRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OpeningRecordBuilder.With' should only be implemented by classes, which could be casted to 'OpeningRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PerformanceRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PerformanceRecordBuilder.java new file mode 100644 index 00000000..ab0803a8 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PerformanceRecordBuilder.java @@ -0,0 +1,520 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.PerformanceRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.PerformanceRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PerformanceRecord result = PerformanceRecordBuilder.create()
    + *     .performanceId(UUID.randomUUID())
    + *     .performanceId(() -> UUID.randomUUID())
    + *     .performanceTitle("example value")
    + *     .performanceTitle("Hello %s", "World")
    + *     .performanceTitle(() -> "example value")
    + *     .performanceTitle(sb -> sb.append("text"))
    + *     .performer("example value")
    + *     .performer("Hello %s", "World")
    + *     .performer(() -> "example value")
    + *     .performer(sb -> sb.append("text"))
    + *     .performanceDate(LocalDate.now())
    + *     .performanceDate(() -> LocalDate.now())
    + *     .durationMinutes(42)
    + *     .durationMinutes(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PerformanceRecord.class) +public class PerformanceRecordBuilder implements IBuilderBase { + + /** + * Tracked value for performanceId: performanceId. + */ + private TrackedValue performanceId = unsetValue(); + /** + * Tracked value for performanceTitle: performanceTitle. + */ + private TrackedValue performanceTitle = unsetValue(); + /** + * Tracked value for performer: performer. + */ + private TrackedValue performer = unsetValue(); + /** + * Tracked value for performanceDate: performanceDate. + */ + private TrackedValue performanceDate = unsetValue(); + /** + * Tracked value for durationMinutes: durationMinutes. + */ + private TrackedValue durationMinutes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PerformanceRecord}. + */ + public PerformanceRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PerformanceRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PerformanceRecordBuilder(PerformanceRecord instance) { + this.performanceId = initialValue(instance.performanceId()); + this.performanceTitle = initialValue(instance.performanceTitle()); + this.performer = initialValue(instance.performer()); + this.performanceDate = initialValue(instance.performanceDate()); + this.durationMinutes = initialValue(instance.durationMinutes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PerformanceRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PerformanceRecordBuilder builder = PerformanceRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PerformanceRecord} + */ + public static PerformanceRecordBuilder create() { + return new PerformanceRecordBuilder(); + } + + /** + * Sets the value for durationMinutes. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(42);
    +   * }
    + * + * @param durationMinutes durationMinutes + * @return current instance of builder + */ + public PerformanceRecordBuilder durationMinutes(int durationMinutes) { + this.durationMinutes = changedValue(durationMinutes); + return this; + } + + /** + * Sets the value for durationMinutes by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(() -> 42);
    +   * }
    + * + * @param durationMinutesSupplier supplier for durationMinutes + * @return current instance of builder + */ + public PerformanceRecordBuilder durationMinutes(Supplier durationMinutesSupplier) { + this.durationMinutes = changedValue(durationMinutesSupplier.get()); + return this; + } + + /** + * Sets the value for performanceDate. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceDate(LocalDate.now());
    +   * }
    + * + * @param performanceDate performanceDate + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceDate(LocalDate performanceDate) { + this.performanceDate = changedValue(performanceDate); + return this; + } + + /** + * Sets the value for performanceDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceDate(() -> LocalDate.now());
    +   * }
    + * + * @param performanceDateSupplier supplier for performanceDate + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceDate(Supplier performanceDateSupplier) { + this.performanceDate = changedValue(performanceDateSupplier.get()); + return this; + } + + /** + * Sets the value for performanceId. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceId(UUID.randomUUID());
    +   * }
    + * + * @param performanceId performanceId + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceId(UUID performanceId) { + this.performanceId = changedValue(performanceId); + return this; + } + + /** + * Sets the value for performanceId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceId(() -> UUID.randomUUID());
    +   * }
    + * + * @param performanceIdSupplier supplier for performanceId + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceId(Supplier performanceIdSupplier) { + this.performanceId = changedValue(performanceIdSupplier.get()); + return this; + } + + /** + * Sets the value for performanceTitle. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceTitle("example value");
    +   * }
    + * + * @param performanceTitle performanceTitle + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceTitle(String performanceTitle) { + this.performanceTitle = changedValue(performanceTitle); + return this; + } + + /** + * Sets the value for performanceTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param performanceTitleStringBuilderConsumer consumer providing an instance of performanceTitle + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceTitle(Consumer performanceTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + performanceTitleStringBuilderConsumer.accept(builder); + this.performanceTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for performanceTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceTitle(() -> "example value");
    +   * }
    + * + * @param performanceTitleSupplier supplier for performanceTitle + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceTitle(Supplier performanceTitleSupplier) { + this.performanceTitle = changedValue(performanceTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for performanceTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PerformanceRecordBuilder performanceTitle(String format, Object... args) { + this.performanceTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for performer. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer("example value");
    +   * }
    + * + * @param performer performer + * @return current instance of builder + */ + public PerformanceRecordBuilder performer(String performer) { + this.performer = changedValue(performer); + return this; + } + + /** + * Sets the value for performer by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer(sb -> sb.append("text"));
    +   * }
    + * + * @param performerStringBuilderConsumer consumer providing an instance of performer + * @return current instance of builder + */ + public PerformanceRecordBuilder performer(Consumer performerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + performerStringBuilderConsumer.accept(builder); + this.performer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for performer by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer(() -> "example value");
    +   * }
    + * + * @param performerSupplier supplier for performer + * @return current instance of builder + */ + public PerformanceRecordBuilder performer(Supplier performerSupplier) { + this.performer = changedValue(performerSupplier.get()); + return this; + } + + /** + * Sets the String value for performer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PerformanceRecord#PerformanceRecord(UUID, String, String, LocalDate, int) PerformanceRecord(UUID + * performanceId, String performanceTitle, String performer, LocalDate performanceDate, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PerformanceRecordBuilder performer(String format, Object... args) { + this.performer = changedValue(String.format(format, args)); + 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 PerformanceRecordBuilder 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 PerformanceRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PerformanceRecord result = builder.build();
    +   * }
    + */ + @Override + public PerformanceRecord build() { + if (!this.durationMinutes.isSet()) { + throw new IllegalStateException("Required field 'durationMinutes' must be set before calling build()"); + } + if (this.durationMinutes.value() == null) { + throw new IllegalStateException("Field 'durationMinutes' is marked as non-null but null value was provided"); + } + PerformanceRecord result = new PerformanceRecord(this.performanceId.value(), + this.performanceTitle.value(), + this.performer.value(), + this.performanceDate.value(), + this.durationMinutes.value()); + 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("performanceId", this.performanceId) + .append("performanceTitle", this.performanceTitle) + .append("performer", this.performer) + .append("performanceDate", this.performanceDate) + .append("durationMinutes", this.durationMinutes) + .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 PerformanceRecord with(Consumer b) { + PerformanceRecordBuilder builder; + try { + builder = new PerformanceRecordBuilder(PerformanceRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PerformanceRecordBuilder.With' should only be implemented by classes, which could be casted to 'PerformanceRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PerformanceRecordBuilder with() { + try { + return new PerformanceRecordBuilder(PerformanceRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PerformanceRecordBuilder.With' should only be implemented by classes, which could be casted to 'PerformanceRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PodcastRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PodcastRecordBuilder.java new file mode 100644 index 00000000..0fb12c7e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PodcastRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.UUID; +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.performance_test.library.events.PodcastRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.PodcastRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PodcastRecord result = PodcastRecordBuilder.create()
    + *     .podcastId(UUID.randomUUID())
    + *     .podcastId(() -> UUID.randomUUID())
    + *     .podcastTitle("example value")
    + *     .podcastTitle("Hello %s", "World")
    + *     .podcastTitle(() -> "example value")
    + *     .podcastTitle(sb -> sb.append("text"))
    + *     .host("example value")
    + *     .host("Hello %s", "World")
    + *     .host(() -> "example value")
    + *     .host(sb -> sb.append("text"))
    + *     .episodeNumber(42)
    + *     .episodeNumber(() -> 42)
    + *     .durationMinutes(42)
    + *     .durationMinutes(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PodcastRecord.class) +public class PodcastRecordBuilder implements IBuilderBase { + + /** + * Tracked value for podcastId: podcastId. + */ + private TrackedValue podcastId = unsetValue(); + /** + * Tracked value for podcastTitle: podcastTitle. + */ + private TrackedValue podcastTitle = unsetValue(); + /** + * Tracked value for host: host. + */ + private TrackedValue host = unsetValue(); + /** + * Tracked value for episodeNumber: episodeNumber. + */ + private TrackedValue episodeNumber = unsetValue(); + /** + * Tracked value for durationMinutes: durationMinutes. + */ + private TrackedValue durationMinutes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PodcastRecord}. + */ + public PodcastRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PodcastRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PodcastRecordBuilder(PodcastRecord instance) { + this.podcastId = initialValue(instance.podcastId()); + this.podcastTitle = initialValue(instance.podcastTitle()); + this.host = initialValue(instance.host()); + this.episodeNumber = initialValue(instance.episodeNumber()); + this.durationMinutes = initialValue(instance.durationMinutes()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PodcastRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PodcastRecordBuilder builder = PodcastRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PodcastRecord} + */ + public static PodcastRecordBuilder create() { + return new PodcastRecordBuilder(); + } + + /** + * Sets the value for durationMinutes. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(42);
    +   * }
    + * + * @param durationMinutes durationMinutes + * @return current instance of builder + */ + public PodcastRecordBuilder durationMinutes(int durationMinutes) { + this.durationMinutes = changedValue(durationMinutes); + return this; + } + + /** + * Sets the value for durationMinutes by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(() -> 42);
    +   * }
    + * + * @param durationMinutesSupplier supplier for durationMinutes + * @return current instance of builder + */ + public PodcastRecordBuilder durationMinutes(Supplier durationMinutesSupplier) { + this.durationMinutes = changedValue(durationMinutesSupplier.get()); + return this; + } + + /** + * Sets the value for episodeNumber. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.episodeNumber(42);
    +   * }
    + * + * @param episodeNumber episodeNumber + * @return current instance of builder + */ + public PodcastRecordBuilder episodeNumber(int episodeNumber) { + this.episodeNumber = changedValue(episodeNumber); + return this; + } + + /** + * Sets the value for episodeNumber by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.episodeNumber(() -> 42);
    +   * }
    + * + * @param episodeNumberSupplier supplier for episodeNumber + * @return current instance of builder + */ + public PodcastRecordBuilder episodeNumber(Supplier episodeNumberSupplier) { + this.episodeNumber = changedValue(episodeNumberSupplier.get()); + return this; + } + + /** + * Sets the value for host. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.host("example value");
    +   * }
    + * + * @param host host + * @return current instance of builder + */ + public PodcastRecordBuilder host(String host) { + this.host = changedValue(host); + return this; + } + + /** + * Sets the value for host by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.host(sb -> sb.append("text"));
    +   * }
    + * + * @param hostStringBuilderConsumer consumer providing an instance of host + * @return current instance of builder + */ + public PodcastRecordBuilder host(Consumer hostStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + hostStringBuilderConsumer.accept(builder); + this.host = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for host by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.host(() -> "example value");
    +   * }
    + * + * @param hostSupplier supplier for host + * @return current instance of builder + */ + public PodcastRecordBuilder host(Supplier hostSupplier) { + this.host = changedValue(hostSupplier.get()); + return this; + } + + /** + * Sets the String value for host by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.host("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PodcastRecordBuilder host(String format, Object... args) { + this.host = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for podcastId. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podcastId(UUID.randomUUID());
    +   * }
    + * + * @param podcastId podcastId + * @return current instance of builder + */ + public PodcastRecordBuilder podcastId(UUID podcastId) { + this.podcastId = changedValue(podcastId); + return this; + } + + /** + * Sets the value for podcastId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podcastId(() -> UUID.randomUUID());
    +   * }
    + * + * @param podcastIdSupplier supplier for podcastId + * @return current instance of builder + */ + public PodcastRecordBuilder podcastId(Supplier podcastIdSupplier) { + this.podcastId = changedValue(podcastIdSupplier.get()); + return this; + } + + /** + * Sets the value for podcastTitle. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podcastTitle("example value");
    +   * }
    + * + * @param podcastTitle podcastTitle + * @return current instance of builder + */ + public PodcastRecordBuilder podcastTitle(String podcastTitle) { + this.podcastTitle = changedValue(podcastTitle); + return this; + } + + /** + * Sets the value for podcastTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podcastTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param podcastTitleStringBuilderConsumer consumer providing an instance of podcastTitle + * @return current instance of builder + */ + public PodcastRecordBuilder podcastTitle(Consumer podcastTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + podcastTitleStringBuilderConsumer.accept(builder); + this.podcastTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for podcastTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podcastTitle(() -> "example value");
    +   * }
    + * + * @param podcastTitleSupplier supplier for podcastTitle + * @return current instance of builder + */ + public PodcastRecordBuilder podcastTitle(Supplier podcastTitleSupplier) { + this.podcastTitle = changedValue(podcastTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for podcastTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PodcastRecord#PodcastRecord(UUID, String, String, int, int) + * PodcastRecord(UUID podcastId, String podcastTitle, String host, int episodeNumber, int durationMinutes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podcastTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PodcastRecordBuilder podcastTitle(String format, Object... args) { + this.podcastTitle = changedValue(String.format(format, args)); + 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 PodcastRecordBuilder 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 PodcastRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PodcastRecord result = builder.build();
    +   * }
    + */ + @Override + public PodcastRecord build() { + if (!this.episodeNumber.isSet()) { + throw new IllegalStateException("Required field 'episodeNumber' must be set before calling build()"); + } + if (this.episodeNumber.value() == null) { + throw new IllegalStateException("Field 'episodeNumber' is marked as non-null but null value was provided"); + } + if (!this.durationMinutes.isSet()) { + throw new IllegalStateException("Required field 'durationMinutes' must be set before calling build()"); + } + if (this.durationMinutes.value() == null) { + throw new IllegalStateException("Field 'durationMinutes' is marked as non-null but null value was provided"); + } + PodcastRecord result = new PodcastRecord(this.podcastId.value(), + this.podcastTitle.value(), + this.host.value(), + this.episodeNumber.value(), + this.durationMinutes.value()); + 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("podcastId", this.podcastId) + .append("podcastTitle", this.podcastTitle) + .append("host", this.host) + .append("episodeNumber", this.episodeNumber) + .append("durationMinutes", this.durationMinutes) + .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 PodcastRecord with(Consumer b) { + PodcastRecordBuilder builder; + try { + builder = new PodcastRecordBuilder(PodcastRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PodcastRecordBuilder.With' should only be implemented by classes, which could be casted to 'PodcastRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PodcastRecordBuilder with() { + try { + return new PodcastRecordBuilder(PodcastRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PodcastRecordBuilder.With' should only be implemented by classes, which could be casted to 'PodcastRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PremiereRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PremiereRecordBuilder.java new file mode 100644 index 00000000..b7d0c9b9 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PremiereRecordBuilder.java @@ -0,0 +1,504 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.PremiereRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.PremiereRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PremiereRecord result = PremiereRecordBuilder.create()
    + *     .premiereId(UUID.randomUUID())
    + *     .premiereId(() -> UUID.randomUUID())
    + *     .premiereTitle("example value")
    + *     .premiereTitle("Hello %s", "World")
    + *     .premiereTitle(() -> "example value")
    + *     .premiereTitle(sb -> sb.append("text"))
    + *     .premiereDate(LocalDate.now())
    + *     .premiereDate(() -> LocalDate.now())
    + *     .director("example value")
    + *     .director("Hello %s", "World")
    + *     .director(() -> "example value")
    + *     .director(sb -> sb.append("text"))
    + *     .guestCount(42)
    + *     .guestCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PremiereRecord.class) +public class PremiereRecordBuilder implements IBuilderBase { + + /** + * Tracked value for premiereId: premiereId. + */ + private TrackedValue premiereId = unsetValue(); + /** + * Tracked value for premiereTitle: premiereTitle. + */ + private TrackedValue premiereTitle = unsetValue(); + /** + * Tracked value for premiereDate: premiereDate. + */ + private TrackedValue premiereDate = unsetValue(); + /** + * Tracked value for director: director. + */ + private TrackedValue director = unsetValue(); + /** + * Tracked value for guestCount: guestCount. + */ + private TrackedValue guestCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PremiereRecord}. + */ + public PremiereRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PremiereRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PremiereRecordBuilder(PremiereRecord instance) { + this.premiereId = initialValue(instance.premiereId()); + this.premiereTitle = initialValue(instance.premiereTitle()); + this.premiereDate = initialValue(instance.premiereDate()); + this.director = initialValue(instance.director()); + this.guestCount = initialValue(instance.guestCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PremiereRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PremiereRecordBuilder builder = PremiereRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PremiereRecord} + */ + public static PremiereRecordBuilder create() { + return new PremiereRecordBuilder(); + } + + /** + * Sets the value for director. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.director("example value");
    +   * }
    + * + * @param director director + * @return current instance of builder + */ + public PremiereRecordBuilder director(String director) { + this.director = changedValue(director); + return this; + } + + /** + * Sets the value for director by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.director(sb -> sb.append("text"));
    +   * }
    + * + * @param directorStringBuilderConsumer consumer providing an instance of director + * @return current instance of builder + */ + public PremiereRecordBuilder director(Consumer directorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + directorStringBuilderConsumer.accept(builder); + this.director = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for director by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.director(() -> "example value");
    +   * }
    + * + * @param directorSupplier supplier for director + * @return current instance of builder + */ + public PremiereRecordBuilder director(Supplier directorSupplier) { + this.director = changedValue(directorSupplier.get()); + return this; + } + + /** + * Sets the String value for director by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.director("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PremiereRecordBuilder director(String format, Object... args) { + this.director = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for guestCount. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.guestCount(42);
    +   * }
    + * + * @param guestCount guestCount + * @return current instance of builder + */ + public PremiereRecordBuilder guestCount(int guestCount) { + this.guestCount = changedValue(guestCount); + return this; + } + + /** + * Sets the value for guestCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.guestCount(() -> 42);
    +   * }
    + * + * @param guestCountSupplier supplier for guestCount + * @return current instance of builder + */ + public PremiereRecordBuilder guestCount(Supplier guestCountSupplier) { + this.guestCount = changedValue(guestCountSupplier.get()); + return this; + } + + /** + * Sets the value for premiereDate. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereDate(LocalDate.now());
    +   * }
    + * + * @param premiereDate premiereDate + * @return current instance of builder + */ + public PremiereRecordBuilder premiereDate(LocalDate premiereDate) { + this.premiereDate = changedValue(premiereDate); + return this; + } + + /** + * Sets the value for premiereDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereDate(() -> LocalDate.now());
    +   * }
    + * + * @param premiereDateSupplier supplier for premiereDate + * @return current instance of builder + */ + public PremiereRecordBuilder premiereDate(Supplier premiereDateSupplier) { + this.premiereDate = changedValue(premiereDateSupplier.get()); + return this; + } + + /** + * Sets the value for premiereId. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereId(UUID.randomUUID());
    +   * }
    + * + * @param premiereId premiereId + * @return current instance of builder + */ + public PremiereRecordBuilder premiereId(UUID premiereId) { + this.premiereId = changedValue(premiereId); + return this; + } + + /** + * Sets the value for premiereId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereId(() -> UUID.randomUUID());
    +   * }
    + * + * @param premiereIdSupplier supplier for premiereId + * @return current instance of builder + */ + public PremiereRecordBuilder premiereId(Supplier premiereIdSupplier) { + this.premiereId = changedValue(premiereIdSupplier.get()); + return this; + } + + /** + * Sets the value for premiereTitle. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereTitle("example value");
    +   * }
    + * + * @param premiereTitle premiereTitle + * @return current instance of builder + */ + public PremiereRecordBuilder premiereTitle(String premiereTitle) { + this.premiereTitle = changedValue(premiereTitle); + return this; + } + + /** + * Sets the value for premiereTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param premiereTitleStringBuilderConsumer consumer providing an instance of premiereTitle + * @return current instance of builder + */ + public PremiereRecordBuilder premiereTitle(Consumer premiereTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + premiereTitleStringBuilderConsumer.accept(builder); + this.premiereTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for premiereTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereTitle(() -> "example value");
    +   * }
    + * + * @param premiereTitleSupplier supplier for premiereTitle + * @return current instance of builder + */ + public PremiereRecordBuilder premiereTitle(Supplier premiereTitleSupplier) { + this.premiereTitle = changedValue(premiereTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for premiereTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PremiereRecord#PremiereRecord(UUID, String, LocalDate, String, int) + * PremiereRecord(UUID premiereId, String premiereTitle, LocalDate premiereDate, String director, int guestCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.premiereTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PremiereRecordBuilder premiereTitle(String format, Object... args) { + this.premiereTitle = changedValue(String.format(format, args)); + 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 PremiereRecordBuilder 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 PremiereRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PremiereRecord result = builder.build();
    +   * }
    + */ + @Override + public PremiereRecord build() { + if (!this.guestCount.isSet()) { + throw new IllegalStateException("Required field 'guestCount' must be set before calling build()"); + } + if (this.guestCount.value() == null) { + throw new IllegalStateException("Field 'guestCount' is marked as non-null but null value was provided"); + } + PremiereRecord result = new PremiereRecord(this.premiereId.value(), + this.premiereTitle.value(), + this.premiereDate.value(), + this.director.value(), + this.guestCount.value()); + 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("premiereId", this.premiereId) + .append("premiereTitle", this.premiereTitle) + .append("premiereDate", this.premiereDate) + .append("director", this.director) + .append("guestCount", this.guestCount) + .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 PremiereRecord with(Consumer b) { + PremiereRecordBuilder builder; + try { + builder = new PremiereRecordBuilder(PremiereRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PremiereRecordBuilder.With' should only be implemented by classes, which could be casted to 'PremiereRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PremiereRecordBuilder with() { + try { + return new PremiereRecordBuilder(PremiereRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PremiereRecordBuilder.With' should only be implemented by classes, which could be casted to 'PremiereRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PresentationRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PresentationRecordBuilder.java new file mode 100644 index 00000000..33b0d76b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PresentationRecordBuilder.java @@ -0,0 +1,520 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.PresentationRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.PresentationRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PresentationRecord result = PresentationRecordBuilder.create()
    + *     .presentationId(UUID.randomUUID())
    + *     .presentationId(() -> UUID.randomUUID())
    + *     .presentationTitle("example value")
    + *     .presentationTitle("Hello %s", "World")
    + *     .presentationTitle(() -> "example value")
    + *     .presentationTitle(sb -> sb.append("text"))
    + *     .presenter("example value")
    + *     .presenter("Hello %s", "World")
    + *     .presenter(() -> "example value")
    + *     .presenter(sb -> sb.append("text"))
    + *     .slideCount(42)
    + *     .slideCount(() -> 42)
    + *     .presentationDate(LocalDate.now())
    + *     .presentationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PresentationRecord.class) +public class PresentationRecordBuilder implements IBuilderBase { + + /** + * Tracked value for presentationId: presentationId. + */ + private TrackedValue presentationId = unsetValue(); + /** + * Tracked value for presentationTitle: presentationTitle. + */ + private TrackedValue presentationTitle = unsetValue(); + /** + * Tracked value for presenter: presenter. + */ + private TrackedValue presenter = unsetValue(); + /** + * Tracked value for slideCount: slideCount. + */ + private TrackedValue slideCount = unsetValue(); + /** + * Tracked value for presentationDate: presentationDate. + */ + private TrackedValue presentationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PresentationRecord}. + */ + public PresentationRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PresentationRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PresentationRecordBuilder(PresentationRecord instance) { + this.presentationId = initialValue(instance.presentationId()); + this.presentationTitle = initialValue(instance.presentationTitle()); + this.presenter = initialValue(instance.presenter()); + this.slideCount = initialValue(instance.slideCount()); + this.presentationDate = initialValue(instance.presentationDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PresentationRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PresentationRecordBuilder builder = PresentationRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PresentationRecord} + */ + public static PresentationRecordBuilder create() { + return new PresentationRecordBuilder(); + } + + /** + * Sets the value for presentationDate. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationDate(LocalDate.now());
    +   * }
    + * + * @param presentationDate presentationDate + * @return current instance of builder + */ + public PresentationRecordBuilder presentationDate(LocalDate presentationDate) { + this.presentationDate = changedValue(presentationDate); + return this; + } + + /** + * Sets the value for presentationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationDate(() -> LocalDate.now());
    +   * }
    + * + * @param presentationDateSupplier supplier for presentationDate + * @return current instance of builder + */ + public PresentationRecordBuilder presentationDate(Supplier presentationDateSupplier) { + this.presentationDate = changedValue(presentationDateSupplier.get()); + return this; + } + + /** + * Sets the value for presentationId. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationId(UUID.randomUUID());
    +   * }
    + * + * @param presentationId presentationId + * @return current instance of builder + */ + public PresentationRecordBuilder presentationId(UUID presentationId) { + this.presentationId = changedValue(presentationId); + return this; + } + + /** + * Sets the value for presentationId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationId(() -> UUID.randomUUID());
    +   * }
    + * + * @param presentationIdSupplier supplier for presentationId + * @return current instance of builder + */ + public PresentationRecordBuilder presentationId(Supplier presentationIdSupplier) { + this.presentationId = changedValue(presentationIdSupplier.get()); + return this; + } + + /** + * Sets the value for presentationTitle. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationTitle("example value");
    +   * }
    + * + * @param presentationTitle presentationTitle + * @return current instance of builder + */ + public PresentationRecordBuilder presentationTitle(String presentationTitle) { + this.presentationTitle = changedValue(presentationTitle); + return this; + } + + /** + * Sets the value for presentationTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param presentationTitleStringBuilderConsumer consumer providing an instance of presentationTitle + * @return current instance of builder + */ + public PresentationRecordBuilder presentationTitle(Consumer presentationTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + presentationTitleStringBuilderConsumer.accept(builder); + this.presentationTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for presentationTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationTitle(() -> "example value");
    +   * }
    + * + * @param presentationTitleSupplier supplier for presentationTitle + * @return current instance of builder + */ + public PresentationRecordBuilder presentationTitle(Supplier presentationTitleSupplier) { + this.presentationTitle = changedValue(presentationTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for presentationTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presentationTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PresentationRecordBuilder presentationTitle(String format, Object... args) { + this.presentationTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for presenter. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter("example value");
    +   * }
    + * + * @param presenter presenter + * @return current instance of builder + */ + public PresentationRecordBuilder presenter(String presenter) { + this.presenter = changedValue(presenter); + return this; + } + + /** + * Sets the value for presenter by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter(sb -> sb.append("text"));
    +   * }
    + * + * @param presenterStringBuilderConsumer consumer providing an instance of presenter + * @return current instance of builder + */ + public PresentationRecordBuilder presenter(Consumer presenterStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + presenterStringBuilderConsumer.accept(builder); + this.presenter = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for presenter by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter(() -> "example value");
    +   * }
    + * + * @param presenterSupplier supplier for presenter + * @return current instance of builder + */ + public PresentationRecordBuilder presenter(Supplier presenterSupplier) { + this.presenter = changedValue(presenterSupplier.get()); + return this; + } + + /** + * Sets the String value for presenter by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PresentationRecordBuilder presenter(String format, Object... args) { + this.presenter = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for slideCount. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.slideCount(42);
    +   * }
    + * + * @param slideCount slideCount + * @return current instance of builder + */ + public PresentationRecordBuilder slideCount(int slideCount) { + this.slideCount = changedValue(slideCount); + return this; + } + + /** + * Sets the value for slideCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PresentationRecord#PresentationRecord(UUID, String, String, int, LocalDate) PresentationRecord(UUID + * presentationId, String presentationTitle, String presenter, int slideCount, LocalDate presentationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.slideCount(() -> 42);
    +   * }
    + * + * @param slideCountSupplier supplier for slideCount + * @return current instance of builder + */ + public PresentationRecordBuilder slideCount(Supplier slideCountSupplier) { + this.slideCount = changedValue(slideCountSupplier.get()); + 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 PresentationRecordBuilder 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 PresentationRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PresentationRecord result = builder.build();
    +   * }
    + */ + @Override + public PresentationRecord build() { + if (!this.slideCount.isSet()) { + throw new IllegalStateException("Required field 'slideCount' must be set before calling build()"); + } + if (this.slideCount.value() == null) { + throw new IllegalStateException("Field 'slideCount' is marked as non-null but null value was provided"); + } + PresentationRecord result = new PresentationRecord(this.presentationId.value(), + this.presentationTitle.value(), + this.presenter.value(), + this.slideCount.value(), + this.presentationDate.value()); + 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("presentationId", this.presentationId) + .append("presentationTitle", this.presentationTitle) + .append("presenter", this.presenter) + .append("slideCount", this.slideCount) + .append("presentationDate", this.presentationDate) + .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 PresentationRecord with(Consumer b) { + PresentationRecordBuilder builder; + try { + builder = new PresentationRecordBuilder(PresentationRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PresentationRecordBuilder.With' should only be implemented by classes, which could be casted to 'PresentationRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PresentationRecordBuilder with() { + try { + return new PresentationRecordBuilder(PresentationRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PresentationRecordBuilder.With' should only be implemented by classes, which could be casted to 'PresentationRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PrizeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PrizeRecordBuilder.java new file mode 100644 index 00000000..5c8f83b5 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PrizeRecordBuilder.java @@ -0,0 +1,496 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.PrizeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.PrizeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PrizeRecord result = PrizeRecordBuilder.create()
    + *     .prizeId(UUID.randomUUID())
    + *     .prizeId(() -> UUID.randomUUID())
    + *     .prizeName("example value")
    + *     .prizeName("Hello %s", "World")
    + *     .prizeName(() -> "example value")
    + *     .prizeName(sb -> sb.append("text"))
    + *     .winner("example value")
    + *     .winner("Hello %s", "World")
    + *     .winner(() -> "example value")
    + *     .winner(sb -> sb.append("text"))
    + *     .prizeDate(LocalDate.now())
    + *     .prizeDate(() -> LocalDate.now())
    + *     .prizeValue(BigDecimal.valueOf(3.14))
    + *     .prizeValue(() -> BigDecimal.valueOf(3.14))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PrizeRecord.class) +public class PrizeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for prizeId: prizeId. + */ + private TrackedValue prizeId = unsetValue(); + /** + * Tracked value for prizeName: prizeName. + */ + private TrackedValue prizeName = unsetValue(); + /** + * Tracked value for winner: winner. + */ + private TrackedValue winner = unsetValue(); + /** + * Tracked value for prizeDate: prizeDate. + */ + private TrackedValue prizeDate = unsetValue(); + /** + * Tracked value for prizeValue: prizeValue. + */ + private TrackedValue prizeValue = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PrizeRecord}. + */ + public PrizeRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PrizeRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PrizeRecordBuilder(PrizeRecord instance) { + this.prizeId = initialValue(instance.prizeId()); + this.prizeName = initialValue(instance.prizeName()); + this.winner = initialValue(instance.winner()); + this.prizeDate = initialValue(instance.prizeDate()); + this.prizeValue = initialValue(instance.prizeValue()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PrizeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PrizeRecordBuilder builder = PrizeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PrizeRecord} + */ + public static PrizeRecordBuilder create() { + return new PrizeRecordBuilder(); + } + + /** + * Sets the value for prizeDate. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeDate(LocalDate.now());
    +   * }
    + * + * @param prizeDate prizeDate + * @return current instance of builder + */ + public PrizeRecordBuilder prizeDate(LocalDate prizeDate) { + this.prizeDate = changedValue(prizeDate); + return this; + } + + /** + * Sets the value for prizeDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeDate(() -> LocalDate.now());
    +   * }
    + * + * @param prizeDateSupplier supplier for prizeDate + * @return current instance of builder + */ + public PrizeRecordBuilder prizeDate(Supplier prizeDateSupplier) { + this.prizeDate = changedValue(prizeDateSupplier.get()); + return this; + } + + /** + * Sets the value for prizeId. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeId(UUID.randomUUID());
    +   * }
    + * + * @param prizeId prizeId + * @return current instance of builder + */ + public PrizeRecordBuilder prizeId(UUID prizeId) { + this.prizeId = changedValue(prizeId); + return this; + } + + /** + * Sets the value for prizeId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeId(() -> UUID.randomUUID());
    +   * }
    + * + * @param prizeIdSupplier supplier for prizeId + * @return current instance of builder + */ + public PrizeRecordBuilder prizeId(Supplier prizeIdSupplier) { + this.prizeId = changedValue(prizeIdSupplier.get()); + return this; + } + + /** + * Sets the value for prizeName. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeName("example value");
    +   * }
    + * + * @param prizeName prizeName + * @return current instance of builder + */ + public PrizeRecordBuilder prizeName(String prizeName) { + this.prizeName = changedValue(prizeName); + return this; + } + + /** + * Sets the value for prizeName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeName(sb -> sb.append("text"));
    +   * }
    + * + * @param prizeNameStringBuilderConsumer consumer providing an instance of prizeName + * @return current instance of builder + */ + public PrizeRecordBuilder prizeName(Consumer prizeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + prizeNameStringBuilderConsumer.accept(builder); + this.prizeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for prizeName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeName(() -> "example value");
    +   * }
    + * + * @param prizeNameSupplier supplier for prizeName + * @return current instance of builder + */ + public PrizeRecordBuilder prizeName(Supplier prizeNameSupplier) { + this.prizeName = changedValue(prizeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for prizeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PrizeRecordBuilder prizeName(String format, Object... args) { + this.prizeName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for prizeValue. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeValue(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param prizeValue prizeValue + * @return current instance of builder + */ + public PrizeRecordBuilder prizeValue(BigDecimal prizeValue) { + this.prizeValue = changedValue(prizeValue); + return this; + } + + /** + * Sets the value for prizeValue by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.prizeValue(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param prizeValueSupplier supplier for prizeValue + * @return current instance of builder + */ + public PrizeRecordBuilder prizeValue(Supplier prizeValueSupplier) { + this.prizeValue = changedValue(prizeValueSupplier.get()); + return this; + } + + /** + * Sets the value for winner. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.winner("example value");
    +   * }
    + * + * @param winner winner + * @return current instance of builder + */ + public PrizeRecordBuilder winner(String winner) { + this.winner = changedValue(winner); + return this; + } + + /** + * Sets the value for winner by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.winner(sb -> sb.append("text"));
    +   * }
    + * + * @param winnerStringBuilderConsumer consumer providing an instance of winner + * @return current instance of builder + */ + public PrizeRecordBuilder winner(Consumer winnerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + winnerStringBuilderConsumer.accept(builder); + this.winner = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for winner by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.winner(() -> "example value");
    +   * }
    + * + * @param winnerSupplier supplier for winner + * @return current instance of builder + */ + public PrizeRecordBuilder winner(Supplier winnerSupplier) { + this.winner = changedValue(winnerSupplier.get()); + return this; + } + + /** + * Sets the String value for winner by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PrizeRecord#PrizeRecord(UUID, String, String, LocalDate, BigDecimal) + * PrizeRecord(UUID prizeId, String prizeName, String winner, LocalDate prizeDate, BigDecimal prizeValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.winner("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PrizeRecordBuilder winner(String format, Object... args) { + this.winner = changedValue(String.format(format, args)); + 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 PrizeRecordBuilder 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 PrizeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PrizeRecord result = builder.build();
    +   * }
    + */ + @Override + public PrizeRecord build() { + PrizeRecord result = new PrizeRecord(this.prizeId + .value(), this.prizeName.value(), this.winner.value(), this.prizeDate.value(), this.prizeValue.value()); + 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("prizeId", this.prizeId) + .append("prizeName", this.prizeName) + .append("winner", this.winner) + .append("prizeDate", this.prizeDate) + .append("prizeValue", this.prizeValue) + .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 PrizeRecord with(Consumer b) { + PrizeRecordBuilder builder; + try { + builder = new PrizeRecordBuilder(PrizeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PrizeRecordBuilder.With' should only be implemented by classes, which could be casted to 'PrizeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PrizeRecordBuilder with() { + try { + return new PrizeRecordBuilder(PrizeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PrizeRecordBuilder.With' should only be implemented by classes, which could be casted to 'PrizeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PublicationRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PublicationRecordBuilder.java new file mode 100644 index 00000000..14289be2 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/PublicationRecordBuilder.java @@ -0,0 +1,562 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.PublicationRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.PublicationRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PublicationRecord result = PublicationRecordBuilder.create()
    + *     .publicationId(UUID.randomUUID())
    + *     .publicationId(() -> UUID.randomUUID())
    + *     .publicationTitle("example value")
    + *     .publicationTitle("Hello %s", "World")
    + *     .publicationTitle(() -> "example value")
    + *     .publicationTitle(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .publisher("example value")
    + *     .publisher("Hello %s", "World")
    + *     .publisher(() -> "example value")
    + *     .publisher(sb -> sb.append("text"))
    + *     .issn("example value")
    + *     .issn("Hello %s", "World")
    + *     .issn(() -> "example value")
    + *     .issn(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PublicationRecord.class) +public class PublicationRecordBuilder implements IBuilderBase { + + /** + * Tracked value for publicationId: publicationId. + */ + private TrackedValue publicationId = unsetValue(); + /** + * Tracked value for publicationTitle: publicationTitle. + */ + private TrackedValue publicationTitle = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for issn: issn. + */ + private TrackedValue issn = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PublicationRecord}. + */ + public PublicationRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PublicationRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PublicationRecordBuilder(PublicationRecord instance) { + this.publicationId = initialValue(instance.publicationId()); + this.publicationTitle = initialValue(instance.publicationTitle()); + this.publicationDate = initialValue(instance.publicationDate()); + this.publisher = initialValue(instance.publisher()); + this.issn = initialValue(instance.issn()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.PublicationRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PublicationRecordBuilder builder = PublicationRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.PublicationRecord} + */ + public static PublicationRecordBuilder create() { + return new PublicationRecordBuilder(); + } + + /** + * Sets the value for issn. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issn("example value");
    +   * }
    + * + * @param issn issn + * @return current instance of builder + */ + public PublicationRecordBuilder issn(String issn) { + this.issn = changedValue(issn); + return this; + } + + /** + * Sets the value for issn by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issn(sb -> sb.append("text"));
    +   * }
    + * + * @param issnStringBuilderConsumer consumer providing an instance of issn + * @return current instance of builder + */ + public PublicationRecordBuilder issn(Consumer issnStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + issnStringBuilderConsumer.accept(builder); + this.issn = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for issn by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issn(() -> "example value");
    +   * }
    + * + * @param issnSupplier supplier for issn + * @return current instance of builder + */ + public PublicationRecordBuilder issn(Supplier issnSupplier) { + this.issn = changedValue(issnSupplier.get()); + return this; + } + + /** + * Sets the String value for issn by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issn("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublicationRecordBuilder issn(String format, Object... args) { + this.issn = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public PublicationRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public PublicationRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for publicationId. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationId(UUID.randomUUID());
    +   * }
    + * + * @param publicationId publicationId + * @return current instance of builder + */ + public PublicationRecordBuilder publicationId(UUID publicationId) { + this.publicationId = changedValue(publicationId); + return this; + } + + /** + * Sets the value for publicationId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationId(() -> UUID.randomUUID());
    +   * }
    + * + * @param publicationIdSupplier supplier for publicationId + * @return current instance of builder + */ + public PublicationRecordBuilder publicationId(Supplier publicationIdSupplier) { + this.publicationId = changedValue(publicationIdSupplier.get()); + return this; + } + + /** + * Sets the value for publicationTitle. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationTitle("example value");
    +   * }
    + * + * @param publicationTitle publicationTitle + * @return current instance of builder + */ + public PublicationRecordBuilder publicationTitle(String publicationTitle) { + this.publicationTitle = changedValue(publicationTitle); + return this; + } + + /** + * Sets the value for publicationTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param publicationTitleStringBuilderConsumer consumer providing an instance of publicationTitle + * @return current instance of builder + */ + public PublicationRecordBuilder publicationTitle(Consumer publicationTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + publicationTitleStringBuilderConsumer.accept(builder); + this.publicationTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for publicationTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationTitle(() -> "example value");
    +   * }
    + * + * @param publicationTitleSupplier supplier for publicationTitle + * @return current instance of builder + */ + public PublicationRecordBuilder publicationTitle(Supplier publicationTitleSupplier) { + this.publicationTitle = changedValue(publicationTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for publicationTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublicationRecordBuilder publicationTitle(String format, Object... args) { + this.publicationTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher("example value");
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public PublicationRecordBuilder publisher(String publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(sb -> sb.append("text"));
    +   * }
    + * + * @param publisherStringBuilderConsumer consumer providing an instance of publisher + * @return current instance of builder + */ + public PublicationRecordBuilder publisher(Consumer publisherStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + publisherStringBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(() -> "example value");
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public PublicationRecordBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the String value for publisher by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PublicationRecord#PublicationRecord(UUID, String, LocalDate, String, String) PublicationRecord(UUID + * publicationId, String publicationTitle, LocalDate publicationDate, String publisher, String issn)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublicationRecordBuilder publisher(String format, Object... args) { + this.publisher = changedValue(String.format(format, args)); + 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 PublicationRecordBuilder 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 PublicationRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PublicationRecord result = builder.build();
    +   * }
    + */ + @Override + public PublicationRecord build() { + PublicationRecord result = new PublicationRecord(this.publicationId.value(), + this.publicationTitle.value(), + this.publicationDate.value(), + this.publisher.value(), + this.issn.value()); + 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("publicationId", this.publicationId) + .append("publicationTitle", this.publicationTitle) + .append("publicationDate", this.publicationDate) + .append("publisher", this.publisher) + .append("issn", this.issn) + .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 PublicationRecord with(Consumer b) { + PublicationRecordBuilder builder; + try { + builder = new PublicationRecordBuilder(PublicationRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublicationRecordBuilder.With' should only be implemented by classes, which could be casted to 'PublicationRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PublicationRecordBuilder with() { + try { + return new PublicationRecordBuilder(PublicationRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublicationRecordBuilder.With' should only be implemented by classes, which could be casted to 'PublicationRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReadingRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReadingRecordBuilder.java new file mode 100644 index 00000000..7a4bc28a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReadingRecordBuilder.java @@ -0,0 +1,501 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.ReadingRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.ReadingRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ReadingRecord result = ReadingRecordBuilder.create()
    + *     .readingId(UUID.randomUUID())
    + *     .readingId(() -> UUID.randomUUID())
    + *     .readingTitle("example value")
    + *     .readingTitle("Hello %s", "World")
    + *     .readingTitle(() -> "example value")
    + *     .readingTitle(sb -> sb.append("text"))
    + *     .reader("example value")
    + *     .reader("Hello %s", "World")
    + *     .reader(() -> "example value")
    + *     .reader(sb -> sb.append("text"))
    + *     .readingDate(LocalDate.now())
    + *     .readingDate(() -> LocalDate.now())
    + *     .audienceCount(42)
    + *     .audienceCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ReadingRecord.class) +public class ReadingRecordBuilder implements IBuilderBase { + + /** + * Tracked value for readingId: readingId. + */ + private TrackedValue readingId = unsetValue(); + /** + * Tracked value for readingTitle: readingTitle. + */ + private TrackedValue readingTitle = unsetValue(); + /** + * Tracked value for reader: reader. + */ + private TrackedValue reader = unsetValue(); + /** + * Tracked value for readingDate: readingDate. + */ + private TrackedValue readingDate = unsetValue(); + /** + * Tracked value for audienceCount: audienceCount. + */ + private TrackedValue audienceCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ReadingRecord}. + */ + public ReadingRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ReadingRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public ReadingRecordBuilder(ReadingRecord instance) { + this.readingId = initialValue(instance.readingId()); + this.readingTitle = initialValue(instance.readingTitle()); + this.reader = initialValue(instance.reader()); + this.readingDate = initialValue(instance.readingDate()); + this.audienceCount = initialValue(instance.audienceCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ReadingRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ReadingRecordBuilder builder = ReadingRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ReadingRecord} + */ + public static ReadingRecordBuilder create() { + return new ReadingRecordBuilder(); + } + + /** + * Sets the value for audienceCount. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceCount(42);
    +   * }
    + * + * @param audienceCount audienceCount + * @return current instance of builder + */ + public ReadingRecordBuilder audienceCount(int audienceCount) { + this.audienceCount = changedValue(audienceCount); + return this; + } + + /** + * Sets the value for audienceCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceCount(() -> 42);
    +   * }
    + * + * @param audienceCountSupplier supplier for audienceCount + * @return current instance of builder + */ + public ReadingRecordBuilder audienceCount(Supplier audienceCountSupplier) { + this.audienceCount = changedValue(audienceCountSupplier.get()); + return this; + } + + /** + * Sets the value for reader. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reader("example value");
    +   * }
    + * + * @param reader reader + * @return current instance of builder + */ + public ReadingRecordBuilder reader(String reader) { + this.reader = changedValue(reader); + return this; + } + + /** + * Sets the value for reader by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reader(sb -> sb.append("text"));
    +   * }
    + * + * @param readerStringBuilderConsumer consumer providing an instance of reader + * @return current instance of builder + */ + public ReadingRecordBuilder reader(Consumer readerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + readerStringBuilderConsumer.accept(builder); + this.reader = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for reader by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reader(() -> "example value");
    +   * }
    + * + * @param readerSupplier supplier for reader + * @return current instance of builder + */ + public ReadingRecordBuilder reader(Supplier readerSupplier) { + this.reader = changedValue(readerSupplier.get()); + return this; + } + + /** + * Sets the String value for reader by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reader("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReadingRecordBuilder reader(String format, Object... args) { + this.reader = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for readingDate. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingDate(LocalDate.now());
    +   * }
    + * + * @param readingDate readingDate + * @return current instance of builder + */ + public ReadingRecordBuilder readingDate(LocalDate readingDate) { + this.readingDate = changedValue(readingDate); + return this; + } + + /** + * Sets the value for readingDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingDate(() -> LocalDate.now());
    +   * }
    + * + * @param readingDateSupplier supplier for readingDate + * @return current instance of builder + */ + public ReadingRecordBuilder readingDate(Supplier readingDateSupplier) { + this.readingDate = changedValue(readingDateSupplier.get()); + return this; + } + + /** + * Sets the value for readingId. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingId(UUID.randomUUID());
    +   * }
    + * + * @param readingId readingId + * @return current instance of builder + */ + public ReadingRecordBuilder readingId(UUID readingId) { + this.readingId = changedValue(readingId); + return this; + } + + /** + * Sets the value for readingId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingId(() -> UUID.randomUUID());
    +   * }
    + * + * @param readingIdSupplier supplier for readingId + * @return current instance of builder + */ + public ReadingRecordBuilder readingId(Supplier readingIdSupplier) { + this.readingId = changedValue(readingIdSupplier.get()); + return this; + } + + /** + * Sets the value for readingTitle. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingTitle("example value");
    +   * }
    + * + * @param readingTitle readingTitle + * @return current instance of builder + */ + public ReadingRecordBuilder readingTitle(String readingTitle) { + this.readingTitle = changedValue(readingTitle); + return this; + } + + /** + * Sets the value for readingTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param readingTitleStringBuilderConsumer consumer providing an instance of readingTitle + * @return current instance of builder + */ + public ReadingRecordBuilder readingTitle(Consumer readingTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + readingTitleStringBuilderConsumer.accept(builder); + this.readingTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for readingTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingTitle(() -> "example value");
    +   * }
    + * + * @param readingTitleSupplier supplier for readingTitle + * @return current instance of builder + */ + public ReadingRecordBuilder readingTitle(Supplier readingTitleSupplier) { + this.readingTitle = changedValue(readingTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for readingTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReadingRecord#ReadingRecord(UUID, String, String, LocalDate, int) + * ReadingRecord(UUID readingId, String readingTitle, String reader, LocalDate readingDate, int audienceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.readingTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReadingRecordBuilder readingTitle(String format, Object... args) { + this.readingTitle = changedValue(String.format(format, args)); + 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 ReadingRecordBuilder 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 ReadingRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ReadingRecord result = builder.build();
    +   * }
    + */ + @Override + public ReadingRecord build() { + if (!this.audienceCount.isSet()) { + throw new IllegalStateException("Required field 'audienceCount' must be set before calling build()"); + } + if (this.audienceCount.value() == null) { + throw new IllegalStateException("Field 'audienceCount' is marked as non-null but null value was provided"); + } + ReadingRecord result = new ReadingRecord(this.readingId + .value(), this.readingTitle.value(), this.reader.value(), this.readingDate.value(), this.audienceCount.value()); + 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("readingId", this.readingId) + .append("readingTitle", this.readingTitle) + .append("reader", this.reader) + .append("readingDate", this.readingDate) + .append("audienceCount", this.audienceCount) + .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 ReadingRecord with(Consumer b) { + ReadingRecordBuilder builder; + try { + builder = new ReadingRecordBuilder(ReadingRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ReadingRecordBuilder.With' should only be implemented by classes, which could be casted to 'ReadingRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ReadingRecordBuilder with() { + try { + return new ReadingRecordBuilder(ReadingRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ReadingRecordBuilder.With' should only be implemented by classes, which could be casted to 'ReadingRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/RecitalRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/RecitalRecordBuilder.java new file mode 100644 index 00000000..4344dbe7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/RecitalRecordBuilder.java @@ -0,0 +1,504 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.RecitalRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.RecitalRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RecitalRecord result = RecitalRecordBuilder.create()
    + *     .recitalId(UUID.randomUUID())
    + *     .recitalId(() -> UUID.randomUUID())
    + *     .recitalTitle("example value")
    + *     .recitalTitle("Hello %s", "World")
    + *     .recitalTitle(() -> "example value")
    + *     .recitalTitle(sb -> sb.append("text"))
    + *     .performer("example value")
    + *     .performer("Hello %s", "World")
    + *     .performer(() -> "example value")
    + *     .performer(sb -> sb.append("text"))
    + *     .recitalDate(LocalDate.now())
    + *     .recitalDate(() -> LocalDate.now())
    + *     .instrumentCount(42)
    + *     .instrumentCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RecitalRecord.class) +public class RecitalRecordBuilder implements IBuilderBase { + + /** + * Tracked value for recitalId: recitalId. + */ + private TrackedValue recitalId = unsetValue(); + /** + * Tracked value for recitalTitle: recitalTitle. + */ + private TrackedValue recitalTitle = unsetValue(); + /** + * Tracked value for performer: performer. + */ + private TrackedValue performer = unsetValue(); + /** + * Tracked value for recitalDate: recitalDate. + */ + private TrackedValue recitalDate = unsetValue(); + /** + * Tracked value for instrumentCount: instrumentCount. + */ + private TrackedValue instrumentCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.RecitalRecord}. + */ + public RecitalRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.RecitalRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public RecitalRecordBuilder(RecitalRecord instance) { + this.recitalId = initialValue(instance.recitalId()); + this.recitalTitle = initialValue(instance.recitalTitle()); + this.performer = initialValue(instance.performer()); + this.recitalDate = initialValue(instance.recitalDate()); + this.instrumentCount = initialValue(instance.instrumentCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.RecitalRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RecitalRecordBuilder builder = RecitalRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.RecitalRecord} + */ + public static RecitalRecordBuilder create() { + return new RecitalRecordBuilder(); + } + + /** + * Sets the value for instrumentCount. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instrumentCount(42);
    +   * }
    + * + * @param instrumentCount instrumentCount + * @return current instance of builder + */ + public RecitalRecordBuilder instrumentCount(int instrumentCount) { + this.instrumentCount = changedValue(instrumentCount); + return this; + } + + /** + * Sets the value for instrumentCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instrumentCount(() -> 42);
    +   * }
    + * + * @param instrumentCountSupplier supplier for instrumentCount + * @return current instance of builder + */ + public RecitalRecordBuilder instrumentCount(Supplier instrumentCountSupplier) { + this.instrumentCount = changedValue(instrumentCountSupplier.get()); + return this; + } + + /** + * Sets the value for performer. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer("example value");
    +   * }
    + * + * @param performer performer + * @return current instance of builder + */ + public RecitalRecordBuilder performer(String performer) { + this.performer = changedValue(performer); + return this; + } + + /** + * Sets the value for performer by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer(sb -> sb.append("text"));
    +   * }
    + * + * @param performerStringBuilderConsumer consumer providing an instance of performer + * @return current instance of builder + */ + public RecitalRecordBuilder performer(Consumer performerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + performerStringBuilderConsumer.accept(builder); + this.performer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for performer by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer(() -> "example value");
    +   * }
    + * + * @param performerSupplier supplier for performer + * @return current instance of builder + */ + public RecitalRecordBuilder performer(Supplier performerSupplier) { + this.performer = changedValue(performerSupplier.get()); + return this; + } + + /** + * Sets the String value for performer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RecitalRecordBuilder performer(String format, Object... args) { + this.performer = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for recitalDate. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalDate(LocalDate.now());
    +   * }
    + * + * @param recitalDate recitalDate + * @return current instance of builder + */ + public RecitalRecordBuilder recitalDate(LocalDate recitalDate) { + this.recitalDate = changedValue(recitalDate); + return this; + } + + /** + * Sets the value for recitalDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalDate(() -> LocalDate.now());
    +   * }
    + * + * @param recitalDateSupplier supplier for recitalDate + * @return current instance of builder + */ + public RecitalRecordBuilder recitalDate(Supplier recitalDateSupplier) { + this.recitalDate = changedValue(recitalDateSupplier.get()); + return this; + } + + /** + * Sets the value for recitalId. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalId(UUID.randomUUID());
    +   * }
    + * + * @param recitalId recitalId + * @return current instance of builder + */ + public RecitalRecordBuilder recitalId(UUID recitalId) { + this.recitalId = changedValue(recitalId); + return this; + } + + /** + * Sets the value for recitalId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalId(() -> UUID.randomUUID());
    +   * }
    + * + * @param recitalIdSupplier supplier for recitalId + * @return current instance of builder + */ + public RecitalRecordBuilder recitalId(Supplier recitalIdSupplier) { + this.recitalId = changedValue(recitalIdSupplier.get()); + return this; + } + + /** + * Sets the value for recitalTitle. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalTitle("example value");
    +   * }
    + * + * @param recitalTitle recitalTitle + * @return current instance of builder + */ + public RecitalRecordBuilder recitalTitle(String recitalTitle) { + this.recitalTitle = changedValue(recitalTitle); + return this; + } + + /** + * Sets the value for recitalTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param recitalTitleStringBuilderConsumer consumer providing an instance of recitalTitle + * @return current instance of builder + */ + public RecitalRecordBuilder recitalTitle(Consumer recitalTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + recitalTitleStringBuilderConsumer.accept(builder); + this.recitalTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for recitalTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalTitle(() -> "example value");
    +   * }
    + * + * @param recitalTitleSupplier supplier for recitalTitle + * @return current instance of builder + */ + public RecitalRecordBuilder recitalTitle(Supplier recitalTitleSupplier) { + this.recitalTitle = changedValue(recitalTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for recitalTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RecitalRecord#RecitalRecord(UUID, String, String, LocalDate, int) + * RecitalRecord(UUID recitalId, String recitalTitle, String performer, LocalDate recitalDate, int instrumentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recitalTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RecitalRecordBuilder recitalTitle(String format, Object... args) { + this.recitalTitle = changedValue(String.format(format, args)); + 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 RecitalRecordBuilder 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 RecitalRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RecitalRecord result = builder.build();
    +   * }
    + */ + @Override + public RecitalRecord build() { + if (!this.instrumentCount.isSet()) { + throw new IllegalStateException("Required field 'instrumentCount' must be set before calling build()"); + } + if (this.instrumentCount.value() == null) { + throw new IllegalStateException("Field 'instrumentCount' is marked as non-null but null value was provided"); + } + RecitalRecord result = new RecitalRecord(this.recitalId.value(), + this.recitalTitle.value(), + this.performer.value(), + this.recitalDate.value(), + this.instrumentCount.value()); + 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("recitalId", this.recitalId) + .append("recitalTitle", this.recitalTitle) + .append("performer", this.performer) + .append("recitalDate", this.recitalDate) + .append("instrumentCount", this.instrumentCount) + .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 RecitalRecord with(Consumer b) { + RecitalRecordBuilder builder; + try { + builder = new RecitalRecordBuilder(RecitalRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RecitalRecordBuilder.With' should only be implemented by classes, which could be casted to 'RecitalRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RecitalRecordBuilder with() { + try { + return new RecitalRecordBuilder(RecitalRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RecitalRecordBuilder.With' should only be implemented by classes, which could be casted to 'RecitalRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReleaseRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReleaseRecordBuilder.java new file mode 100644 index 00000000..43fd03f0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ReleaseRecordBuilder.java @@ -0,0 +1,541 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.ReleaseRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.ReleaseRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ReleaseRecord result = ReleaseRecordBuilder.create()
    + *     .releaseId(UUID.randomUUID())
    + *     .releaseId(() -> UUID.randomUUID())
    + *     .releaseTitle("example value")
    + *     .releaseTitle("Hello %s", "World")
    + *     .releaseTitle(() -> "example value")
    + *     .releaseTitle(sb -> sb.append("text"))
    + *     .releaseDate(LocalDate.now())
    + *     .releaseDate(() -> LocalDate.now())
    + *     .version("example value")
    + *     .version("Hello %s", "World")
    + *     .version(() -> "example value")
    + *     .version(sb -> sb.append("text"))
    + *     .platform("example value")
    + *     .platform("Hello %s", "World")
    + *     .platform(() -> "example value")
    + *     .platform(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ReleaseRecord.class) +public class ReleaseRecordBuilder implements IBuilderBase { + + /** + * Tracked value for releaseId: releaseId. + */ + private TrackedValue releaseId = unsetValue(); + /** + * Tracked value for releaseTitle: releaseTitle. + */ + private TrackedValue releaseTitle = unsetValue(); + /** + * Tracked value for releaseDate: releaseDate. + */ + private TrackedValue releaseDate = unsetValue(); + /** + * Tracked value for version: version. + */ + private TrackedValue version = unsetValue(); + /** + * Tracked value for platform: platform. + */ + private TrackedValue platform = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ReleaseRecord}. + */ + public ReleaseRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ReleaseRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public ReleaseRecordBuilder(ReleaseRecord instance) { + this.releaseId = initialValue(instance.releaseId()); + this.releaseTitle = initialValue(instance.releaseTitle()); + this.releaseDate = initialValue(instance.releaseDate()); + this.version = initialValue(instance.version()); + this.platform = initialValue(instance.platform()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ReleaseRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ReleaseRecordBuilder builder = ReleaseRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ReleaseRecord} + */ + public static ReleaseRecordBuilder create() { + return new ReleaseRecordBuilder(); + } + + /** + * Sets the value for platform. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform("example value");
    +   * }
    + * + * @param platform platform + * @return current instance of builder + */ + public ReleaseRecordBuilder platform(String platform) { + this.platform = changedValue(platform); + return this; + } + + /** + * Sets the value for platform by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform(sb -> sb.append("text"));
    +   * }
    + * + * @param platformStringBuilderConsumer consumer providing an instance of platform + * @return current instance of builder + */ + public ReleaseRecordBuilder platform(Consumer platformStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + platformStringBuilderConsumer.accept(builder); + this.platform = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for platform by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform(() -> "example value");
    +   * }
    + * + * @param platformSupplier supplier for platform + * @return current instance of builder + */ + public ReleaseRecordBuilder platform(Supplier platformSupplier) { + this.platform = changedValue(platformSupplier.get()); + return this; + } + + /** + * Sets the String value for platform by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReleaseRecordBuilder platform(String format, Object... args) { + this.platform = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for releaseDate. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseDate(LocalDate.now());
    +   * }
    + * + * @param releaseDate releaseDate + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseDate(LocalDate releaseDate) { + this.releaseDate = changedValue(releaseDate); + return this; + } + + /** + * Sets the value for releaseDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseDate(() -> LocalDate.now());
    +   * }
    + * + * @param releaseDateSupplier supplier for releaseDate + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseDate(Supplier releaseDateSupplier) { + this.releaseDate = changedValue(releaseDateSupplier.get()); + return this; + } + + /** + * Sets the value for releaseId. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseId(UUID.randomUUID());
    +   * }
    + * + * @param releaseId releaseId + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseId(UUID releaseId) { + this.releaseId = changedValue(releaseId); + return this; + } + + /** + * Sets the value for releaseId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseId(() -> UUID.randomUUID());
    +   * }
    + * + * @param releaseIdSupplier supplier for releaseId + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseId(Supplier releaseIdSupplier) { + this.releaseId = changedValue(releaseIdSupplier.get()); + return this; + } + + /** + * Sets the value for releaseTitle. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseTitle("example value");
    +   * }
    + * + * @param releaseTitle releaseTitle + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseTitle(String releaseTitle) { + this.releaseTitle = changedValue(releaseTitle); + return this; + } + + /** + * Sets the value for releaseTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param releaseTitleStringBuilderConsumer consumer providing an instance of releaseTitle + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseTitle(Consumer releaseTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + releaseTitleStringBuilderConsumer.accept(builder); + this.releaseTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for releaseTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseTitle(() -> "example value");
    +   * }
    + * + * @param releaseTitleSupplier supplier for releaseTitle + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseTitle(Supplier releaseTitleSupplier) { + this.releaseTitle = changedValue(releaseTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for releaseTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReleaseRecordBuilder releaseTitle(String format, Object... args) { + this.releaseTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for version. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.version("example value");
    +   * }
    + * + * @param version version + * @return current instance of builder + */ + public ReleaseRecordBuilder version(String version) { + this.version = changedValue(version); + return this; + } + + /** + * Sets the value for version by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.version(sb -> sb.append("text"));
    +   * }
    + * + * @param versionStringBuilderConsumer consumer providing an instance of version + * @return current instance of builder + */ + public ReleaseRecordBuilder version(Consumer versionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + versionStringBuilderConsumer.accept(builder); + this.version = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for version by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.version(() -> "example value");
    +   * }
    + * + * @param versionSupplier supplier for version + * @return current instance of builder + */ + public ReleaseRecordBuilder version(Supplier versionSupplier) { + this.version = changedValue(versionSupplier.get()); + return this; + } + + /** + * Sets the String value for version by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReleaseRecord#ReleaseRecord(UUID, String, LocalDate, String, String) + * ReleaseRecord(UUID releaseId, String releaseTitle, LocalDate releaseDate, String version, String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.version("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReleaseRecordBuilder version(String format, Object... args) { + this.version = changedValue(String.format(format, args)); + 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 ReleaseRecordBuilder 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 ReleaseRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ReleaseRecord result = builder.build();
    +   * }
    + */ + @Override + public ReleaseRecord build() { + ReleaseRecord result = new ReleaseRecord(this.releaseId + .value(), this.releaseTitle.value(), this.releaseDate.value(), this.version.value(), this.platform.value()); + 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("releaseId", this.releaseId) + .append("releaseTitle", this.releaseTitle) + .append("releaseDate", this.releaseDate) + .append("version", this.version) + .append("platform", this.platform) + .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 ReleaseRecord with(Consumer b) { + ReleaseRecordBuilder builder; + try { + builder = new ReleaseRecordBuilder(ReleaseRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ReleaseRecordBuilder.With' should only be implemented by classes, which could be casted to 'ReleaseRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ReleaseRecordBuilder with() { + try { + return new ReleaseRecordBuilder(ReleaseRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ReleaseRecordBuilder.With' should only be implemented by classes, which could be casted to 'ReleaseRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ResidencyRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ResidencyRecordBuilder.java new file mode 100644 index 00000000..08958b78 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ResidencyRecordBuilder.java @@ -0,0 +1,546 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.UUID; +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.performance_test.library.events.ResidencyRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.ResidencyRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ResidencyRecord result = ResidencyRecordBuilder.create()
    + *     .residencyId(UUID.randomUUID())
    + *     .residencyId(() -> UUID.randomUUID())
    + *     .residencyName("example value")
    + *     .residencyName("Hello %s", "World")
    + *     .residencyName(() -> "example value")
    + *     .residencyName(sb -> sb.append("text"))
    + *     .resident("example value")
    + *     .resident("Hello %s", "World")
    + *     .resident(() -> "example value")
    + *     .resident(sb -> sb.append("text"))
    + *     .durationMonths(42)
    + *     .durationMonths(() -> 42)
    + *     .program("example value")
    + *     .program("Hello %s", "World")
    + *     .program(() -> "example value")
    + *     .program(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResidencyRecord.class) +public class ResidencyRecordBuilder implements IBuilderBase { + + /** + * Tracked value for residencyId: residencyId. + */ + private TrackedValue residencyId = unsetValue(); + /** + * Tracked value for residencyName: residencyName. + */ + private TrackedValue residencyName = unsetValue(); + /** + * Tracked value for resident: resident. + */ + private TrackedValue resident = unsetValue(); + /** + * Tracked value for durationMonths: durationMonths. + */ + private TrackedValue durationMonths = unsetValue(); + /** + * Tracked value for program: program. + */ + private TrackedValue program = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ResidencyRecord}. + */ + public ResidencyRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ResidencyRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResidencyRecordBuilder(ResidencyRecord instance) { + this.residencyId = initialValue(instance.residencyId()); + this.residencyName = initialValue(instance.residencyName()); + this.resident = initialValue(instance.resident()); + this.durationMonths = initialValue(instance.durationMonths()); + this.program = initialValue(instance.program()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ResidencyRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ResidencyRecordBuilder builder = ResidencyRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ResidencyRecord} + */ + public static ResidencyRecordBuilder create() { + return new ResidencyRecordBuilder(); + } + + /** + * Sets the value for durationMonths. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMonths(42);
    +   * }
    + * + * @param durationMonths durationMonths + * @return current instance of builder + */ + public ResidencyRecordBuilder durationMonths(int durationMonths) { + this.durationMonths = changedValue(durationMonths); + return this; + } + + /** + * Sets the value for durationMonths by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMonths(() -> 42);
    +   * }
    + * + * @param durationMonthsSupplier supplier for durationMonths + * @return current instance of builder + */ + public ResidencyRecordBuilder durationMonths(Supplier durationMonthsSupplier) { + this.durationMonths = changedValue(durationMonthsSupplier.get()); + return this; + } + + /** + * Sets the value for program. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program("example value");
    +   * }
    + * + * @param program program + * @return current instance of builder + */ + public ResidencyRecordBuilder program(String program) { + this.program = changedValue(program); + return this; + } + + /** + * Sets the value for program by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program(sb -> sb.append("text"));
    +   * }
    + * + * @param programStringBuilderConsumer consumer providing an instance of program + * @return current instance of builder + */ + public ResidencyRecordBuilder program(Consumer programStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + programStringBuilderConsumer.accept(builder); + this.program = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for program by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program(() -> "example value");
    +   * }
    + * + * @param programSupplier supplier for program + * @return current instance of builder + */ + public ResidencyRecordBuilder program(Supplier programSupplier) { + this.program = changedValue(programSupplier.get()); + return this; + } + + /** + * Sets the String value for program by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResidencyRecordBuilder program(String format, Object... args) { + this.program = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for residencyId. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residencyId(UUID.randomUUID());
    +   * }
    + * + * @param residencyId residencyId + * @return current instance of builder + */ + public ResidencyRecordBuilder residencyId(UUID residencyId) { + this.residencyId = changedValue(residencyId); + return this; + } + + /** + * Sets the value for residencyId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residencyId(() -> UUID.randomUUID());
    +   * }
    + * + * @param residencyIdSupplier supplier for residencyId + * @return current instance of builder + */ + public ResidencyRecordBuilder residencyId(Supplier residencyIdSupplier) { + this.residencyId = changedValue(residencyIdSupplier.get()); + return this; + } + + /** + * Sets the value for residencyName. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residencyName("example value");
    +   * }
    + * + * @param residencyName residencyName + * @return current instance of builder + */ + public ResidencyRecordBuilder residencyName(String residencyName) { + this.residencyName = changedValue(residencyName); + return this; + } + + /** + * Sets the value for residencyName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residencyName(sb -> sb.append("text"));
    +   * }
    + * + * @param residencyNameStringBuilderConsumer consumer providing an instance of residencyName + * @return current instance of builder + */ + public ResidencyRecordBuilder residencyName(Consumer residencyNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + residencyNameStringBuilderConsumer.accept(builder); + this.residencyName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for residencyName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residencyName(() -> "example value");
    +   * }
    + * + * @param residencyNameSupplier supplier for residencyName + * @return current instance of builder + */ + public ResidencyRecordBuilder residencyName(Supplier residencyNameSupplier) { + this.residencyName = changedValue(residencyNameSupplier.get()); + return this; + } + + /** + * Sets the String value for residencyName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residencyName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResidencyRecordBuilder residencyName(String format, Object... args) { + this.residencyName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for resident. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.resident("example value");
    +   * }
    + * + * @param resident resident + * @return current instance of builder + */ + public ResidencyRecordBuilder resident(String resident) { + this.resident = changedValue(resident); + return this; + } + + /** + * Sets the value for resident by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.resident(sb -> sb.append("text"));
    +   * }
    + * + * @param residentStringBuilderConsumer consumer providing an instance of resident + * @return current instance of builder + */ + public ResidencyRecordBuilder resident(Consumer residentStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + residentStringBuilderConsumer.accept(builder); + this.resident = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for resident by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.resident(() -> "example value");
    +   * }
    + * + * @param residentSupplier supplier for resident + * @return current instance of builder + */ + public ResidencyRecordBuilder resident(Supplier residentSupplier) { + this.resident = changedValue(residentSupplier.get()); + return this; + } + + /** + * Sets the String value for resident by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResidencyRecord#ResidencyRecord(UUID, String, String, int, String) + * ResidencyRecord(UUID residencyId, String residencyName, String resident, int durationMonths, String program)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.resident("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResidencyRecordBuilder resident(String format, Object... args) { + this.resident = changedValue(String.format(format, args)); + 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 ResidencyRecordBuilder 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 ResidencyRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResidencyRecord result = builder.build();
    +   * }
    + */ + @Override + public ResidencyRecord build() { + if (!this.durationMonths.isSet()) { + throw new IllegalStateException("Required field 'durationMonths' must be set before calling build()"); + } + if (this.durationMonths.value() == null) { + throw new IllegalStateException("Field 'durationMonths' is marked as non-null but null value was provided"); + } + ResidencyRecord result = new ResidencyRecord(this.residencyId + .value(), this.residencyName.value(), this.resident.value(), this.durationMonths.value(), this.program.value()); + 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("residencyId", this.residencyId) + .append("residencyName", this.residencyName) + .append("resident", this.resident) + .append("durationMonths", this.durationMonths) + .append("program", this.program) + .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 ResidencyRecord with(Consumer b) { + ResidencyRecordBuilder builder; + try { + builder = new ResidencyRecordBuilder(ResidencyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResidencyRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResidencyRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResidencyRecordBuilder with() { + try { + return new ResidencyRecordBuilder(ResidencyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResidencyRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResidencyRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ScreeningRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ScreeningRecordBuilder.java new file mode 100644 index 00000000..734c29e8 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ScreeningRecordBuilder.java @@ -0,0 +1,518 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.ScreeningRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.ScreeningRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ScreeningRecord result = ScreeningRecordBuilder.create()
    + *     .screeningId(UUID.randomUUID())
    + *     .screeningId(() -> UUID.randomUUID())
    + *     .screeningTitle("example value")
    + *     .screeningTitle("Hello %s", "World")
    + *     .screeningTitle(() -> "example value")
    + *     .screeningTitle(sb -> sb.append("text"))
    + *     .screeningDate(LocalDate.now())
    + *     .screeningDate(() -> LocalDate.now())
    + *     .durationMinutes(42)
    + *     .durationMinutes(() -> 42)
    + *     .format("example value")
    + *     .format("Hello %s", "World")
    + *     .format(() -> "example value")
    + *     .format(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScreeningRecord.class) +public class ScreeningRecordBuilder implements IBuilderBase { + + /** + * Tracked value for screeningId: screeningId. + */ + private TrackedValue screeningId = unsetValue(); + /** + * Tracked value for screeningTitle: screeningTitle. + */ + private TrackedValue screeningTitle = unsetValue(); + /** + * Tracked value for screeningDate: screeningDate. + */ + private TrackedValue screeningDate = unsetValue(); + /** + * Tracked value for durationMinutes: durationMinutes. + */ + private TrackedValue durationMinutes = unsetValue(); + /** + * Tracked value for format: format. + */ + private TrackedValue format = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ScreeningRecord}. + */ + public ScreeningRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ScreeningRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScreeningRecordBuilder(ScreeningRecord instance) { + this.screeningId = initialValue(instance.screeningId()); + this.screeningTitle = initialValue(instance.screeningTitle()); + this.screeningDate = initialValue(instance.screeningDate()); + this.durationMinutes = initialValue(instance.durationMinutes()); + this.format = initialValue(instance.format()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ScreeningRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ScreeningRecordBuilder builder = ScreeningRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ScreeningRecord} + */ + public static ScreeningRecordBuilder create() { + return new ScreeningRecordBuilder(); + } + + /** + * Sets the value for durationMinutes. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(42);
    +   * }
    + * + * @param durationMinutes durationMinutes + * @return current instance of builder + */ + public ScreeningRecordBuilder durationMinutes(int durationMinutes) { + this.durationMinutes = changedValue(durationMinutes); + return this; + } + + /** + * Sets the value for durationMinutes by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(() -> 42);
    +   * }
    + * + * @param durationMinutesSupplier supplier for durationMinutes + * @return current instance of builder + */ + public ScreeningRecordBuilder durationMinutes(Supplier durationMinutesSupplier) { + this.durationMinutes = changedValue(durationMinutesSupplier.get()); + return this; + } + + /** + * Sets the value for format. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("example value");
    +   * }
    + * + * @param format format + * @return current instance of builder + */ + public ScreeningRecordBuilder format(String format) { + this.format = changedValue(format); + return this; + } + + /** + * Sets the value for format by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(sb -> sb.append("text"));
    +   * }
    + * + * @param formatStringBuilderConsumer consumer providing an instance of format + * @return current instance of builder + */ + public ScreeningRecordBuilder format(Consumer formatStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + formatStringBuilderConsumer.accept(builder); + this.format = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for format by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(() -> "example value");
    +   * }
    + * + * @param formatSupplier supplier for format + * @return current instance of builder + */ + public ScreeningRecordBuilder format(Supplier formatSupplier) { + this.format = changedValue(formatSupplier.get()); + return this; + } + + /** + * Sets the String value for format by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScreeningRecordBuilder format(String format, Object... args) { + this.format = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for screeningDate. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningDate(LocalDate.now());
    +   * }
    + * + * @param screeningDate screeningDate + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningDate(LocalDate screeningDate) { + this.screeningDate = changedValue(screeningDate); + return this; + } + + /** + * Sets the value for screeningDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningDate(() -> LocalDate.now());
    +   * }
    + * + * @param screeningDateSupplier supplier for screeningDate + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningDate(Supplier screeningDateSupplier) { + this.screeningDate = changedValue(screeningDateSupplier.get()); + return this; + } + + /** + * Sets the value for screeningId. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningId(UUID.randomUUID());
    +   * }
    + * + * @param screeningId screeningId + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningId(UUID screeningId) { + this.screeningId = changedValue(screeningId); + return this; + } + + /** + * Sets the value for screeningId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningId(() -> UUID.randomUUID());
    +   * }
    + * + * @param screeningIdSupplier supplier for screeningId + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningId(Supplier screeningIdSupplier) { + this.screeningId = changedValue(screeningIdSupplier.get()); + return this; + } + + /** + * Sets the value for screeningTitle. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningTitle("example value");
    +   * }
    + * + * @param screeningTitle screeningTitle + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningTitle(String screeningTitle) { + this.screeningTitle = changedValue(screeningTitle); + return this; + } + + /** + * Sets the value for screeningTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param screeningTitleStringBuilderConsumer consumer providing an instance of screeningTitle + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningTitle(Consumer screeningTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + screeningTitleStringBuilderConsumer.accept(builder); + this.screeningTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for screeningTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningTitle(() -> "example value");
    +   * }
    + * + * @param screeningTitleSupplier supplier for screeningTitle + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningTitle(Supplier screeningTitleSupplier) { + this.screeningTitle = changedValue(screeningTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for screeningTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ScreeningRecord#ScreeningRecord(UUID, String, LocalDate, int, String) ScreeningRecord(UUID screeningId, + * String screeningTitle, LocalDate screeningDate, int durationMinutes, String format)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screeningTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScreeningRecordBuilder screeningTitle(String format, Object... args) { + this.screeningTitle = changedValue(String.format(format, args)); + 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 ScreeningRecordBuilder 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 ScreeningRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScreeningRecord result = builder.build();
    +   * }
    + */ + @Override + public ScreeningRecord build() { + if (!this.durationMinutes.isSet()) { + throw new IllegalStateException("Required field 'durationMinutes' must be set before calling build()"); + } + if (this.durationMinutes.value() == null) { + throw new IllegalStateException("Field 'durationMinutes' is marked as non-null but null value was provided"); + } + ScreeningRecord result = new ScreeningRecord(this.screeningId.value(), + this.screeningTitle.value(), + this.screeningDate.value(), + this.durationMinutes.value(), + this.format.value()); + 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("screeningId", this.screeningId) + .append("screeningTitle", this.screeningTitle) + .append("screeningDate", this.screeningDate) + .append("durationMinutes", this.durationMinutes) + .append("format", this.format) + .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 ScreeningRecord with(Consumer b) { + ScreeningRecordBuilder builder; + try { + builder = new ScreeningRecordBuilder(ScreeningRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScreeningRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScreeningRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScreeningRecordBuilder with() { + try { + return new ScreeningRecordBuilder(ScreeningRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScreeningRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScreeningRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SeminarRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SeminarRecordBuilder.java new file mode 100644 index 00000000..f558e433 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SeminarRecordBuilder.java @@ -0,0 +1,504 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.SeminarRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.SeminarRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SeminarRecord result = SeminarRecordBuilder.create()
    + *     .seminarId(UUID.randomUUID())
    + *     .seminarId(() -> UUID.randomUUID())
    + *     .seminarTitle("example value")
    + *     .seminarTitle("Hello %s", "World")
    + *     .seminarTitle(() -> "example value")
    + *     .seminarTitle(sb -> sb.append("text"))
    + *     .seminarDate(LocalDate.now())
    + *     .seminarDate(() -> LocalDate.now())
    + *     .durationHours(42)
    + *     .durationHours(() -> 42)
    + *     .instructor("example value")
    + *     .instructor("Hello %s", "World")
    + *     .instructor(() -> "example value")
    + *     .instructor(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SeminarRecord.class) +public class SeminarRecordBuilder implements IBuilderBase { + + /** + * Tracked value for seminarId: seminarId. + */ + private TrackedValue seminarId = unsetValue(); + /** + * Tracked value for seminarTitle: seminarTitle. + */ + private TrackedValue seminarTitle = unsetValue(); + /** + * Tracked value for seminarDate: seminarDate. + */ + private TrackedValue seminarDate = unsetValue(); + /** + * Tracked value for durationHours: durationHours. + */ + private TrackedValue durationHours = unsetValue(); + /** + * Tracked value for instructor: instructor. + */ + private TrackedValue instructor = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SeminarRecord}. + */ + public SeminarRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SeminarRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public SeminarRecordBuilder(SeminarRecord instance) { + this.seminarId = initialValue(instance.seminarId()); + this.seminarTitle = initialValue(instance.seminarTitle()); + this.seminarDate = initialValue(instance.seminarDate()); + this.durationHours = initialValue(instance.durationHours()); + this.instructor = initialValue(instance.instructor()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SeminarRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SeminarRecordBuilder builder = SeminarRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SeminarRecord} + */ + public static SeminarRecordBuilder create() { + return new SeminarRecordBuilder(); + } + + /** + * Sets the value for durationHours. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationHours(42);
    +   * }
    + * + * @param durationHours durationHours + * @return current instance of builder + */ + public SeminarRecordBuilder durationHours(int durationHours) { + this.durationHours = changedValue(durationHours); + return this; + } + + /** + * Sets the value for durationHours by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationHours(() -> 42);
    +   * }
    + * + * @param durationHoursSupplier supplier for durationHours + * @return current instance of builder + */ + public SeminarRecordBuilder durationHours(Supplier durationHoursSupplier) { + this.durationHours = changedValue(durationHoursSupplier.get()); + return this; + } + + /** + * Sets the value for instructor. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor("example value");
    +   * }
    + * + * @param instructor instructor + * @return current instance of builder + */ + public SeminarRecordBuilder instructor(String instructor) { + this.instructor = changedValue(instructor); + return this; + } + + /** + * Sets the value for instructor by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor(sb -> sb.append("text"));
    +   * }
    + * + * @param instructorStringBuilderConsumer consumer providing an instance of instructor + * @return current instance of builder + */ + public SeminarRecordBuilder instructor(Consumer instructorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + instructorStringBuilderConsumer.accept(builder); + this.instructor = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for instructor by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor(() -> "example value");
    +   * }
    + * + * @param instructorSupplier supplier for instructor + * @return current instance of builder + */ + public SeminarRecordBuilder instructor(Supplier instructorSupplier) { + this.instructor = changedValue(instructorSupplier.get()); + return this; + } + + /** + * Sets the String value for instructor by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SeminarRecordBuilder instructor(String format, Object... args) { + this.instructor = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for seminarDate. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarDate(LocalDate.now());
    +   * }
    + * + * @param seminarDate seminarDate + * @return current instance of builder + */ + public SeminarRecordBuilder seminarDate(LocalDate seminarDate) { + this.seminarDate = changedValue(seminarDate); + return this; + } + + /** + * Sets the value for seminarDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarDate(() -> LocalDate.now());
    +   * }
    + * + * @param seminarDateSupplier supplier for seminarDate + * @return current instance of builder + */ + public SeminarRecordBuilder seminarDate(Supplier seminarDateSupplier) { + this.seminarDate = changedValue(seminarDateSupplier.get()); + return this; + } + + /** + * Sets the value for seminarId. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarId(UUID.randomUUID());
    +   * }
    + * + * @param seminarId seminarId + * @return current instance of builder + */ + public SeminarRecordBuilder seminarId(UUID seminarId) { + this.seminarId = changedValue(seminarId); + return this; + } + + /** + * Sets the value for seminarId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarId(() -> UUID.randomUUID());
    +   * }
    + * + * @param seminarIdSupplier supplier for seminarId + * @return current instance of builder + */ + public SeminarRecordBuilder seminarId(Supplier seminarIdSupplier) { + this.seminarId = changedValue(seminarIdSupplier.get()); + return this; + } + + /** + * Sets the value for seminarTitle. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarTitle("example value");
    +   * }
    + * + * @param seminarTitle seminarTitle + * @return current instance of builder + */ + public SeminarRecordBuilder seminarTitle(String seminarTitle) { + this.seminarTitle = changedValue(seminarTitle); + return this; + } + + /** + * Sets the value for seminarTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param seminarTitleStringBuilderConsumer consumer providing an instance of seminarTitle + * @return current instance of builder + */ + public SeminarRecordBuilder seminarTitle(Consumer seminarTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + seminarTitleStringBuilderConsumer.accept(builder); + this.seminarTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for seminarTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarTitle(() -> "example value");
    +   * }
    + * + * @param seminarTitleSupplier supplier for seminarTitle + * @return current instance of builder + */ + public SeminarRecordBuilder seminarTitle(Supplier seminarTitleSupplier) { + this.seminarTitle = changedValue(seminarTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for seminarTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SeminarRecord#SeminarRecord(UUID, String, LocalDate, int, String) + * SeminarRecord(UUID seminarId, String seminarTitle, LocalDate seminarDate, int durationHours, String instructor)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seminarTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SeminarRecordBuilder seminarTitle(String format, Object... args) { + this.seminarTitle = changedValue(String.format(format, args)); + 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 SeminarRecordBuilder 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 SeminarRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SeminarRecord result = builder.build();
    +   * }
    + */ + @Override + public SeminarRecord build() { + if (!this.durationHours.isSet()) { + throw new IllegalStateException("Required field 'durationHours' must be set before calling build()"); + } + if (this.durationHours.value() == null) { + throw new IllegalStateException("Field 'durationHours' is marked as non-null but null value was provided"); + } + SeminarRecord result = new SeminarRecord(this.seminarId.value(), + this.seminarTitle.value(), + this.seminarDate.value(), + this.durationHours.value(), + this.instructor.value()); + 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("seminarId", this.seminarId) + .append("seminarTitle", this.seminarTitle) + .append("seminarDate", this.seminarDate) + .append("durationHours", this.durationHours) + .append("instructor", this.instructor) + .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 SeminarRecord with(Consumer b) { + SeminarRecordBuilder builder; + try { + builder = new SeminarRecordBuilder(SeminarRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SeminarRecordBuilder.With' should only be implemented by classes, which could be casted to 'SeminarRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SeminarRecordBuilder with() { + try { + return new SeminarRecordBuilder(SeminarRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SeminarRecordBuilder.With' should only be implemented by classes, which could be casted to 'SeminarRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SessionRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SessionRecordBuilder.java new file mode 100644 index 00000000..16af7e19 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SessionRecordBuilder.java @@ -0,0 +1,455 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalTime; +import java.util.UUID; +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.performance_test.library.events.SessionRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.SessionRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SessionRecord result = SessionRecordBuilder.create()
    + *     .sessionId(UUID.randomUUID())
    + *     .sessionId(() -> UUID.randomUUID())
    + *     .sessionTitle("example value")
    + *     .sessionTitle("Hello %s", "World")
    + *     .sessionTitle(() -> "example value")
    + *     .sessionTitle(sb -> sb.append("text"))
    + *     .startTime(LocalTime.now())
    + *     .startTime(() -> LocalTime.now())
    + *     .endTime(LocalTime.now())
    + *     .endTime(() -> LocalTime.now())
    + *     .attendeeCount(42)
    + *     .attendeeCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SessionRecord.class) +public class SessionRecordBuilder implements IBuilderBase { + + /** + * Tracked value for sessionId: sessionId. + */ + private TrackedValue sessionId = unsetValue(); + /** + * Tracked value for sessionTitle: sessionTitle. + */ + private TrackedValue sessionTitle = unsetValue(); + /** + * Tracked value for startTime: startTime. + */ + private TrackedValue startTime = unsetValue(); + /** + * Tracked value for endTime: endTime. + */ + private TrackedValue endTime = unsetValue(); + /** + * Tracked value for attendeeCount: attendeeCount. + */ + private TrackedValue attendeeCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SessionRecord}. + */ + public SessionRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SessionRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public SessionRecordBuilder(SessionRecord instance) { + this.sessionId = initialValue(instance.sessionId()); + this.sessionTitle = initialValue(instance.sessionTitle()); + this.startTime = initialValue(instance.startTime()); + this.endTime = initialValue(instance.endTime()); + this.attendeeCount = initialValue(instance.attendeeCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SessionRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SessionRecordBuilder builder = SessionRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SessionRecord} + */ + public static SessionRecordBuilder create() { + return new SessionRecordBuilder(); + } + + /** + * Sets the value for attendeeCount. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.attendeeCount(42);
    +   * }
    + * + * @param attendeeCount attendeeCount + * @return current instance of builder + */ + public SessionRecordBuilder attendeeCount(int attendeeCount) { + this.attendeeCount = changedValue(attendeeCount); + return this; + } + + /** + * Sets the value for attendeeCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.attendeeCount(() -> 42);
    +   * }
    + * + * @param attendeeCountSupplier supplier for attendeeCount + * @return current instance of builder + */ + public SessionRecordBuilder attendeeCount(Supplier attendeeCountSupplier) { + this.attendeeCount = changedValue(attendeeCountSupplier.get()); + return this; + } + + /** + * Sets the value for endTime. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endTime(LocalTime.now());
    +   * }
    + * + * @param endTime endTime + * @return current instance of builder + */ + public SessionRecordBuilder endTime(LocalTime endTime) { + this.endTime = changedValue(endTime); + return this; + } + + /** + * Sets the value for endTime by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endTime(() -> LocalTime.now());
    +   * }
    + * + * @param endTimeSupplier supplier for endTime + * @return current instance of builder + */ + public SessionRecordBuilder endTime(Supplier endTimeSupplier) { + this.endTime = changedValue(endTimeSupplier.get()); + return this; + } + + /** + * Sets the value for sessionId. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionId(UUID.randomUUID());
    +   * }
    + * + * @param sessionId sessionId + * @return current instance of builder + */ + public SessionRecordBuilder sessionId(UUID sessionId) { + this.sessionId = changedValue(sessionId); + return this; + } + + /** + * Sets the value for sessionId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionId(() -> UUID.randomUUID());
    +   * }
    + * + * @param sessionIdSupplier supplier for sessionId + * @return current instance of builder + */ + public SessionRecordBuilder sessionId(Supplier sessionIdSupplier) { + this.sessionId = changedValue(sessionIdSupplier.get()); + return this; + } + + /** + * Sets the value for sessionTitle. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionTitle("example value");
    +   * }
    + * + * @param sessionTitle sessionTitle + * @return current instance of builder + */ + public SessionRecordBuilder sessionTitle(String sessionTitle) { + this.sessionTitle = changedValue(sessionTitle); + return this; + } + + /** + * Sets the value for sessionTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param sessionTitleStringBuilderConsumer consumer providing an instance of sessionTitle + * @return current instance of builder + */ + public SessionRecordBuilder sessionTitle(Consumer sessionTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sessionTitleStringBuilderConsumer.accept(builder); + this.sessionTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sessionTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionTitle(() -> "example value");
    +   * }
    + * + * @param sessionTitleSupplier supplier for sessionTitle + * @return current instance of builder + */ + public SessionRecordBuilder sessionTitle(Supplier sessionTitleSupplier) { + this.sessionTitle = changedValue(sessionTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for sessionTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SessionRecordBuilder sessionTitle(String format, Object... args) { + this.sessionTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startTime. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startTime(LocalTime.now());
    +   * }
    + * + * @param startTime startTime + * @return current instance of builder + */ + public SessionRecordBuilder startTime(LocalTime startTime) { + this.startTime = changedValue(startTime); + return this; + } + + /** + * Sets the value for startTime by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SessionRecord#SessionRecord(UUID, String, LocalTime, LocalTime, int) + * SessionRecord(UUID sessionId, String sessionTitle, LocalTime startTime, LocalTime endTime, int attendeeCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startTime(() -> LocalTime.now());
    +   * }
    + * + * @param startTimeSupplier supplier for startTime + * @return current instance of builder + */ + public SessionRecordBuilder startTime(Supplier startTimeSupplier) { + this.startTime = changedValue(startTimeSupplier.get()); + 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 SessionRecordBuilder 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 SessionRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SessionRecord result = builder.build();
    +   * }
    + */ + @Override + public SessionRecord build() { + if (!this.attendeeCount.isSet()) { + throw new IllegalStateException("Required field 'attendeeCount' must be set before calling build()"); + } + if (this.attendeeCount.value() == null) { + throw new IllegalStateException("Field 'attendeeCount' is marked as non-null but null value was provided"); + } + SessionRecord result = new SessionRecord(this.sessionId + .value(), this.sessionTitle.value(), this.startTime.value(), this.endTime.value(), this.attendeeCount.value()); + 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("sessionId", this.sessionId) + .append("sessionTitle", this.sessionTitle) + .append("startTime", this.startTime) + .append("endTime", this.endTime) + .append("attendeeCount", this.attendeeCount) + .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 SessionRecord with(Consumer b) { + SessionRecordBuilder builder; + try { + builder = new SessionRecordBuilder(SessionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SessionRecordBuilder.With' should only be implemented by classes, which could be casted to 'SessionRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SessionRecordBuilder with() { + try { + return new SessionRecordBuilder(SessionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SessionRecordBuilder.With' should only be implemented by classes, which could be casted to 'SessionRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ShowRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ShowRecordBuilder.java new file mode 100644 index 00000000..67fea05e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/ShowRecordBuilder.java @@ -0,0 +1,501 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.ShowRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.ShowRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ShowRecord result = ShowRecordBuilder.create()
    + *     .showId(UUID.randomUUID())
    + *     .showId(() -> UUID.randomUUID())
    + *     .showName("example value")
    + *     .showName("Hello %s", "World")
    + *     .showName(() -> "example value")
    + *     .showName(sb -> sb.append("text"))
    + *     .showDate(LocalDate.now())
    + *     .showDate(() -> LocalDate.now())
    + *     .ticketCount(42)
    + *     .ticketCount(() -> 42)
    + *     .venue("example value")
    + *     .venue("Hello %s", "World")
    + *     .venue(() -> "example value")
    + *     .venue(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ShowRecord.class) +public class ShowRecordBuilder implements IBuilderBase { + + /** + * Tracked value for showId: showId. + */ + private TrackedValue showId = unsetValue(); + /** + * Tracked value for showName: showName. + */ + private TrackedValue showName = unsetValue(); + /** + * Tracked value for showDate: showDate. + */ + private TrackedValue showDate = unsetValue(); + /** + * Tracked value for ticketCount: ticketCount. + */ + private TrackedValue ticketCount = unsetValue(); + /** + * Tracked value for venue: venue. + */ + private TrackedValue venue = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.ShowRecord}. + */ + public ShowRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ShowRecord} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public ShowRecordBuilder(ShowRecord instance) { + this.showId = initialValue(instance.showId()); + this.showName = initialValue(instance.showName()); + this.showDate = initialValue(instance.showDate()); + this.ticketCount = initialValue(instance.ticketCount()); + this.venue = initialValue(instance.venue()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ShowRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ShowRecordBuilder builder = ShowRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.ShowRecord} + */ + public static ShowRecordBuilder create() { + return new ShowRecordBuilder(); + } + + /** + * Sets the value for showDate. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showDate(LocalDate.now());
    +   * }
    + * + * @param showDate showDate + * @return current instance of builder + */ + public ShowRecordBuilder showDate(LocalDate showDate) { + this.showDate = changedValue(showDate); + return this; + } + + /** + * Sets the value for showDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showDate(() -> LocalDate.now());
    +   * }
    + * + * @param showDateSupplier supplier for showDate + * @return current instance of builder + */ + public ShowRecordBuilder showDate(Supplier showDateSupplier) { + this.showDate = changedValue(showDateSupplier.get()); + return this; + } + + /** + * Sets the value for showId. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showId(UUID.randomUUID());
    +   * }
    + * + * @param showId showId + * @return current instance of builder + */ + public ShowRecordBuilder showId(UUID showId) { + this.showId = changedValue(showId); + return this; + } + + /** + * Sets the value for showId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showId(() -> UUID.randomUUID());
    +   * }
    + * + * @param showIdSupplier supplier for showId + * @return current instance of builder + */ + public ShowRecordBuilder showId(Supplier showIdSupplier) { + this.showId = changedValue(showIdSupplier.get()); + return this; + } + + /** + * Sets the value for showName. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showName("example value");
    +   * }
    + * + * @param showName showName + * @return current instance of builder + */ + public ShowRecordBuilder showName(String showName) { + this.showName = changedValue(showName); + return this; + } + + /** + * Sets the value for showName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showName(sb -> sb.append("text"));
    +   * }
    + * + * @param showNameStringBuilderConsumer consumer providing an instance of showName + * @return current instance of builder + */ + public ShowRecordBuilder showName(Consumer showNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + showNameStringBuilderConsumer.accept(builder); + this.showName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for showName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showName(() -> "example value");
    +   * }
    + * + * @param showNameSupplier supplier for showName + * @return current instance of builder + */ + public ShowRecordBuilder showName(Supplier showNameSupplier) { + this.showName = changedValue(showNameSupplier.get()); + return this; + } + + /** + * Sets the String value for showName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShowRecordBuilder showName(String format, Object... args) { + this.showName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for ticketCount. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ticketCount(42);
    +   * }
    + * + * @param ticketCount ticketCount + * @return current instance of builder + */ + public ShowRecordBuilder ticketCount(int ticketCount) { + this.ticketCount = changedValue(ticketCount); + return this; + } + + /** + * Sets the value for ticketCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ticketCount(() -> 42);
    +   * }
    + * + * @param ticketCountSupplier supplier for ticketCount + * @return current instance of builder + */ + public ShowRecordBuilder ticketCount(Supplier ticketCountSupplier) { + this.ticketCount = changedValue(ticketCountSupplier.get()); + return this; + } + + /** + * Sets the value for venue. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.venue("example value");
    +   * }
    + * + * @param venue venue + * @return current instance of builder + */ + public ShowRecordBuilder venue(String venue) { + this.venue = changedValue(venue); + return this; + } + + /** + * Sets the value for venue by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.venue(sb -> sb.append("text"));
    +   * }
    + * + * @param venueStringBuilderConsumer consumer providing an instance of venue + * @return current instance of builder + */ + public ShowRecordBuilder venue(Consumer venueStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + venueStringBuilderConsumer.accept(builder); + this.venue = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for venue by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.venue(() -> "example value");
    +   * }
    + * + * @param venueSupplier supplier for venue + * @return current instance of builder + */ + public ShowRecordBuilder venue(Supplier venueSupplier) { + this.venue = changedValue(venueSupplier.get()); + return this; + } + + /** + * Sets the String value for venue by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ShowRecord#ShowRecord(UUID, String, LocalDate, int, String) + * ShowRecord(UUID showId, String showName, LocalDate showDate, int ticketCount, String venue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.venue("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShowRecordBuilder venue(String format, Object... args) { + this.venue = changedValue(String.format(format, args)); + 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 ShowRecordBuilder 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 ShowRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ShowRecord result = builder.build();
    +   * }
    + */ + @Override + public ShowRecord build() { + if (!this.ticketCount.isSet()) { + throw new IllegalStateException("Required field 'ticketCount' must be set before calling build()"); + } + if (this.ticketCount.value() == null) { + throw new IllegalStateException("Field 'ticketCount' is marked as non-null but null value was provided"); + } + ShowRecord result = new ShowRecord(this.showId + .value(), this.showName.value(), this.showDate.value(), this.ticketCount.value(), this.venue.value()); + 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("showId", this.showId) + .append("showName", this.showName) + .append("showDate", this.showDate) + .append("ticketCount", this.ticketCount) + .append("venue", this.venue) + .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 ShowRecord with(Consumer b) { + ShowRecordBuilder builder; + try { + builder = new ShowRecordBuilder(ShowRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ShowRecordBuilder.With' should only be implemented by classes, which could be casted to 'ShowRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ShowRecordBuilder with() { + try { + return new ShowRecordBuilder(ShowRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ShowRecordBuilder.With' should only be implemented by classes, which could be casted to 'ShowRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SimpleTypesBenchmarkBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SimpleTypesBenchmarkBuilder.java new file mode 100644 index 00000000..2e4d1aa1 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SimpleTypesBenchmarkBuilder.java @@ -0,0 +1,1309 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.SimpleTypesBenchmark}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.SimpleTypesBenchmark 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. + * + *

    Example:

    + * + *
    {@code
    + * SimpleTypesBenchmark result = SimpleTypesBenchmarkBuilder.create()
    + *     .attendanceRatio(3.14f)
    + *     .attendanceRatio(() -> 3.14f)
    + *     .bookingIdentifier(42L)
    + *     .bookingIdentifier(() -> 42L)
    + *     .categoryCode('x')
    + *     .categoryCode(() -> 'x')
    + *     .costRatio(3.14f)
    + *     .costRatio(() -> 3.14f)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .discountRatio(3.14f)
    + *     .discountRatio(() -> 3.14f)
    + *     .durationMeasurement(3.14)
    + *     .durationMeasurement(() -> 3.14)
    + *     .eventCount(42)
    + *     .eventCount(() -> 42)
    + *     .eventIdentifier(42L)
    + *     .eventIdentifier(() -> 42L)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .isActive(true)
    + *     .isActive(() -> true)
    + *     .isPublic(true)
    + *     .isPublic(() -> true)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .participantCount(42)
    + *     .participantCount(() -> 42)
    + *     .revenueMeasurement(3.14)
    + *     .revenueMeasurement(() -> 3.14)
    + *     .scoreMeasurement(3.14)
    + *     .scoreMeasurement(() -> 3.14)
    + *     .sessionIdentifier(42L)
    + *     .sessionIdentifier(() -> 42L)
    + *     .statusCode('x')
    + *     .statusCode(() -> 'x')
    + *     .ticketCount(42)
    + *     .ticketCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SimpleTypesBenchmark.class) +public class SimpleTypesBenchmarkBuilder implements IBuilderBase { + + /** + * Tracked value for attendanceRatio: attendanceRatio. + */ + private TrackedValue attendanceRatio = unsetValue(); + /** + * Tracked value for bookingIdentifier: bookingIdentifier. + */ + private TrackedValue bookingIdentifier = unsetValue(); + /** + * Tracked value for categoryCode: categoryCode. + */ + private TrackedValue categoryCode = unsetValue(); + /** + * Tracked value for costRatio: costRatio. + */ + private TrackedValue costRatio = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for discountRatio: discountRatio. + */ + private TrackedValue discountRatio = unsetValue(); + /** + * Tracked value for durationMeasurement: durationMeasurement. + */ + private TrackedValue durationMeasurement = unsetValue(); + /** + * Tracked value for eventCount: eventCount. + */ + private TrackedValue eventCount = unsetValue(); + /** + * Tracked value for eventIdentifier: eventIdentifier. + */ + private TrackedValue eventIdentifier = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for isActive: isActive. + */ + private TrackedValue isActive = unsetValue(); + /** + * Tracked value for isPublic: isPublic. + */ + private TrackedValue isPublic = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for participantCount: participantCount. + */ + private TrackedValue participantCount = unsetValue(); + /** + * Tracked value for priorityLevel: priorityLevel. + */ + private TrackedValue priorityLevel = unsetValue(); + /** + * Tracked value for revenueMeasurement: revenueMeasurement. + */ + private TrackedValue revenueMeasurement = unsetValue(); + /** + * Tracked value for scoreMeasurement: scoreMeasurement. + */ + private TrackedValue scoreMeasurement = unsetValue(); + /** + * Tracked value for seatIndex: seatIndex. + */ + private TrackedValue seatIndex = unsetValue(); + /** + * Tracked value for sessionIdentifier: sessionIdentifier. + */ + private TrackedValue sessionIdentifier = unsetValue(); + /** + * Tracked value for statusCode: statusCode. + */ + private TrackedValue statusCode = unsetValue(); + /** + * Tracked value for ticketCount: ticketCount. + */ + private TrackedValue ticketCount = unsetValue(); + /** + * Tracked value for urgencyLevel: urgencyLevel. + */ + private TrackedValue urgencyLevel = unsetValue(); + /** + * Tracked value for waitlistIndex: waitlistIndex. + */ + private TrackedValue waitlistIndex = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SimpleTypesBenchmark}. + */ + public SimpleTypesBenchmarkBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SimpleTypesBenchmark} by a instance. + * + * @param instance object instance for initialisiation + */ + public SimpleTypesBenchmarkBuilder(SimpleTypesBenchmark instance) { + this.attendanceRatio = initialValue(instance.getAttendanceRatio()); + this.bookingIdentifier = initialValue(instance.getBookingIdentifier()); + this.categoryCode = initialValue(instance.getCategoryCode()); + this.costRatio = initialValue(instance.getCostRatio()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.discountRatio = initialValue(instance.getDiscountRatio()); + this.durationMeasurement = initialValue(instance.getDurationMeasurement()); + this.eventCount = initialValue(instance.getEventCount()); + this.eventIdentifier = initialValue(instance.getEventIdentifier()); + this.id = initialValue(instance.getId()); + this.isActive = initialValue(instance.isIsActive()); + this.isPublic = initialValue(instance.isIsPublic()); + this.name = initialValue(instance.getName()); + this.participantCount = initialValue(instance.getParticipantCount()); + this.priorityLevel = initialValue(instance.getPriorityLevel()); + this.revenueMeasurement = initialValue(instance.getRevenueMeasurement()); + this.scoreMeasurement = initialValue(instance.getScoreMeasurement()); + this.seatIndex = initialValue(instance.getSeatIndex()); + this.sessionIdentifier = initialValue(instance.getSessionIdentifier()); + this.statusCode = initialValue(instance.getStatusCode()); + this.ticketCount = initialValue(instance.getTicketCount()); + this.urgencyLevel = initialValue(instance.getUrgencyLevel()); + this.waitlistIndex = initialValue(instance.getWaitlistIndex()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SimpleTypesBenchmark}. + * + *

    Example:

    + * + *
    {@code
    +   * SimpleTypesBenchmarkBuilder builder = SimpleTypesBenchmarkBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SimpleTypesBenchmark} + */ + public static SimpleTypesBenchmarkBuilder create() { + return new SimpleTypesBenchmarkBuilder(); + } + + /** + * Sets the value for attendanceRatio. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setAttendanceRatio(float) setAttendanceRatio(float + * attendanceRatio)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.attendanceRatio(3.14f);
    +   * }
    + * + * @param attendanceRatio attendanceRatio + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder attendanceRatio(float attendanceRatio) { + this.attendanceRatio = changedValue(attendanceRatio); + return this; + } + + /** + * Sets the value for attendanceRatio by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setAttendanceRatio(float) setAttendanceRatio(float + * attendanceRatio)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.attendanceRatio(() -> 3.14f);
    +   * }
    + * + * @param attendanceRatioSupplier supplier for attendanceRatio + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder attendanceRatio(Supplier attendanceRatioSupplier) { + this.attendanceRatio = changedValue(attendanceRatioSupplier.get()); + return this; + } + + /** + * Sets the value for bookingIdentifier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setBookingIdentifier(long) setBookingIdentifier(long + * bookingIdentifier)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bookingIdentifier(42L);
    +   * }
    + * + * @param bookingIdentifier bookingIdentifier + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder bookingIdentifier(long bookingIdentifier) { + this.bookingIdentifier = changedValue(bookingIdentifier); + return this; + } + + /** + * Sets the value for bookingIdentifier by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setBookingIdentifier(long) setBookingIdentifier(long + * bookingIdentifier)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bookingIdentifier(() -> 42L);
    +   * }
    + * + * @param bookingIdentifierSupplier supplier for bookingIdentifier + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder bookingIdentifier(Supplier bookingIdentifierSupplier) { + this.bookingIdentifier = changedValue(bookingIdentifierSupplier.get()); + return this; + } + + /** + * Sets the value for categoryCode. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setCategoryCode(char) setCategoryCode(char categoryCode)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.categoryCode('x');
    +   * }
    + * + * @param categoryCode categoryCode + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder categoryCode(char categoryCode) { + this.categoryCode = changedValue(categoryCode); + return this; + } + + /** + * Sets the value for categoryCode by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setCategoryCode(char) setCategoryCode(char categoryCode)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.categoryCode(() -> 'x');
    +   * }
    + * + * @param categoryCodeSupplier supplier for categoryCode + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder categoryCode(Supplier categoryCodeSupplier) { + this.categoryCode = changedValue(categoryCodeSupplier.get()); + return this; + } + + /** + * Sets the value for costRatio. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setCostRatio(float) setCostRatio(float costRatio)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.costRatio(3.14f);
    +   * }
    + * + * @param costRatio costRatio + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder costRatio(float costRatio) { + this.costRatio = changedValue(costRatio); + return this; + } + + /** + * Sets the value for costRatio by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setCostRatio(float) setCostRatio(float costRatio)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.costRatio(() -> 3.14f);
    +   * }
    + * + * @param costRatioSupplier supplier for costRatio + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder costRatio(Supplier costRatioSupplier) { + this.costRatio = changedValue(costRatioSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for discountRatio. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setDiscountRatio(float) setDiscountRatio(float discountRatio)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.discountRatio(3.14f);
    +   * }
    + * + * @param discountRatio discountRatio + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder discountRatio(float discountRatio) { + this.discountRatio = changedValue(discountRatio); + return this; + } + + /** + * Sets the value for discountRatio by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setDiscountRatio(float) setDiscountRatio(float discountRatio)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.discountRatio(() -> 3.14f);
    +   * }
    + * + * @param discountRatioSupplier supplier for discountRatio + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder discountRatio(Supplier discountRatioSupplier) { + this.discountRatio = changedValue(discountRatioSupplier.get()); + return this; + } + + /** + * Sets the value for durationMeasurement. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setDurationMeasurement(double) setDurationMeasurement(double + * durationMeasurement)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMeasurement(3.14);
    +   * }
    + * + * @param durationMeasurement durationMeasurement + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder durationMeasurement(double durationMeasurement) { + this.durationMeasurement = changedValue(durationMeasurement); + return this; + } + + /** + * Sets the value for durationMeasurement by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setDurationMeasurement(double) setDurationMeasurement(double + * durationMeasurement)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMeasurement(() -> 3.14);
    +   * }
    + * + * @param durationMeasurementSupplier supplier for durationMeasurement + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder durationMeasurement(Supplier durationMeasurementSupplier) { + this.durationMeasurement = changedValue(durationMeasurementSupplier.get()); + return this; + } + + /** + * Sets the value for eventCount. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setEventCount(int) setEventCount(int eventCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eventCount(42);
    +   * }
    + * + * @param eventCount eventCount + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder eventCount(int eventCount) { + this.eventCount = changedValue(eventCount); + return this; + } + + /** + * Sets the value for eventCount by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setEventCount(int) setEventCount(int eventCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eventCount(() -> 42);
    +   * }
    + * + * @param eventCountSupplier supplier for eventCount + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder eventCount(Supplier eventCountSupplier) { + this.eventCount = changedValue(eventCountSupplier.get()); + return this; + } + + /** + * Sets the value for eventIdentifier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setEventIdentifier(long) setEventIdentifier(long + * eventIdentifier)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eventIdentifier(42L);
    +   * }
    + * + * @param eventIdentifier eventIdentifier + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder eventIdentifier(long eventIdentifier) { + this.eventIdentifier = changedValue(eventIdentifier); + return this; + } + + /** + * Sets the value for eventIdentifier by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setEventIdentifier(long) setEventIdentifier(long + * eventIdentifier)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eventIdentifier(() -> 42L);
    +   * }
    + * + * @param eventIdentifierSupplier supplier for eventIdentifier + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder eventIdentifier(Supplier eventIdentifierSupplier) { + this.eventIdentifier = changedValue(eventIdentifierSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for isActive. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setIsActive(boolean) setIsActive(boolean isActive)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isActive(true);
    +   * }
    + * + * @param isActive isActive + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder isActive(boolean isActive) { + this.isActive = changedValue(isActive); + return this; + } + + /** + * Sets the value for isActive by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setIsActive(boolean) setIsActive(boolean isActive)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isActive(() -> true);
    +   * }
    + * + * @param isActiveSupplier supplier for isActive + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder isActive(Supplier isActiveSupplier) { + this.isActive = changedValue(isActiveSupplier.get()); + return this; + } + + /** + * Sets the value for isPublic. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setIsPublic(boolean) setIsPublic(boolean isPublic)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isPublic(true);
    +   * }
    + * + * @param isPublic isPublic + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder isPublic(boolean isPublic) { + this.isPublic = changedValue(isPublic); + return this; + } + + /** + * Sets the value for isPublic by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setIsPublic(boolean) setIsPublic(boolean isPublic)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isPublic(() -> true);
    +   * }
    + * + * @param isPublicSupplier supplier for isPublic + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder isPublic(Supplier isPublicSupplier) { + this.isPublic = changedValue(isPublicSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder 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. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder 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. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for participantCount. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setParticipantCount(int) setParticipantCount(int + * participantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.participantCount(42);
    +   * }
    + * + * @param participantCount participantCount + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder participantCount(int participantCount) { + this.participantCount = changedValue(participantCount); + return this; + } + + /** + * Sets the value for participantCount by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setParticipantCount(int) setParticipantCount(int + * participantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.participantCount(() -> 42);
    +   * }
    + * + * @param participantCountSupplier supplier for participantCount + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder participantCount(Supplier participantCountSupplier) { + this.participantCount = changedValue(participantCountSupplier.get()); + return this; + } + + /** + * Sets the value for priorityLevel. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setPriorityLevel(byte) setPriorityLevel(byte priorityLevel)} + * + * @param priorityLevel priorityLevel + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder priorityLevel(byte priorityLevel) { + this.priorityLevel = changedValue(priorityLevel); + return this; + } + + /** + * Sets the value for priorityLevel by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setPriorityLevel(byte) setPriorityLevel(byte priorityLevel)} + * + * @param priorityLevelSupplier supplier for priorityLevel + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder priorityLevel(Supplier priorityLevelSupplier) { + this.priorityLevel = changedValue(priorityLevelSupplier.get()); + return this; + } + + /** + * Sets the value for revenueMeasurement. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setRevenueMeasurement(double) setRevenueMeasurement(double + * revenueMeasurement)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.revenueMeasurement(3.14);
    +   * }
    + * + * @param revenueMeasurement revenueMeasurement + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder revenueMeasurement(double revenueMeasurement) { + this.revenueMeasurement = changedValue(revenueMeasurement); + return this; + } + + /** + * Sets the value for revenueMeasurement by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setRevenueMeasurement(double) setRevenueMeasurement(double + * revenueMeasurement)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.revenueMeasurement(() -> 3.14);
    +   * }
    + * + * @param revenueMeasurementSupplier supplier for revenueMeasurement + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder revenueMeasurement(Supplier revenueMeasurementSupplier) { + this.revenueMeasurement = changedValue(revenueMeasurementSupplier.get()); + return this; + } + + /** + * Sets the value for scoreMeasurement. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setScoreMeasurement(double) setScoreMeasurement(double + * scoreMeasurement)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scoreMeasurement(3.14);
    +   * }
    + * + * @param scoreMeasurement scoreMeasurement + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder scoreMeasurement(double scoreMeasurement) { + this.scoreMeasurement = changedValue(scoreMeasurement); + return this; + } + + /** + * Sets the value for scoreMeasurement by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setScoreMeasurement(double) setScoreMeasurement(double + * scoreMeasurement)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scoreMeasurement(() -> 3.14);
    +   * }
    + * + * @param scoreMeasurementSupplier supplier for scoreMeasurement + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder scoreMeasurement(Supplier scoreMeasurementSupplier) { + this.scoreMeasurement = changedValue(scoreMeasurementSupplier.get()); + return this; + } + + /** + * Sets the value for seatIndex. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setSeatIndex(short) setSeatIndex(short seatIndex)} + * + * @param seatIndex seatIndex + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder seatIndex(short seatIndex) { + this.seatIndex = changedValue(seatIndex); + return this; + } + + /** + * Sets the value for seatIndex by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setSeatIndex(short) setSeatIndex(short seatIndex)} + * + * @param seatIndexSupplier supplier for seatIndex + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder seatIndex(Supplier seatIndexSupplier) { + this.seatIndex = changedValue(seatIndexSupplier.get()); + return this; + } + + /** + * Sets the value for sessionIdentifier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setSessionIdentifier(long) setSessionIdentifier(long + * sessionIdentifier)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionIdentifier(42L);
    +   * }
    + * + * @param sessionIdentifier sessionIdentifier + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder sessionIdentifier(long sessionIdentifier) { + this.sessionIdentifier = changedValue(sessionIdentifier); + return this; + } + + /** + * Sets the value for sessionIdentifier by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setSessionIdentifier(long) setSessionIdentifier(long + * sessionIdentifier)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sessionIdentifier(() -> 42L);
    +   * }
    + * + * @param sessionIdentifierSupplier supplier for sessionIdentifier + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder sessionIdentifier(Supplier sessionIdentifierSupplier) { + this.sessionIdentifier = changedValue(sessionIdentifierSupplier.get()); + return this; + } + + /** + * Sets the value for statusCode. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setStatusCode(char) setStatusCode(char statusCode)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statusCode('x');
    +   * }
    + * + * @param statusCode statusCode + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder statusCode(char statusCode) { + this.statusCode = changedValue(statusCode); + return this; + } + + /** + * Sets the value for statusCode by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setStatusCode(char) setStatusCode(char statusCode)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statusCode(() -> 'x');
    +   * }
    + * + * @param statusCodeSupplier supplier for statusCode + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder statusCode(Supplier statusCodeSupplier) { + this.statusCode = changedValue(statusCodeSupplier.get()); + return this; + } + + /** + * Sets the value for ticketCount. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setTicketCount(int) setTicketCount(int ticketCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ticketCount(42);
    +   * }
    + * + * @param ticketCount ticketCount + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder ticketCount(int ticketCount) { + this.ticketCount = changedValue(ticketCount); + return this; + } + + /** + * Sets the value for ticketCount by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setTicketCount(int) setTicketCount(int ticketCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ticketCount(() -> 42);
    +   * }
    + * + * @param ticketCountSupplier supplier for ticketCount + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder ticketCount(Supplier ticketCountSupplier) { + this.ticketCount = changedValue(ticketCountSupplier.get()); + return this; + } + + /** + * Sets the value for urgencyLevel. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setUrgencyLevel(byte) setUrgencyLevel(byte urgencyLevel)} + * + * @param urgencyLevel urgencyLevel + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder urgencyLevel(byte urgencyLevel) { + this.urgencyLevel = changedValue(urgencyLevel); + return this; + } + + /** + * Sets the value for urgencyLevel by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setUrgencyLevel(byte) setUrgencyLevel(byte urgencyLevel)} + * + * @param urgencyLevelSupplier supplier for urgencyLevel + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder urgencyLevel(Supplier urgencyLevelSupplier) { + this.urgencyLevel = changedValue(urgencyLevelSupplier.get()); + return this; + } + + /** + * Sets the value for waitlistIndex. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setWaitlistIndex(short) setWaitlistIndex(short waitlistIndex)} + * + * @param waitlistIndex waitlistIndex + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder waitlistIndex(short waitlistIndex) { + this.waitlistIndex = changedValue(waitlistIndex); + return this; + } + + /** + * Sets the value for waitlistIndex by invoking the provided supplier. + *

    + * Generated from setter {@link SimpleTypesBenchmark#setWaitlistIndex(short) setWaitlistIndex(short waitlistIndex)} + * + * @param waitlistIndexSupplier supplier for waitlistIndex + * @return current instance of builder + */ + public SimpleTypesBenchmarkBuilder waitlistIndex(Supplier waitlistIndexSupplier) { + this.waitlistIndex = changedValue(waitlistIndexSupplier.get()); + 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 SimpleTypesBenchmarkBuilder 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 SimpleTypesBenchmarkBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SimpleTypesBenchmark result = builder.build();
    +   * }
    + */ + @Override + public SimpleTypesBenchmark build() { + if (this.attendanceRatio.isSet() && this.attendanceRatio.value() == null) { + throw new IllegalStateException("Field 'attendanceRatio' is marked as non-null but null value was provided"); + } + if (this.bookingIdentifier.isSet() && this.bookingIdentifier.value() == null) { + throw new IllegalStateException("Field 'bookingIdentifier' is marked as non-null but null value was provided"); + } + if (this.categoryCode.isSet() && this.categoryCode.value() == null) { + throw new IllegalStateException("Field 'categoryCode' is marked as non-null but null value was provided"); + } + if (this.costRatio.isSet() && this.costRatio.value() == null) { + throw new IllegalStateException("Field 'costRatio' is marked as non-null but null value was provided"); + } + if (this.discountRatio.isSet() && this.discountRatio.value() == null) { + throw new IllegalStateException("Field 'discountRatio' is marked as non-null but null value was provided"); + } + if (this.durationMeasurement.isSet() && this.durationMeasurement.value() == null) { + throw new IllegalStateException("Field 'durationMeasurement' is marked as non-null but null value was provided"); + } + if (this.eventCount.isSet() && this.eventCount.value() == null) { + throw new IllegalStateException("Field 'eventCount' is marked as non-null but null value was provided"); + } + if (this.eventIdentifier.isSet() && this.eventIdentifier.value() == null) { + throw new IllegalStateException("Field 'eventIdentifier' is marked as non-null but null value was provided"); + } + if (this.isActive.isSet() && this.isActive.value() == null) { + throw new IllegalStateException("Field 'isActive' is marked as non-null but null value was provided"); + } + if (this.isPublic.isSet() && this.isPublic.value() == null) { + throw new IllegalStateException("Field 'isPublic' is marked as non-null but null value was provided"); + } + if (this.participantCount.isSet() && this.participantCount.value() == null) { + throw new IllegalStateException("Field 'participantCount' is marked as non-null but null value was provided"); + } + if (this.priorityLevel.isSet() && this.priorityLevel.value() == null) { + throw new IllegalStateException("Field 'priorityLevel' is marked as non-null but null value was provided"); + } + if (this.revenueMeasurement.isSet() && this.revenueMeasurement.value() == null) { + throw new IllegalStateException("Field 'revenueMeasurement' is marked as non-null but null value was provided"); + } + if (this.scoreMeasurement.isSet() && this.scoreMeasurement.value() == null) { + throw new IllegalStateException("Field 'scoreMeasurement' is marked as non-null but null value was provided"); + } + if (this.seatIndex.isSet() && this.seatIndex.value() == null) { + throw new IllegalStateException("Field 'seatIndex' is marked as non-null but null value was provided"); + } + if (this.sessionIdentifier.isSet() && this.sessionIdentifier.value() == null) { + throw new IllegalStateException("Field 'sessionIdentifier' is marked as non-null but null value was provided"); + } + if (this.statusCode.isSet() && this.statusCode.value() == null) { + throw new IllegalStateException("Field 'statusCode' is marked as non-null but null value was provided"); + } + if (this.ticketCount.isSet() && this.ticketCount.value() == null) { + throw new IllegalStateException("Field 'ticketCount' is marked as non-null but null value was provided"); + } + if (this.urgencyLevel.isSet() && this.urgencyLevel.value() == null) { + throw new IllegalStateException("Field 'urgencyLevel' is marked as non-null but null value was provided"); + } + if (this.waitlistIndex.isSet() && this.waitlistIndex.value() == null) { + throw new IllegalStateException("Field 'waitlistIndex' is marked as non-null but null value was provided"); + } + SimpleTypesBenchmark result = new SimpleTypesBenchmark(); + this.attendanceRatio.ifSet(result::setAttendanceRatio); + this.bookingIdentifier.ifSet(result::setBookingIdentifier); + this.categoryCode.ifSet(result::setCategoryCode); + this.costRatio.ifSet(result::setCostRatio); + this.createdAt.ifSet(result::setCreatedAt); + this.discountRatio.ifSet(result::setDiscountRatio); + this.durationMeasurement.ifSet(result::setDurationMeasurement); + this.eventCount.ifSet(result::setEventCount); + this.eventIdentifier.ifSet(result::setEventIdentifier); + this.id.ifSet(result::setId); + this.isActive.ifSet(result::setIsActive); + this.isPublic.ifSet(result::setIsPublic); + this.name.ifSet(result::setName); + this.participantCount.ifSet(result::setParticipantCount); + this.priorityLevel.ifSet(result::setPriorityLevel); + this.revenueMeasurement.ifSet(result::setRevenueMeasurement); + this.scoreMeasurement.ifSet(result::setScoreMeasurement); + this.seatIndex.ifSet(result::setSeatIndex); + this.sessionIdentifier.ifSet(result::setSessionIdentifier); + this.statusCode.ifSet(result::setStatusCode); + this.ticketCount.ifSet(result::setTicketCount); + this.urgencyLevel.ifSet(result::setUrgencyLevel); + this.waitlistIndex.ifSet(result::setWaitlistIndex); + 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("attendanceRatio", this.attendanceRatio) + .append("bookingIdentifier", this.bookingIdentifier) + .append("categoryCode", this.categoryCode) + .append("costRatio", this.costRatio) + .append("createdAt", this.createdAt) + .append("discountRatio", this.discountRatio) + .append("durationMeasurement", this.durationMeasurement) + .append("eventCount", this.eventCount) + .append("eventIdentifier", this.eventIdentifier) + .append("id", this.id) + .append("isActive", this.isActive) + .append("isPublic", this.isPublic) + .append("name", this.name) + .append("participantCount", this.participantCount) + .append("priorityLevel", this.priorityLevel) + .append("revenueMeasurement", this.revenueMeasurement) + .append("scoreMeasurement", this.scoreMeasurement) + .append("seatIndex", this.seatIndex) + .append("sessionIdentifier", this.sessionIdentifier) + .append("statusCode", this.statusCode) + .append("ticketCount", this.ticketCount) + .append("urgencyLevel", this.urgencyLevel) + .append("waitlistIndex", this.waitlistIndex) + .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 SimpleTypesBenchmark with(Consumer b) { + SimpleTypesBenchmarkBuilder builder; + try { + builder = new SimpleTypesBenchmarkBuilder(SimpleTypesBenchmark.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SimpleTypesBenchmarkBuilder.With' should only be implemented by classes, which could be casted to 'SimpleTypesBenchmark'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SimpleTypesBenchmarkBuilder with() { + try { + return new SimpleTypesBenchmarkBuilder(SimpleTypesBenchmark.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SimpleTypesBenchmarkBuilder.With' should only be implemented by classes, which could be casted to 'SimpleTypesBenchmark'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/StipendRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/StipendRecordBuilder.java new file mode 100644 index 00000000..54d9a200 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/StipendRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.StipendRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.StipendRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * StipendRecord result = StipendRecordBuilder.create()
    + *     .fellowshipId(UUID.randomUUID())
    + *     .fellowshipId(() -> UUID.randomUUID())
    + *     .fellowshipName("example value")
    + *     .fellowshipName("Hello %s", "World")
    + *     .fellowshipName(() -> "example value")
    + *     .fellowshipName(sb -> sb.append("text"))
    + *     .fellow("example value")
    + *     .fellow("Hello %s", "World")
    + *     .fellow(() -> "example value")
    + *     .fellow(sb -> sb.append("text"))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .endDate(LocalDate.now())
    + *     .endDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StipendRecord.class) +public class StipendRecordBuilder implements IBuilderBase { + + /** + * Tracked value for fellowshipId: fellowshipId. + */ + private TrackedValue fellowshipId = unsetValue(); + /** + * Tracked value for fellowshipName: fellowshipName. + */ + private TrackedValue fellowshipName = unsetValue(); + /** + * Tracked value for fellow: fellow. + */ + private TrackedValue fellow = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + /** + * Tracked value for endDate: endDate. + */ + private TrackedValue endDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.StipendRecord}. + */ + public StipendRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.StipendRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public StipendRecordBuilder(StipendRecord instance) { + this.fellowshipId = initialValue(instance.fellowshipId()); + this.fellowshipName = initialValue(instance.fellowshipName()); + this.fellow = initialValue(instance.fellow()); + this.startDate = initialValue(instance.startDate()); + this.endDate = initialValue(instance.endDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.StipendRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * StipendRecordBuilder builder = StipendRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.StipendRecord} + */ + public static StipendRecordBuilder create() { + return new StipendRecordBuilder(); + } + + /** + * Sets the value for endDate. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endDate(LocalDate.now());
    +   * }
    + * + * @param endDate endDate + * @return current instance of builder + */ + public StipendRecordBuilder endDate(LocalDate endDate) { + this.endDate = changedValue(endDate); + return this; + } + + /** + * Sets the value for endDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endDate(() -> LocalDate.now());
    +   * }
    + * + * @param endDateSupplier supplier for endDate + * @return current instance of builder + */ + public StipendRecordBuilder endDate(Supplier endDateSupplier) { + this.endDate = changedValue(endDateSupplier.get()); + return this; + } + + /** + * Sets the value for fellow. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellow("example value");
    +   * }
    + * + * @param fellow fellow + * @return current instance of builder + */ + public StipendRecordBuilder fellow(String fellow) { + this.fellow = changedValue(fellow); + return this; + } + + /** + * Sets the value for fellow by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellow(sb -> sb.append("text"));
    +   * }
    + * + * @param fellowStringBuilderConsumer consumer providing an instance of fellow + * @return current instance of builder + */ + public StipendRecordBuilder fellow(Consumer fellowStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fellowStringBuilderConsumer.accept(builder); + this.fellow = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for fellow by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellow(() -> "example value");
    +   * }
    + * + * @param fellowSupplier supplier for fellow + * @return current instance of builder + */ + public StipendRecordBuilder fellow(Supplier fellowSupplier) { + this.fellow = changedValue(fellowSupplier.get()); + return this; + } + + /** + * Sets the String value for fellow by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellow("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StipendRecordBuilder fellow(String format, Object... args) { + this.fellow = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for fellowshipId. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellowshipId(UUID.randomUUID());
    +   * }
    + * + * @param fellowshipId fellowshipId + * @return current instance of builder + */ + public StipendRecordBuilder fellowshipId(UUID fellowshipId) { + this.fellowshipId = changedValue(fellowshipId); + return this; + } + + /** + * Sets the value for fellowshipId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellowshipId(() -> UUID.randomUUID());
    +   * }
    + * + * @param fellowshipIdSupplier supplier for fellowshipId + * @return current instance of builder + */ + public StipendRecordBuilder fellowshipId(Supplier fellowshipIdSupplier) { + this.fellowshipId = changedValue(fellowshipIdSupplier.get()); + return this; + } + + /** + * Sets the value for fellowshipName. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellowshipName("example value");
    +   * }
    + * + * @param fellowshipName fellowshipName + * @return current instance of builder + */ + public StipendRecordBuilder fellowshipName(String fellowshipName) { + this.fellowshipName = changedValue(fellowshipName); + return this; + } + + /** + * Sets the value for fellowshipName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellowshipName(sb -> sb.append("text"));
    +   * }
    + * + * @param fellowshipNameStringBuilderConsumer consumer providing an instance of fellowshipName + * @return current instance of builder + */ + public StipendRecordBuilder fellowshipName(Consumer fellowshipNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fellowshipNameStringBuilderConsumer.accept(builder); + this.fellowshipName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for fellowshipName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellowshipName(() -> "example value");
    +   * }
    + * + * @param fellowshipNameSupplier supplier for fellowshipName + * @return current instance of builder + */ + public StipendRecordBuilder fellowshipName(Supplier fellowshipNameSupplier) { + this.fellowshipName = changedValue(fellowshipNameSupplier.get()); + return this; + } + + /** + * Sets the String value for fellowshipName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fellowshipName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StipendRecordBuilder fellowshipName(String format, Object... args) { + this.fellowshipName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public StipendRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StipendRecord#StipendRecord(UUID, String, String, LocalDate, LocalDate) StipendRecord(UUID fellowshipId, + * String fellowshipName, String fellow, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public StipendRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + 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 StipendRecordBuilder 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 StipendRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StipendRecord result = builder.build();
    +   * }
    + */ + @Override + public StipendRecord build() { + StipendRecord result = new StipendRecord(this.fellowshipId + .value(), this.fellowshipName.value(), this.fellow.value(), this.startDate.value(), this.endDate.value()); + 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("fellowshipId", this.fellowshipId) + .append("fellowshipName", this.fellowshipName) + .append("fellow", this.fellow) + .append("startDate", this.startDate) + .append("endDate", this.endDate) + .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 StipendRecord with(Consumer b) { + StipendRecordBuilder builder; + try { + builder = new StipendRecordBuilder(StipendRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StipendRecordBuilder.With' should only be implemented by classes, which could be casted to 'StipendRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StipendRecordBuilder with() { + try { + return new StipendRecordBuilder(StipendRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StipendRecordBuilder.With' should only be implemented by classes, which could be casted to 'StipendRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SymposiumRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SymposiumRecordBuilder.java new file mode 100644 index 00000000..477783ba --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/SymposiumRecordBuilder.java @@ -0,0 +1,515 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.SymposiumRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.SymposiumRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SymposiumRecord result = SymposiumRecordBuilder.create()
    + *     .symposiumId(UUID.randomUUID())
    + *     .symposiumId(() -> UUID.randomUUID())
    + *     .symposiumTitle("example value")
    + *     .symposiumTitle("Hello %s", "World")
    + *     .symposiumTitle(() -> "example value")
    + *     .symposiumTitle(sb -> sb.append("text"))
    + *     .symposiumDate(LocalDate.now())
    + *     .symposiumDate(() -> LocalDate.now())
    + *     .panelCount(42)
    + *     .panelCount(() -> 42)
    + *     .theme("example value")
    + *     .theme("Hello %s", "World")
    + *     .theme(() -> "example value")
    + *     .theme(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SymposiumRecord.class) +public class SymposiumRecordBuilder implements IBuilderBase { + + /** + * Tracked value for symposiumId: symposiumId. + */ + private TrackedValue symposiumId = unsetValue(); + /** + * Tracked value for symposiumTitle: symposiumTitle. + */ + private TrackedValue symposiumTitle = unsetValue(); + /** + * Tracked value for symposiumDate: symposiumDate. + */ + private TrackedValue symposiumDate = unsetValue(); + /** + * Tracked value for panelCount: panelCount. + */ + private TrackedValue panelCount = unsetValue(); + /** + * Tracked value for theme: theme. + */ + private TrackedValue theme = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SymposiumRecord}. + */ + public SymposiumRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.SymposiumRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SymposiumRecordBuilder(SymposiumRecord instance) { + this.symposiumId = initialValue(instance.symposiumId()); + this.symposiumTitle = initialValue(instance.symposiumTitle()); + this.symposiumDate = initialValue(instance.symposiumDate()); + this.panelCount = initialValue(instance.panelCount()); + this.theme = initialValue(instance.theme()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SymposiumRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SymposiumRecordBuilder builder = SymposiumRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.SymposiumRecord} + */ + public static SymposiumRecordBuilder create() { + return new SymposiumRecordBuilder(); + } + + /** + * Sets the value for panelCount. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.panelCount(42);
    +   * }
    + * + * @param panelCount panelCount + * @return current instance of builder + */ + public SymposiumRecordBuilder panelCount(int panelCount) { + this.panelCount = changedValue(panelCount); + return this; + } + + /** + * Sets the value for panelCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.panelCount(() -> 42);
    +   * }
    + * + * @param panelCountSupplier supplier for panelCount + * @return current instance of builder + */ + public SymposiumRecordBuilder panelCount(Supplier panelCountSupplier) { + this.panelCount = changedValue(panelCountSupplier.get()); + return this; + } + + /** + * Sets the value for symposiumDate. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumDate(LocalDate.now());
    +   * }
    + * + * @param symposiumDate symposiumDate + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumDate(LocalDate symposiumDate) { + this.symposiumDate = changedValue(symposiumDate); + return this; + } + + /** + * Sets the value for symposiumDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumDate(() -> LocalDate.now());
    +   * }
    + * + * @param symposiumDateSupplier supplier for symposiumDate + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumDate(Supplier symposiumDateSupplier) { + this.symposiumDate = changedValue(symposiumDateSupplier.get()); + return this; + } + + /** + * Sets the value for symposiumId. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumId(UUID.randomUUID());
    +   * }
    + * + * @param symposiumId symposiumId + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumId(UUID symposiumId) { + this.symposiumId = changedValue(symposiumId); + return this; + } + + /** + * Sets the value for symposiumId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumId(() -> UUID.randomUUID());
    +   * }
    + * + * @param symposiumIdSupplier supplier for symposiumId + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumId(Supplier symposiumIdSupplier) { + this.symposiumId = changedValue(symposiumIdSupplier.get()); + return this; + } + + /** + * Sets the value for symposiumTitle. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumTitle("example value");
    +   * }
    + * + * @param symposiumTitle symposiumTitle + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumTitle(String symposiumTitle) { + this.symposiumTitle = changedValue(symposiumTitle); + return this; + } + + /** + * Sets the value for symposiumTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param symposiumTitleStringBuilderConsumer consumer providing an instance of symposiumTitle + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumTitle(Consumer symposiumTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + symposiumTitleStringBuilderConsumer.accept(builder); + this.symposiumTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for symposiumTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumTitle(() -> "example value");
    +   * }
    + * + * @param symposiumTitleSupplier supplier for symposiumTitle + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumTitle(Supplier symposiumTitleSupplier) { + this.symposiumTitle = changedValue(symposiumTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for symposiumTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.symposiumTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SymposiumRecordBuilder symposiumTitle(String format, Object... args) { + this.symposiumTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for theme. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theme("example value");
    +   * }
    + * + * @param theme theme + * @return current instance of builder + */ + public SymposiumRecordBuilder theme(String theme) { + this.theme = changedValue(theme); + return this; + } + + /** + * Sets the value for theme by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theme(sb -> sb.append("text"));
    +   * }
    + * + * @param themeStringBuilderConsumer consumer providing an instance of theme + * @return current instance of builder + */ + public SymposiumRecordBuilder theme(Consumer themeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + themeStringBuilderConsumer.accept(builder); + this.theme = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for theme by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theme(() -> "example value");
    +   * }
    + * + * @param themeSupplier supplier for theme + * @return current instance of builder + */ + public SymposiumRecordBuilder theme(Supplier themeSupplier) { + this.theme = changedValue(themeSupplier.get()); + return this; + } + + /** + * Sets the String value for theme by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SymposiumRecord#SymposiumRecord(UUID, String, LocalDate, int, String) SymposiumRecord(UUID symposiumId, + * String symposiumTitle, LocalDate symposiumDate, int panelCount, String theme)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theme("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SymposiumRecordBuilder theme(String format, Object... args) { + this.theme = changedValue(String.format(format, args)); + 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 SymposiumRecordBuilder 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 SymposiumRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SymposiumRecord result = builder.build();
    +   * }
    + */ + @Override + public SymposiumRecord build() { + if (!this.panelCount.isSet()) { + throw new IllegalStateException("Required field 'panelCount' must be set before calling build()"); + } + if (this.panelCount.value() == null) { + throw new IllegalStateException("Field 'panelCount' is marked as non-null but null value was provided"); + } + SymposiumRecord result = new SymposiumRecord(this.symposiumId + .value(), this.symposiumTitle.value(), this.symposiumDate.value(), this.panelCount.value(), this.theme.value()); + 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("symposiumId", this.symposiumId) + .append("symposiumTitle", this.symposiumTitle) + .append("symposiumDate", this.symposiumDate) + .append("panelCount", this.panelCount) + .append("theme", this.theme) + .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 SymposiumRecord with(Consumer b) { + SymposiumRecordBuilder builder; + try { + builder = new SymposiumRecordBuilder(SymposiumRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SymposiumRecordBuilder.With' should only be implemented by classes, which could be casted to 'SymposiumRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SymposiumRecordBuilder with() { + try { + return new SymposiumRecordBuilder(SymposiumRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SymposiumRecordBuilder.With' should only be implemented by classes, which could be casted to 'SymposiumRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TalkRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TalkRecordBuilder.java new file mode 100644 index 00000000..756c67c2 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TalkRecordBuilder.java @@ -0,0 +1,501 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.TalkRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.TalkRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TalkRecord result = TalkRecordBuilder.create()
    + *     .talkId(UUID.randomUUID())
    + *     .talkId(() -> UUID.randomUUID())
    + *     .talkTitle("example value")
    + *     .talkTitle("Hello %s", "World")
    + *     .talkTitle(() -> "example value")
    + *     .talkTitle(sb -> sb.append("text"))
    + *     .speaker("example value")
    + *     .speaker("Hello %s", "World")
    + *     .speaker(() -> "example value")
    + *     .speaker(sb -> sb.append("text"))
    + *     .talkDate(LocalDate.now())
    + *     .talkDate(() -> LocalDate.now())
    + *     .audienceSize(42)
    + *     .audienceSize(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TalkRecord.class) +public class TalkRecordBuilder implements IBuilderBase { + + /** + * Tracked value for talkId: talkId. + */ + private TrackedValue talkId = unsetValue(); + /** + * Tracked value for talkTitle: talkTitle. + */ + private TrackedValue talkTitle = unsetValue(); + /** + * Tracked value for speaker: speaker. + */ + private TrackedValue speaker = unsetValue(); + /** + * Tracked value for talkDate: talkDate. + */ + private TrackedValue talkDate = unsetValue(); + /** + * Tracked value for audienceSize: audienceSize. + */ + private TrackedValue audienceSize = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TalkRecord}. + */ + public TalkRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TalkRecord} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public TalkRecordBuilder(TalkRecord instance) { + this.talkId = initialValue(instance.talkId()); + this.talkTitle = initialValue(instance.talkTitle()); + this.speaker = initialValue(instance.speaker()); + this.talkDate = initialValue(instance.talkDate()); + this.audienceSize = initialValue(instance.audienceSize()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TalkRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TalkRecordBuilder builder = TalkRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TalkRecord} + */ + public static TalkRecordBuilder create() { + return new TalkRecordBuilder(); + } + + /** + * Sets the value for audienceSize. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceSize(42);
    +   * }
    + * + * @param audienceSize audienceSize + * @return current instance of builder + */ + public TalkRecordBuilder audienceSize(int audienceSize) { + this.audienceSize = changedValue(audienceSize); + return this; + } + + /** + * Sets the value for audienceSize by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceSize(() -> 42);
    +   * }
    + * + * @param audienceSizeSupplier supplier for audienceSize + * @return current instance of builder + */ + public TalkRecordBuilder audienceSize(Supplier audienceSizeSupplier) { + this.audienceSize = changedValue(audienceSizeSupplier.get()); + return this; + } + + /** + * Sets the value for speaker. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.speaker("example value");
    +   * }
    + * + * @param speaker speaker + * @return current instance of builder + */ + public TalkRecordBuilder speaker(String speaker) { + this.speaker = changedValue(speaker); + return this; + } + + /** + * Sets the value for speaker by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.speaker(sb -> sb.append("text"));
    +   * }
    + * + * @param speakerStringBuilderConsumer consumer providing an instance of speaker + * @return current instance of builder + */ + public TalkRecordBuilder speaker(Consumer speakerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + speakerStringBuilderConsumer.accept(builder); + this.speaker = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for speaker by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.speaker(() -> "example value");
    +   * }
    + * + * @param speakerSupplier supplier for speaker + * @return current instance of builder + */ + public TalkRecordBuilder speaker(Supplier speakerSupplier) { + this.speaker = changedValue(speakerSupplier.get()); + return this; + } + + /** + * Sets the String value for speaker by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.speaker("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TalkRecordBuilder speaker(String format, Object... args) { + this.speaker = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for talkDate. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkDate(LocalDate.now());
    +   * }
    + * + * @param talkDate talkDate + * @return current instance of builder + */ + public TalkRecordBuilder talkDate(LocalDate talkDate) { + this.talkDate = changedValue(talkDate); + return this; + } + + /** + * Sets the value for talkDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkDate(() -> LocalDate.now());
    +   * }
    + * + * @param talkDateSupplier supplier for talkDate + * @return current instance of builder + */ + public TalkRecordBuilder talkDate(Supplier talkDateSupplier) { + this.talkDate = changedValue(talkDateSupplier.get()); + return this; + } + + /** + * Sets the value for talkId. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkId(UUID.randomUUID());
    +   * }
    + * + * @param talkId talkId + * @return current instance of builder + */ + public TalkRecordBuilder talkId(UUID talkId) { + this.talkId = changedValue(talkId); + return this; + } + + /** + * Sets the value for talkId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkId(() -> UUID.randomUUID());
    +   * }
    + * + * @param talkIdSupplier supplier for talkId + * @return current instance of builder + */ + public TalkRecordBuilder talkId(Supplier talkIdSupplier) { + this.talkId = changedValue(talkIdSupplier.get()); + return this; + } + + /** + * Sets the value for talkTitle. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkTitle("example value");
    +   * }
    + * + * @param talkTitle talkTitle + * @return current instance of builder + */ + public TalkRecordBuilder talkTitle(String talkTitle) { + this.talkTitle = changedValue(talkTitle); + return this; + } + + /** + * Sets the value for talkTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param talkTitleStringBuilderConsumer consumer providing an instance of talkTitle + * @return current instance of builder + */ + public TalkRecordBuilder talkTitle(Consumer talkTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + talkTitleStringBuilderConsumer.accept(builder); + this.talkTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for talkTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkTitle(() -> "example value");
    +   * }
    + * + * @param talkTitleSupplier supplier for talkTitle + * @return current instance of builder + */ + public TalkRecordBuilder talkTitle(Supplier talkTitleSupplier) { + this.talkTitle = changedValue(talkTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for talkTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TalkRecord#TalkRecord(UUID, String, String, LocalDate, int) + * TalkRecord(UUID talkId, String talkTitle, String speaker, LocalDate talkDate, int audienceSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.talkTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TalkRecordBuilder talkTitle(String format, Object... args) { + this.talkTitle = changedValue(String.format(format, args)); + 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 TalkRecordBuilder 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 TalkRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TalkRecord result = builder.build();
    +   * }
    + */ + @Override + public TalkRecord build() { + if (!this.audienceSize.isSet()) { + throw new IllegalStateException("Required field 'audienceSize' must be set before calling build()"); + } + if (this.audienceSize.value() == null) { + throw new IllegalStateException("Field 'audienceSize' is marked as non-null but null value was provided"); + } + TalkRecord result = new TalkRecord(this.talkId + .value(), this.talkTitle.value(), this.speaker.value(), this.talkDate.value(), this.audienceSize.value()); + 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("talkId", this.talkId) + .append("talkTitle", this.talkTitle) + .append("speaker", this.speaker) + .append("talkDate", this.talkDate) + .append("audienceSize", this.audienceSize) + .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 TalkRecord with(Consumer b) { + TalkRecordBuilder builder; + try { + builder = new TalkRecordBuilder(TalkRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TalkRecordBuilder.With' should only be implemented by classes, which could be casted to 'TalkRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TalkRecordBuilder with() { + try { + return new TalkRecordBuilder(TalkRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TalkRecordBuilder.With' should only be implemented by classes, which could be casted to 'TalkRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TelecastRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TelecastRecordBuilder.java new file mode 100644 index 00000000..2adef7ba --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TelecastRecordBuilder.java @@ -0,0 +1,560 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.TelecastRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.TelecastRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TelecastRecord result = TelecastRecordBuilder.create()
    + *     .telecastId(UUID.randomUUID())
    + *     .telecastId(() -> UUID.randomUUID())
    + *     .telecastTitle("example value")
    + *     .telecastTitle("Hello %s", "World")
    + *     .telecastTitle(() -> "example value")
    + *     .telecastTitle(sb -> sb.append("text"))
    + *     .telecastDate(LocalDate.now())
    + *     .telecastDate(() -> LocalDate.now())
    + *     .network("example value")
    + *     .network("Hello %s", "World")
    + *     .network(() -> "example value")
    + *     .network(sb -> sb.append("text"))
    + *     .audienceRating("example value")
    + *     .audienceRating("Hello %s", "World")
    + *     .audienceRating(() -> "example value")
    + *     .audienceRating(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TelecastRecord.class) +public class TelecastRecordBuilder implements IBuilderBase { + + /** + * Tracked value for telecastId: telecastId. + */ + private TrackedValue telecastId = unsetValue(); + /** + * Tracked value for telecastTitle: telecastTitle. + */ + private TrackedValue telecastTitle = unsetValue(); + /** + * Tracked value for telecastDate: telecastDate. + */ + private TrackedValue telecastDate = unsetValue(); + /** + * Tracked value for network: network. + */ + private TrackedValue network = unsetValue(); + /** + * Tracked value for audienceRating: audienceRating. + */ + private TrackedValue audienceRating = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TelecastRecord}. + */ + public TelecastRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TelecastRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TelecastRecordBuilder(TelecastRecord instance) { + this.telecastId = initialValue(instance.telecastId()); + this.telecastTitle = initialValue(instance.telecastTitle()); + this.telecastDate = initialValue(instance.telecastDate()); + this.network = initialValue(instance.network()); + this.audienceRating = initialValue(instance.audienceRating()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TelecastRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TelecastRecordBuilder builder = TelecastRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TelecastRecord} + */ + public static TelecastRecordBuilder create() { + return new TelecastRecordBuilder(); + } + + /** + * Sets the value for audienceRating. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceRating("example value");
    +   * }
    + * + * @param audienceRating audienceRating + * @return current instance of builder + */ + public TelecastRecordBuilder audienceRating(String audienceRating) { + this.audienceRating = changedValue(audienceRating); + return this; + } + + /** + * Sets the value for audienceRating by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceRating(sb -> sb.append("text"));
    +   * }
    + * + * @param audienceRatingStringBuilderConsumer consumer providing an instance of audienceRating + * @return current instance of builder + */ + public TelecastRecordBuilder audienceRating(Consumer audienceRatingStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + audienceRatingStringBuilderConsumer.accept(builder); + this.audienceRating = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for audienceRating by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceRating(() -> "example value");
    +   * }
    + * + * @param audienceRatingSupplier supplier for audienceRating + * @return current instance of builder + */ + public TelecastRecordBuilder audienceRating(Supplier audienceRatingSupplier) { + this.audienceRating = changedValue(audienceRatingSupplier.get()); + return this; + } + + /** + * Sets the String value for audienceRating by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.audienceRating("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TelecastRecordBuilder audienceRating(String format, Object... args) { + this.audienceRating = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for network. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.network("example value");
    +   * }
    + * + * @param network network + * @return current instance of builder + */ + public TelecastRecordBuilder network(String network) { + this.network = changedValue(network); + return this; + } + + /** + * Sets the value for network by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.network(sb -> sb.append("text"));
    +   * }
    + * + * @param networkStringBuilderConsumer consumer providing an instance of network + * @return current instance of builder + */ + public TelecastRecordBuilder network(Consumer networkStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + networkStringBuilderConsumer.accept(builder); + this.network = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for network by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.network(() -> "example value");
    +   * }
    + * + * @param networkSupplier supplier for network + * @return current instance of builder + */ + public TelecastRecordBuilder network(Supplier networkSupplier) { + this.network = changedValue(networkSupplier.get()); + return this; + } + + /** + * Sets the String value for network by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.network("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TelecastRecordBuilder network(String format, Object... args) { + this.network = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for telecastDate. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastDate(LocalDate.now());
    +   * }
    + * + * @param telecastDate telecastDate + * @return current instance of builder + */ + public TelecastRecordBuilder telecastDate(LocalDate telecastDate) { + this.telecastDate = changedValue(telecastDate); + return this; + } + + /** + * Sets the value for telecastDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastDate(() -> LocalDate.now());
    +   * }
    + * + * @param telecastDateSupplier supplier for telecastDate + * @return current instance of builder + */ + public TelecastRecordBuilder telecastDate(Supplier telecastDateSupplier) { + this.telecastDate = changedValue(telecastDateSupplier.get()); + return this; + } + + /** + * Sets the value for telecastId. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastId(UUID.randomUUID());
    +   * }
    + * + * @param telecastId telecastId + * @return current instance of builder + */ + public TelecastRecordBuilder telecastId(UUID telecastId) { + this.telecastId = changedValue(telecastId); + return this; + } + + /** + * Sets the value for telecastId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastId(() -> UUID.randomUUID());
    +   * }
    + * + * @param telecastIdSupplier supplier for telecastId + * @return current instance of builder + */ + public TelecastRecordBuilder telecastId(Supplier telecastIdSupplier) { + this.telecastId = changedValue(telecastIdSupplier.get()); + return this; + } + + /** + * Sets the value for telecastTitle. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastTitle("example value");
    +   * }
    + * + * @param telecastTitle telecastTitle + * @return current instance of builder + */ + public TelecastRecordBuilder telecastTitle(String telecastTitle) { + this.telecastTitle = changedValue(telecastTitle); + return this; + } + + /** + * Sets the value for telecastTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param telecastTitleStringBuilderConsumer consumer providing an instance of telecastTitle + * @return current instance of builder + */ + public TelecastRecordBuilder telecastTitle(Consumer telecastTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + telecastTitleStringBuilderConsumer.accept(builder); + this.telecastTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for telecastTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastTitle(() -> "example value");
    +   * }
    + * + * @param telecastTitleSupplier supplier for telecastTitle + * @return current instance of builder + */ + public TelecastRecordBuilder telecastTitle(Supplier telecastTitleSupplier) { + this.telecastTitle = changedValue(telecastTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for telecastTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TelecastRecord#TelecastRecord(UUID, String, LocalDate, String, String) TelecastRecord(UUID telecastId, + * String telecastTitle, LocalDate telecastDate, String network, String audienceRating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.telecastTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TelecastRecordBuilder telecastTitle(String format, Object... args) { + this.telecastTitle = changedValue(String.format(format, args)); + 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 TelecastRecordBuilder 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 TelecastRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TelecastRecord result = builder.build();
    +   * }
    + */ + @Override + public TelecastRecord build() { + TelecastRecord result = new TelecastRecord(this.telecastId.value(), + this.telecastTitle.value(), + this.telecastDate.value(), + this.network.value(), + this.audienceRating.value()); + 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("telecastId", this.telecastId) + .append("telecastTitle", this.telecastTitle) + .append("telecastDate", this.telecastDate) + .append("network", this.network) + .append("audienceRating", this.audienceRating) + .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 TelecastRecord with(Consumer b) { + TelecastRecordBuilder builder; + try { + builder = new TelecastRecordBuilder(TelecastRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TelecastRecordBuilder.With' should only be implemented by classes, which could be casted to 'TelecastRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TelecastRecordBuilder with() { + try { + return new TelecastRecordBuilder(TelecastRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TelecastRecordBuilder.With' should only be implemented by classes, which could be casted to 'TelecastRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TransmissionRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TransmissionRecordBuilder.java new file mode 100644 index 00000000..d477ed3a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TransmissionRecordBuilder.java @@ -0,0 +1,520 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.TransmissionRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.TransmissionRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TransmissionRecord result = TransmissionRecordBuilder.create()
    + *     .transmissionId(UUID.randomUUID())
    + *     .transmissionId(() -> UUID.randomUUID())
    + *     .transmissionTitle("example value")
    + *     .transmissionTitle("Hello %s", "World")
    + *     .transmissionTitle(() -> "example value")
    + *     .transmissionTitle(sb -> sb.append("text"))
    + *     .transmissionDate(LocalDate.now())
    + *     .transmissionDate(() -> LocalDate.now())
    + *     .frequency("example value")
    + *     .frequency("Hello %s", "World")
    + *     .frequency(() -> "example value")
    + *     .frequency(sb -> sb.append("text"))
    + *     .signalStrength(3.14)
    + *     .signalStrength(() -> 3.14)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TransmissionRecord.class) +public class TransmissionRecordBuilder implements IBuilderBase { + + /** + * Tracked value for transmissionId: transmissionId. + */ + private TrackedValue transmissionId = unsetValue(); + /** + * Tracked value for transmissionTitle: transmissionTitle. + */ + private TrackedValue transmissionTitle = unsetValue(); + /** + * Tracked value for transmissionDate: transmissionDate. + */ + private TrackedValue transmissionDate = unsetValue(); + /** + * Tracked value for frequency: frequency. + */ + private TrackedValue frequency = unsetValue(); + /** + * Tracked value for signalStrength: signalStrength. + */ + private TrackedValue signalStrength = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TransmissionRecord}. + */ + public TransmissionRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TransmissionRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TransmissionRecordBuilder(TransmissionRecord instance) { + this.transmissionId = initialValue(instance.transmissionId()); + this.transmissionTitle = initialValue(instance.transmissionTitle()); + this.transmissionDate = initialValue(instance.transmissionDate()); + this.frequency = initialValue(instance.frequency()); + this.signalStrength = initialValue(instance.signalStrength()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TransmissionRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TransmissionRecordBuilder builder = TransmissionRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TransmissionRecord} + */ + public static TransmissionRecordBuilder create() { + return new TransmissionRecordBuilder(); + } + + /** + * Sets the value for frequency. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.frequency("example value");
    +   * }
    + * + * @param frequency frequency + * @return current instance of builder + */ + public TransmissionRecordBuilder frequency(String frequency) { + this.frequency = changedValue(frequency); + return this; + } + + /** + * Sets the value for frequency by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.frequency(sb -> sb.append("text"));
    +   * }
    + * + * @param frequencyStringBuilderConsumer consumer providing an instance of frequency + * @return current instance of builder + */ + public TransmissionRecordBuilder frequency(Consumer frequencyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + frequencyStringBuilderConsumer.accept(builder); + this.frequency = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for frequency by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.frequency(() -> "example value");
    +   * }
    + * + * @param frequencySupplier supplier for frequency + * @return current instance of builder + */ + public TransmissionRecordBuilder frequency(Supplier frequencySupplier) { + this.frequency = changedValue(frequencySupplier.get()); + return this; + } + + /** + * Sets the String value for frequency by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.frequency("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TransmissionRecordBuilder frequency(String format, Object... args) { + this.frequency = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for signalStrength. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signalStrength(3.14);
    +   * }
    + * + * @param signalStrength signalStrength + * @return current instance of builder + */ + public TransmissionRecordBuilder signalStrength(double signalStrength) { + this.signalStrength = changedValue(signalStrength); + return this; + } + + /** + * Sets the value for signalStrength by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signalStrength(() -> 3.14);
    +   * }
    + * + * @param signalStrengthSupplier supplier for signalStrength + * @return current instance of builder + */ + public TransmissionRecordBuilder signalStrength(Supplier signalStrengthSupplier) { + this.signalStrength = changedValue(signalStrengthSupplier.get()); + return this; + } + + /** + * Sets the value for transmissionDate. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionDate(LocalDate.now());
    +   * }
    + * + * @param transmissionDate transmissionDate + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionDate(LocalDate transmissionDate) { + this.transmissionDate = changedValue(transmissionDate); + return this; + } + + /** + * Sets the value for transmissionDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionDate(() -> LocalDate.now());
    +   * }
    + * + * @param transmissionDateSupplier supplier for transmissionDate + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionDate(Supplier transmissionDateSupplier) { + this.transmissionDate = changedValue(transmissionDateSupplier.get()); + return this; + } + + /** + * Sets the value for transmissionId. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionId(UUID.randomUUID());
    +   * }
    + * + * @param transmissionId transmissionId + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionId(UUID transmissionId) { + this.transmissionId = changedValue(transmissionId); + return this; + } + + /** + * Sets the value for transmissionId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionId(() -> UUID.randomUUID());
    +   * }
    + * + * @param transmissionIdSupplier supplier for transmissionId + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionId(Supplier transmissionIdSupplier) { + this.transmissionId = changedValue(transmissionIdSupplier.get()); + return this; + } + + /** + * Sets the value for transmissionTitle. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionTitle("example value");
    +   * }
    + * + * @param transmissionTitle transmissionTitle + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionTitle(String transmissionTitle) { + this.transmissionTitle = changedValue(transmissionTitle); + return this; + } + + /** + * Sets the value for transmissionTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param transmissionTitleStringBuilderConsumer consumer providing an instance of transmissionTitle + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionTitle(Consumer transmissionTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + transmissionTitleStringBuilderConsumer.accept(builder); + this.transmissionTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for transmissionTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionTitle(() -> "example value");
    +   * }
    + * + * @param transmissionTitleSupplier supplier for transmissionTitle + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionTitle(Supplier transmissionTitleSupplier) { + this.transmissionTitle = changedValue(transmissionTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for transmissionTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TransmissionRecord#TransmissionRecord(UUID, String, LocalDate, String, double) TransmissionRecord(UUID + * transmissionId, String transmissionTitle, LocalDate transmissionDate, String frequency, double signalStrength)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.transmissionTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TransmissionRecordBuilder transmissionTitle(String format, Object... args) { + this.transmissionTitle = changedValue(String.format(format, args)); + 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 TransmissionRecordBuilder 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 TransmissionRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TransmissionRecord result = builder.build();
    +   * }
    + */ + @Override + public TransmissionRecord build() { + if (!this.signalStrength.isSet()) { + throw new IllegalStateException("Required field 'signalStrength' must be set before calling build()"); + } + if (this.signalStrength.value() == null) { + throw new IllegalStateException("Field 'signalStrength' is marked as non-null but null value was provided"); + } + TransmissionRecord result = new TransmissionRecord(this.transmissionId.value(), + this.transmissionTitle.value(), + this.transmissionDate.value(), + this.frequency.value(), + this.signalStrength.value()); + 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("transmissionId", this.transmissionId) + .append("transmissionTitle", this.transmissionTitle) + .append("transmissionDate", this.transmissionDate) + .append("frequency", this.frequency) + .append("signalStrength", this.signalStrength) + .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 TransmissionRecord with(Consumer b) { + TransmissionRecordBuilder builder; + try { + builder = new TransmissionRecordBuilder(TransmissionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TransmissionRecordBuilder.With' should only be implemented by classes, which could be casted to 'TransmissionRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TransmissionRecordBuilder with() { + try { + return new TransmissionRecordBuilder(TransmissionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TransmissionRecordBuilder.With' should only be implemented by classes, which could be casted to 'TransmissionRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TreatyRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TreatyRecordBuilder.java new file mode 100644 index 00000000..9866310b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/TreatyRecordBuilder.java @@ -0,0 +1,504 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.TreatyRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.TreatyRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TreatyRecord result = TreatyRecordBuilder.create()
    + *     .treatyId(UUID.randomUUID())
    + *     .treatyId(() -> UUID.randomUUID())
    + *     .treatyName("example value")
    + *     .treatyName("Hello %s", "World")
    + *     .treatyName(() -> "example value")
    + *     .treatyName(sb -> sb.append("text"))
    + *     .signatoryCount(42)
    + *     .signatoryCount(() -> 42)
    + *     .signedDate(LocalDate.now())
    + *     .signedDate(() -> LocalDate.now())
    + *     .jurisdiction("example value")
    + *     .jurisdiction("Hello %s", "World")
    + *     .jurisdiction(() -> "example value")
    + *     .jurisdiction(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TreatyRecord.class) +public class TreatyRecordBuilder implements IBuilderBase { + + /** + * Tracked value for treatyId: treatyId. + */ + private TrackedValue treatyId = unsetValue(); + /** + * Tracked value for treatyName: treatyName. + */ + private TrackedValue treatyName = unsetValue(); + /** + * Tracked value for signatoryCount: signatoryCount. + */ + private TrackedValue signatoryCount = unsetValue(); + /** + * Tracked value for signedDate: signedDate. + */ + private TrackedValue signedDate = unsetValue(); + /** + * Tracked value for jurisdiction: jurisdiction. + */ + private TrackedValue jurisdiction = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.TreatyRecord}. + */ + public TreatyRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TreatyRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public TreatyRecordBuilder(TreatyRecord instance) { + this.treatyId = initialValue(instance.treatyId()); + this.treatyName = initialValue(instance.treatyName()); + this.signatoryCount = initialValue(instance.signatoryCount()); + this.signedDate = initialValue(instance.signedDate()); + this.jurisdiction = initialValue(instance.jurisdiction()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TreatyRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TreatyRecordBuilder builder = TreatyRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.TreatyRecord} + */ + public static TreatyRecordBuilder create() { + return new TreatyRecordBuilder(); + } + + /** + * Sets the value for jurisdiction. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction("example value");
    +   * }
    + * + * @param jurisdiction jurisdiction + * @return current instance of builder + */ + public TreatyRecordBuilder jurisdiction(String jurisdiction) { + this.jurisdiction = changedValue(jurisdiction); + return this; + } + + /** + * Sets the value for jurisdiction by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction(sb -> sb.append("text"));
    +   * }
    + * + * @param jurisdictionStringBuilderConsumer consumer providing an instance of jurisdiction + * @return current instance of builder + */ + public TreatyRecordBuilder jurisdiction(Consumer jurisdictionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + jurisdictionStringBuilderConsumer.accept(builder); + this.jurisdiction = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for jurisdiction by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction(() -> "example value");
    +   * }
    + * + * @param jurisdictionSupplier supplier for jurisdiction + * @return current instance of builder + */ + public TreatyRecordBuilder jurisdiction(Supplier jurisdictionSupplier) { + this.jurisdiction = changedValue(jurisdictionSupplier.get()); + return this; + } + + /** + * Sets the String value for jurisdiction by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TreatyRecordBuilder jurisdiction(String format, Object... args) { + this.jurisdiction = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for signatoryCount. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signatoryCount(42);
    +   * }
    + * + * @param signatoryCount signatoryCount + * @return current instance of builder + */ + public TreatyRecordBuilder signatoryCount(int signatoryCount) { + this.signatoryCount = changedValue(signatoryCount); + return this; + } + + /** + * Sets the value for signatoryCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signatoryCount(() -> 42);
    +   * }
    + * + * @param signatoryCountSupplier supplier for signatoryCount + * @return current instance of builder + */ + public TreatyRecordBuilder signatoryCount(Supplier signatoryCountSupplier) { + this.signatoryCount = changedValue(signatoryCountSupplier.get()); + return this; + } + + /** + * Sets the value for signedDate. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signedDate(LocalDate.now());
    +   * }
    + * + * @param signedDate signedDate + * @return current instance of builder + */ + public TreatyRecordBuilder signedDate(LocalDate signedDate) { + this.signedDate = changedValue(signedDate); + return this; + } + + /** + * Sets the value for signedDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signedDate(() -> LocalDate.now());
    +   * }
    + * + * @param signedDateSupplier supplier for signedDate + * @return current instance of builder + */ + public TreatyRecordBuilder signedDate(Supplier signedDateSupplier) { + this.signedDate = changedValue(signedDateSupplier.get()); + return this; + } + + /** + * Sets the value for treatyId. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.treatyId(UUID.randomUUID());
    +   * }
    + * + * @param treatyId treatyId + * @return current instance of builder + */ + public TreatyRecordBuilder treatyId(UUID treatyId) { + this.treatyId = changedValue(treatyId); + return this; + } + + /** + * Sets the value for treatyId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.treatyId(() -> UUID.randomUUID());
    +   * }
    + * + * @param treatyIdSupplier supplier for treatyId + * @return current instance of builder + */ + public TreatyRecordBuilder treatyId(Supplier treatyIdSupplier) { + this.treatyId = changedValue(treatyIdSupplier.get()); + return this; + } + + /** + * Sets the value for treatyName. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.treatyName("example value");
    +   * }
    + * + * @param treatyName treatyName + * @return current instance of builder + */ + public TreatyRecordBuilder treatyName(String treatyName) { + this.treatyName = changedValue(treatyName); + return this; + } + + /** + * Sets the value for treatyName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.treatyName(sb -> sb.append("text"));
    +   * }
    + * + * @param treatyNameStringBuilderConsumer consumer providing an instance of treatyName + * @return current instance of builder + */ + public TreatyRecordBuilder treatyName(Consumer treatyNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + treatyNameStringBuilderConsumer.accept(builder); + this.treatyName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for treatyName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.treatyName(() -> "example value");
    +   * }
    + * + * @param treatyNameSupplier supplier for treatyName + * @return current instance of builder + */ + public TreatyRecordBuilder treatyName(Supplier treatyNameSupplier) { + this.treatyName = changedValue(treatyNameSupplier.get()); + return this; + } + + /** + * Sets the String value for treatyName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TreatyRecord#TreatyRecord(UUID, String, int, LocalDate, String) + * TreatyRecord(UUID treatyId, String treatyName, int signatoryCount, LocalDate signedDate, String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.treatyName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TreatyRecordBuilder treatyName(String format, Object... args) { + this.treatyName = changedValue(String.format(format, args)); + 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 TreatyRecordBuilder 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 TreatyRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TreatyRecord result = builder.build();
    +   * }
    + */ + @Override + public TreatyRecord build() { + if (!this.signatoryCount.isSet()) { + throw new IllegalStateException("Required field 'signatoryCount' must be set before calling build()"); + } + if (this.signatoryCount.value() == null) { + throw new IllegalStateException("Field 'signatoryCount' is marked as non-null but null value was provided"); + } + TreatyRecord result = new TreatyRecord(this.treatyId.value(), + this.treatyName.value(), + this.signatoryCount.value(), + this.signedDate.value(), + this.jurisdiction.value()); + 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("treatyId", this.treatyId) + .append("treatyName", this.treatyName) + .append("signatoryCount", this.signatoryCount) + .append("signedDate", this.signedDate) + .append("jurisdiction", this.jurisdiction) + .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 TreatyRecord with(Consumer b) { + TreatyRecordBuilder builder; + try { + builder = new TreatyRecordBuilder(TreatyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TreatyRecordBuilder.With' should only be implemented by classes, which could be casted to 'TreatyRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TreatyRecordBuilder with() { + try { + return new TreatyRecordBuilder(TreatyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TreatyRecordBuilder.With' should only be implemented by classes, which could be casted to 'TreatyRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebcastRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebcastRecordBuilder.java new file mode 100644 index 00000000..5d23ddef --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebcastRecordBuilder.java @@ -0,0 +1,501 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.WebcastRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.WebcastRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * WebcastRecord result = WebcastRecordBuilder.create()
    + *     .webcastId(UUID.randomUUID())
    + *     .webcastId(() -> UUID.randomUUID())
    + *     .webcastTitle("example value")
    + *     .webcastTitle("Hello %s", "World")
    + *     .webcastTitle(() -> "example value")
    + *     .webcastTitle(sb -> sb.append("text"))
    + *     .webcastDate(LocalDate.now())
    + *     .webcastDate(() -> LocalDate.now())
    + *     .url("example value")
    + *     .url("Hello %s", "World")
    + *     .url(() -> "example value")
    + *     .url(sb -> sb.append("text"))
    + *     .viewerCount(42)
    + *     .viewerCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WebcastRecord.class) +public class WebcastRecordBuilder implements IBuilderBase { + + /** + * Tracked value for webcastId: webcastId. + */ + private TrackedValue webcastId = unsetValue(); + /** + * Tracked value for webcastTitle: webcastTitle. + */ + private TrackedValue webcastTitle = unsetValue(); + /** + * Tracked value for webcastDate: webcastDate. + */ + private TrackedValue webcastDate = unsetValue(); + /** + * Tracked value for url: url. + */ + private TrackedValue url = unsetValue(); + /** + * Tracked value for viewerCount: viewerCount. + */ + private TrackedValue viewerCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.WebcastRecord}. + */ + public WebcastRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WebcastRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public WebcastRecordBuilder(WebcastRecord instance) { + this.webcastId = initialValue(instance.webcastId()); + this.webcastTitle = initialValue(instance.webcastTitle()); + this.webcastDate = initialValue(instance.webcastDate()); + this.url = initialValue(instance.url()); + this.viewerCount = initialValue(instance.viewerCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WebcastRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * WebcastRecordBuilder builder = WebcastRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WebcastRecord} + */ + public static WebcastRecordBuilder create() { + return new WebcastRecordBuilder(); + } + + /** + * Sets the value for url. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.url("example value");
    +   * }
    + * + * @param url url + * @return current instance of builder + */ + public WebcastRecordBuilder url(String url) { + this.url = changedValue(url); + return this; + } + + /** + * Sets the value for url by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.url(sb -> sb.append("text"));
    +   * }
    + * + * @param urlStringBuilderConsumer consumer providing an instance of url + * @return current instance of builder + */ + public WebcastRecordBuilder url(Consumer urlStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + urlStringBuilderConsumer.accept(builder); + this.url = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for url by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.url(() -> "example value");
    +   * }
    + * + * @param urlSupplier supplier for url + * @return current instance of builder + */ + public WebcastRecordBuilder url(Supplier urlSupplier) { + this.url = changedValue(urlSupplier.get()); + return this; + } + + /** + * Sets the String value for url by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.url("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WebcastRecordBuilder url(String format, Object... args) { + this.url = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for viewerCount. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.viewerCount(42);
    +   * }
    + * + * @param viewerCount viewerCount + * @return current instance of builder + */ + public WebcastRecordBuilder viewerCount(int viewerCount) { + this.viewerCount = changedValue(viewerCount); + return this; + } + + /** + * Sets the value for viewerCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.viewerCount(() -> 42);
    +   * }
    + * + * @param viewerCountSupplier supplier for viewerCount + * @return current instance of builder + */ + public WebcastRecordBuilder viewerCount(Supplier viewerCountSupplier) { + this.viewerCount = changedValue(viewerCountSupplier.get()); + return this; + } + + /** + * Sets the value for webcastDate. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastDate(LocalDate.now());
    +   * }
    + * + * @param webcastDate webcastDate + * @return current instance of builder + */ + public WebcastRecordBuilder webcastDate(LocalDate webcastDate) { + this.webcastDate = changedValue(webcastDate); + return this; + } + + /** + * Sets the value for webcastDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastDate(() -> LocalDate.now());
    +   * }
    + * + * @param webcastDateSupplier supplier for webcastDate + * @return current instance of builder + */ + public WebcastRecordBuilder webcastDate(Supplier webcastDateSupplier) { + this.webcastDate = changedValue(webcastDateSupplier.get()); + return this; + } + + /** + * Sets the value for webcastId. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastId(UUID.randomUUID());
    +   * }
    + * + * @param webcastId webcastId + * @return current instance of builder + */ + public WebcastRecordBuilder webcastId(UUID webcastId) { + this.webcastId = changedValue(webcastId); + return this; + } + + /** + * Sets the value for webcastId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastId(() -> UUID.randomUUID());
    +   * }
    + * + * @param webcastIdSupplier supplier for webcastId + * @return current instance of builder + */ + public WebcastRecordBuilder webcastId(Supplier webcastIdSupplier) { + this.webcastId = changedValue(webcastIdSupplier.get()); + return this; + } + + /** + * Sets the value for webcastTitle. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastTitle("example value");
    +   * }
    + * + * @param webcastTitle webcastTitle + * @return current instance of builder + */ + public WebcastRecordBuilder webcastTitle(String webcastTitle) { + this.webcastTitle = changedValue(webcastTitle); + return this; + } + + /** + * Sets the value for webcastTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param webcastTitleStringBuilderConsumer consumer providing an instance of webcastTitle + * @return current instance of builder + */ + public WebcastRecordBuilder webcastTitle(Consumer webcastTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + webcastTitleStringBuilderConsumer.accept(builder); + this.webcastTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for webcastTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastTitle(() -> "example value");
    +   * }
    + * + * @param webcastTitleSupplier supplier for webcastTitle + * @return current instance of builder + */ + public WebcastRecordBuilder webcastTitle(Supplier webcastTitleSupplier) { + this.webcastTitle = changedValue(webcastTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for webcastTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WebcastRecord#WebcastRecord(UUID, String, LocalDate, String, int) + * WebcastRecord(UUID webcastId, String webcastTitle, LocalDate webcastDate, String url, int viewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webcastTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WebcastRecordBuilder webcastTitle(String format, Object... args) { + this.webcastTitle = changedValue(String.format(format, args)); + 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 WebcastRecordBuilder 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 WebcastRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WebcastRecord result = builder.build();
    +   * }
    + */ + @Override + public WebcastRecord build() { + if (!this.viewerCount.isSet()) { + throw new IllegalStateException("Required field 'viewerCount' must be set before calling build()"); + } + if (this.viewerCount.value() == null) { + throw new IllegalStateException("Field 'viewerCount' is marked as non-null but null value was provided"); + } + WebcastRecord result = new WebcastRecord(this.webcastId + .value(), this.webcastTitle.value(), this.webcastDate.value(), this.url.value(), this.viewerCount.value()); + 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("webcastId", this.webcastId) + .append("webcastTitle", this.webcastTitle) + .append("webcastDate", this.webcastDate) + .append("url", this.url) + .append("viewerCount", this.viewerCount) + .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 WebcastRecord with(Consumer b) { + WebcastRecordBuilder builder; + try { + builder = new WebcastRecordBuilder(WebcastRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WebcastRecordBuilder.With' should only be implemented by classes, which could be casted to 'WebcastRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WebcastRecordBuilder with() { + try { + return new WebcastRecordBuilder(WebcastRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WebcastRecordBuilder.With' should only be implemented by classes, which could be casted to 'WebcastRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebinarRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebinarRecordBuilder.java new file mode 100644 index 00000000..bff912e9 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WebinarRecordBuilder.java @@ -0,0 +1,504 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.events.WebinarRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.WebinarRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * WebinarRecord result = WebinarRecordBuilder.create()
    + *     .webinarId(UUID.randomUUID())
    + *     .webinarId(() -> UUID.randomUUID())
    + *     .webinarTitle("example value")
    + *     .webinarTitle("Hello %s", "World")
    + *     .webinarTitle(() -> "example value")
    + *     .webinarTitle(sb -> sb.append("text"))
    + *     .presenter("example value")
    + *     .presenter("Hello %s", "World")
    + *     .presenter(() -> "example value")
    + *     .presenter(sb -> sb.append("text"))
    + *     .webinarDate(LocalDate.now())
    + *     .webinarDate(() -> LocalDate.now())
    + *     .registrantCount(42)
    + *     .registrantCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WebinarRecord.class) +public class WebinarRecordBuilder implements IBuilderBase { + + /** + * Tracked value for webinarId: webinarId. + */ + private TrackedValue webinarId = unsetValue(); + /** + * Tracked value for webinarTitle: webinarTitle. + */ + private TrackedValue webinarTitle = unsetValue(); + /** + * Tracked value for presenter: presenter. + */ + private TrackedValue presenter = unsetValue(); + /** + * Tracked value for webinarDate: webinarDate. + */ + private TrackedValue webinarDate = unsetValue(); + /** + * Tracked value for registrantCount: registrantCount. + */ + private TrackedValue registrantCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.WebinarRecord}. + */ + public WebinarRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WebinarRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public WebinarRecordBuilder(WebinarRecord instance) { + this.webinarId = initialValue(instance.webinarId()); + this.webinarTitle = initialValue(instance.webinarTitle()); + this.presenter = initialValue(instance.presenter()); + this.webinarDate = initialValue(instance.webinarDate()); + this.registrantCount = initialValue(instance.registrantCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WebinarRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * WebinarRecordBuilder builder = WebinarRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WebinarRecord} + */ + public static WebinarRecordBuilder create() { + return new WebinarRecordBuilder(); + } + + /** + * Sets the value for presenter. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter("example value");
    +   * }
    + * + * @param presenter presenter + * @return current instance of builder + */ + public WebinarRecordBuilder presenter(String presenter) { + this.presenter = changedValue(presenter); + return this; + } + + /** + * Sets the value for presenter by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter(sb -> sb.append("text"));
    +   * }
    + * + * @param presenterStringBuilderConsumer consumer providing an instance of presenter + * @return current instance of builder + */ + public WebinarRecordBuilder presenter(Consumer presenterStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + presenterStringBuilderConsumer.accept(builder); + this.presenter = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for presenter by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter(() -> "example value");
    +   * }
    + * + * @param presenterSupplier supplier for presenter + * @return current instance of builder + */ + public WebinarRecordBuilder presenter(Supplier presenterSupplier) { + this.presenter = changedValue(presenterSupplier.get()); + return this; + } + + /** + * Sets the String value for presenter by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.presenter("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WebinarRecordBuilder presenter(String format, Object... args) { + this.presenter = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for registrantCount. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registrantCount(42);
    +   * }
    + * + * @param registrantCount registrantCount + * @return current instance of builder + */ + public WebinarRecordBuilder registrantCount(int registrantCount) { + this.registrantCount = changedValue(registrantCount); + return this; + } + + /** + * Sets the value for registrantCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registrantCount(() -> 42);
    +   * }
    + * + * @param registrantCountSupplier supplier for registrantCount + * @return current instance of builder + */ + public WebinarRecordBuilder registrantCount(Supplier registrantCountSupplier) { + this.registrantCount = changedValue(registrantCountSupplier.get()); + return this; + } + + /** + * Sets the value for webinarDate. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarDate(LocalDate.now());
    +   * }
    + * + * @param webinarDate webinarDate + * @return current instance of builder + */ + public WebinarRecordBuilder webinarDate(LocalDate webinarDate) { + this.webinarDate = changedValue(webinarDate); + return this; + } + + /** + * Sets the value for webinarDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarDate(() -> LocalDate.now());
    +   * }
    + * + * @param webinarDateSupplier supplier for webinarDate + * @return current instance of builder + */ + public WebinarRecordBuilder webinarDate(Supplier webinarDateSupplier) { + this.webinarDate = changedValue(webinarDateSupplier.get()); + return this; + } + + /** + * Sets the value for webinarId. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarId(UUID.randomUUID());
    +   * }
    + * + * @param webinarId webinarId + * @return current instance of builder + */ + public WebinarRecordBuilder webinarId(UUID webinarId) { + this.webinarId = changedValue(webinarId); + return this; + } + + /** + * Sets the value for webinarId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarId(() -> UUID.randomUUID());
    +   * }
    + * + * @param webinarIdSupplier supplier for webinarId + * @return current instance of builder + */ + public WebinarRecordBuilder webinarId(Supplier webinarIdSupplier) { + this.webinarId = changedValue(webinarIdSupplier.get()); + return this; + } + + /** + * Sets the value for webinarTitle. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarTitle("example value");
    +   * }
    + * + * @param webinarTitle webinarTitle + * @return current instance of builder + */ + public WebinarRecordBuilder webinarTitle(String webinarTitle) { + this.webinarTitle = changedValue(webinarTitle); + return this; + } + + /** + * Sets the value for webinarTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param webinarTitleStringBuilderConsumer consumer providing an instance of webinarTitle + * @return current instance of builder + */ + public WebinarRecordBuilder webinarTitle(Consumer webinarTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + webinarTitleStringBuilderConsumer.accept(builder); + this.webinarTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for webinarTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarTitle(() -> "example value");
    +   * }
    + * + * @param webinarTitleSupplier supplier for webinarTitle + * @return current instance of builder + */ + public WebinarRecordBuilder webinarTitle(Supplier webinarTitleSupplier) { + this.webinarTitle = changedValue(webinarTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for webinarTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WebinarRecord#WebinarRecord(UUID, String, String, LocalDate, int) + * WebinarRecord(UUID webinarId, String webinarTitle, String presenter, LocalDate webinarDate, int registrantCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.webinarTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WebinarRecordBuilder webinarTitle(String format, Object... args) { + this.webinarTitle = changedValue(String.format(format, args)); + 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 WebinarRecordBuilder 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 WebinarRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WebinarRecord result = builder.build();
    +   * }
    + */ + @Override + public WebinarRecord build() { + if (!this.registrantCount.isSet()) { + throw new IllegalStateException("Required field 'registrantCount' must be set before calling build()"); + } + if (this.registrantCount.value() == null) { + throw new IllegalStateException("Field 'registrantCount' is marked as non-null but null value was provided"); + } + WebinarRecord result = new WebinarRecord(this.webinarId.value(), + this.webinarTitle.value(), + this.presenter.value(), + this.webinarDate.value(), + this.registrantCount.value()); + 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("webinarId", this.webinarId) + .append("webinarTitle", this.webinarTitle) + .append("presenter", this.presenter) + .append("webinarDate", this.webinarDate) + .append("registrantCount", this.registrantCount) + .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 WebinarRecord with(Consumer b) { + WebinarRecordBuilder builder; + try { + builder = new WebinarRecordBuilder(WebinarRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WebinarRecordBuilder.With' should only be implemented by classes, which could be casted to 'WebinarRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WebinarRecordBuilder with() { + try { + return new WebinarRecordBuilder(WebinarRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WebinarRecordBuilder.With' should only be implemented by classes, which could be casted to 'WebinarRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WorkshopRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WorkshopRecordBuilder.java new file mode 100644 index 00000000..23682ea6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/events/WorkshopRecordBuilder.java @@ -0,0 +1,550 @@ +package org.javahelpers.simple.builders.performance_test.library.events; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.events.WorkshopRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.events.WorkshopRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * WorkshopRecord result = WorkshopRecordBuilder.create()
    + *     .workshopId(UUID.randomUUID())
    + *     .workshopId(() -> UUID.randomUUID())
    + *     .workshopName("example value")
    + *     .workshopName("Hello %s", "World")
    + *     .workshopName(() -> "example value")
    + *     .workshopName(sb -> sb.append("text"))
    + *     .workshopDate(LocalDate.now())
    + *     .workshopDate(() -> LocalDate.now())
    + *     .maxParticipants(42)
    + *     .maxParticipants(() -> 42)
    + *     .materials(List.of("example value"))
    + *     .materials(() -> List.of("example value"))
    + *     .materials(t -> t.add("example value"))
    + *     .materials("example value", "example value")
    + *     .add2Materials("example value")
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WorkshopRecord.class) +public class WorkshopRecordBuilder implements IBuilderBase { + + /** + * Tracked value for workshopId: workshopId. + */ + private TrackedValue workshopId = unsetValue(); + /** + * Tracked value for workshopName: workshopName. + */ + private TrackedValue workshopName = unsetValue(); + /** + * Tracked value for workshopDate: workshopDate. + */ + private TrackedValue workshopDate = unsetValue(); + /** + * Tracked value for maxParticipants: maxParticipants. + */ + private TrackedValue maxParticipants = unsetValue(); + /** + * Tracked value for materials: materials. + */ + private TrackedValue> materials = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.WorkshopRecord}. + */ + public WorkshopRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.events.WorkshopRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public WorkshopRecordBuilder(WorkshopRecord instance) { + this.workshopId = initialValue(instance.workshopId()); + this.workshopName = initialValue(instance.workshopName()); + this.workshopDate = initialValue(instance.workshopDate()); + this.maxParticipants = initialValue(instance.maxParticipants()); + this.materials = initialValue(instance.materials()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WorkshopRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * WorkshopRecordBuilder builder = WorkshopRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.events.WorkshopRecord} + */ + public static WorkshopRecordBuilder create() { + return new WorkshopRecordBuilder(); + } + + /** + * Adds a single element to materials. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Materials("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public WorkshopRecordBuilder add2Materials(String element) { + List newCollection; + if (this.materials.isSet()) { + newCollection = new ArrayList<>(this.materials.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.materials = changedValue(newCollection); + return this; + } + + /** + * Sets the value for materials. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.materials("example value", "example value");
    +   * }
    + * + * @param materials materials + * @return current instance of builder + */ + public WorkshopRecordBuilder materials(String... materials) { + this.materials = changedValue(List.of(materials)); + return this; + } + + /** + * Sets the value for materials. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.materials(List.of("example value"));
    +   * }
    + * + * @param materials materials + * @return current instance of builder + */ + public WorkshopRecordBuilder materials(List materials) { + this.materials = changedValue(materials); + return this; + } + + /** + * Sets the value for materials using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.materials(t -> t.add("example value"));
    +   * }
    + * + * @param materialsBuilderConsumer consumer providing an instance of a builder for materials + * @return current instance of builder + */ + public WorkshopRecordBuilder materials(Consumer> materialsBuilderConsumer) { + ArrayListBuilder builder = this.materials.isSet() + ? new ArrayListBuilder(this.materials.value()) + : new ArrayListBuilder(); + materialsBuilderConsumer.accept(builder); + this.materials = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for materials by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.materials(() -> List.of("example value"));
    +   * }
    + * + * @param materialsSupplier supplier for materials + * @return current instance of builder + */ + public WorkshopRecordBuilder materials(Supplier> materialsSupplier) { + this.materials = changedValue(materialsSupplier.get()); + return this; + } + + /** + * Sets the value for maxParticipants. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.maxParticipants(42);
    +   * }
    + * + * @param maxParticipants maxParticipants + * @return current instance of builder + */ + public WorkshopRecordBuilder maxParticipants(int maxParticipants) { + this.maxParticipants = changedValue(maxParticipants); + return this; + } + + /** + * Sets the value for maxParticipants by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.maxParticipants(() -> 42);
    +   * }
    + * + * @param maxParticipantsSupplier supplier for maxParticipants + * @return current instance of builder + */ + public WorkshopRecordBuilder maxParticipants(Supplier maxParticipantsSupplier) { + this.maxParticipants = changedValue(maxParticipantsSupplier.get()); + return this; + } + + /** + * Sets the value for workshopDate. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopDate(LocalDate.now());
    +   * }
    + * + * @param workshopDate workshopDate + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopDate(LocalDate workshopDate) { + this.workshopDate = changedValue(workshopDate); + return this; + } + + /** + * Sets the value for workshopDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopDate(() -> LocalDate.now());
    +   * }
    + * + * @param workshopDateSupplier supplier for workshopDate + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopDate(Supplier workshopDateSupplier) { + this.workshopDate = changedValue(workshopDateSupplier.get()); + return this; + } + + /** + * Sets the value for workshopId. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopId(UUID.randomUUID());
    +   * }
    + * + * @param workshopId workshopId + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopId(UUID workshopId) { + this.workshopId = changedValue(workshopId); + return this; + } + + /** + * Sets the value for workshopId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopId(() -> UUID.randomUUID());
    +   * }
    + * + * @param workshopIdSupplier supplier for workshopId + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopId(Supplier workshopIdSupplier) { + this.workshopId = changedValue(workshopIdSupplier.get()); + return this; + } + + /** + * Sets the value for workshopName. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopName("example value");
    +   * }
    + * + * @param workshopName workshopName + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopName(String workshopName) { + this.workshopName = changedValue(workshopName); + return this; + } + + /** + * Sets the value for workshopName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopName(sb -> sb.append("text"));
    +   * }
    + * + * @param workshopNameStringBuilderConsumer consumer providing an instance of workshopName + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopName(Consumer workshopNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + workshopNameStringBuilderConsumer.accept(builder); + this.workshopName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for workshopName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopName(() -> "example value");
    +   * }
    + * + * @param workshopNameSupplier supplier for workshopName + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopName(Supplier workshopNameSupplier) { + this.workshopName = changedValue(workshopNameSupplier.get()); + return this; + } + + /** + * Sets the String value for workshopName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WorkshopRecord#WorkshopRecord(UUID, String, LocalDate, int, List) + * WorkshopRecord(UUID workshopId, String workshopName, LocalDate workshopDate, int maxParticipants, List + * materials)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workshopName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WorkshopRecordBuilder workshopName(String format, Object... args) { + this.workshopName = changedValue(String.format(format, args)); + 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 WorkshopRecordBuilder 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 WorkshopRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WorkshopRecord result = builder.build();
    +   * }
    + */ + @Override + public WorkshopRecord build() { + if (!this.maxParticipants.isSet()) { + throw new IllegalStateException("Required field 'maxParticipants' must be set before calling build()"); + } + if (this.maxParticipants.value() == null) { + throw new IllegalStateException("Field 'maxParticipants' is marked as non-null but null value was provided"); + } + WorkshopRecord result = new WorkshopRecord(this.workshopId.value(), + this.workshopName.value(), + this.workshopDate.value(), + this.maxParticipants.value(), + this.materials.value()); + 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("workshopId", this.workshopId) + .append("workshopName", this.workshopName) + .append("workshopDate", this.workshopDate) + .append("maxParticipants", this.maxParticipants) + .append("materials", this.materials) + .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 WorkshopRecord with(Consumer b) { + WorkshopRecordBuilder builder; + try { + builder = new WorkshopRecordBuilder(WorkshopRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WorkshopRecordBuilder.With' should only be implemented by classes, which could be casted to 'WorkshopRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WorkshopRecordBuilder with() { + try { + return new WorkshopRecordBuilder(WorkshopRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WorkshopRecordBuilder.With' should only be implemented by classes, which could be casted to 'WorkshopRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MangaRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MangaRecordBuilder.java new file mode 100644 index 00000000..0d79d1c3 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MangaRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.MangaRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.MangaRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MangaRecord result = MangaRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .volumeNumber(42)
    + *     .volumeNumber(() -> 42)
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MangaRecord.class) +public class MangaRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for volumeNumber: volumeNumber. + */ + private TrackedValue volumeNumber = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MangaRecord}. + */ + public MangaRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MangaRecord} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public MangaRecordBuilder(MangaRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.volumeNumber = initialValue(instance.volumeNumber()); + this.pageCount = initialValue(instance.pageCount()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MangaRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MangaRecordBuilder builder = MangaRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MangaRecord} + */ + public static MangaRecordBuilder create() { + return new MangaRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public MangaRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public MangaRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public MangaRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MangaRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public MangaRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public MangaRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public MangaRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public MangaRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public MangaRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public MangaRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public MangaRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MangaRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for volumeNumber. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volumeNumber(42);
    +   * }
    + * + * @param volumeNumber volumeNumber + * @return current instance of builder + */ + public MangaRecordBuilder volumeNumber(int volumeNumber) { + this.volumeNumber = changedValue(volumeNumber); + return this; + } + + /** + * Sets the value for volumeNumber by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MangaRecord#MangaRecord(String, String, int, int, LocalDate) + * MangaRecord(String title, String authorName, int volumeNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volumeNumber(() -> 42);
    +   * }
    + * + * @param volumeNumberSupplier supplier for volumeNumber + * @return current instance of builder + */ + public MangaRecordBuilder volumeNumber(Supplier volumeNumberSupplier) { + this.volumeNumber = changedValue(volumeNumberSupplier.get()); + 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 MangaRecordBuilder 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 MangaRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MangaRecord result = builder.build();
    +   * }
    + */ + @Override + public MangaRecord build() { + if (!this.volumeNumber.isSet()) { + throw new IllegalStateException("Required field 'volumeNumber' must be set before calling build()"); + } + if (this.volumeNumber.value() == null) { + throw new IllegalStateException("Field 'volumeNumber' is marked as non-null but null value was provided"); + } + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + MangaRecord result = new MangaRecord(this.title.value(), + this.authorName.value(), + this.volumeNumber.value(), + this.pageCount.value(), + this.publicationDate.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("volumeNumber", this.volumeNumber) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .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 MangaRecord with(Consumer b) { + MangaRecordBuilder builder; + try { + builder = new MangaRecordBuilder(MangaRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MangaRecordBuilder.With' should only be implemented by classes, which could be casted to 'MangaRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MangaRecordBuilder with() { + try { + return new MangaRecordBuilder(MangaRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MangaRecordBuilder.With' should only be implemented by classes, which could be casted to 'MangaRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ManuscriptRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ManuscriptRecordBuilder.java new file mode 100644 index 00000000..ec790ef2 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ManuscriptRecordBuilder.java @@ -0,0 +1,521 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.ManuscriptRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.ManuscriptRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ManuscriptRecord result = ManuscriptRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .creationDate(LocalDate.now())
    + *     .creationDate(() -> LocalDate.now())
    + *     .draftNumber(42)
    + *     .draftNumber(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ManuscriptRecord.class) +public class ManuscriptRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for creationDate: creationDate. + */ + private TrackedValue creationDate = unsetValue(); + /** + * Tracked value for draftNumber: draftNumber. + */ + private TrackedValue draftNumber = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ManuscriptRecord}. + */ + public ManuscriptRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ManuscriptRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ManuscriptRecordBuilder(ManuscriptRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.pageCount = initialValue(instance.pageCount()); + this.creationDate = initialValue(instance.creationDate()); + this.draftNumber = initialValue(instance.draftNumber()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ManuscriptRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ManuscriptRecordBuilder builder = ManuscriptRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ManuscriptRecord} + */ + public static ManuscriptRecordBuilder create() { + return new ManuscriptRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public ManuscriptRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public ManuscriptRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public ManuscriptRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManuscriptRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for creationDate. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(LocalDate.now());
    +   * }
    + * + * @param creationDate creationDate + * @return current instance of builder + */ + public ManuscriptRecordBuilder creationDate(LocalDate creationDate) { + this.creationDate = changedValue(creationDate); + return this; + } + + /** + * Sets the value for creationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(() -> LocalDate.now());
    +   * }
    + * + * @param creationDateSupplier supplier for creationDate + * @return current instance of builder + */ + public ManuscriptRecordBuilder creationDate(Supplier creationDateSupplier) { + this.creationDate = changedValue(creationDateSupplier.get()); + return this; + } + + /** + * Sets the value for draftNumber. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.draftNumber(42);
    +   * }
    + * + * @param draftNumber draftNumber + * @return current instance of builder + */ + public ManuscriptRecordBuilder draftNumber(int draftNumber) { + this.draftNumber = changedValue(draftNumber); + return this; + } + + /** + * Sets the value for draftNumber by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.draftNumber(() -> 42);
    +   * }
    + * + * @param draftNumberSupplier supplier for draftNumber + * @return current instance of builder + */ + public ManuscriptRecordBuilder draftNumber(Supplier draftNumberSupplier) { + this.draftNumber = changedValue(draftNumberSupplier.get()); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public ManuscriptRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public ManuscriptRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public ManuscriptRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public ManuscriptRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public ManuscriptRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ManuscriptRecord#ManuscriptRecord(String, String, int, LocalDate, int) ManuscriptRecord(String title, String + * authorName, int pageCount, LocalDate creationDate, int draftNumber)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManuscriptRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 ManuscriptRecordBuilder 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 ManuscriptRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ManuscriptRecord result = builder.build();
    +   * }
    + */ + @Override + public ManuscriptRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + if (!this.draftNumber.isSet()) { + throw new IllegalStateException("Required field 'draftNumber' must be set before calling build()"); + } + if (this.draftNumber.value() == null) { + throw new IllegalStateException("Field 'draftNumber' is marked as non-null but null value was provided"); + } + ManuscriptRecord result = new ManuscriptRecord(this.title + .value(), this.authorName.value(), this.pageCount.value(), this.creationDate.value(), this.draftNumber.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("pageCount", this.pageCount) + .append("creationDate", this.creationDate) + .append("draftNumber", this.draftNumber) + .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 ManuscriptRecord with(Consumer b) { + ManuscriptRecordBuilder builder; + try { + builder = new ManuscriptRecordBuilder(ManuscriptRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ManuscriptRecordBuilder.With' should only be implemented by classes, which could be casted to 'ManuscriptRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ManuscriptRecordBuilder with() { + try { + return new ManuscriptRecordBuilder(ManuscriptRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ManuscriptRecordBuilder.With' should only be implemented by classes, which could be casted to 'ManuscriptRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MapRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MapRecordBuilder.java new file mode 100644 index 00000000..7c06d526 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MapRecordBuilder.java @@ -0,0 +1,493 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.MapRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.MapRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MapRecord result = MapRecordBuilder.create()
    + *     .region("example value")
    + *     .region("Hello %s", "World")
    + *     .region(() -> "example value")
    + *     .region(sb -> sb.append("text"))
    + *     .scale("example value")
    + *     .scale("Hello %s", "World")
    + *     .scale(() -> "example value")
    + *     .scale(sb -> sb.append("text"))
    + *     .dimensions("example value")
    + *     .dimensions("Hello %s", "World")
    + *     .dimensions(() -> "example value")
    + *     .dimensions(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MapRecord.class) +public class MapRecordBuilder implements IBuilderBase { + + /** + * Tracked value for region: region. + */ + private TrackedValue region = unsetValue(); + /** + * Tracked value for scale: scale. + */ + private TrackedValue scale = unsetValue(); + /** + * Tracked value for dimensions: dimensions. + */ + private TrackedValue dimensions = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MapRecord}. + */ + public MapRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MapRecord} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public MapRecordBuilder(MapRecord instance) { + this.region = initialValue(instance.region()); + this.scale = initialValue(instance.scale()); + this.dimensions = initialValue(instance.dimensions()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MapRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MapRecordBuilder builder = MapRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MapRecord} + */ + public static MapRecordBuilder create() { + return new MapRecordBuilder(); + } + + /** + * Sets the value for dimensions. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("example value");
    +   * }
    + * + * @param dimensions dimensions + * @return current instance of builder + */ + public MapRecordBuilder dimensions(String dimensions) { + this.dimensions = changedValue(dimensions); + return this; + } + + /** + * Sets the value for dimensions by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(sb -> sb.append("text"));
    +   * }
    + * + * @param dimensionsStringBuilderConsumer consumer providing an instance of dimensions + * @return current instance of builder + */ + public MapRecordBuilder dimensions(Consumer dimensionsStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + dimensionsStringBuilderConsumer.accept(builder); + this.dimensions = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for dimensions by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(() -> "example value");
    +   * }
    + * + * @param dimensionsSupplier supplier for dimensions + * @return current instance of builder + */ + public MapRecordBuilder dimensions(Supplier dimensionsSupplier) { + this.dimensions = changedValue(dimensionsSupplier.get()); + return this; + } + + /** + * Sets the String value for dimensions by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MapRecordBuilder dimensions(String format, Object... args) { + this.dimensions = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public MapRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public MapRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for region. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("example value");
    +   * }
    + * + * @param region region + * @return current instance of builder + */ + public MapRecordBuilder region(String region) { + this.region = changedValue(region); + return this; + } + + /** + * Sets the value for region by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(sb -> sb.append("text"));
    +   * }
    + * + * @param regionStringBuilderConsumer consumer providing an instance of region + * @return current instance of builder + */ + public MapRecordBuilder region(Consumer regionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + regionStringBuilderConsumer.accept(builder); + this.region = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for region by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(() -> "example value");
    +   * }
    + * + * @param regionSupplier supplier for region + * @return current instance of builder + */ + public MapRecordBuilder region(Supplier regionSupplier) { + this.region = changedValue(regionSupplier.get()); + return this; + } + + /** + * Sets the String value for region by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MapRecordBuilder region(String format, Object... args) { + this.region = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for scale. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scale("example value");
    +   * }
    + * + * @param scale scale + * @return current instance of builder + */ + public MapRecordBuilder scale(String scale) { + this.scale = changedValue(scale); + return this; + } + + /** + * Sets the value for scale by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scale(sb -> sb.append("text"));
    +   * }
    + * + * @param scaleStringBuilderConsumer consumer providing an instance of scale + * @return current instance of builder + */ + public MapRecordBuilder scale(Consumer scaleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + scaleStringBuilderConsumer.accept(builder); + this.scale = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for scale by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scale(() -> "example value");
    +   * }
    + * + * @param scaleSupplier supplier for scale + * @return current instance of builder + */ + public MapRecordBuilder scale(Supplier scaleSupplier) { + this.scale = changedValue(scaleSupplier.get()); + return this; + } + + /** + * Sets the String value for scale by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MapRecord#MapRecord(String, String, String, LocalDate) + * MapRecord(String region, String scale, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scale("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MapRecordBuilder scale(String format, Object... args) { + this.scale = changedValue(String.format(format, args)); + 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 MapRecordBuilder 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 MapRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MapRecord result = builder.build();
    +   * }
    + */ + @Override + public MapRecord build() { + MapRecord result = new MapRecord(this.region.value(), + this.scale.value(), + this.dimensions.value(), + this.publicationDate.value()); + 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("region", this.region) + .append("scale", this.scale) + .append("dimensions", this.dimensions) + .append("publicationDate", this.publicationDate) + .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 MapRecord with(Consumer b) { + MapRecordBuilder builder; + try { + builder = new MapRecordBuilder(MapRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MapRecordBuilder.With' should only be implemented by classes, which could be casted to 'MapRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MapRecordBuilder with() { + try { + return new MapRecordBuilder(MapRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MapRecordBuilder.With' should only be implemented by classes, which could be casted to 'MapRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MemorandumRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MemorandumRecordBuilder.java new file mode 100644 index 00000000..a679ba04 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MemorandumRecordBuilder.java @@ -0,0 +1,563 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.MemorandumRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.MemorandumRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MemorandumRecord result = MemorandumRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .from("example value")
    + *     .from("Hello %s", "World")
    + *     .from(() -> "example value")
    + *     .from(sb -> sb.append("text"))
    + *     .to("example value")
    + *     .to("Hello %s", "World")
    + *     .to(() -> "example value")
    + *     .to(sb -> sb.append("text"))
    + *     .date(LocalDate.now())
    + *     .date(() -> LocalDate.now())
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MemorandumRecord.class) +public class MemorandumRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for from: from. + */ + private TrackedValue from = unsetValue(); + /** + * Tracked value for to: to. + */ + private TrackedValue to = unsetValue(); + /** + * Tracked value for date: date. + */ + private TrackedValue date = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MemorandumRecord}. + */ + public MemorandumRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MemorandumRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public MemorandumRecordBuilder(MemorandumRecord instance) { + this.subject = initialValue(instance.subject()); + this.from = initialValue(instance.from()); + this.to = initialValue(instance.to()); + this.date = initialValue(instance.date()); + this.pageCount = initialValue(instance.pageCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MemorandumRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MemorandumRecordBuilder builder = MemorandumRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MemorandumRecord} + */ + public static MemorandumRecordBuilder create() { + return new MemorandumRecordBuilder(); + } + + /** + * Sets the value for date. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.date(LocalDate.now());
    +   * }
    + * + * @param date date + * @return current instance of builder + */ + public MemorandumRecordBuilder date(LocalDate date) { + this.date = changedValue(date); + return this; + } + + /** + * Sets the value for date by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.date(() -> LocalDate.now());
    +   * }
    + * + * @param dateSupplier supplier for date + * @return current instance of builder + */ + public MemorandumRecordBuilder date(Supplier dateSupplier) { + this.date = changedValue(dateSupplier.get()); + return this; + } + + /** + * Sets the value for from. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.from("example value");
    +   * }
    + * + * @param from from + * @return current instance of builder + */ + public MemorandumRecordBuilder from(String from) { + this.from = changedValue(from); + return this; + } + + /** + * Sets the value for from by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.from(sb -> sb.append("text"));
    +   * }
    + * + * @param fromStringBuilderConsumer consumer providing an instance of from + * @return current instance of builder + */ + public MemorandumRecordBuilder from(Consumer fromStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fromStringBuilderConsumer.accept(builder); + this.from = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for from by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.from(() -> "example value");
    +   * }
    + * + * @param fromSupplier supplier for from + * @return current instance of builder + */ + public MemorandumRecordBuilder from(Supplier fromSupplier) { + this.from = changedValue(fromSupplier.get()); + return this; + } + + /** + * Sets the String value for from by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.from("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MemorandumRecordBuilder from(String format, Object... args) { + this.from = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public MemorandumRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public MemorandumRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public MemorandumRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public MemorandumRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public MemorandumRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MemorandumRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for to. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.to("example value");
    +   * }
    + * + * @param to to + * @return current instance of builder + */ + public MemorandumRecordBuilder to(String to) { + this.to = changedValue(to); + return this; + } + + /** + * Sets the value for to by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.to(sb -> sb.append("text"));
    +   * }
    + * + * @param toStringBuilderConsumer consumer providing an instance of to + * @return current instance of builder + */ + public MemorandumRecordBuilder to(Consumer toStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + toStringBuilderConsumer.accept(builder); + this.to = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for to by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.to(() -> "example value");
    +   * }
    + * + * @param toSupplier supplier for to + * @return current instance of builder + */ + public MemorandumRecordBuilder to(Supplier toSupplier) { + this.to = changedValue(toSupplier.get()); + return this; + } + + /** + * Sets the String value for to by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MemorandumRecord#MemorandumRecord(String, String, String, LocalDate, int) MemorandumRecord(String subject, + * String from, String to, LocalDate date, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.to("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MemorandumRecordBuilder to(String format, Object... args) { + this.to = changedValue(String.format(format, args)); + 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 MemorandumRecordBuilder 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 MemorandumRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MemorandumRecord result = builder.build();
    +   * }
    + */ + @Override + public MemorandumRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + MemorandumRecord result = new MemorandumRecord(this.subject + .value(), this.from.value(), this.to.value(), this.date.value(), this.pageCount.value()); + 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("subject", this.subject) + .append("from", this.from) + .append("to", this.to) + .append("date", this.date) + .append("pageCount", this.pageCount) + .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 MemorandumRecord with(Consumer b) { + MemorandumRecordBuilder builder; + try { + builder = new MemorandumRecordBuilder(MemorandumRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MemorandumRecordBuilder.With' should only be implemented by classes, which could be casted to 'MemorandumRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MemorandumRecordBuilder with() { + try { + return new MemorandumRecordBuilder(MemorandumRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MemorandumRecordBuilder.With' should only be implemented by classes, which could be casted to 'MemorandumRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MicroformRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MicroformRecordBuilder.java new file mode 100644 index 00000000..0e42bd09 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MicroformRecordBuilder.java @@ -0,0 +1,455 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.MicroformRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.MicroformRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MicroformRecord result = MicroformRecordBuilder.create()
    + *     .contentDescription("example value")
    + *     .contentDescription("Hello %s", "World")
    + *     .contentDescription(() -> "example value")
    + *     .contentDescription(sb -> sb.append("text"))
    + *     .frameCount(42)
    + *     .frameCount(() -> 42)
    + *     .format("example value")
    + *     .format("Hello %s", "World")
    + *     .format(() -> "example value")
    + *     .format(sb -> sb.append("text"))
    + *     .productionDate(LocalDate.now())
    + *     .productionDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MicroformRecord.class) +public class MicroformRecordBuilder implements IBuilderBase { + + /** + * Tracked value for contentDescription: contentDescription. + */ + private TrackedValue contentDescription = unsetValue(); + /** + * Tracked value for frameCount: frameCount. + */ + private TrackedValue frameCount = unsetValue(); + /** + * Tracked value for format: format. + */ + private TrackedValue format = unsetValue(); + /** + * Tracked value for productionDate: productionDate. + */ + private TrackedValue productionDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MicroformRecord}. + */ + public MicroformRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MicroformRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public MicroformRecordBuilder(MicroformRecord instance) { + this.contentDescription = initialValue(instance.contentDescription()); + this.frameCount = initialValue(instance.frameCount()); + this.format = initialValue(instance.format()); + this.productionDate = initialValue(instance.productionDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MicroformRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MicroformRecordBuilder builder = MicroformRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MicroformRecord} + */ + public static MicroformRecordBuilder create() { + return new MicroformRecordBuilder(); + } + + /** + * Sets the value for contentDescription. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentDescription("example value");
    +   * }
    + * + * @param contentDescription contentDescription + * @return current instance of builder + */ + public MicroformRecordBuilder contentDescription(String contentDescription) { + this.contentDescription = changedValue(contentDescription); + return this; + } + + /** + * Sets the value for contentDescription by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentDescription(sb -> sb.append("text"));
    +   * }
    + * + * @param contentDescriptionStringBuilderConsumer consumer providing an instance of contentDescription + * @return current instance of builder + */ + public MicroformRecordBuilder contentDescription(Consumer contentDescriptionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + contentDescriptionStringBuilderConsumer.accept(builder); + this.contentDescription = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for contentDescription by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentDescription(() -> "example value");
    +   * }
    + * + * @param contentDescriptionSupplier supplier for contentDescription + * @return current instance of builder + */ + public MicroformRecordBuilder contentDescription(Supplier contentDescriptionSupplier) { + this.contentDescription = changedValue(contentDescriptionSupplier.get()); + return this; + } + + /** + * Sets the String value for contentDescription by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentDescription("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MicroformRecordBuilder contentDescription(String format, Object... args) { + this.contentDescription = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for format. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("example value");
    +   * }
    + * + * @param format format + * @return current instance of builder + */ + public MicroformRecordBuilder format(String format) { + this.format = changedValue(format); + return this; + } + + /** + * Sets the value for format by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(sb -> sb.append("text"));
    +   * }
    + * + * @param formatStringBuilderConsumer consumer providing an instance of format + * @return current instance of builder + */ + public MicroformRecordBuilder format(Consumer formatStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + formatStringBuilderConsumer.accept(builder); + this.format = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for format by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(() -> "example value");
    +   * }
    + * + * @param formatSupplier supplier for format + * @return current instance of builder + */ + public MicroformRecordBuilder format(Supplier formatSupplier) { + this.format = changedValue(formatSupplier.get()); + return this; + } + + /** + * Sets the String value for format by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MicroformRecordBuilder format(String format, Object... args) { + this.format = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for frameCount. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.frameCount(42);
    +   * }
    + * + * @param frameCount frameCount + * @return current instance of builder + */ + public MicroformRecordBuilder frameCount(int frameCount) { + this.frameCount = changedValue(frameCount); + return this; + } + + /** + * Sets the value for frameCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.frameCount(() -> 42);
    +   * }
    + * + * @param frameCountSupplier supplier for frameCount + * @return current instance of builder + */ + public MicroformRecordBuilder frameCount(Supplier frameCountSupplier) { + this.frameCount = changedValue(frameCountSupplier.get()); + return this; + } + + /** + * Sets the value for productionDate. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionDate(LocalDate.now());
    +   * }
    + * + * @param productionDate productionDate + * @return current instance of builder + */ + public MicroformRecordBuilder productionDate(LocalDate productionDate) { + this.productionDate = changedValue(productionDate); + return this; + } + + /** + * Sets the value for productionDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MicroformRecord#MicroformRecord(String, int, String, LocalDate) + * MicroformRecord(String contentDescription, int frameCount, String format, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionDate(() -> LocalDate.now());
    +   * }
    + * + * @param productionDateSupplier supplier for productionDate + * @return current instance of builder + */ + public MicroformRecordBuilder productionDate(Supplier productionDateSupplier) { + this.productionDate = changedValue(productionDateSupplier.get()); + 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 MicroformRecordBuilder 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 MicroformRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MicroformRecord result = builder.build();
    +   * }
    + */ + @Override + public MicroformRecord build() { + if (!this.frameCount.isSet()) { + throw new IllegalStateException("Required field 'frameCount' must be set before calling build()"); + } + if (this.frameCount.value() == null) { + throw new IllegalStateException("Field 'frameCount' is marked as non-null but null value was provided"); + } + MicroformRecord result = new MicroformRecord(this.contentDescription.value(), + this.frameCount.value(), + this.format.value(), + this.productionDate.value()); + 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("contentDescription", this.contentDescription) + .append("frameCount", this.frameCount) + .append("format", this.format) + .append("productionDate", this.productionDate) + .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 MicroformRecord with(Consumer b) { + MicroformRecordBuilder builder; + try { + builder = new MicroformRecordBuilder(MicroformRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MicroformRecordBuilder.With' should only be implemented by classes, which could be casted to 'MicroformRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MicroformRecordBuilder with() { + try { + return new MicroformRecordBuilder(MicroformRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MicroformRecordBuilder.With' should only be implemented by classes, which could be casted to 'MicroformRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MonographRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MonographRecordBuilder.java new file mode 100644 index 00000000..469aaa79 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/MonographRecordBuilder.java @@ -0,0 +1,562 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.MonographRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.MonographRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MonographRecord result = MonographRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .field("example value")
    + *     .field("Hello %s", "World")
    + *     .field(() -> "example value")
    + *     .field(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MonographRecord.class) +public class MonographRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for field: field. + */ + private TrackedValue field = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MonographRecord}. + */ + public MonographRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.MonographRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public MonographRecordBuilder(MonographRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.pageCount = initialValue(instance.pageCount()); + this.field = initialValue(instance.field()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MonographRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MonographRecordBuilder builder = MonographRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.MonographRecord} + */ + public static MonographRecordBuilder create() { + return new MonographRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public MonographRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public MonographRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public MonographRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MonographRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for field. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("example value");
    +   * }
    + * + * @param field field + * @return current instance of builder + */ + public MonographRecordBuilder field(String field) { + this.field = changedValue(field); + return this; + } + + /** + * Sets the value for field by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(sb -> sb.append("text"));
    +   * }
    + * + * @param fieldStringBuilderConsumer consumer providing an instance of field + * @return current instance of builder + */ + public MonographRecordBuilder field(Consumer fieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fieldStringBuilderConsumer.accept(builder); + this.field = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for field by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(() -> "example value");
    +   * }
    + * + * @param fieldSupplier supplier for field + * @return current instance of builder + */ + public MonographRecordBuilder field(Supplier fieldSupplier) { + this.field = changedValue(fieldSupplier.get()); + return this; + } + + /** + * Sets the String value for field by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MonographRecordBuilder field(String format, Object... args) { + this.field = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public MonographRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public MonographRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public MonographRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public MonographRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public MonographRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public MonographRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public MonographRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MonographRecord#MonographRecord(String, String, int, String, LocalDate) MonographRecord(String title, String + * authorName, int pageCount, String field, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MonographRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 MonographRecordBuilder 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 MonographRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MonographRecord result = builder.build();
    +   * }
    + */ + @Override + public MonographRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + MonographRecord result = new MonographRecord(this.title + .value(), this.authorName.value(), this.pageCount.value(), this.field.value(), this.publicationDate.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("pageCount", this.pageCount) + .append("field", this.field) + .append("publicationDate", this.publicationDate) + .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 MonographRecord with(Consumer b) { + MonographRecordBuilder builder; + try { + builder = new MonographRecordBuilder(MonographRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MonographRecordBuilder.With' should only be implemented by classes, which could be casted to 'MonographRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MonographRecordBuilder with() { + try { + return new MonographRecordBuilder(MonographRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MonographRecordBuilder.With' should only be implemented by classes, which could be casted to 'MonographRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NegativeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NegativeRecordBuilder.java new file mode 100644 index 00000000..725d119b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NegativeRecordBuilder.java @@ -0,0 +1,494 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.NegativeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.NegativeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * NegativeRecord result = NegativeRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .photographer("example value")
    + *     .photographer("Hello %s", "World")
    + *     .photographer(() -> "example value")
    + *     .photographer(sb -> sb.append("text"))
    + *     .format("example value")
    + *     .format("Hello %s", "World")
    + *     .format(() -> "example value")
    + *     .format(sb -> sb.append("text"))
    + *     .captureDate(LocalDate.now())
    + *     .captureDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NegativeRecord.class) +public class NegativeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for photographer: photographer. + */ + private TrackedValue photographer = unsetValue(); + /** + * Tracked value for format: format. + */ + private TrackedValue format = unsetValue(); + /** + * Tracked value for captureDate: captureDate. + */ + private TrackedValue captureDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.NegativeRecord}. + */ + public NegativeRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NegativeRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public NegativeRecordBuilder(NegativeRecord instance) { + this.subject = initialValue(instance.subject()); + this.photographer = initialValue(instance.photographer()); + this.format = initialValue(instance.format()); + this.captureDate = initialValue(instance.captureDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NegativeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * NegativeRecordBuilder builder = NegativeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NegativeRecord} + */ + public static NegativeRecordBuilder create() { + return new NegativeRecordBuilder(); + } + + /** + * Sets the value for captureDate. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.captureDate(LocalDate.now());
    +   * }
    + * + * @param captureDate captureDate + * @return current instance of builder + */ + public NegativeRecordBuilder captureDate(LocalDate captureDate) { + this.captureDate = changedValue(captureDate); + return this; + } + + /** + * Sets the value for captureDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.captureDate(() -> LocalDate.now());
    +   * }
    + * + * @param captureDateSupplier supplier for captureDate + * @return current instance of builder + */ + public NegativeRecordBuilder captureDate(Supplier captureDateSupplier) { + this.captureDate = changedValue(captureDateSupplier.get()); + return this; + } + + /** + * Sets the value for format. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("example value");
    +   * }
    + * + * @param format format + * @return current instance of builder + */ + public NegativeRecordBuilder format(String format) { + this.format = changedValue(format); + return this; + } + + /** + * Sets the value for format by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(sb -> sb.append("text"));
    +   * }
    + * + * @param formatStringBuilderConsumer consumer providing an instance of format + * @return current instance of builder + */ + public NegativeRecordBuilder format(Consumer formatStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + formatStringBuilderConsumer.accept(builder); + this.format = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for format by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(() -> "example value");
    +   * }
    + * + * @param formatSupplier supplier for format + * @return current instance of builder + */ + public NegativeRecordBuilder format(Supplier formatSupplier) { + this.format = changedValue(formatSupplier.get()); + return this; + } + + /** + * Sets the String value for format by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NegativeRecordBuilder format(String format, Object... args) { + this.format = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for photographer. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer("example value");
    +   * }
    + * + * @param photographer photographer + * @return current instance of builder + */ + public NegativeRecordBuilder photographer(String photographer) { + this.photographer = changedValue(photographer); + return this; + } + + /** + * Sets the value for photographer by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer(sb -> sb.append("text"));
    +   * }
    + * + * @param photographerStringBuilderConsumer consumer providing an instance of photographer + * @return current instance of builder + */ + public NegativeRecordBuilder photographer(Consumer photographerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + photographerStringBuilderConsumer.accept(builder); + this.photographer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for photographer by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer(() -> "example value");
    +   * }
    + * + * @param photographerSupplier supplier for photographer + * @return current instance of builder + */ + public NegativeRecordBuilder photographer(Supplier photographerSupplier) { + this.photographer = changedValue(photographerSupplier.get()); + return this; + } + + /** + * Sets the String value for photographer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NegativeRecordBuilder photographer(String format, Object... args) { + this.photographer = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public NegativeRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public NegativeRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public NegativeRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link NegativeRecord#NegativeRecord(String, String, String, LocalDate) + * NegativeRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NegativeRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 NegativeRecordBuilder 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 NegativeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NegativeRecord result = builder.build();
    +   * }
    + */ + @Override + public NegativeRecord build() { + NegativeRecord result = new NegativeRecord(this.subject.value(), + this.photographer.value(), + this.format.value(), + this.captureDate.value()); + 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("subject", this.subject) + .append("photographer", this.photographer) + .append("format", this.format) + .append("captureDate", this.captureDate) + .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 NegativeRecord with(Consumer b) { + NegativeRecordBuilder builder; + try { + builder = new NegativeRecordBuilder(NegativeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NegativeRecordBuilder.With' should only be implemented by classes, which could be casted to 'NegativeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NegativeRecordBuilder with() { + try { + return new NegativeRecordBuilder(NegativeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NegativeRecordBuilder.With' should only be implemented by classes, which could be casted to 'NegativeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NewsletterRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NewsletterRecordBuilder.java new file mode 100644 index 00000000..31e7da93 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NewsletterRecordBuilder.java @@ -0,0 +1,524 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.NewsletterRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.NewsletterRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * NewsletterRecord result = NewsletterRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .publisher("example value")
    + *     .publisher("Hello %s", "World")
    + *     .publisher(() -> "example value")
    + *     .publisher(sb -> sb.append("text"))
    + *     .issueNumber(42)
    + *     .issueNumber(() -> 42)
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NewsletterRecord.class) +public class NewsletterRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for issueNumber: issueNumber. + */ + private TrackedValue issueNumber = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.NewsletterRecord}. + */ + public NewsletterRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.NewsletterRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public NewsletterRecordBuilder(NewsletterRecord instance) { + this.title = initialValue(instance.title()); + this.publisher = initialValue(instance.publisher()); + this.issueNumber = initialValue(instance.issueNumber()); + this.pageCount = initialValue(instance.pageCount()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NewsletterRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * NewsletterRecordBuilder builder = NewsletterRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NewsletterRecord} + */ + public static NewsletterRecordBuilder create() { + return new NewsletterRecordBuilder(); + } + + /** + * Sets the value for issueNumber. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issueNumber(42);
    +   * }
    + * + * @param issueNumber issueNumber + * @return current instance of builder + */ + public NewsletterRecordBuilder issueNumber(int issueNumber) { + this.issueNumber = changedValue(issueNumber); + return this; + } + + /** + * Sets the value for issueNumber by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issueNumber(() -> 42);
    +   * }
    + * + * @param issueNumberSupplier supplier for issueNumber + * @return current instance of builder + */ + public NewsletterRecordBuilder issueNumber(Supplier issueNumberSupplier) { + this.issueNumber = changedValue(issueNumberSupplier.get()); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public NewsletterRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public NewsletterRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public NewsletterRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public NewsletterRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher("example value");
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public NewsletterRecordBuilder publisher(String publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(sb -> sb.append("text"));
    +   * }
    + * + * @param publisherStringBuilderConsumer consumer providing an instance of publisher + * @return current instance of builder + */ + public NewsletterRecordBuilder publisher(Consumer publisherStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + publisherStringBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(() -> "example value");
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public NewsletterRecordBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the String value for publisher by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NewsletterRecordBuilder publisher(String format, Object... args) { + this.publisher = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public NewsletterRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public NewsletterRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public NewsletterRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NewsletterRecord#NewsletterRecord(String, String, int, int, LocalDate) NewsletterRecord(String title, String + * publisher, int issueNumber, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NewsletterRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 NewsletterRecordBuilder 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 NewsletterRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NewsletterRecord result = builder.build();
    +   * }
    + */ + @Override + public NewsletterRecord build() { + if (!this.issueNumber.isSet()) { + throw new IllegalStateException("Required field 'issueNumber' must be set before calling build()"); + } + if (this.issueNumber.value() == null) { + throw new IllegalStateException("Field 'issueNumber' is marked as non-null but null value was provided"); + } + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + NewsletterRecord result = new NewsletterRecord(this.title.value(), + this.publisher.value(), + this.issueNumber.value(), + this.pageCount.value(), + this.publicationDate.value()); + 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("title", this.title) + .append("publisher", this.publisher) + .append("issueNumber", this.issueNumber) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .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 NewsletterRecord with(Consumer b) { + NewsletterRecordBuilder builder; + try { + builder = new NewsletterRecordBuilder(NewsletterRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NewsletterRecordBuilder.With' should only be implemented by classes, which could be casted to 'NewsletterRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NewsletterRecordBuilder with() { + try { + return new NewsletterRecordBuilder(NewsletterRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NewsletterRecordBuilder.With' should only be implemented by classes, which could be casted to 'NewsletterRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovelRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovelRecordBuilder.java new file mode 100644 index 00000000..de1b5987 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovelRecordBuilder.java @@ -0,0 +1,721 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.NovelRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.NovelRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * NovelRecord result = NovelRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .genre("example value")
    + *     .genre("Hello %s", "World")
    + *     .genre(() -> "example value")
    + *     .genre(sb -> sb.append("text"))
    + *     .wordCount(42L)
    + *     .wordCount(() -> 42L)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .available(true)
    + *     .available(() -> true)
    + *     .language("example value")
    + *     .language("Hello %s", "World")
    + *     .language(() -> "example value")
    + *     .language(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NovelRecord.class) +public class NovelRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for genre: genre. + */ + private TrackedValue genre = unsetValue(); + /** + * Tracked value for wordCount: wordCount. + */ + private TrackedValue wordCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for available: available. + */ + private TrackedValue available = unsetValue(); + /** + * Tracked value for language: language. + */ + private TrackedValue language = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.NovelRecord}. + */ + public NovelRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NovelRecord} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public NovelRecordBuilder(NovelRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.genre = initialValue(instance.genre()); + this.wordCount = initialValue(instance.wordCount()); + this.publicationDate = initialValue(instance.publicationDate()); + this.available = initialValue(instance.available()); + this.language = initialValue(instance.language()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NovelRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * NovelRecordBuilder builder = NovelRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NovelRecord} + */ + public static NovelRecordBuilder create() { + return new NovelRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public NovelRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public NovelRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public NovelRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovelRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for available. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.available(true);
    +   * }
    + * + * @param available available + * @return current instance of builder + */ + public NovelRecordBuilder available(boolean available) { + this.available = changedValue(available); + return this; + } + + /** + * Sets the value for available by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.available(() -> true);
    +   * }
    + * + * @param availableSupplier supplier for available + * @return current instance of builder + */ + public NovelRecordBuilder available(Supplier availableSupplier) { + this.available = changedValue(availableSupplier.get()); + return this; + } + + /** + * Sets the value for genre. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre("example value");
    +   * }
    + * + * @param genre genre + * @return current instance of builder + */ + public NovelRecordBuilder genre(String genre) { + this.genre = changedValue(genre); + return this; + } + + /** + * Sets the value for genre by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre(sb -> sb.append("text"));
    +   * }
    + * + * @param genreStringBuilderConsumer consumer providing an instance of genre + * @return current instance of builder + */ + public NovelRecordBuilder genre(Consumer genreStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + genreStringBuilderConsumer.accept(builder); + this.genre = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for genre by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre(() -> "example value");
    +   * }
    + * + * @param genreSupplier supplier for genre + * @return current instance of builder + */ + public NovelRecordBuilder genre(Supplier genreSupplier) { + this.genre = changedValue(genreSupplier.get()); + return this; + } + + /** + * Sets the String value for genre by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovelRecordBuilder genre(String format, Object... args) { + this.genre = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for language. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language("example value");
    +   * }
    + * + * @param language language + * @return current instance of builder + */ + public NovelRecordBuilder language(String language) { + this.language = changedValue(language); + return this; + } + + /** + * Sets the value for language by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language(sb -> sb.append("text"));
    +   * }
    + * + * @param languageStringBuilderConsumer consumer providing an instance of language + * @return current instance of builder + */ + public NovelRecordBuilder language(Consumer languageStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + languageStringBuilderConsumer.accept(builder); + this.language = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for language by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language(() -> "example value");
    +   * }
    + * + * @param languageSupplier supplier for language + * @return current instance of builder + */ + public NovelRecordBuilder language(Supplier languageSupplier) { + this.language = changedValue(languageSupplier.get()); + return this; + } + + /** + * Sets the String value for language by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovelRecordBuilder language(String format, Object... args) { + this.language = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public NovelRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public NovelRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public NovelRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public NovelRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public NovelRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovelRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for wordCount. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(42L);
    +   * }
    + * + * @param wordCount wordCount + * @return current instance of builder + */ + public NovelRecordBuilder wordCount(long wordCount) { + this.wordCount = changedValue(wordCount); + return this; + } + + /** + * Sets the value for wordCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovelRecord#NovelRecord(String, String, String, long, LocalDate, boolean, String) NovelRecord(String title, + * String authorName, String genre, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(() -> 42L);
    +   * }
    + * + * @param wordCountSupplier supplier for wordCount + * @return current instance of builder + */ + public NovelRecordBuilder wordCount(Supplier wordCountSupplier) { + this.wordCount = changedValue(wordCountSupplier.get()); + 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 NovelRecordBuilder 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 NovelRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NovelRecord result = builder.build();
    +   * }
    + */ + @Override + public NovelRecord build() { + if (!this.wordCount.isSet()) { + throw new IllegalStateException("Required field 'wordCount' must be set before calling build()"); + } + if (this.wordCount.value() == null) { + throw new IllegalStateException("Field 'wordCount' is marked as non-null but null value was provided"); + } + if (!this.available.isSet()) { + throw new IllegalStateException("Required field 'available' must be set before calling build()"); + } + if (this.available.value() == null) { + throw new IllegalStateException("Field 'available' is marked as non-null but null value was provided"); + } + NovelRecord result = new NovelRecord(this.title.value(), + this.authorName.value(), + this.genre.value(), + this.wordCount.value(), + this.publicationDate.value(), + this.available.value(), + this.language.valueOr("EN")); + 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("title", this.title) + .append("authorName", this.authorName) + .append("genre", this.genre) + .append("wordCount", this.wordCount) + .append("publicationDate", this.publicationDate) + .append("available", this.available) + .append("language", this.language) + .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 NovelRecord with(Consumer b) { + NovelRecordBuilder builder; + try { + builder = new NovelRecordBuilder(NovelRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NovelRecordBuilder.With' should only be implemented by classes, which could be casted to 'NovelRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NovelRecordBuilder with() { + try { + return new NovelRecordBuilder(NovelRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NovelRecordBuilder.With' should only be implemented by classes, which could be casted to 'NovelRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovellaRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovellaRecordBuilder.java new file mode 100644 index 00000000..70a4cccc --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/NovellaRecordBuilder.java @@ -0,0 +1,622 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.NovellaRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.NovellaRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * NovellaRecord result = NovellaRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .wordCount(42L)
    + *     .wordCount(() -> 42L)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .available(true)
    + *     .available(() -> true)
    + *     .language("example value")
    + *     .language("Hello %s", "World")
    + *     .language(() -> "example value")
    + *     .language(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NovellaRecord.class) +public class NovellaRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for wordCount: wordCount. + */ + private TrackedValue wordCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for available: available. + */ + private TrackedValue available = unsetValue(); + /** + * Tracked value for language: language. + */ + private TrackedValue language = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.NovellaRecord}. + */ + public NovellaRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NovellaRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public NovellaRecordBuilder(NovellaRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.wordCount = initialValue(instance.wordCount()); + this.publicationDate = initialValue(instance.publicationDate()); + this.available = initialValue(instance.available()); + this.language = initialValue(instance.language()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NovellaRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * NovellaRecordBuilder builder = NovellaRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.NovellaRecord} + */ + public static NovellaRecordBuilder create() { + return new NovellaRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public NovellaRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public NovellaRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public NovellaRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovellaRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for available. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.available(true);
    +   * }
    + * + * @param available available + * @return current instance of builder + */ + public NovellaRecordBuilder available(boolean available) { + this.available = changedValue(available); + return this; + } + + /** + * Sets the value for available by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.available(() -> true);
    +   * }
    + * + * @param availableSupplier supplier for available + * @return current instance of builder + */ + public NovellaRecordBuilder available(Supplier availableSupplier) { + this.available = changedValue(availableSupplier.get()); + return this; + } + + /** + * Sets the value for language. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language("example value");
    +   * }
    + * + * @param language language + * @return current instance of builder + */ + public NovellaRecordBuilder language(String language) { + this.language = changedValue(language); + return this; + } + + /** + * Sets the value for language by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language(sb -> sb.append("text"));
    +   * }
    + * + * @param languageStringBuilderConsumer consumer providing an instance of language + * @return current instance of builder + */ + public NovellaRecordBuilder language(Consumer languageStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + languageStringBuilderConsumer.accept(builder); + this.language = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for language by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language(() -> "example value");
    +   * }
    + * + * @param languageSupplier supplier for language + * @return current instance of builder + */ + public NovellaRecordBuilder language(Supplier languageSupplier) { + this.language = changedValue(languageSupplier.get()); + return this; + } + + /** + * Sets the String value for language by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovellaRecordBuilder language(String format, Object... args) { + this.language = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public NovellaRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public NovellaRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public NovellaRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public NovellaRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public NovellaRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NovellaRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for wordCount. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(42L);
    +   * }
    + * + * @param wordCount wordCount + * @return current instance of builder + */ + public NovellaRecordBuilder wordCount(long wordCount) { + this.wordCount = changedValue(wordCount); + return this; + } + + /** + * Sets the value for wordCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link NovellaRecord#NovellaRecord(String, String, long, LocalDate, boolean, String) NovellaRecord(String title, + * String authorName, long wordCount, LocalDate publicationDate, boolean available, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(() -> 42L);
    +   * }
    + * + * @param wordCountSupplier supplier for wordCount + * @return current instance of builder + */ + public NovellaRecordBuilder wordCount(Supplier wordCountSupplier) { + this.wordCount = changedValue(wordCountSupplier.get()); + 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 NovellaRecordBuilder 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 NovellaRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NovellaRecord result = builder.build();
    +   * }
    + */ + @Override + public NovellaRecord build() { + if (!this.wordCount.isSet()) { + throw new IllegalStateException("Required field 'wordCount' must be set before calling build()"); + } + if (this.wordCount.value() == null) { + throw new IllegalStateException("Field 'wordCount' is marked as non-null but null value was provided"); + } + if (!this.available.isSet()) { + throw new IllegalStateException("Required field 'available' must be set before calling build()"); + } + if (this.available.value() == null) { + throw new IllegalStateException("Field 'available' is marked as non-null but null value was provided"); + } + NovellaRecord result = new NovellaRecord(this.title.value(), + this.authorName.value(), + this.wordCount.value(), + this.publicationDate.value(), + this.available.value(), + this.language.valueOr("EN")); + 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("title", this.title) + .append("authorName", this.authorName) + .append("wordCount", this.wordCount) + .append("publicationDate", this.publicationDate) + .append("available", this.available) + .append("language", this.language) + .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 NovellaRecord with(Consumer b) { + NovellaRecordBuilder builder; + try { + builder = new NovellaRecordBuilder(NovellaRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NovellaRecordBuilder.With' should only be implemented by classes, which could be casted to 'NovellaRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NovellaRecordBuilder with() { + try { + return new NovellaRecordBuilder(NovellaRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NovellaRecordBuilder.With' should only be implemented by classes, which could be casted to 'NovellaRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/OctavoRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/OctavoRecordBuilder.java new file mode 100644 index 00000000..8335ce20 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/OctavoRecordBuilder.java @@ -0,0 +1,454 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.OctavoRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.OctavoRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * OctavoRecord result = OctavoRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .dimensions("example value")
    + *     .dimensions("Hello %s", "World")
    + *     .dimensions(() -> "example value")
    + *     .dimensions(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = OctavoRecord.class) +public class OctavoRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for dimensions: dimensions. + */ + private TrackedValue dimensions = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.OctavoRecord}. + */ + public OctavoRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.OctavoRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public OctavoRecordBuilder(OctavoRecord instance) { + this.title = initialValue(instance.title()); + this.pageCount = initialValue(instance.pageCount()); + this.dimensions = initialValue(instance.dimensions()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.OctavoRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * OctavoRecordBuilder builder = OctavoRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.OctavoRecord} + */ + public static OctavoRecordBuilder create() { + return new OctavoRecordBuilder(); + } + + /** + * Sets the value for dimensions. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("example value");
    +   * }
    + * + * @param dimensions dimensions + * @return current instance of builder + */ + public OctavoRecordBuilder dimensions(String dimensions) { + this.dimensions = changedValue(dimensions); + return this; + } + + /** + * Sets the value for dimensions by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(sb -> sb.append("text"));
    +   * }
    + * + * @param dimensionsStringBuilderConsumer consumer providing an instance of dimensions + * @return current instance of builder + */ + public OctavoRecordBuilder dimensions(Consumer dimensionsStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + dimensionsStringBuilderConsumer.accept(builder); + this.dimensions = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for dimensions by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(() -> "example value");
    +   * }
    + * + * @param dimensionsSupplier supplier for dimensions + * @return current instance of builder + */ + public OctavoRecordBuilder dimensions(Supplier dimensionsSupplier) { + this.dimensions = changedValue(dimensionsSupplier.get()); + return this; + } + + /** + * Sets the String value for dimensions by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OctavoRecordBuilder dimensions(String format, Object... args) { + this.dimensions = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public OctavoRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public OctavoRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public OctavoRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public OctavoRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public OctavoRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public OctavoRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public OctavoRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OctavoRecord#OctavoRecord(String, int, String, LocalDate) + * OctavoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OctavoRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 OctavoRecordBuilder 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 OctavoRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * OctavoRecord result = builder.build();
    +   * }
    + */ + @Override + public OctavoRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + OctavoRecord result = new OctavoRecord(this.title.value(), + this.pageCount.value(), + this.dimensions.value(), + this.publicationDate.value()); + 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("title", this.title) + .append("pageCount", this.pageCount) + .append("dimensions", this.dimensions) + .append("publicationDate", this.publicationDate) + .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 OctavoRecord with(Consumer b) { + OctavoRecordBuilder builder; + try { + builder = new OctavoRecordBuilder(OctavoRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OctavoRecordBuilder.With' should only be implemented by classes, which could be casted to 'OctavoRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default OctavoRecordBuilder with() { + try { + return new OctavoRecordBuilder(OctavoRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OctavoRecordBuilder.With' should only be implemented by classes, which could be casted to 'OctavoRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PamphletRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PamphletRecordBuilder.java new file mode 100644 index 00000000..6b0b8632 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PamphletRecordBuilder.java @@ -0,0 +1,454 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.PamphletRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PamphletRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PamphletRecord result = PamphletRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PamphletRecord.class) +public class PamphletRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PamphletRecord}. + */ + public PamphletRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PamphletRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PamphletRecordBuilder(PamphletRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.pageCount = initialValue(instance.pageCount()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PamphletRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PamphletRecordBuilder builder = PamphletRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PamphletRecord} + */ + public static PamphletRecordBuilder create() { + return new PamphletRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public PamphletRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public PamphletRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public PamphletRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PamphletRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public PamphletRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public PamphletRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public PamphletRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public PamphletRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public PamphletRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public PamphletRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public PamphletRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PamphletRecord#PamphletRecord(String, String, int, LocalDate) + * PamphletRecord(String title, String authorName, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PamphletRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 PamphletRecordBuilder 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 PamphletRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PamphletRecord result = builder.build();
    +   * }
    + */ + @Override + public PamphletRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + PamphletRecord result = new PamphletRecord(this.title.value(), + this.authorName.value(), + this.pageCount.value(), + this.publicationDate.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .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 PamphletRecord with(Consumer b) { + PamphletRecordBuilder builder; + try { + builder = new PamphletRecordBuilder(PamphletRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PamphletRecordBuilder.With' should only be implemented by classes, which could be casted to 'PamphletRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PamphletRecordBuilder with() { + try { + return new PamphletRecordBuilder(PamphletRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PamphletRecordBuilder.With' should only be implemented by classes, which could be casted to 'PamphletRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PeerReviewedJournalBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PeerReviewedJournalBuilder.java new file mode 100644 index 00000000..900e2230 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PeerReviewedJournalBuilder.java @@ -0,0 +1,948 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.items.PeerReviewedJournal}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PeerReviewedJournal 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. + * + *

    Example:

    + * + *
    {@code
    + * PeerReviewedJournal result = PeerReviewedJournalBuilder.create()
    + *     .articles(List.of("example value"))
    + *     .articles(() -> List.of("example value"))
    + *     .articles(t -> t.add("example value"))
    + *     .articles("example value", "example value")
    + *     .add2Articles("example value")
    + *     .catalogId(UUID.randomUUID())
    + *     .catalogId(() -> UUID.randomUUID())
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .field("example value")
    + *     .field("Hello %s", "World")
    + *     .field(() -> "example value")
    + *     .field(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .issue(42)
    + *     .issue(() -> 42)
    + *     .journalName("example value")
    + *     .journalName("Hello %s", "World")
    + *     .journalName(() -> "example value")
    + *     .journalName(sb -> sb.append("text"))
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .reviewerCount(42)
    + *     .reviewerCount(() -> 42)
    + *     .volume(42)
    + *     .volume(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PeerReviewedJournal.class) +public class PeerReviewedJournalBuilder implements IBuilderBase { + + /** + * Tracked value for articles: articles. + */ + private TrackedValue> articles = unsetValue(); + /** + * Tracked value for catalogId: catalogId. + */ + private TrackedValue catalogId = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for field: field. + */ + private TrackedValue field = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for issue: issue. + */ + private TrackedValue issue = unsetValue(); + /** + * Tracked value for journalName: journalName. + */ + private TrackedValue journalName = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for reviewerCount: reviewerCount. + */ + private TrackedValue reviewerCount = unsetValue(); + /** + * Tracked value for volume: volume. + */ + private TrackedValue volume = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PeerReviewedJournal}. + */ + public PeerReviewedJournalBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PeerReviewedJournal} by a instance. + * + * @param instance object instance for initialisiation + */ + public PeerReviewedJournalBuilder(PeerReviewedJournal instance) { + this.articles = initialValue(instance.getArticles()); + this.catalogId = initialValue(instance.getCatalogId()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.field = initialValue(instance.getField()); + this.id = initialValue(instance.getId()); + this.issue = initialValue(instance.getIssue()); + this.journalName = initialValue(instance.getJournalName()); + this.name = initialValue(instance.getName()); + this.pageCount = initialValue(instance.getPageCount()); + this.publicationDate = initialValue(instance.getPublicationDate()); + this.reviewerCount = initialValue(instance.getReviewerCount()); + this.volume = initialValue(instance.getVolume()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PeerReviewedJournal}. + * + *

    Example:

    + * + *
    {@code
    +   * PeerReviewedJournalBuilder builder = PeerReviewedJournalBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PeerReviewedJournal} + */ + public static PeerReviewedJournalBuilder create() { + return new PeerReviewedJournalBuilder(); + } + + /** + * Adds a single element to articles. + *

    + * Generated from setter {@link PeerReviewedJournal#setArticles(List) setArticles(List articles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Articles("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PeerReviewedJournalBuilder add2Articles(String element) { + List newCollection; + if (this.articles.isSet()) { + newCollection = new ArrayList<>(this.articles.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.articles = changedValue(newCollection); + return this; + } + + /** + * Sets the value for articles. + *

    + * Generated from setter {@link PeerReviewedJournal#setArticles(List) setArticles(List articles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.articles("example value", "example value");
    +   * }
    + * + * @param articles articles + * @return current instance of builder + */ + public PeerReviewedJournalBuilder articles(String... articles) { + this.articles = changedValue(List.of(articles)); + return this; + } + + /** + * Sets the value for articles. + *

    + * Generated from setter {@link PeerReviewedJournal#setArticles(List) setArticles(List articles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.articles(List.of("example value"));
    +   * }
    + * + * @param articles articles + * @return current instance of builder + */ + public PeerReviewedJournalBuilder articles(List articles) { + this.articles = changedValue(articles); + return this; + } + + /** + * Sets the value for articles using a builder consumer that produces the value. + *

    + * Generated from setter {@link PeerReviewedJournal#setArticles(List) setArticles(List articles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.articles(t -> t.add("example value"));
    +   * }
    + * + * @param articlesBuilderConsumer consumer providing an instance of a builder for articles + * @return current instance of builder + */ + public PeerReviewedJournalBuilder articles(Consumer> articlesBuilderConsumer) { + ArrayListBuilder builder = this.articles.isSet() + ? new ArrayListBuilder(this.articles.value()) + : new ArrayListBuilder(); + articlesBuilderConsumer.accept(builder); + this.articles = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for articles by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setArticles(List) setArticles(List articles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.articles(() -> List.of("example value"));
    +   * }
    + * + * @param articlesSupplier supplier for articles + * @return current instance of builder + */ + public PeerReviewedJournalBuilder articles(Supplier> articlesSupplier) { + this.articles = changedValue(articlesSupplier.get()); + return this; + } + + /** + * Sets the value for catalogId. + *

    + * Generated from setter {@link PeerReviewedJournal#setCatalogId(UUID) setCatalogId(UUID catalogId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogId(UUID.randomUUID());
    +   * }
    + * + * @param catalogId catalogId + * @return current instance of builder + */ + public PeerReviewedJournalBuilder catalogId(UUID catalogId) { + this.catalogId = changedValue(catalogId); + return this; + } + + /** + * Sets the value for catalogId by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setCatalogId(UUID) setCatalogId(UUID catalogId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogId(() -> UUID.randomUUID());
    +   * }
    + * + * @param catalogIdSupplier supplier for catalogId + * @return current instance of builder + */ + public PeerReviewedJournalBuilder catalogId(Supplier catalogIdSupplier) { + this.catalogId = changedValue(catalogIdSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PeerReviewedJournal#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PeerReviewedJournalBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PeerReviewedJournalBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for field. + *

    + * Generated from setter {@link PeerReviewedJournal#setField(String) setField(String field)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("example value");
    +   * }
    + * + * @param field field + * @return current instance of builder + */ + public PeerReviewedJournalBuilder field(String field) { + this.field = changedValue(field); + return this; + } + + /** + * Sets the value for field by executing the provided consumer. + *

    + * Generated from setter {@link PeerReviewedJournal#setField(String) setField(String field)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(sb -> sb.append("text"));
    +   * }
    + * + * @param fieldStringBuilderConsumer consumer providing an instance of field + * @return current instance of builder + */ + public PeerReviewedJournalBuilder field(Consumer fieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fieldStringBuilderConsumer.accept(builder); + this.field = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for field by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setField(String) setField(String field)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(() -> "example value");
    +   * }
    + * + * @param fieldSupplier supplier for field + * @return current instance of builder + */ + public PeerReviewedJournalBuilder field(Supplier fieldSupplier) { + this.field = changedValue(fieldSupplier.get()); + return this; + } + + /** + * Sets the String value for field by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PeerReviewedJournal#setField(String) setField(String field)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PeerReviewedJournalBuilder field(String format, Object... args) { + this.field = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PeerReviewedJournal#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PeerReviewedJournalBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PeerReviewedJournalBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for issue. + *

    + * Generated from setter {@link PeerReviewedJournal#setIssue(int) setIssue(int issue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issue(42);
    +   * }
    + * + * @param issue issue + * @return current instance of builder + */ + public PeerReviewedJournalBuilder issue(int issue) { + this.issue = changedValue(issue); + return this; + } + + /** + * Sets the value for issue by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setIssue(int) setIssue(int issue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issue(() -> 42);
    +   * }
    + * + * @param issueSupplier supplier for issue + * @return current instance of builder + */ + public PeerReviewedJournalBuilder issue(Supplier issueSupplier) { + this.issue = changedValue(issueSupplier.get()); + return this; + } + + /** + * Sets the value for journalName. + *

    + * Generated from setter {@link PeerReviewedJournal#setJournalName(String) setJournalName(String journalName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalName("example value");
    +   * }
    + * + * @param journalName journalName + * @return current instance of builder + */ + public PeerReviewedJournalBuilder journalName(String journalName) { + this.journalName = changedValue(journalName); + return this; + } + + /** + * Sets the value for journalName by executing the provided consumer. + *

    + * Generated from setter {@link PeerReviewedJournal#setJournalName(String) setJournalName(String journalName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalName(sb -> sb.append("text"));
    +   * }
    + * + * @param journalNameStringBuilderConsumer consumer providing an instance of journalName + * @return current instance of builder + */ + public PeerReviewedJournalBuilder journalName(Consumer journalNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + journalNameStringBuilderConsumer.accept(builder); + this.journalName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for journalName by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setJournalName(String) setJournalName(String journalName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalName(() -> "example value");
    +   * }
    + * + * @param journalNameSupplier supplier for journalName + * @return current instance of builder + */ + public PeerReviewedJournalBuilder journalName(Supplier journalNameSupplier) { + this.journalName = changedValue(journalNameSupplier.get()); + return this; + } + + /** + * Sets the String value for journalName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PeerReviewedJournal#setJournalName(String) setJournalName(String journalName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PeerReviewedJournalBuilder journalName(String format, Object... args) { + this.journalName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PeerReviewedJournal#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PeerReviewedJournalBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PeerReviewedJournal#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PeerReviewedJournalBuilder 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. + *

    + * Generated from setter {@link PeerReviewedJournal#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PeerReviewedJournalBuilder 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. + *

    + * Generated from setter {@link PeerReviewedJournal#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PeerReviewedJournalBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from setter {@link PeerReviewedJournal#setPageCount(int) setPageCount(int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public PeerReviewedJournalBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setPageCount(int) setPageCount(int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public PeerReviewedJournalBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from setter {@link PeerReviewedJournal#setPublicationDate(LocalDate) setPublicationDate(LocalDate + * publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public PeerReviewedJournalBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setPublicationDate(LocalDate) setPublicationDate(LocalDate + * publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public PeerReviewedJournalBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for reviewerCount. + *

    + * Generated from setter {@link PeerReviewedJournal#setReviewerCount(int) setReviewerCount(int reviewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerCount(42);
    +   * }
    + * + * @param reviewerCount reviewerCount + * @return current instance of builder + */ + public PeerReviewedJournalBuilder reviewerCount(int reviewerCount) { + this.reviewerCount = changedValue(reviewerCount); + return this; + } + + /** + * Sets the value for reviewerCount by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setReviewerCount(int) setReviewerCount(int reviewerCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerCount(() -> 42);
    +   * }
    + * + * @param reviewerCountSupplier supplier for reviewerCount + * @return current instance of builder + */ + public PeerReviewedJournalBuilder reviewerCount(Supplier reviewerCountSupplier) { + this.reviewerCount = changedValue(reviewerCountSupplier.get()); + return this; + } + + /** + * Sets the value for volume. + *

    + * Generated from setter {@link PeerReviewedJournal#setVolume(int) setVolume(int volume)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volume(42);
    +   * }
    + * + * @param volume volume + * @return current instance of builder + */ + public PeerReviewedJournalBuilder volume(int volume) { + this.volume = changedValue(volume); + return this; + } + + /** + * Sets the value for volume by invoking the provided supplier. + *

    + * Generated from setter {@link PeerReviewedJournal#setVolume(int) setVolume(int volume)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volume(() -> 42);
    +   * }
    + * + * @param volumeSupplier supplier for volume + * @return current instance of builder + */ + public PeerReviewedJournalBuilder volume(Supplier volumeSupplier) { + this.volume = changedValue(volumeSupplier.get()); + 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 PeerReviewedJournalBuilder 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 PeerReviewedJournalBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PeerReviewedJournal result = builder.build();
    +   * }
    + */ + @Override + public PeerReviewedJournal build() { + if (this.issue.isSet() && this.issue.value() == null) { + throw new IllegalStateException("Field 'issue' is marked as non-null but null value was provided"); + } + if (this.pageCount.isSet() && this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + if (this.reviewerCount.isSet() && this.reviewerCount.value() == null) { + throw new IllegalStateException("Field 'reviewerCount' is marked as non-null but null value was provided"); + } + if (this.volume.isSet() && this.volume.value() == null) { + throw new IllegalStateException("Field 'volume' is marked as non-null but null value was provided"); + } + PeerReviewedJournal result = new PeerReviewedJournal(); + this.articles.ifSet(result::setArticles); + this.catalogId.ifSet(result::setCatalogId); + this.createdAt.ifSet(result::setCreatedAt); + this.field.ifSet(result::setField); + this.id.ifSet(result::setId); + this.issue.ifSet(result::setIssue); + this.journalName.ifSet(result::setJournalName); + this.name.ifSet(result::setName); + this.pageCount.ifSet(result::setPageCount); + this.publicationDate.ifSet(result::setPublicationDate); + this.reviewerCount.ifSet(result::setReviewerCount); + this.volume.ifSet(result::setVolume); + 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("articles", this.articles) + .append("catalogId", this.catalogId) + .append("createdAt", this.createdAt) + .append("field", this.field) + .append("id", this.id) + .append("issue", this.issue) + .append("journalName", this.journalName) + .append("name", this.name) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .append("reviewerCount", this.reviewerCount) + .append("volume", this.volume) + .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 PeerReviewedJournal with(Consumer b) { + PeerReviewedJournalBuilder builder; + try { + builder = new PeerReviewedJournalBuilder(PeerReviewedJournal.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PeerReviewedJournalBuilder.With' should only be implemented by classes, which could be casted to 'PeerReviewedJournal'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PeerReviewedJournalBuilder with() { + try { + return new PeerReviewedJournalBuilder(PeerReviewedJournal.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PeerReviewedJournalBuilder.With' should only be implemented by classes, which could be casted to 'PeerReviewedJournal'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PhotographRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PhotographRecordBuilder.java new file mode 100644 index 00000000..c068c4ef --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PhotographRecordBuilder.java @@ -0,0 +1,495 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.PhotographRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PhotographRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PhotographRecord result = PhotographRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .photographer("example value")
    + *     .photographer("Hello %s", "World")
    + *     .photographer(() -> "example value")
    + *     .photographer(sb -> sb.append("text"))
    + *     .captureDate(LocalDate.now())
    + *     .captureDate(() -> LocalDate.now())
    + *     .dimensions("example value")
    + *     .dimensions("Hello %s", "World")
    + *     .dimensions(() -> "example value")
    + *     .dimensions(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PhotographRecord.class) +public class PhotographRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for photographer: photographer. + */ + private TrackedValue photographer = unsetValue(); + /** + * Tracked value for captureDate: captureDate. + */ + private TrackedValue captureDate = unsetValue(); + /** + * Tracked value for dimensions: dimensions. + */ + private TrackedValue dimensions = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PhotographRecord}. + */ + public PhotographRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PhotographRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PhotographRecordBuilder(PhotographRecord instance) { + this.subject = initialValue(instance.subject()); + this.photographer = initialValue(instance.photographer()); + this.captureDate = initialValue(instance.captureDate()); + this.dimensions = initialValue(instance.dimensions()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PhotographRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PhotographRecordBuilder builder = PhotographRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PhotographRecord} + */ + public static PhotographRecordBuilder create() { + return new PhotographRecordBuilder(); + } + + /** + * Sets the value for captureDate. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.captureDate(LocalDate.now());
    +   * }
    + * + * @param captureDate captureDate + * @return current instance of builder + */ + public PhotographRecordBuilder captureDate(LocalDate captureDate) { + this.captureDate = changedValue(captureDate); + return this; + } + + /** + * Sets the value for captureDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.captureDate(() -> LocalDate.now());
    +   * }
    + * + * @param captureDateSupplier supplier for captureDate + * @return current instance of builder + */ + public PhotographRecordBuilder captureDate(Supplier captureDateSupplier) { + this.captureDate = changedValue(captureDateSupplier.get()); + return this; + } + + /** + * Sets the value for dimensions. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("example value");
    +   * }
    + * + * @param dimensions dimensions + * @return current instance of builder + */ + public PhotographRecordBuilder dimensions(String dimensions) { + this.dimensions = changedValue(dimensions); + return this; + } + + /** + * Sets the value for dimensions by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(sb -> sb.append("text"));
    +   * }
    + * + * @param dimensionsStringBuilderConsumer consumer providing an instance of dimensions + * @return current instance of builder + */ + public PhotographRecordBuilder dimensions(Consumer dimensionsStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + dimensionsStringBuilderConsumer.accept(builder); + this.dimensions = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for dimensions by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(() -> "example value");
    +   * }
    + * + * @param dimensionsSupplier supplier for dimensions + * @return current instance of builder + */ + public PhotographRecordBuilder dimensions(Supplier dimensionsSupplier) { + this.dimensions = changedValue(dimensionsSupplier.get()); + return this; + } + + /** + * Sets the String value for dimensions by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PhotographRecordBuilder dimensions(String format, Object... args) { + this.dimensions = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for photographer. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer("example value");
    +   * }
    + * + * @param photographer photographer + * @return current instance of builder + */ + public PhotographRecordBuilder photographer(String photographer) { + this.photographer = changedValue(photographer); + return this; + } + + /** + * Sets the value for photographer by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer(sb -> sb.append("text"));
    +   * }
    + * + * @param photographerStringBuilderConsumer consumer providing an instance of photographer + * @return current instance of builder + */ + public PhotographRecordBuilder photographer(Consumer photographerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + photographerStringBuilderConsumer.accept(builder); + this.photographer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for photographer by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer(() -> "example value");
    +   * }
    + * + * @param photographerSupplier supplier for photographer + * @return current instance of builder + */ + public PhotographRecordBuilder photographer(Supplier photographerSupplier) { + this.photographer = changedValue(photographerSupplier.get()); + return this; + } + + /** + * Sets the String value for photographer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PhotographRecordBuilder photographer(String format, Object... args) { + this.photographer = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public PhotographRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public PhotographRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public PhotographRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PhotographRecord#PhotographRecord(String, String, LocalDate, String) + * PhotographRecord(String subject, String photographer, LocalDate captureDate, String dimensions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PhotographRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 PhotographRecordBuilder 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 PhotographRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PhotographRecord result = builder.build();
    +   * }
    + */ + @Override + public PhotographRecord build() { + PhotographRecord result = new PhotographRecord(this.subject.value(), + this.photographer.value(), + this.captureDate.value(), + this.dimensions.value()); + 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("subject", this.subject) + .append("photographer", this.photographer) + .append("captureDate", this.captureDate) + .append("dimensions", this.dimensions) + .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 PhotographRecord with(Consumer b) { + PhotographRecordBuilder builder; + try { + builder = new PhotographRecordBuilder(PhotographRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PhotographRecordBuilder.With' should only be implemented by classes, which could be casted to 'PhotographRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PhotographRecordBuilder with() { + try { + return new PhotographRecordBuilder(PhotographRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PhotographRecordBuilder.With' should only be implemented by classes, which could be casted to 'PhotographRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PoetryRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PoetryRecordBuilder.java new file mode 100644 index 00000000..11ea514c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PoetryRecordBuilder.java @@ -0,0 +1,716 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.items.PoetryRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PoetryRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PoetryRecord result = PoetryRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .poetName("example value")
    + *     .poetName("Hello %s", "World")
    + *     .poetName(() -> "example value")
    + *     .poetName(sb -> sb.append("text"))
    + *     .poemCount(42)
    + *     .poemCount(() -> 42)
    + *     .form("example value")
    + *     .form("Hello %s", "World")
    + *     .form(() -> "example value")
    + *     .form(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .isbn(UUID.randomUUID())
    + *     .isbn(() -> UUID.randomUUID())
    + *     .language("example value")
    + *     .language("Hello %s", "World")
    + *     .language(() -> "example value")
    + *     .language(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PoetryRecord.class) +public class PoetryRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for poetName: poetName. + */ + private TrackedValue poetName = unsetValue(); + /** + * Tracked value for poemCount: poemCount. + */ + private TrackedValue poemCount = unsetValue(); + /** + * Tracked value for form: form. + */ + private TrackedValue form = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for isbn: isbn. + */ + private TrackedValue isbn = unsetValue(); + /** + * Tracked value for language: language. + */ + private TrackedValue language = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PoetryRecord}. + */ + public PoetryRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PoetryRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PoetryRecordBuilder(PoetryRecord instance) { + this.title = initialValue(instance.title()); + this.poetName = initialValue(instance.poetName()); + this.poemCount = initialValue(instance.poemCount()); + this.form = initialValue(instance.form()); + this.publicationDate = initialValue(instance.publicationDate()); + this.isbn = initialValue(instance.isbn()); + this.language = initialValue(instance.language()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PoetryRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PoetryRecordBuilder builder = PoetryRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PoetryRecord} + */ + public static PoetryRecordBuilder create() { + return new PoetryRecordBuilder(); + } + + /** + * Sets the value for form. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.form("example value");
    +   * }
    + * + * @param form form + * @return current instance of builder + */ + public PoetryRecordBuilder form(String form) { + this.form = changedValue(form); + return this; + } + + /** + * Sets the value for form by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.form(sb -> sb.append("text"));
    +   * }
    + * + * @param formStringBuilderConsumer consumer providing an instance of form + * @return current instance of builder + */ + public PoetryRecordBuilder form(Consumer formStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + formStringBuilderConsumer.accept(builder); + this.form = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for form by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.form(() -> "example value");
    +   * }
    + * + * @param formSupplier supplier for form + * @return current instance of builder + */ + public PoetryRecordBuilder form(Supplier formSupplier) { + this.form = changedValue(formSupplier.get()); + return this; + } + + /** + * Sets the String value for form by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.form("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PoetryRecordBuilder form(String format, Object... args) { + this.form = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for isbn. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isbn(UUID.randomUUID());
    +   * }
    + * + * @param isbn isbn + * @return current instance of builder + */ + public PoetryRecordBuilder isbn(UUID isbn) { + this.isbn = changedValue(isbn); + return this; + } + + /** + * Sets the value for isbn by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isbn(() -> UUID.randomUUID());
    +   * }
    + * + * @param isbnSupplier supplier for isbn + * @return current instance of builder + */ + public PoetryRecordBuilder isbn(Supplier isbnSupplier) { + this.isbn = changedValue(isbnSupplier.get()); + return this; + } + + /** + * Sets the value for language. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language("example value");
    +   * }
    + * + * @param language language + * @return current instance of builder + */ + public PoetryRecordBuilder language(String language) { + this.language = changedValue(language); + return this; + } + + /** + * Sets the value for language by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language(sb -> sb.append("text"));
    +   * }
    + * + * @param languageStringBuilderConsumer consumer providing an instance of language + * @return current instance of builder + */ + public PoetryRecordBuilder language(Consumer languageStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + languageStringBuilderConsumer.accept(builder); + this.language = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for language by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language(() -> "example value");
    +   * }
    + * + * @param languageSupplier supplier for language + * @return current instance of builder + */ + public PoetryRecordBuilder language(Supplier languageSupplier) { + this.language = changedValue(languageSupplier.get()); + return this; + } + + /** + * Sets the String value for language by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.language("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PoetryRecordBuilder language(String format, Object... args) { + this.language = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for poemCount. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poemCount(42);
    +   * }
    + * + * @param poemCount poemCount + * @return current instance of builder + */ + public PoetryRecordBuilder poemCount(int poemCount) { + this.poemCount = changedValue(poemCount); + return this; + } + + /** + * Sets the value for poemCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poemCount(() -> 42);
    +   * }
    + * + * @param poemCountSupplier supplier for poemCount + * @return current instance of builder + */ + public PoetryRecordBuilder poemCount(Supplier poemCountSupplier) { + this.poemCount = changedValue(poemCountSupplier.get()); + return this; + } + + /** + * Sets the value for poetName. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poetName("example value");
    +   * }
    + * + * @param poetName poetName + * @return current instance of builder + */ + public PoetryRecordBuilder poetName(String poetName) { + this.poetName = changedValue(poetName); + return this; + } + + /** + * Sets the value for poetName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poetName(sb -> sb.append("text"));
    +   * }
    + * + * @param poetNameStringBuilderConsumer consumer providing an instance of poetName + * @return current instance of builder + */ + public PoetryRecordBuilder poetName(Consumer poetNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + poetNameStringBuilderConsumer.accept(builder); + this.poetName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for poetName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poetName(() -> "example value");
    +   * }
    + * + * @param poetNameSupplier supplier for poetName + * @return current instance of builder + */ + public PoetryRecordBuilder poetName(Supplier poetNameSupplier) { + this.poetName = changedValue(poetNameSupplier.get()); + return this; + } + + /** + * Sets the String value for poetName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poetName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PoetryRecordBuilder poetName(String format, Object... args) { + this.poetName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public PoetryRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public PoetryRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public PoetryRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public PoetryRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public PoetryRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PoetryRecord#PoetryRecord(String, String, int, String, LocalDate, UUID, String) PoetryRecord(String title, + * String poetName, int poemCount, String form, LocalDate publicationDate, UUID isbn, String language)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PoetryRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 PoetryRecordBuilder 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 PoetryRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PoetryRecord result = builder.build();
    +   * }
    + */ + @Override + public PoetryRecord build() { + if (!this.poemCount.isSet()) { + throw new IllegalStateException("Required field 'poemCount' must be set before calling build()"); + } + if (this.poemCount.value() == null) { + throw new IllegalStateException("Field 'poemCount' is marked as non-null but null value was provided"); + } + PoetryRecord result = new PoetryRecord(this.title.value(), + this.poetName.value(), + this.poemCount.value(), + this.form.value(), + this.publicationDate.value(), + this.isbn.value(), + this.language.valueOr("EN")); + 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("title", this.title) + .append("poetName", this.poetName) + .append("poemCount", this.poemCount) + .append("form", this.form) + .append("publicationDate", this.publicationDate) + .append("isbn", this.isbn) + .append("language", this.language) + .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 PoetryRecord with(Consumer b) { + PoetryRecordBuilder builder; + try { + builder = new PoetryRecordBuilder(PoetryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PoetryRecordBuilder.With' should only be implemented by classes, which could be casted to 'PoetryRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PoetryRecordBuilder with() { + try { + return new PoetryRecordBuilder(PoetryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PoetryRecordBuilder.With' should only be implemented by classes, which could be casted to 'PoetryRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PostcardRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PostcardRecordBuilder.java new file mode 100644 index 00000000..c5392b6d --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PostcardRecordBuilder.java @@ -0,0 +1,494 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.PostcardRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PostcardRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PostcardRecord result = PostcardRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .sender("example value")
    + *     .sender("Hello %s", "World")
    + *     .sender(() -> "example value")
    + *     .sender(sb -> sb.append("text"))
    + *     .recipient("example value")
    + *     .recipient("Hello %s", "World")
    + *     .recipient(() -> "example value")
    + *     .recipient(sb -> sb.append("text"))
    + *     .postmarkDate(LocalDate.now())
    + *     .postmarkDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PostcardRecord.class) +public class PostcardRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for sender: sender. + */ + private TrackedValue sender = unsetValue(); + /** + * Tracked value for recipient: recipient. + */ + private TrackedValue recipient = unsetValue(); + /** + * Tracked value for postmarkDate: postmarkDate. + */ + private TrackedValue postmarkDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PostcardRecord}. + */ + public PostcardRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PostcardRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PostcardRecordBuilder(PostcardRecord instance) { + this.subject = initialValue(instance.subject()); + this.sender = initialValue(instance.sender()); + this.recipient = initialValue(instance.recipient()); + this.postmarkDate = initialValue(instance.postmarkDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PostcardRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PostcardRecordBuilder builder = PostcardRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PostcardRecord} + */ + public static PostcardRecordBuilder create() { + return new PostcardRecordBuilder(); + } + + /** + * Sets the value for postmarkDate. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.postmarkDate(LocalDate.now());
    +   * }
    + * + * @param postmarkDate postmarkDate + * @return current instance of builder + */ + public PostcardRecordBuilder postmarkDate(LocalDate postmarkDate) { + this.postmarkDate = changedValue(postmarkDate); + return this; + } + + /** + * Sets the value for postmarkDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.postmarkDate(() -> LocalDate.now());
    +   * }
    + * + * @param postmarkDateSupplier supplier for postmarkDate + * @return current instance of builder + */ + public PostcardRecordBuilder postmarkDate(Supplier postmarkDateSupplier) { + this.postmarkDate = changedValue(postmarkDateSupplier.get()); + return this; + } + + /** + * Sets the value for recipient. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient("example value");
    +   * }
    + * + * @param recipient recipient + * @return current instance of builder + */ + public PostcardRecordBuilder recipient(String recipient) { + this.recipient = changedValue(recipient); + return this; + } + + /** + * Sets the value for recipient by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient(sb -> sb.append("text"));
    +   * }
    + * + * @param recipientStringBuilderConsumer consumer providing an instance of recipient + * @return current instance of builder + */ + public PostcardRecordBuilder recipient(Consumer recipientStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + recipientStringBuilderConsumer.accept(builder); + this.recipient = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for recipient by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient(() -> "example value");
    +   * }
    + * + * @param recipientSupplier supplier for recipient + * @return current instance of builder + */ + public PostcardRecordBuilder recipient(Supplier recipientSupplier) { + this.recipient = changedValue(recipientSupplier.get()); + return this; + } + + /** + * Sets the String value for recipient by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PostcardRecordBuilder recipient(String format, Object... args) { + this.recipient = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sender. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender("example value");
    +   * }
    + * + * @param sender sender + * @return current instance of builder + */ + public PostcardRecordBuilder sender(String sender) { + this.sender = changedValue(sender); + return this; + } + + /** + * Sets the value for sender by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender(sb -> sb.append("text"));
    +   * }
    + * + * @param senderStringBuilderConsumer consumer providing an instance of sender + * @return current instance of builder + */ + public PostcardRecordBuilder sender(Consumer senderStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + senderStringBuilderConsumer.accept(builder); + this.sender = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sender by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender(() -> "example value");
    +   * }
    + * + * @param senderSupplier supplier for sender + * @return current instance of builder + */ + public PostcardRecordBuilder sender(Supplier senderSupplier) { + this.sender = changedValue(senderSupplier.get()); + return this; + } + + /** + * Sets the String value for sender by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PostcardRecordBuilder sender(String format, Object... args) { + this.sender = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public PostcardRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public PostcardRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public PostcardRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PostcardRecord#PostcardRecord(String, String, String, LocalDate) + * PostcardRecord(String subject, String sender, String recipient, LocalDate postmarkDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PostcardRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 PostcardRecordBuilder 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 PostcardRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PostcardRecord result = builder.build();
    +   * }
    + */ + @Override + public PostcardRecord build() { + PostcardRecord result = new PostcardRecord(this.subject.value(), + this.sender.value(), + this.recipient.value(), + this.postmarkDate.value()); + 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("subject", this.subject) + .append("sender", this.sender) + .append("recipient", this.recipient) + .append("postmarkDate", this.postmarkDate) + .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 PostcardRecord with(Consumer b) { + PostcardRecordBuilder builder; + try { + builder = new PostcardRecordBuilder(PostcardRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PostcardRecordBuilder.With' should only be implemented by classes, which could be casted to 'PostcardRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PostcardRecordBuilder with() { + try { + return new PostcardRecordBuilder(PostcardRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PostcardRecordBuilder.With' should only be implemented by classes, which could be casted to 'PostcardRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PosterRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PosterRecordBuilder.java new file mode 100644 index 00000000..c976533e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PosterRecordBuilder.java @@ -0,0 +1,494 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.PosterRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PosterRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PosterRecord result = PosterRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .creator("example value")
    + *     .creator("Hello %s", "World")
    + *     .creator(() -> "example value")
    + *     .creator(sb -> sb.append("text"))
    + *     .dimensions("example value")
    + *     .dimensions("Hello %s", "World")
    + *     .dimensions(() -> "example value")
    + *     .dimensions(sb -> sb.append("text"))
    + *     .productionDate(LocalDate.now())
    + *     .productionDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PosterRecord.class) +public class PosterRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for creator: creator. + */ + private TrackedValue creator = unsetValue(); + /** + * Tracked value for dimensions: dimensions. + */ + private TrackedValue dimensions = unsetValue(); + /** + * Tracked value for productionDate: productionDate. + */ + private TrackedValue productionDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PosterRecord}. + */ + public PosterRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PosterRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PosterRecordBuilder(PosterRecord instance) { + this.title = initialValue(instance.title()); + this.creator = initialValue(instance.creator()); + this.dimensions = initialValue(instance.dimensions()); + this.productionDate = initialValue(instance.productionDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PosterRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PosterRecordBuilder builder = PosterRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PosterRecord} + */ + public static PosterRecordBuilder create() { + return new PosterRecordBuilder(); + } + + /** + * Sets the value for creator. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator("example value");
    +   * }
    + * + * @param creator creator + * @return current instance of builder + */ + public PosterRecordBuilder creator(String creator) { + this.creator = changedValue(creator); + return this; + } + + /** + * Sets the value for creator by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator(sb -> sb.append("text"));
    +   * }
    + * + * @param creatorStringBuilderConsumer consumer providing an instance of creator + * @return current instance of builder + */ + public PosterRecordBuilder creator(Consumer creatorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + creatorStringBuilderConsumer.accept(builder); + this.creator = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for creator by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator(() -> "example value");
    +   * }
    + * + * @param creatorSupplier supplier for creator + * @return current instance of builder + */ + public PosterRecordBuilder creator(Supplier creatorSupplier) { + this.creator = changedValue(creatorSupplier.get()); + return this; + } + + /** + * Sets the String value for creator by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PosterRecordBuilder creator(String format, Object... args) { + this.creator = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for dimensions. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("example value");
    +   * }
    + * + * @param dimensions dimensions + * @return current instance of builder + */ + public PosterRecordBuilder dimensions(String dimensions) { + this.dimensions = changedValue(dimensions); + return this; + } + + /** + * Sets the value for dimensions by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(sb -> sb.append("text"));
    +   * }
    + * + * @param dimensionsStringBuilderConsumer consumer providing an instance of dimensions + * @return current instance of builder + */ + public PosterRecordBuilder dimensions(Consumer dimensionsStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + dimensionsStringBuilderConsumer.accept(builder); + this.dimensions = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for dimensions by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(() -> "example value");
    +   * }
    + * + * @param dimensionsSupplier supplier for dimensions + * @return current instance of builder + */ + public PosterRecordBuilder dimensions(Supplier dimensionsSupplier) { + this.dimensions = changedValue(dimensionsSupplier.get()); + return this; + } + + /** + * Sets the String value for dimensions by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PosterRecordBuilder dimensions(String format, Object... args) { + this.dimensions = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for productionDate. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionDate(LocalDate.now());
    +   * }
    + * + * @param productionDate productionDate + * @return current instance of builder + */ + public PosterRecordBuilder productionDate(LocalDate productionDate) { + this.productionDate = changedValue(productionDate); + return this; + } + + /** + * Sets the value for productionDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionDate(() -> LocalDate.now());
    +   * }
    + * + * @param productionDateSupplier supplier for productionDate + * @return current instance of builder + */ + public PosterRecordBuilder productionDate(Supplier productionDateSupplier) { + this.productionDate = changedValue(productionDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public PosterRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public PosterRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public PosterRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PosterRecord#PosterRecord(String, String, String, LocalDate) + * PosterRecord(String title, String creator, String dimensions, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PosterRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 PosterRecordBuilder 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 PosterRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PosterRecord result = builder.build();
    +   * }
    + */ + @Override + public PosterRecord build() { + PosterRecord result = new PosterRecord(this.title.value(), + this.creator.value(), + this.dimensions.value(), + this.productionDate.value()); + 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("title", this.title) + .append("creator", this.creator) + .append("dimensions", this.dimensions) + .append("productionDate", this.productionDate) + .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 PosterRecord with(Consumer b) { + PosterRecordBuilder builder; + try { + builder = new PosterRecordBuilder(PosterRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PosterRecordBuilder.With' should only be implemented by classes, which could be casted to 'PosterRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PosterRecordBuilder with() { + try { + return new PosterRecordBuilder(PosterRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PosterRecordBuilder.With' should only be implemented by classes, which could be casted to 'PosterRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PressReleaseRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PressReleaseRecordBuilder.java new file mode 100644 index 00000000..b48b66b6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/PressReleaseRecordBuilder.java @@ -0,0 +1,468 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.PressReleaseRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.PressReleaseRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PressReleaseRecord result = PressReleaseRecordBuilder.create()
    + *     .headline("example value")
    + *     .headline("Hello %s", "World")
    + *     .headline(() -> "example value")
    + *     .headline(sb -> sb.append("text"))
    + *     .organization("example value")
    + *     .organization("Hello %s", "World")
    + *     .organization(() -> "example value")
    + *     .organization(sb -> sb.append("text"))
    + *     .releaseDate(LocalDate.now())
    + *     .releaseDate(() -> LocalDate.now())
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PressReleaseRecord.class) +public class PressReleaseRecordBuilder implements IBuilderBase { + + /** + * Tracked value for headline: headline. + */ + private TrackedValue headline = unsetValue(); + /** + * Tracked value for organization: organization. + */ + private TrackedValue organization = unsetValue(); + /** + * Tracked value for releaseDate: releaseDate. + */ + private TrackedValue releaseDate = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PressReleaseRecord}. + */ + public PressReleaseRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PressReleaseRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PressReleaseRecordBuilder(PressReleaseRecord instance) { + this.headline = initialValue(instance.headline()); + this.organization = initialValue(instance.organization()); + this.releaseDate = initialValue(instance.releaseDate()); + this.pageCount = initialValue(instance.pageCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.PressReleaseRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PressReleaseRecordBuilder builder = PressReleaseRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.PressReleaseRecord} + */ + public static PressReleaseRecordBuilder create() { + return new PressReleaseRecordBuilder(); + } + + /** + * Sets the value for headline. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headline("example value");
    +   * }
    + * + * @param headline headline + * @return current instance of builder + */ + public PressReleaseRecordBuilder headline(String headline) { + this.headline = changedValue(headline); + return this; + } + + /** + * Sets the value for headline by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headline(sb -> sb.append("text"));
    +   * }
    + * + * @param headlineStringBuilderConsumer consumer providing an instance of headline + * @return current instance of builder + */ + public PressReleaseRecordBuilder headline(Consumer headlineStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + headlineStringBuilderConsumer.accept(builder); + this.headline = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for headline by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headline(() -> "example value");
    +   * }
    + * + * @param headlineSupplier supplier for headline + * @return current instance of builder + */ + public PressReleaseRecordBuilder headline(Supplier headlineSupplier) { + this.headline = changedValue(headlineSupplier.get()); + return this; + } + + /** + * Sets the String value for headline by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headline("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PressReleaseRecordBuilder headline(String format, Object... args) { + this.headline = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for organization. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("example value");
    +   * }
    + * + * @param organization organization + * @return current instance of builder + */ + public PressReleaseRecordBuilder organization(String organization) { + this.organization = changedValue(organization); + return this; + } + + /** + * Sets the value for organization by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(sb -> sb.append("text"));
    +   * }
    + * + * @param organizationStringBuilderConsumer consumer providing an instance of organization + * @return current instance of builder + */ + public PressReleaseRecordBuilder organization(Consumer organizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizationStringBuilderConsumer.accept(builder); + this.organization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organization by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(() -> "example value");
    +   * }
    + * + * @param organizationSupplier supplier for organization + * @return current instance of builder + */ + public PressReleaseRecordBuilder organization(Supplier organizationSupplier) { + this.organization = changedValue(organizationSupplier.get()); + return this; + } + + /** + * Sets the String value for organization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PressReleaseRecordBuilder organization(String format, Object... args) { + this.organization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public PressReleaseRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public PressReleaseRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for releaseDate. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseDate(LocalDate.now());
    +   * }
    + * + * @param releaseDate releaseDate + * @return current instance of builder + */ + public PressReleaseRecordBuilder releaseDate(LocalDate releaseDate) { + this.releaseDate = changedValue(releaseDate); + return this; + } + + /** + * Sets the value for releaseDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PressReleaseRecord#PressReleaseRecord(String, String, LocalDate, int) PressReleaseRecord(String headline, + * String organization, LocalDate releaseDate, int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.releaseDate(() -> LocalDate.now());
    +   * }
    + * + * @param releaseDateSupplier supplier for releaseDate + * @return current instance of builder + */ + public PressReleaseRecordBuilder releaseDate(Supplier releaseDateSupplier) { + this.releaseDate = changedValue(releaseDateSupplier.get()); + 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 PressReleaseRecordBuilder 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 PressReleaseRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PressReleaseRecord result = builder.build();
    +   * }
    + */ + @Override + public PressReleaseRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + PressReleaseRecord result = new PressReleaseRecord(this.headline.value(), + this.organization.value(), + this.releaseDate.value(), + this.pageCount.value()); + 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("headline", this.headline) + .append("organization", this.organization) + .append("releaseDate", this.releaseDate) + .append("pageCount", this.pageCount) + .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 PressReleaseRecord with(Consumer b) { + PressReleaseRecordBuilder builder; + try { + builder = new PressReleaseRecordBuilder(PressReleaseRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PressReleaseRecordBuilder.With' should only be implemented by classes, which could be casted to 'PressReleaseRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PressReleaseRecordBuilder with() { + try { + return new PressReleaseRecordBuilder(PressReleaseRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PressReleaseRecordBuilder.With' should only be implemented by classes, which could be casted to 'PressReleaseRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ProceedingsRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ProceedingsRecordBuilder.java new file mode 100644 index 00000000..122ea73a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ProceedingsRecordBuilder.java @@ -0,0 +1,525 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.ProceedingsRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.ProceedingsRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ProceedingsRecord result = ProceedingsRecordBuilder.create()
    + *     .conferenceName("example value")
    + *     .conferenceName("Hello %s", "World")
    + *     .conferenceName(() -> "example value")
    + *     .conferenceName(sb -> sb.append("text"))
    + *     .editorName("example value")
    + *     .editorName("Hello %s", "World")
    + *     .editorName(() -> "example value")
    + *     .editorName(sb -> sb.append("text"))
    + *     .paperCount(42)
    + *     .paperCount(() -> 42)
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ProceedingsRecord.class) +public class ProceedingsRecordBuilder implements IBuilderBase { + + /** + * Tracked value for conferenceName: conferenceName. + */ + private TrackedValue conferenceName = unsetValue(); + /** + * Tracked value for editorName: editorName. + */ + private TrackedValue editorName = unsetValue(); + /** + * Tracked value for paperCount: paperCount. + */ + private TrackedValue paperCount = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ProceedingsRecord}. + */ + public ProceedingsRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ProceedingsRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ProceedingsRecordBuilder(ProceedingsRecord instance) { + this.conferenceName = initialValue(instance.conferenceName()); + this.editorName = initialValue(instance.editorName()); + this.paperCount = initialValue(instance.paperCount()); + this.pageCount = initialValue(instance.pageCount()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ProceedingsRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ProceedingsRecordBuilder builder = ProceedingsRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ProceedingsRecord} + */ + public static ProceedingsRecordBuilder create() { + return new ProceedingsRecordBuilder(); + } + + /** + * Sets the value for conferenceName. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.conferenceName("example value");
    +   * }
    + * + * @param conferenceName conferenceName + * @return current instance of builder + */ + public ProceedingsRecordBuilder conferenceName(String conferenceName) { + this.conferenceName = changedValue(conferenceName); + return this; + } + + /** + * Sets the value for conferenceName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.conferenceName(sb -> sb.append("text"));
    +   * }
    + * + * @param conferenceNameStringBuilderConsumer consumer providing an instance of conferenceName + * @return current instance of builder + */ + public ProceedingsRecordBuilder conferenceName(Consumer conferenceNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + conferenceNameStringBuilderConsumer.accept(builder); + this.conferenceName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for conferenceName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.conferenceName(() -> "example value");
    +   * }
    + * + * @param conferenceNameSupplier supplier for conferenceName + * @return current instance of builder + */ + public ProceedingsRecordBuilder conferenceName(Supplier conferenceNameSupplier) { + this.conferenceName = changedValue(conferenceNameSupplier.get()); + return this; + } + + /** + * Sets the String value for conferenceName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.conferenceName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProceedingsRecordBuilder conferenceName(String format, Object... args) { + this.conferenceName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for editorName. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.editorName("example value");
    +   * }
    + * + * @param editorName editorName + * @return current instance of builder + */ + public ProceedingsRecordBuilder editorName(String editorName) { + this.editorName = changedValue(editorName); + return this; + } + + /** + * Sets the value for editorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.editorName(sb -> sb.append("text"));
    +   * }
    + * + * @param editorNameStringBuilderConsumer consumer providing an instance of editorName + * @return current instance of builder + */ + public ProceedingsRecordBuilder editorName(Consumer editorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + editorNameStringBuilderConsumer.accept(builder); + this.editorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for editorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.editorName(() -> "example value");
    +   * }
    + * + * @param editorNameSupplier supplier for editorName + * @return current instance of builder + */ + public ProceedingsRecordBuilder editorName(Supplier editorNameSupplier) { + this.editorName = changedValue(editorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for editorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.editorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProceedingsRecordBuilder editorName(String format, Object... args) { + this.editorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public ProceedingsRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public ProceedingsRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for paperCount. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.paperCount(42);
    +   * }
    + * + * @param paperCount paperCount + * @return current instance of builder + */ + public ProceedingsRecordBuilder paperCount(int paperCount) { + this.paperCount = changedValue(paperCount); + return this; + } + + /** + * Sets the value for paperCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.paperCount(() -> 42);
    +   * }
    + * + * @param paperCountSupplier supplier for paperCount + * @return current instance of builder + */ + public ProceedingsRecordBuilder paperCount(Supplier paperCountSupplier) { + this.paperCount = changedValue(paperCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public ProceedingsRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProceedingsRecord#ProceedingsRecord(String, String, int, int, LocalDate) ProceedingsRecord(String + * conferenceName, String editorName, int paperCount, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public ProceedingsRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + 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 ProceedingsRecordBuilder 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 ProceedingsRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ProceedingsRecord result = builder.build();
    +   * }
    + */ + @Override + public ProceedingsRecord build() { + if (!this.paperCount.isSet()) { + throw new IllegalStateException("Required field 'paperCount' must be set before calling build()"); + } + if (this.paperCount.value() == null) { + throw new IllegalStateException("Field 'paperCount' is marked as non-null but null value was provided"); + } + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + ProceedingsRecord result = new ProceedingsRecord(this.conferenceName.value(), + this.editorName.value(), + this.paperCount.value(), + this.pageCount.value(), + this.publicationDate.value()); + 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("conferenceName", this.conferenceName) + .append("editorName", this.editorName) + .append("paperCount", this.paperCount) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .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 ProceedingsRecord with(Consumer b) { + ProceedingsRecordBuilder builder; + try { + builder = new ProceedingsRecordBuilder(ProceedingsRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProceedingsRecordBuilder.With' should only be implemented by classes, which could be casted to 'ProceedingsRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ProceedingsRecordBuilder with() { + try { + return new ProceedingsRecordBuilder(ProceedingsRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProceedingsRecordBuilder.With' should only be implemented by classes, which could be casted to 'ProceedingsRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/QuartoRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/QuartoRecordBuilder.java new file mode 100644 index 00000000..81c8e90a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/QuartoRecordBuilder.java @@ -0,0 +1,454 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.QuartoRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.QuartoRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * QuartoRecord result = QuartoRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .dimensions("example value")
    + *     .dimensions("Hello %s", "World")
    + *     .dimensions(() -> "example value")
    + *     .dimensions(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = QuartoRecord.class) +public class QuartoRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for dimensions: dimensions. + */ + private TrackedValue dimensions = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.QuartoRecord}. + */ + public QuartoRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.QuartoRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public QuartoRecordBuilder(QuartoRecord instance) { + this.title = initialValue(instance.title()); + this.pageCount = initialValue(instance.pageCount()); + this.dimensions = initialValue(instance.dimensions()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.QuartoRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * QuartoRecordBuilder builder = QuartoRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.QuartoRecord} + */ + public static QuartoRecordBuilder create() { + return new QuartoRecordBuilder(); + } + + /** + * Sets the value for dimensions. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("example value");
    +   * }
    + * + * @param dimensions dimensions + * @return current instance of builder + */ + public QuartoRecordBuilder dimensions(String dimensions) { + this.dimensions = changedValue(dimensions); + return this; + } + + /** + * Sets the value for dimensions by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(sb -> sb.append("text"));
    +   * }
    + * + * @param dimensionsStringBuilderConsumer consumer providing an instance of dimensions + * @return current instance of builder + */ + public QuartoRecordBuilder dimensions(Consumer dimensionsStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + dimensionsStringBuilderConsumer.accept(builder); + this.dimensions = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for dimensions by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions(() -> "example value");
    +   * }
    + * + * @param dimensionsSupplier supplier for dimensions + * @return current instance of builder + */ + public QuartoRecordBuilder dimensions(Supplier dimensionsSupplier) { + this.dimensions = changedValue(dimensionsSupplier.get()); + return this; + } + + /** + * Sets the String value for dimensions by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dimensions("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public QuartoRecordBuilder dimensions(String format, Object... args) { + this.dimensions = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public QuartoRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public QuartoRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public QuartoRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public QuartoRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public QuartoRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public QuartoRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public QuartoRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link QuartoRecord#QuartoRecord(String, int, String, LocalDate) + * QuartoRecord(String title, int pageCount, String dimensions, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public QuartoRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 QuartoRecordBuilder 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 QuartoRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * QuartoRecord result = builder.build();
    +   * }
    + */ + @Override + public QuartoRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + QuartoRecord result = new QuartoRecord(this.title.value(), + this.pageCount.value(), + this.dimensions.value(), + this.publicationDate.value()); + 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("title", this.title) + .append("pageCount", this.pageCount) + .append("dimensions", this.dimensions) + .append("publicationDate", this.publicationDate) + .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 QuartoRecord with(Consumer b) { + QuartoRecordBuilder builder; + try { + builder = new QuartoRecordBuilder(QuartoRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'QuartoRecordBuilder.With' should only be implemented by classes, which could be casted to 'QuartoRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default QuartoRecordBuilder with() { + try { + return new QuartoRecordBuilder(QuartoRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'QuartoRecordBuilder.With' should only be implemented by classes, which could be casted to 'QuartoRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ShortStoryRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ShortStoryRecordBuilder.java new file mode 100644 index 00000000..1946185c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ShortStoryRecordBuilder.java @@ -0,0 +1,623 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.ShortStoryRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.ShortStoryRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ShortStoryRecord result = ShortStoryRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .wordCount(42)
    + *     .wordCount(() -> 42)
    + *     .genre("example value")
    + *     .genre("Hello %s", "World")
    + *     .genre(() -> "example value")
    + *     .genre(sb -> sb.append("text"))
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .available(true)
    + *     .available(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ShortStoryRecord.class) +public class ShortStoryRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for wordCount: wordCount. + */ + private TrackedValue wordCount = unsetValue(); + /** + * Tracked value for genre: genre. + */ + private TrackedValue genre = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for available: available. + */ + private TrackedValue available = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ShortStoryRecord}. + */ + public ShortStoryRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ShortStoryRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ShortStoryRecordBuilder(ShortStoryRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.wordCount = initialValue(instance.wordCount()); + this.genre = initialValue(instance.genre()); + this.publicationDate = initialValue(instance.publicationDate()); + this.available = initialValue(instance.available()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ShortStoryRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ShortStoryRecordBuilder builder = ShortStoryRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ShortStoryRecord} + */ + public static ShortStoryRecordBuilder create() { + return new ShortStoryRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public ShortStoryRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public ShortStoryRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public ShortStoryRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShortStoryRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for available. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.available(true);
    +   * }
    + * + * @param available available + * @return current instance of builder + */ + public ShortStoryRecordBuilder available(boolean available) { + this.available = changedValue(available); + return this; + } + + /** + * Sets the value for available by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.available(() -> true);
    +   * }
    + * + * @param availableSupplier supplier for available + * @return current instance of builder + */ + public ShortStoryRecordBuilder available(Supplier availableSupplier) { + this.available = changedValue(availableSupplier.get()); + return this; + } + + /** + * Sets the value for genre. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre("example value");
    +   * }
    + * + * @param genre genre + * @return current instance of builder + */ + public ShortStoryRecordBuilder genre(String genre) { + this.genre = changedValue(genre); + return this; + } + + /** + * Sets the value for genre by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre(sb -> sb.append("text"));
    +   * }
    + * + * @param genreStringBuilderConsumer consumer providing an instance of genre + * @return current instance of builder + */ + public ShortStoryRecordBuilder genre(Consumer genreStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + genreStringBuilderConsumer.accept(builder); + this.genre = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for genre by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre(() -> "example value");
    +   * }
    + * + * @param genreSupplier supplier for genre + * @return current instance of builder + */ + public ShortStoryRecordBuilder genre(Supplier genreSupplier) { + this.genre = changedValue(genreSupplier.get()); + return this; + } + + /** + * Sets the String value for genre by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genre("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShortStoryRecordBuilder genre(String format, Object... args) { + this.genre = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public ShortStoryRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public ShortStoryRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public ShortStoryRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public ShortStoryRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public ShortStoryRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShortStoryRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for wordCount. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(42);
    +   * }
    + * + * @param wordCount wordCount + * @return current instance of builder + */ + public ShortStoryRecordBuilder wordCount(int wordCount) { + this.wordCount = changedValue(wordCount); + return this; + } + + /** + * Sets the value for wordCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ShortStoryRecord#ShortStoryRecord(String, String, int, String, LocalDate, boolean) ShortStoryRecord(String + * title, String authorName, int wordCount, String genre, LocalDate publicationDate, boolean available)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(() -> 42);
    +   * }
    + * + * @param wordCountSupplier supplier for wordCount + * @return current instance of builder + */ + public ShortStoryRecordBuilder wordCount(Supplier wordCountSupplier) { + this.wordCount = changedValue(wordCountSupplier.get()); + 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 ShortStoryRecordBuilder 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 ShortStoryRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ShortStoryRecord result = builder.build();
    +   * }
    + */ + @Override + public ShortStoryRecord build() { + if (!this.wordCount.isSet()) { + throw new IllegalStateException("Required field 'wordCount' must be set before calling build()"); + } + if (this.wordCount.value() == null) { + throw new IllegalStateException("Field 'wordCount' is marked as non-null but null value was provided"); + } + if (!this.available.isSet()) { + throw new IllegalStateException("Required field 'available' must be set before calling build()"); + } + if (this.available.value() == null) { + throw new IllegalStateException("Field 'available' is marked as non-null but null value was provided"); + } + ShortStoryRecord result = new ShortStoryRecord(this.title.value(), + this.authorName.value(), + this.wordCount.value(), + this.genre.value(), + this.publicationDate.value(), + this.available.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("wordCount", this.wordCount) + .append("genre", this.genre) + .append("publicationDate", this.publicationDate) + .append("available", this.available) + .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 ShortStoryRecord with(Consumer b) { + ShortStoryRecordBuilder builder; + try { + builder = new ShortStoryRecordBuilder(ShortStoryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ShortStoryRecordBuilder.With' should only be implemented by classes, which could be casted to 'ShortStoryRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ShortStoryRecordBuilder with() { + try { + return new ShortStoryRecordBuilder(ShortStoryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ShortStoryRecordBuilder.With' should only be implemented by classes, which could be casted to 'ShortStoryRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SlideRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SlideRecordBuilder.java new file mode 100644 index 00000000..45b6531a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SlideRecordBuilder.java @@ -0,0 +1,494 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.SlideRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.SlideRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SlideRecord result = SlideRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .photographer("example value")
    + *     .photographer("Hello %s", "World")
    + *     .photographer(() -> "example value")
    + *     .photographer(sb -> sb.append("text"))
    + *     .format("example value")
    + *     .format("Hello %s", "World")
    + *     .format(() -> "example value")
    + *     .format(sb -> sb.append("text"))
    + *     .captureDate(LocalDate.now())
    + *     .captureDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SlideRecord.class) +public class SlideRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for photographer: photographer. + */ + private TrackedValue photographer = unsetValue(); + /** + * Tracked value for format: format. + */ + private TrackedValue format = unsetValue(); + /** + * Tracked value for captureDate: captureDate. + */ + private TrackedValue captureDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.SlideRecord}. + */ + public SlideRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.SlideRecord} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public SlideRecordBuilder(SlideRecord instance) { + this.subject = initialValue(instance.subject()); + this.photographer = initialValue(instance.photographer()); + this.format = initialValue(instance.format()); + this.captureDate = initialValue(instance.captureDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.SlideRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SlideRecordBuilder builder = SlideRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.SlideRecord} + */ + public static SlideRecordBuilder create() { + return new SlideRecordBuilder(); + } + + /** + * Sets the value for captureDate. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.captureDate(LocalDate.now());
    +   * }
    + * + * @param captureDate captureDate + * @return current instance of builder + */ + public SlideRecordBuilder captureDate(LocalDate captureDate) { + this.captureDate = changedValue(captureDate); + return this; + } + + /** + * Sets the value for captureDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.captureDate(() -> LocalDate.now());
    +   * }
    + * + * @param captureDateSupplier supplier for captureDate + * @return current instance of builder + */ + public SlideRecordBuilder captureDate(Supplier captureDateSupplier) { + this.captureDate = changedValue(captureDateSupplier.get()); + return this; + } + + /** + * Sets the value for format. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("example value");
    +   * }
    + * + * @param format format + * @return current instance of builder + */ + public SlideRecordBuilder format(String format) { + this.format = changedValue(format); + return this; + } + + /** + * Sets the value for format by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(sb -> sb.append("text"));
    +   * }
    + * + * @param formatStringBuilderConsumer consumer providing an instance of format + * @return current instance of builder + */ + public SlideRecordBuilder format(Consumer formatStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + formatStringBuilderConsumer.accept(builder); + this.format = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for format by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(() -> "example value");
    +   * }
    + * + * @param formatSupplier supplier for format + * @return current instance of builder + */ + public SlideRecordBuilder format(Supplier formatSupplier) { + this.format = changedValue(formatSupplier.get()); + return this; + } + + /** + * Sets the String value for format by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SlideRecordBuilder format(String format, Object... args) { + this.format = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for photographer. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer("example value");
    +   * }
    + * + * @param photographer photographer + * @return current instance of builder + */ + public SlideRecordBuilder photographer(String photographer) { + this.photographer = changedValue(photographer); + return this; + } + + /** + * Sets the value for photographer by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer(sb -> sb.append("text"));
    +   * }
    + * + * @param photographerStringBuilderConsumer consumer providing an instance of photographer + * @return current instance of builder + */ + public SlideRecordBuilder photographer(Consumer photographerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + photographerStringBuilderConsumer.accept(builder); + this.photographer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for photographer by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer(() -> "example value");
    +   * }
    + * + * @param photographerSupplier supplier for photographer + * @return current instance of builder + */ + public SlideRecordBuilder photographer(Supplier photographerSupplier) { + this.photographer = changedValue(photographerSupplier.get()); + return this; + } + + /** + * Sets the String value for photographer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photographer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SlideRecordBuilder photographer(String format, Object... args) { + this.photographer = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public SlideRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public SlideRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public SlideRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SlideRecord#SlideRecord(String, String, String, LocalDate) + * SlideRecord(String subject, String photographer, String format, LocalDate captureDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SlideRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 SlideRecordBuilder 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 SlideRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SlideRecord result = builder.build();
    +   * }
    + */ + @Override + public SlideRecord build() { + SlideRecord result = new SlideRecord(this.subject.value(), + this.photographer.value(), + this.format.value(), + this.captureDate.value()); + 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("subject", this.subject) + .append("photographer", this.photographer) + .append("format", this.format) + .append("captureDate", this.captureDate) + .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 SlideRecord with(Consumer b) { + SlideRecordBuilder builder; + try { + builder = new SlideRecordBuilder(SlideRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SlideRecordBuilder.With' should only be implemented by classes, which could be casted to 'SlideRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SlideRecordBuilder with() { + try { + return new SlideRecordBuilder(SlideRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SlideRecordBuilder.With' should only be implemented by classes, which could be casted to 'SlideRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SyllabusRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SyllabusRecordBuilder.java new file mode 100644 index 00000000..568e274b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/SyllabusRecordBuilder.java @@ -0,0 +1,551 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.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.performance_test.library.items.SyllabusRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.SyllabusRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SyllabusRecord result = SyllabusRecordBuilder.create()
    + *     .courseTitle("example value")
    + *     .courseTitle("Hello %s", "World")
    + *     .courseTitle(() -> "example value")
    + *     .courseTitle(sb -> sb.append("text"))
    + *     .instructor("example value")
    + *     .instructor("Hello %s", "World")
    + *     .instructor(() -> "example value")
    + *     .instructor(sb -> sb.append("text"))
    + *     .creditHours(42)
    + *     .creditHours(() -> 42)
    + *     .weekCount(42)
    + *     .weekCount(() -> 42)
    + *     .semester("example value")
    + *     .semester("Hello %s", "World")
    + *     .semester(() -> "example value")
    + *     .semester(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SyllabusRecord.class) +public class SyllabusRecordBuilder implements IBuilderBase { + + /** + * Tracked value for courseTitle: courseTitle. + */ + private TrackedValue courseTitle = unsetValue(); + /** + * Tracked value for instructor: instructor. + */ + private TrackedValue instructor = unsetValue(); + /** + * Tracked value for creditHours: creditHours. + */ + private TrackedValue creditHours = unsetValue(); + /** + * Tracked value for weekCount: weekCount. + */ + private TrackedValue weekCount = unsetValue(); + /** + * Tracked value for semester: semester. + */ + private TrackedValue semester = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.SyllabusRecord}. + */ + public SyllabusRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.SyllabusRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public SyllabusRecordBuilder(SyllabusRecord instance) { + this.courseTitle = initialValue(instance.courseTitle()); + this.instructor = initialValue(instance.instructor()); + this.creditHours = initialValue(instance.creditHours()); + this.weekCount = initialValue(instance.weekCount()); + this.semester = initialValue(instance.semester()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.SyllabusRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SyllabusRecordBuilder builder = SyllabusRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.SyllabusRecord} + */ + public static SyllabusRecordBuilder create() { + return new SyllabusRecordBuilder(); + } + + /** + * Sets the value for courseTitle. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.courseTitle("example value");
    +   * }
    + * + * @param courseTitle courseTitle + * @return current instance of builder + */ + public SyllabusRecordBuilder courseTitle(String courseTitle) { + this.courseTitle = changedValue(courseTitle); + return this; + } + + /** + * Sets the value for courseTitle by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.courseTitle(sb -> sb.append("text"));
    +   * }
    + * + * @param courseTitleStringBuilderConsumer consumer providing an instance of courseTitle + * @return current instance of builder + */ + public SyllabusRecordBuilder courseTitle(Consumer courseTitleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + courseTitleStringBuilderConsumer.accept(builder); + this.courseTitle = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for courseTitle by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.courseTitle(() -> "example value");
    +   * }
    + * + * @param courseTitleSupplier supplier for courseTitle + * @return current instance of builder + */ + public SyllabusRecordBuilder courseTitle(Supplier courseTitleSupplier) { + this.courseTitle = changedValue(courseTitleSupplier.get()); + return this; + } + + /** + * Sets the String value for courseTitle by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.courseTitle("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SyllabusRecordBuilder courseTitle(String format, Object... args) { + this.courseTitle = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for creditHours. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creditHours(42);
    +   * }
    + * + * @param creditHours creditHours + * @return current instance of builder + */ + public SyllabusRecordBuilder creditHours(int creditHours) { + this.creditHours = changedValue(creditHours); + return this; + } + + /** + * Sets the value for creditHours by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creditHours(() -> 42);
    +   * }
    + * + * @param creditHoursSupplier supplier for creditHours + * @return current instance of builder + */ + public SyllabusRecordBuilder creditHours(Supplier creditHoursSupplier) { + this.creditHours = changedValue(creditHoursSupplier.get()); + return this; + } + + /** + * Sets the value for instructor. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor("example value");
    +   * }
    + * + * @param instructor instructor + * @return current instance of builder + */ + public SyllabusRecordBuilder instructor(String instructor) { + this.instructor = changedValue(instructor); + return this; + } + + /** + * Sets the value for instructor by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor(sb -> sb.append("text"));
    +   * }
    + * + * @param instructorStringBuilderConsumer consumer providing an instance of instructor + * @return current instance of builder + */ + public SyllabusRecordBuilder instructor(Consumer instructorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + instructorStringBuilderConsumer.accept(builder); + this.instructor = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for instructor by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor(() -> "example value");
    +   * }
    + * + * @param instructorSupplier supplier for instructor + * @return current instance of builder + */ + public SyllabusRecordBuilder instructor(Supplier instructorSupplier) { + this.instructor = changedValue(instructorSupplier.get()); + return this; + } + + /** + * Sets the String value for instructor by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instructor("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SyllabusRecordBuilder instructor(String format, Object... args) { + this.instructor = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for semester. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.semester("example value");
    +   * }
    + * + * @param semester semester + * @return current instance of builder + */ + public SyllabusRecordBuilder semester(String semester) { + this.semester = changedValue(semester); + return this; + } + + /** + * Sets the value for semester by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.semester(sb -> sb.append("text"));
    +   * }
    + * + * @param semesterStringBuilderConsumer consumer providing an instance of semester + * @return current instance of builder + */ + public SyllabusRecordBuilder semester(Consumer semesterStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + semesterStringBuilderConsumer.accept(builder); + this.semester = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for semester by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.semester(() -> "example value");
    +   * }
    + * + * @param semesterSupplier supplier for semester + * @return current instance of builder + */ + public SyllabusRecordBuilder semester(Supplier semesterSupplier) { + this.semester = changedValue(semesterSupplier.get()); + return this; + } + + /** + * Sets the String value for semester by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.semester("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SyllabusRecordBuilder semester(String format, Object... args) { + this.semester = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for weekCount. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.weekCount(42);
    +   * }
    + * + * @param weekCount weekCount + * @return current instance of builder + */ + public SyllabusRecordBuilder weekCount(int weekCount) { + this.weekCount = changedValue(weekCount); + return this; + } + + /** + * Sets the value for weekCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SyllabusRecord#SyllabusRecord(String, String, int, int, String) + * SyllabusRecord(String courseTitle, String instructor, int creditHours, int weekCount, String semester)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.weekCount(() -> 42);
    +   * }
    + * + * @param weekCountSupplier supplier for weekCount + * @return current instance of builder + */ + public SyllabusRecordBuilder weekCount(Supplier weekCountSupplier) { + this.weekCount = changedValue(weekCountSupplier.get()); + 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 SyllabusRecordBuilder 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 SyllabusRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SyllabusRecord result = builder.build();
    +   * }
    + */ + @Override + public SyllabusRecord build() { + if (!this.creditHours.isSet()) { + throw new IllegalStateException("Required field 'creditHours' must be set before calling build()"); + } + if (this.creditHours.value() == null) { + throw new IllegalStateException("Field 'creditHours' is marked as non-null but null value was provided"); + } + if (!this.weekCount.isSet()) { + throw new IllegalStateException("Required field 'weekCount' must be set before calling build()"); + } + if (this.weekCount.value() == null) { + throw new IllegalStateException("Field 'weekCount' is marked as non-null but null value was provided"); + } + SyllabusRecord result = new SyllabusRecord(this.courseTitle + .value(), this.instructor.value(), this.creditHours.value(), this.weekCount.value(), this.semester.value()); + 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("courseTitle", this.courseTitle) + .append("instructor", this.instructor) + .append("creditHours", this.creditHours) + .append("weekCount", this.weekCount) + .append("semester", this.semester) + .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 SyllabusRecord with(Consumer b) { + SyllabusRecordBuilder builder; + try { + builder = new SyllabusRecordBuilder(SyllabusRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SyllabusRecordBuilder.With' should only be implemented by classes, which could be casted to 'SyllabusRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SyllabusRecordBuilder with() { + try { + return new SyllabusRecordBuilder(SyllabusRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SyllabusRecordBuilder.With' should only be implemented by classes, which could be casted to 'SyllabusRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TeacherManualBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TeacherManualBuilder.java new file mode 100644 index 00000000..27687979 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TeacherManualBuilder.java @@ -0,0 +1,993 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; +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.builders.ArrayListBuilder; +import org.javahelpers.simple.builders.core.builders.HashSetBuilder; +import org.javahelpers.simple.builders.core.interfaces.IBuilderBase; +import org.javahelpers.simple.builders.core.util.BuilderToStringStyle; +import org.javahelpers.simple.builders.core.util.TrackedValue; +import org.javahelpers.simple.builders.performance_test.library.organizations.EducationalPublisher; +import org.javahelpers.simple.builders.performance_test.library.organizations.EducationalPublisherBuilder; + +/** + * Builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TeacherManual}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.TeacherManual 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. + * + *

    Example:

    + * + *
    {@code
    + * TeacherManual result = TeacherManualBuilder.create()
    + *     .assessmentTools(Set.of("example value"))
    + *     .assessmentTools(() -> Set.of("example value"))
    + *     .assessmentTools(t -> t.add("example value"))
    + *     .assessmentTools("example value", "example value")
    + *     .add2AssessmentTools("example value")
    + *     .catalogId(UUID.randomUUID())
    + *     .catalogId(() -> UUID.randomUUID())
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .gradeLevel("example value")
    + *     .gradeLevel("Hello %s", "World")
    + *     .gradeLevel(() -> "example value")
    + *     .gradeLevel(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .lessonPlans(List.of("example value"))
    + *     .lessonPlans(() -> List.of("example value"))
    + *     .lessonPlans(t -> t.add("example value"))
    + *     .lessonPlans("example value", "example value")
    + *     .add2LessonPlans("example value")
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .publisher(new EducationalPublisher())
    + *     .publisher(EducationalPublisher::new)
    + *     .publisher(educationalPublisherBuilder -> educationalPublisherBuilder)
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TeacherManual.class) +public class TeacherManualBuilder implements IBuilderBase { + + /** + * Tracked value for assessmentTools: assessmentTools. + */ + private TrackedValue> assessmentTools = unsetValue(); + /** + * Tracked value for catalogId: catalogId. + */ + private TrackedValue catalogId = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for gradeLevel: gradeLevel. + */ + private TrackedValue gradeLevel = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for lessonPlans: lessonPlans. + */ + private TrackedValue> lessonPlans = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TeacherManual}. + */ + public TeacherManualBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TeacherManual} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public TeacherManualBuilder(TeacherManual instance) { + this.assessmentTools = initialValue(instance.getAssessmentTools()); + this.catalogId = initialValue(instance.getCatalogId()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.gradeLevel = initialValue(instance.getGradeLevel()); + this.id = initialValue(instance.getId()); + this.lessonPlans = initialValue(instance.getLessonPlans()); + this.name = initialValue(instance.getName()); + this.pageCount = initialValue(instance.getPageCount()); + this.publicationDate = initialValue(instance.getPublicationDate()); + this.publisher = initialValue(instance.getPublisher()); + this.subject = initialValue(instance.getSubject()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TeacherManual}. + * + *

    Example:

    + * + *
    {@code
    +   * TeacherManualBuilder builder = TeacherManualBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TeacherManual} + */ + public static TeacherManualBuilder create() { + return new TeacherManualBuilder(); + } + + /** + * Adds a single element to assessmentTools. + *

    + * Generated from setter {@link TeacherManual#setAssessmentTools(Set) setAssessmentTools(Set assessmentTools)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2AssessmentTools("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TeacherManualBuilder add2AssessmentTools(String element) { + Set newCollection; + if (this.assessmentTools.isSet()) { + newCollection = new HashSet<>(this.assessmentTools.value()); + } else { + newCollection = new HashSet<>(); + } + newCollection.add(element); + this.assessmentTools = changedValue(newCollection); + return this; + } + + /** + * Adds a single element to lessonPlans. + *

    + * Generated from setter {@link TeacherManual#setLessonPlans(List) setLessonPlans(List lessonPlans)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2LessonPlans("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TeacherManualBuilder add2LessonPlans(String element) { + List newCollection; + if (this.lessonPlans.isSet()) { + newCollection = new ArrayList<>(this.lessonPlans.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.lessonPlans = changedValue(newCollection); + return this; + } + + /** + * Sets the value for assessmentTools. + *

    + * Generated from setter {@link TeacherManual#setAssessmentTools(Set) setAssessmentTools(Set assessmentTools)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.assessmentTools("example value", "example value");
    +   * }
    + * + * @param assessmentTools assessmentTools + * @return current instance of builder + */ + public TeacherManualBuilder assessmentTools(String... assessmentTools) { + this.assessmentTools = changedValue(Set.of(assessmentTools)); + return this; + } + + /** + * Sets the value for assessmentTools. + *

    + * Generated from setter {@link TeacherManual#setAssessmentTools(Set) setAssessmentTools(Set assessmentTools)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.assessmentTools(Set.of("example value"));
    +   * }
    + * + * @param assessmentTools assessmentTools + * @return current instance of builder + */ + public TeacherManualBuilder assessmentTools(Set assessmentTools) { + this.assessmentTools = changedValue(assessmentTools); + return this; + } + + /** + * Sets the value for assessmentTools using a builder consumer that produces the value. + *

    + * Generated from setter {@link TeacherManual#setAssessmentTools(Set) setAssessmentTools(Set assessmentTools)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.assessmentTools(t -> t.add("example value"));
    +   * }
    + * + * @param assessmentToolsBuilderConsumer consumer providing an instance of a builder for assessmentTools + * @return current instance of builder + */ + public TeacherManualBuilder assessmentTools(Consumer> assessmentToolsBuilderConsumer) { + HashSetBuilder builder = this.assessmentTools.isSet() + ? new HashSetBuilder(this.assessmentTools.value()) + : new HashSetBuilder(); + assessmentToolsBuilderConsumer.accept(builder); + this.assessmentTools = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for assessmentTools by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setAssessmentTools(Set) setAssessmentTools(Set assessmentTools)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.assessmentTools(() -> Set.of("example value"));
    +   * }
    + * + * @param assessmentToolsSupplier supplier for assessmentTools + * @return current instance of builder + */ + public TeacherManualBuilder assessmentTools(Supplier> assessmentToolsSupplier) { + this.assessmentTools = changedValue(assessmentToolsSupplier.get()); + return this; + } + + /** + * Sets the value for catalogId. + *

    + * Generated from setter {@link TeacherManual#setCatalogId(UUID) setCatalogId(UUID catalogId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogId(UUID.randomUUID());
    +   * }
    + * + * @param catalogId catalogId + * @return current instance of builder + */ + public TeacherManualBuilder catalogId(UUID catalogId) { + this.catalogId = changedValue(catalogId); + return this; + } + + /** + * Sets the value for catalogId by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setCatalogId(UUID) setCatalogId(UUID catalogId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogId(() -> UUID.randomUUID());
    +   * }
    + * + * @param catalogIdSupplier supplier for catalogId + * @return current instance of builder + */ + public TeacherManualBuilder catalogId(Supplier catalogIdSupplier) { + this.catalogId = changedValue(catalogIdSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link TeacherManual#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TeacherManualBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TeacherManualBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for gradeLevel. + *

    + * Generated from setter {@link TeacherManual#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel("example value");
    +   * }
    + * + * @param gradeLevel gradeLevel + * @return current instance of builder + */ + public TeacherManualBuilder gradeLevel(String gradeLevel) { + this.gradeLevel = changedValue(gradeLevel); + return this; + } + + /** + * Sets the value for gradeLevel by executing the provided consumer. + *

    + * Generated from setter {@link TeacherManual#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param gradeLevelStringBuilderConsumer consumer providing an instance of gradeLevel + * @return current instance of builder + */ + public TeacherManualBuilder gradeLevel(Consumer gradeLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + gradeLevelStringBuilderConsumer.accept(builder); + this.gradeLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for gradeLevel by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel(() -> "example value");
    +   * }
    + * + * @param gradeLevelSupplier supplier for gradeLevel + * @return current instance of builder + */ + public TeacherManualBuilder gradeLevel(Supplier gradeLevelSupplier) { + this.gradeLevel = changedValue(gradeLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for gradeLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TeacherManual#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TeacherManualBuilder gradeLevel(String format, Object... args) { + this.gradeLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link TeacherManual#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TeacherManualBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TeacherManualBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for lessonPlans. + *

    + * Generated from setter {@link TeacherManual#setLessonPlans(List) setLessonPlans(List lessonPlans)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lessonPlans("example value", "example value");
    +   * }
    + * + * @param lessonPlans lessonPlans + * @return current instance of builder + */ + public TeacherManualBuilder lessonPlans(String... lessonPlans) { + this.lessonPlans = changedValue(List.of(lessonPlans)); + return this; + } + + /** + * Sets the value for lessonPlans. + *

    + * Generated from setter {@link TeacherManual#setLessonPlans(List) setLessonPlans(List lessonPlans)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lessonPlans(List.of("example value"));
    +   * }
    + * + * @param lessonPlans lessonPlans + * @return current instance of builder + */ + public TeacherManualBuilder lessonPlans(List lessonPlans) { + this.lessonPlans = changedValue(lessonPlans); + return this; + } + + /** + * Sets the value for lessonPlans using a builder consumer that produces the value. + *

    + * Generated from setter {@link TeacherManual#setLessonPlans(List) setLessonPlans(List lessonPlans)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lessonPlans(t -> t.add("example value"));
    +   * }
    + * + * @param lessonPlansBuilderConsumer consumer providing an instance of a builder for lessonPlans + * @return current instance of builder + */ + public TeacherManualBuilder lessonPlans(Consumer> lessonPlansBuilderConsumer) { + ArrayListBuilder builder = this.lessonPlans.isSet() + ? new ArrayListBuilder(this.lessonPlans.value()) + : new ArrayListBuilder(); + lessonPlansBuilderConsumer.accept(builder); + this.lessonPlans = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for lessonPlans by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setLessonPlans(List) setLessonPlans(List lessonPlans)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lessonPlans(() -> List.of("example value"));
    +   * }
    + * + * @param lessonPlansSupplier supplier for lessonPlans + * @return current instance of builder + */ + public TeacherManualBuilder lessonPlans(Supplier> lessonPlansSupplier) { + this.lessonPlans = changedValue(lessonPlansSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link TeacherManual#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TeacherManualBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link TeacherManual#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TeacherManualBuilder 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. + *

    + * Generated from setter {@link TeacherManual#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TeacherManualBuilder 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. + *

    + * Generated from setter {@link TeacherManual#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TeacherManualBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from setter {@link TeacherManual#setPageCount(int) setPageCount(int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public TeacherManualBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setPageCount(int) setPageCount(int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public TeacherManualBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from setter {@link TeacherManual#setPublicationDate(LocalDate) setPublicationDate(LocalDate + * publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public TeacherManualBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setPublicationDate(LocalDate) setPublicationDate(LocalDate + * publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public TeacherManualBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from setter {@link TeacherManual#setPublisher(EducationalPublisher) setPublisher(EducationalPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(new EducationalPublisher());
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public TeacherManualBuilder publisher(EducationalPublisher publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher using a builder consumer that produces the value. + *

    + * Generated from setter {@link TeacherManual#setPublisher(EducationalPublisher) setPublisher(EducationalPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(educationalPublisherBuilder -> educationalPublisherBuilder);
    +   * }
    + * + * @param publisherBuilderConsumer consumer providing an instance of a builder for publisher + * @return current instance of builder + */ + public TeacherManualBuilder publisher(Consumer publisherBuilderConsumer) { + EducationalPublisherBuilder builder = this.publisher.isSet() + ? new EducationalPublisherBuilder(this.publisher.value()) + : new EducationalPublisherBuilder(); + publisherBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setPublisher(EducationalPublisher) setPublisher(EducationalPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(EducationalPublisher::new);
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public TeacherManualBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from setter {@link TeacherManual#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public TeacherManualBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from setter {@link TeacherManual#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public TeacherManualBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from setter {@link TeacherManual#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public TeacherManualBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TeacherManual#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TeacherManualBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 TeacherManualBuilder 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 TeacherManualBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TeacherManual result = builder.build();
    +   * }
    + */ + @Override + public TeacherManual build() { + if (this.pageCount.isSet() && this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + TeacherManual result = new TeacherManual(); + this.assessmentTools.ifSet(result::setAssessmentTools); + this.catalogId.ifSet(result::setCatalogId); + this.createdAt.ifSet(result::setCreatedAt); + this.gradeLevel.ifSet(result::setGradeLevel); + this.id.ifSet(result::setId); + this.lessonPlans.ifSet(result::setLessonPlans); + this.name.ifSet(result::setName); + this.pageCount.ifSet(result::setPageCount); + this.publicationDate.ifSet(result::setPublicationDate); + this.publisher.ifSet(result::setPublisher); + this.subject.ifSet(result::setSubject); + 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("assessmentTools", this.assessmentTools) + .append("catalogId", this.catalogId) + .append("createdAt", this.createdAt) + .append("gradeLevel", this.gradeLevel) + .append("id", this.id) + .append("lessonPlans", this.lessonPlans) + .append("name", this.name) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .append("publisher", this.publisher) + .append("subject", this.subject) + .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 TeacherManual with(Consumer b) { + TeacherManualBuilder builder; + try { + builder = new TeacherManualBuilder(TeacherManual.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TeacherManualBuilder.With' should only be implemented by classes, which could be casted to 'TeacherManual'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TeacherManualBuilder with() { + try { + return new TeacherManualBuilder(TeacherManual.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TeacherManualBuilder.With' should only be implemented by classes, which could be casted to 'TeacherManual'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TelegramRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TelegramRecordBuilder.java new file mode 100644 index 00000000..ffd61493 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TelegramRecordBuilder.java @@ -0,0 +1,454 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.TelegramRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.TelegramRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TelegramRecord result = TelegramRecordBuilder.create()
    + *     .sender("example value")
    + *     .sender("Hello %s", "World")
    + *     .sender(() -> "example value")
    + *     .sender(sb -> sb.append("text"))
    + *     .recipient("example value")
    + *     .recipient("Hello %s", "World")
    + *     .recipient(() -> "example value")
    + *     .recipient(sb -> sb.append("text"))
    + *     .date(LocalDate.now())
    + *     .date(() -> LocalDate.now())
    + *     .wordCount(42)
    + *     .wordCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TelegramRecord.class) +public class TelegramRecordBuilder implements IBuilderBase { + + /** + * Tracked value for sender: sender. + */ + private TrackedValue sender = unsetValue(); + /** + * Tracked value for recipient: recipient. + */ + private TrackedValue recipient = unsetValue(); + /** + * Tracked value for date: date. + */ + private TrackedValue date = unsetValue(); + /** + * Tracked value for wordCount: wordCount. + */ + private TrackedValue wordCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TelegramRecord}. + */ + public TelegramRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TelegramRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public TelegramRecordBuilder(TelegramRecord instance) { + this.sender = initialValue(instance.sender()); + this.recipient = initialValue(instance.recipient()); + this.date = initialValue(instance.date()); + this.wordCount = initialValue(instance.wordCount()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TelegramRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TelegramRecordBuilder builder = TelegramRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TelegramRecord} + */ + public static TelegramRecordBuilder create() { + return new TelegramRecordBuilder(); + } + + /** + * Sets the value for date. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.date(LocalDate.now());
    +   * }
    + * + * @param date date + * @return current instance of builder + */ + public TelegramRecordBuilder date(LocalDate date) { + this.date = changedValue(date); + return this; + } + + /** + * Sets the value for date by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.date(() -> LocalDate.now());
    +   * }
    + * + * @param dateSupplier supplier for date + * @return current instance of builder + */ + public TelegramRecordBuilder date(Supplier dateSupplier) { + this.date = changedValue(dateSupplier.get()); + return this; + } + + /** + * Sets the value for recipient. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient("example value");
    +   * }
    + * + * @param recipient recipient + * @return current instance of builder + */ + public TelegramRecordBuilder recipient(String recipient) { + this.recipient = changedValue(recipient); + return this; + } + + /** + * Sets the value for recipient by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient(sb -> sb.append("text"));
    +   * }
    + * + * @param recipientStringBuilderConsumer consumer providing an instance of recipient + * @return current instance of builder + */ + public TelegramRecordBuilder recipient(Consumer recipientStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + recipientStringBuilderConsumer.accept(builder); + this.recipient = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for recipient by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient(() -> "example value");
    +   * }
    + * + * @param recipientSupplier supplier for recipient + * @return current instance of builder + */ + public TelegramRecordBuilder recipient(Supplier recipientSupplier) { + this.recipient = changedValue(recipientSupplier.get()); + return this; + } + + /** + * Sets the String value for recipient by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.recipient("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TelegramRecordBuilder recipient(String format, Object... args) { + this.recipient = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sender. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender("example value");
    +   * }
    + * + * @param sender sender + * @return current instance of builder + */ + public TelegramRecordBuilder sender(String sender) { + this.sender = changedValue(sender); + return this; + } + + /** + * Sets the value for sender by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender(sb -> sb.append("text"));
    +   * }
    + * + * @param senderStringBuilderConsumer consumer providing an instance of sender + * @return current instance of builder + */ + public TelegramRecordBuilder sender(Consumer senderStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + senderStringBuilderConsumer.accept(builder); + this.sender = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sender by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender(() -> "example value");
    +   * }
    + * + * @param senderSupplier supplier for sender + * @return current instance of builder + */ + public TelegramRecordBuilder sender(Supplier senderSupplier) { + this.sender = changedValue(senderSupplier.get()); + return this; + } + + /** + * Sets the String value for sender by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sender("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TelegramRecordBuilder sender(String format, Object... args) { + this.sender = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for wordCount. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(42);
    +   * }
    + * + * @param wordCount wordCount + * @return current instance of builder + */ + public TelegramRecordBuilder wordCount(int wordCount) { + this.wordCount = changedValue(wordCount); + return this; + } + + /** + * Sets the value for wordCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TelegramRecord#TelegramRecord(String, String, LocalDate, int) + * TelegramRecord(String sender, String recipient, LocalDate date, int wordCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wordCount(() -> 42);
    +   * }
    + * + * @param wordCountSupplier supplier for wordCount + * @return current instance of builder + */ + public TelegramRecordBuilder wordCount(Supplier wordCountSupplier) { + this.wordCount = changedValue(wordCountSupplier.get()); + 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 TelegramRecordBuilder 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 TelegramRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TelegramRecord result = builder.build();
    +   * }
    + */ + @Override + public TelegramRecord build() { + if (!this.wordCount.isSet()) { + throw new IllegalStateException("Required field 'wordCount' must be set before calling build()"); + } + if (this.wordCount.value() == null) { + throw new IllegalStateException("Field 'wordCount' is marked as non-null but null value was provided"); + } + TelegramRecord result = new TelegramRecord(this.sender.value(), + this.recipient.value(), + this.date.value(), + this.wordCount.value()); + 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("sender", this.sender) + .append("recipient", this.recipient) + .append("date", this.date) + .append("wordCount", this.wordCount) + .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 TelegramRecord with(Consumer b) { + TelegramRecordBuilder builder; + try { + builder = new TelegramRecordBuilder(TelegramRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TelegramRecordBuilder.With' should only be implemented by classes, which could be casted to 'TelegramRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TelegramRecordBuilder with() { + try { + return new TelegramRecordBuilder(TelegramRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TelegramRecordBuilder.With' should only be implemented by classes, which could be casted to 'TelegramRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TextbookBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TextbookBuilder.java new file mode 100644 index 00000000..66f042df --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TextbookBuilder.java @@ -0,0 +1,1060 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +import org.javahelpers.simple.builders.core.interfaces.IBuilderBase; +import org.javahelpers.simple.builders.core.util.BuilderToStringStyle; +import org.javahelpers.simple.builders.core.util.TrackedValue; +import org.javahelpers.simple.builders.performance_test.library.organizations.EducationalPublisher; +import org.javahelpers.simple.builders.performance_test.library.organizations.EducationalPublisherBuilder; + +/** + * Builder for {@code org.javahelpers.simple.builders.performance_test.library.items.Textbook}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.Textbook 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. + * + *

    Example:

    + * + *
    {@code
    + * Textbook result = TextbookBuilder.create()
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .catalogId(UUID.randomUUID())
    + *     .catalogId(() -> UUID.randomUUID())
    + *     .chapters(List.of("example value"))
    + *     .chapters(() -> List.of("example value"))
    + *     .chapters(t -> t.add("example value"))
    + *     .chapters("example value", "example value")
    + *     .add2Chapters("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .edition(42)
    + *     .edition(() -> 42)
    + *     .exercises(true)
    + *     .exercises(() -> true)
    + *     .gradeLevel("example value")
    + *     .gradeLevel("Hello %s", "World")
    + *     .gradeLevel(() -> "example value")
    + *     .gradeLevel(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .publisher(new EducationalPublisher())
    + *     .publisher(EducationalPublisher::new)
    + *     .publisher(educationalPublisherBuilder -> educationalPublisherBuilder)
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Textbook.class) +public class TextbookBuilder implements IBuilderBase { + + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for catalogId: catalogId. + */ + private TrackedValue catalogId = unsetValue(); + /** + * Tracked value for chapters: chapters. + */ + private TrackedValue> chapters = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for edition: edition. + */ + private TrackedValue edition = unsetValue(); + /** + * Tracked value for exercises: exercises. + */ + private TrackedValue exercises = unsetValue(); + /** + * Tracked value for gradeLevel: gradeLevel. + */ + private TrackedValue gradeLevel = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + + /** + * Empty constructor of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.Textbook}. + */ + public TextbookBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.Textbook} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public TextbookBuilder(Textbook instance) { + this.authorName = initialValue(instance.getAuthorName()); + this.catalogId = initialValue(instance.getCatalogId()); + this.chapters = initialValue(instance.getChapters()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.edition = initialValue(instance.getEdition()); + this.exercises = initialValue(instance.isExercises()); + this.gradeLevel = initialValue(instance.getGradeLevel()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.pageCount = initialValue(instance.getPageCount()); + this.publicationDate = initialValue(instance.getPublicationDate()); + this.publisher = initialValue(instance.getPublisher()); + this.subject = initialValue(instance.getSubject()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.Textbook}. + * + *

    Example:

    + * + *
    {@code
    +   * TextbookBuilder builder = TextbookBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.Textbook} + */ + public static TextbookBuilder create() { + return new TextbookBuilder(); + } + + /** + * Adds a single element to chapters. + *

    + * Generated from setter {@link Textbook#setChapters(List) setChapters(List chapters)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Chapters("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TextbookBuilder add2Chapters(String element) { + List newCollection; + if (this.chapters.isSet()) { + newCollection = new ArrayList<>(this.chapters.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.chapters = changedValue(newCollection); + return this; + } + + /** + * Sets the value for authorName. + *

    + * Generated from setter {@link Textbook#setAuthorName(String) setAuthorName(String authorName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public TextbookBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from setter {@link Textbook#setAuthorName(String) setAuthorName(String authorName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public TextbookBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setAuthorName(String) setAuthorName(String authorName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public TextbookBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Textbook#setAuthorName(String) setAuthorName(String authorName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TextbookBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for catalogId. + *

    + * Generated from setter {@link Textbook#setCatalogId(UUID) setCatalogId(UUID catalogId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogId(UUID.randomUUID());
    +   * }
    + * + * @param catalogId catalogId + * @return current instance of builder + */ + public TextbookBuilder catalogId(UUID catalogId) { + this.catalogId = changedValue(catalogId); + return this; + } + + /** + * Sets the value for catalogId by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setCatalogId(UUID) setCatalogId(UUID catalogId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogId(() -> UUID.randomUUID());
    +   * }
    + * + * @param catalogIdSupplier supplier for catalogId + * @return current instance of builder + */ + public TextbookBuilder catalogId(Supplier catalogIdSupplier) { + this.catalogId = changedValue(catalogIdSupplier.get()); + return this; + } + + /** + * Sets the value for chapters. + *

    + * Generated from setter {@link Textbook#setChapters(List) setChapters(List chapters)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.chapters("example value", "example value");
    +   * }
    + * + * @param chapters chapters + * @return current instance of builder + */ + public TextbookBuilder chapters(String... chapters) { + this.chapters = changedValue(List.of(chapters)); + return this; + } + + /** + * Sets the value for chapters. + *

    + * Generated from setter {@link Textbook#setChapters(List) setChapters(List chapters)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.chapters(List.of("example value"));
    +   * }
    + * + * @param chapters chapters + * @return current instance of builder + */ + public TextbookBuilder chapters(List chapters) { + this.chapters = changedValue(chapters); + return this; + } + + /** + * Sets the value for chapters using a builder consumer that produces the value. + *

    + * Generated from setter {@link Textbook#setChapters(List) setChapters(List chapters)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.chapters(t -> t.add("example value"));
    +   * }
    + * + * @param chaptersBuilderConsumer consumer providing an instance of a builder for chapters + * @return current instance of builder + */ + public TextbookBuilder chapters(Consumer> chaptersBuilderConsumer) { + ArrayListBuilder builder = this.chapters.isSet() + ? new ArrayListBuilder(this.chapters.value()) + : new ArrayListBuilder(); + chaptersBuilderConsumer.accept(builder); + this.chapters = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for chapters by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setChapters(List) setChapters(List chapters)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.chapters(() -> List.of("example value"));
    +   * }
    + * + * @param chaptersSupplier supplier for chapters + * @return current instance of builder + */ + public TextbookBuilder chapters(Supplier> chaptersSupplier) { + this.chapters = changedValue(chaptersSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Textbook#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TextbookBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TextbookBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for edition. + *

    + * Generated from setter {@link Textbook#setEdition(int) setEdition(int edition)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.edition(42);
    +   * }
    + * + * @param edition edition + * @return current instance of builder + */ + public TextbookBuilder edition(int edition) { + this.edition = changedValue(edition); + return this; + } + + /** + * Sets the value for edition by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setEdition(int) setEdition(int edition)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.edition(() -> 42);
    +   * }
    + * + * @param editionSupplier supplier for edition + * @return current instance of builder + */ + public TextbookBuilder edition(Supplier editionSupplier) { + this.edition = changedValue(editionSupplier.get()); + return this; + } + + /** + * Sets the value for exercises. + *

    + * Generated from setter {@link Textbook#setExercises(boolean) setExercises(boolean exercises)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exercises(true);
    +   * }
    + * + * @param exercises exercises + * @return current instance of builder + */ + public TextbookBuilder exercises(boolean exercises) { + this.exercises = changedValue(exercises); + return this; + } + + /** + * Sets the value for exercises by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setExercises(boolean) setExercises(boolean exercises)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exercises(() -> true);
    +   * }
    + * + * @param exercisesSupplier supplier for exercises + * @return current instance of builder + */ + public TextbookBuilder exercises(Supplier exercisesSupplier) { + this.exercises = changedValue(exercisesSupplier.get()); + return this; + } + + /** + * Sets the value for gradeLevel. + *

    + * Generated from setter {@link Textbook#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel("example value");
    +   * }
    + * + * @param gradeLevel gradeLevel + * @return current instance of builder + */ + public TextbookBuilder gradeLevel(String gradeLevel) { + this.gradeLevel = changedValue(gradeLevel); + return this; + } + + /** + * Sets the value for gradeLevel by executing the provided consumer. + *

    + * Generated from setter {@link Textbook#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param gradeLevelStringBuilderConsumer consumer providing an instance of gradeLevel + * @return current instance of builder + */ + public TextbookBuilder gradeLevel(Consumer gradeLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + gradeLevelStringBuilderConsumer.accept(builder); + this.gradeLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for gradeLevel by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel(() -> "example value");
    +   * }
    + * + * @param gradeLevelSupplier supplier for gradeLevel + * @return current instance of builder + */ + public TextbookBuilder gradeLevel(Supplier gradeLevelSupplier) { + this.gradeLevel = changedValue(gradeLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for gradeLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Textbook#setGradeLevel(String) setGradeLevel(String gradeLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TextbookBuilder gradeLevel(String format, Object... args) { + this.gradeLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Textbook#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TextbookBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TextbookBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Textbook#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TextbookBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Textbook#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TextbookBuilder 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. + *

    + * Generated from setter {@link Textbook#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TextbookBuilder 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. + *

    + * Generated from setter {@link Textbook#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TextbookBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from setter {@link Textbook#setPageCount(int) setPageCount(int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public TextbookBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setPageCount(int) setPageCount(int pageCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public TextbookBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from setter {@link Textbook#setPublicationDate(LocalDate) setPublicationDate(LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public TextbookBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setPublicationDate(LocalDate) setPublicationDate(LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public TextbookBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from setter {@link Textbook#setPublisher(EducationalPublisher) setPublisher(EducationalPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(new EducationalPublisher());
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public TextbookBuilder publisher(EducationalPublisher publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher using a builder consumer that produces the value. + *

    + * Generated from setter {@link Textbook#setPublisher(EducationalPublisher) setPublisher(EducationalPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(educationalPublisherBuilder -> educationalPublisherBuilder);
    +   * }
    + * + * @param publisherBuilderConsumer consumer providing an instance of a builder for publisher + * @return current instance of builder + */ + public TextbookBuilder publisher(Consumer publisherBuilderConsumer) { + EducationalPublisherBuilder builder = this.publisher.isSet() + ? new EducationalPublisherBuilder(this.publisher.value()) + : new EducationalPublisherBuilder(); + publisherBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setPublisher(EducationalPublisher) setPublisher(EducationalPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(EducationalPublisher::new);
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public TextbookBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from setter {@link Textbook#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public TextbookBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from setter {@link Textbook#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public TextbookBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from setter {@link Textbook#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public TextbookBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Textbook#setSubject(String) setSubject(String subject)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TextbookBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 TextbookBuilder 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 TextbookBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Textbook result = builder.build();
    +   * }
    + */ + @Override + public Textbook build() { + if (this.edition.isSet() && this.edition.value() == null) { + throw new IllegalStateException("Field 'edition' is marked as non-null but null value was provided"); + } + if (this.exercises.isSet() && this.exercises.value() == null) { + throw new IllegalStateException("Field 'exercises' is marked as non-null but null value was provided"); + } + if (this.pageCount.isSet() && this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + Textbook result = new Textbook(); + this.authorName.ifSet(result::setAuthorName); + this.catalogId.ifSet(result::setCatalogId); + this.chapters.ifSet(result::setChapters); + this.createdAt.ifSet(result::setCreatedAt); + this.edition.ifSet(result::setEdition); + this.exercises.ifSet(result::setExercises); + this.gradeLevel.ifSet(result::setGradeLevel); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.pageCount.ifSet(result::setPageCount); + this.publicationDate.ifSet(result::setPublicationDate); + this.publisher.ifSet(result::setPublisher); + this.subject.ifSet(result::setSubject); + 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("authorName", this.authorName) + .append("catalogId", this.catalogId) + .append("chapters", this.chapters) + .append("createdAt", this.createdAt) + .append("edition", this.edition) + .append("exercises", this.exercises) + .append("gradeLevel", this.gradeLevel) + .append("id", this.id) + .append("name", this.name) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .append("publisher", this.publisher) + .append("subject", this.subject) + .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 Textbook with(Consumer b) { + TextbookBuilder builder; + try { + builder = new TextbookBuilder(Textbook.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TextbookBuilder.With' should only be implemented by classes, which could be casted to 'Textbook'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TextbookBuilder with() { + try { + return new TextbookBuilder(Textbook.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TextbookBuilder.With' should only be implemented by classes, which could be casted to 'Textbook'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ThesisRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ThesisRecordBuilder.java new file mode 100644 index 00000000..cbe419ea --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ThesisRecordBuilder.java @@ -0,0 +1,664 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.ThesisRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.ThesisRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ThesisRecord result = ThesisRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .university("example value")
    + *     .university("Hello %s", "World")
    + *     .university(() -> "example value")
    + *     .university(sb -> sb.append("text"))
    + *     .degreeLevel("example value")
    + *     .degreeLevel("Hello %s", "World")
    + *     .degreeLevel(() -> "example value")
    + *     .degreeLevel(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .submissionDate(LocalDate.now())
    + *     .submissionDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ThesisRecord.class) +public class ThesisRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for university: university. + */ + private TrackedValue university = unsetValue(); + /** + * Tracked value for degreeLevel: degreeLevel. + */ + private TrackedValue degreeLevel = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for submissionDate: submissionDate. + */ + private TrackedValue submissionDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.ThesisRecord}. + */ + public ThesisRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ThesisRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public ThesisRecordBuilder(ThesisRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.university = initialValue(instance.university()); + this.degreeLevel = initialValue(instance.degreeLevel()); + this.pageCount = initialValue(instance.pageCount()); + this.submissionDate = initialValue(instance.submissionDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ThesisRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ThesisRecordBuilder builder = ThesisRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ThesisRecord} + */ + public static ThesisRecordBuilder create() { + return new ThesisRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public ThesisRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public ThesisRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public ThesisRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ThesisRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for degreeLevel. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.degreeLevel("example value");
    +   * }
    + * + * @param degreeLevel degreeLevel + * @return current instance of builder + */ + public ThesisRecordBuilder degreeLevel(String degreeLevel) { + this.degreeLevel = changedValue(degreeLevel); + return this; + } + + /** + * Sets the value for degreeLevel by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.degreeLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param degreeLevelStringBuilderConsumer consumer providing an instance of degreeLevel + * @return current instance of builder + */ + public ThesisRecordBuilder degreeLevel(Consumer degreeLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + degreeLevelStringBuilderConsumer.accept(builder); + this.degreeLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for degreeLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.degreeLevel(() -> "example value");
    +   * }
    + * + * @param degreeLevelSupplier supplier for degreeLevel + * @return current instance of builder + */ + public ThesisRecordBuilder degreeLevel(Supplier degreeLevelSupplier) { + this.degreeLevel = changedValue(degreeLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for degreeLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.degreeLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ThesisRecordBuilder degreeLevel(String format, Object... args) { + this.degreeLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public ThesisRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public ThesisRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for submissionDate. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.submissionDate(LocalDate.now());
    +   * }
    + * + * @param submissionDate submissionDate + * @return current instance of builder + */ + public ThesisRecordBuilder submissionDate(LocalDate submissionDate) { + this.submissionDate = changedValue(submissionDate); + return this; + } + + /** + * Sets the value for submissionDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.submissionDate(() -> LocalDate.now());
    +   * }
    + * + * @param submissionDateSupplier supplier for submissionDate + * @return current instance of builder + */ + public ThesisRecordBuilder submissionDate(Supplier submissionDateSupplier) { + this.submissionDate = changedValue(submissionDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public ThesisRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public ThesisRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public ThesisRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ThesisRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for university. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.university("example value");
    +   * }
    + * + * @param university university + * @return current instance of builder + */ + public ThesisRecordBuilder university(String university) { + this.university = changedValue(university); + return this; + } + + /** + * Sets the value for university by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.university(sb -> sb.append("text"));
    +   * }
    + * + * @param universityStringBuilderConsumer consumer providing an instance of university + * @return current instance of builder + */ + public ThesisRecordBuilder university(Consumer universityStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + universityStringBuilderConsumer.accept(builder); + this.university = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for university by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.university(() -> "example value");
    +   * }
    + * + * @param universitySupplier supplier for university + * @return current instance of builder + */ + public ThesisRecordBuilder university(Supplier universitySupplier) { + this.university = changedValue(universitySupplier.get()); + return this; + } + + /** + * Sets the String value for university by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ThesisRecord#ThesisRecord(String, String, String, String, int, LocalDate) ThesisRecord(String title, String + * authorName, String university, String degreeLevel, int pageCount, LocalDate submissionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.university("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ThesisRecordBuilder university(String format, Object... args) { + this.university = changedValue(String.format(format, args)); + 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 ThesisRecordBuilder 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 ThesisRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ThesisRecord result = builder.build();
    +   * }
    + */ + @Override + public ThesisRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + ThesisRecord result = new ThesisRecord(this.title.value(), + this.authorName.value(), + this.university.value(), + this.degreeLevel.value(), + this.pageCount.value(), + this.submissionDate.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("university", this.university) + .append("degreeLevel", this.degreeLevel) + .append("pageCount", this.pageCount) + .append("submissionDate", this.submissionDate) + .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 ThesisRecord with(Consumer b) { + ThesisRecordBuilder builder; + try { + builder = new ThesisRecordBuilder(ThesisRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ThesisRecordBuilder.With' should only be implemented by classes, which could be casted to 'ThesisRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ThesisRecordBuilder with() { + try { + return new ThesisRecordBuilder(ThesisRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ThesisRecordBuilder.With' should only be implemented by classes, which could be casted to 'ThesisRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransactionsRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransactionsRecordBuilder.java new file mode 100644 index 00000000..533fe1ac --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransactionsRecordBuilder.java @@ -0,0 +1,416 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.TransactionsRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.TransactionsRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TransactionsRecord result = TransactionsRecordBuilder.create()
    + *     .organization("example value")
    + *     .organization("Hello %s", "World")
    + *     .organization(() -> "example value")
    + *     .organization(sb -> sb.append("text"))
    + *     .volume(42)
    + *     .volume(() -> 42)
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TransactionsRecord.class) +public class TransactionsRecordBuilder implements IBuilderBase { + + /** + * Tracked value for organization: organization. + */ + private TrackedValue organization = unsetValue(); + /** + * Tracked value for volume: volume. + */ + private TrackedValue volume = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TransactionsRecord}. + */ + public TransactionsRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TransactionsRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TransactionsRecordBuilder(TransactionsRecord instance) { + this.organization = initialValue(instance.organization()); + this.volume = initialValue(instance.volume()); + this.pageCount = initialValue(instance.pageCount()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TransactionsRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TransactionsRecordBuilder builder = TransactionsRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TransactionsRecord} + */ + public static TransactionsRecordBuilder create() { + return new TransactionsRecordBuilder(); + } + + /** + * Sets the value for organization. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("example value");
    +   * }
    + * + * @param organization organization + * @return current instance of builder + */ + public TransactionsRecordBuilder organization(String organization) { + this.organization = changedValue(organization); + return this; + } + + /** + * Sets the value for organization by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(sb -> sb.append("text"));
    +   * }
    + * + * @param organizationStringBuilderConsumer consumer providing an instance of organization + * @return current instance of builder + */ + public TransactionsRecordBuilder organization(Consumer organizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizationStringBuilderConsumer.accept(builder); + this.organization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organization by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(() -> "example value");
    +   * }
    + * + * @param organizationSupplier supplier for organization + * @return current instance of builder + */ + public TransactionsRecordBuilder organization(Supplier organizationSupplier) { + this.organization = changedValue(organizationSupplier.get()); + return this; + } + + /** + * Sets the String value for organization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TransactionsRecordBuilder organization(String format, Object... args) { + this.organization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public TransactionsRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public TransactionsRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public TransactionsRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public TransactionsRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for volume. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volume(42);
    +   * }
    + * + * @param volume volume + * @return current instance of builder + */ + public TransactionsRecordBuilder volume(int volume) { + this.volume = changedValue(volume); + return this; + } + + /** + * Sets the value for volume by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TransactionsRecord#TransactionsRecord(String, int, int, LocalDate) + * TransactionsRecord(String organization, int volume, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volume(() -> 42);
    +   * }
    + * + * @param volumeSupplier supplier for volume + * @return current instance of builder + */ + public TransactionsRecordBuilder volume(Supplier volumeSupplier) { + this.volume = changedValue(volumeSupplier.get()); + 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 TransactionsRecordBuilder 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 TransactionsRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TransactionsRecord result = builder.build();
    +   * }
    + */ + @Override + public TransactionsRecord build() { + if (!this.volume.isSet()) { + throw new IllegalStateException("Required field 'volume' must be set before calling build()"); + } + if (this.volume.value() == null) { + throw new IllegalStateException("Field 'volume' is marked as non-null but null value was provided"); + } + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + TransactionsRecord result = new TransactionsRecord(this.organization.value(), + this.volume.value(), + this.pageCount.value(), + this.publicationDate.value()); + 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("organization", this.organization) + .append("volume", this.volume) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .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 TransactionsRecord with(Consumer b) { + TransactionsRecordBuilder builder; + try { + builder = new TransactionsRecordBuilder(TransactionsRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TransactionsRecordBuilder.With' should only be implemented by classes, which could be casted to 'TransactionsRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TransactionsRecordBuilder with() { + try { + return new TransactionsRecordBuilder(TransactionsRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TransactionsRecordBuilder.With' should only be implemented by classes, which could be casted to 'TransactionsRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransparencyRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransparencyRecordBuilder.java new file mode 100644 index 00000000..a316aac0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TransparencyRecordBuilder.java @@ -0,0 +1,510 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.TransparencyRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.TransparencyRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TransparencyRecord result = TransparencyRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .creator("example value")
    + *     .creator("Hello %s", "World")
    + *     .creator(() -> "example value")
    + *     .creator(sb -> sb.append("text"))
    + *     .format("example value")
    + *     .format("Hello %s", "World")
    + *     .format(() -> "example value")
    + *     .format(sb -> sb.append("text"))
    + *     .creationDate(LocalDate.now())
    + *     .creationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TransparencyRecord.class) +public class TransparencyRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for creator: creator. + */ + private TrackedValue creator = unsetValue(); + /** + * Tracked value for format: format. + */ + private TrackedValue format = unsetValue(); + /** + * Tracked value for creationDate: creationDate. + */ + private TrackedValue creationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TransparencyRecord}. + */ + public TransparencyRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TransparencyRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TransparencyRecordBuilder(TransparencyRecord instance) { + this.subject = initialValue(instance.subject()); + this.creator = initialValue(instance.creator()); + this.format = initialValue(instance.format()); + this.creationDate = initialValue(instance.creationDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TransparencyRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TransparencyRecordBuilder builder = TransparencyRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TransparencyRecord} + */ + public static TransparencyRecordBuilder create() { + return new TransparencyRecordBuilder(); + } + + /** + * Sets the value for creationDate. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(LocalDate.now());
    +   * }
    + * + * @param creationDate creationDate + * @return current instance of builder + */ + public TransparencyRecordBuilder creationDate(LocalDate creationDate) { + this.creationDate = changedValue(creationDate); + return this; + } + + /** + * Sets the value for creationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(() -> LocalDate.now());
    +   * }
    + * + * @param creationDateSupplier supplier for creationDate + * @return current instance of builder + */ + public TransparencyRecordBuilder creationDate(Supplier creationDateSupplier) { + this.creationDate = changedValue(creationDateSupplier.get()); + return this; + } + + /** + * Sets the value for creator. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator("example value");
    +   * }
    + * + * @param creator creator + * @return current instance of builder + */ + public TransparencyRecordBuilder creator(String creator) { + this.creator = changedValue(creator); + return this; + } + + /** + * Sets the value for creator by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator(sb -> sb.append("text"));
    +   * }
    + * + * @param creatorStringBuilderConsumer consumer providing an instance of creator + * @return current instance of builder + */ + public TransparencyRecordBuilder creator(Consumer creatorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + creatorStringBuilderConsumer.accept(builder); + this.creator = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for creator by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator(() -> "example value");
    +   * }
    + * + * @param creatorSupplier supplier for creator + * @return current instance of builder + */ + public TransparencyRecordBuilder creator(Supplier creatorSupplier) { + this.creator = changedValue(creatorSupplier.get()); + return this; + } + + /** + * Sets the String value for creator by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TransparencyRecordBuilder creator(String format, Object... args) { + this.creator = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for format. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("example value");
    +   * }
    + * + * @param format format + * @return current instance of builder + */ + public TransparencyRecordBuilder format(String format) { + this.format = changedValue(format); + return this; + } + + /** + * Sets the value for format by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(sb -> sb.append("text"));
    +   * }
    + * + * @param formatStringBuilderConsumer consumer providing an instance of format + * @return current instance of builder + */ + public TransparencyRecordBuilder format(Consumer formatStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + formatStringBuilderConsumer.accept(builder); + this.format = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for format by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format(() -> "example value");
    +   * }
    + * + * @param formatSupplier supplier for format + * @return current instance of builder + */ + public TransparencyRecordBuilder format(Supplier formatSupplier) { + this.format = changedValue(formatSupplier.get()); + return this; + } + + /** + * Sets the String value for format by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.format("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TransparencyRecordBuilder format(String format, Object... args) { + this.format = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public TransparencyRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public TransparencyRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public TransparencyRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TransparencyRecord#TransparencyRecord(String, String, String, LocalDate) TransparencyRecord(String subject, + * String creator, String format, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TransparencyRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 TransparencyRecordBuilder 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 TransparencyRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TransparencyRecord result = builder.build();
    +   * }
    + */ + @Override + public TransparencyRecord build() { + TransparencyRecord result = new TransparencyRecord(this.subject.value(), + this.creator.value(), + this.format.value(), + this.creationDate.value()); + 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("subject", this.subject) + .append("creator", this.creator) + .append("format", this.format) + .append("creationDate", this.creationDate) + .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 TransparencyRecord with(Consumer b) { + TransparencyRecordBuilder builder; + try { + builder = new TransparencyRecordBuilder(TransparencyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TransparencyRecordBuilder.With' should only be implemented by classes, which could be casted to 'TransparencyRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TransparencyRecordBuilder with() { + try { + return new TransparencyRecordBuilder(TransparencyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TransparencyRecordBuilder.With' should only be implemented by classes, which could be casted to 'TransparencyRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TreatiseRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TreatiseRecordBuilder.java new file mode 100644 index 00000000..58ac0bc5 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TreatiseRecordBuilder.java @@ -0,0 +1,562 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.TreatiseRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.TreatiseRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TreatiseRecord result = TreatiseRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .publicationDate(LocalDate.now())
    + *     .publicationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TreatiseRecord.class) +public class TreatiseRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for publicationDate: publicationDate. + */ + private TrackedValue publicationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TreatiseRecord}. + */ + public TreatiseRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TreatiseRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public TreatiseRecordBuilder(TreatiseRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.subject = initialValue(instance.subject()); + this.pageCount = initialValue(instance.pageCount()); + this.publicationDate = initialValue(instance.publicationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TreatiseRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TreatiseRecordBuilder builder = TreatiseRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TreatiseRecord} + */ + public static TreatiseRecordBuilder create() { + return new TreatiseRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public TreatiseRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public TreatiseRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public TreatiseRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TreatiseRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public TreatiseRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public TreatiseRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for publicationDate. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(LocalDate.now());
    +   * }
    + * + * @param publicationDate publicationDate + * @return current instance of builder + */ + public TreatiseRecordBuilder publicationDate(LocalDate publicationDate) { + this.publicationDate = changedValue(publicationDate); + return this; + } + + /** + * Sets the value for publicationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationDate(() -> LocalDate.now());
    +   * }
    + * + * @param publicationDateSupplier supplier for publicationDate + * @return current instance of builder + */ + public TreatiseRecordBuilder publicationDate(Supplier publicationDateSupplier) { + this.publicationDate = changedValue(publicationDateSupplier.get()); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public TreatiseRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public TreatiseRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public TreatiseRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TreatiseRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public TreatiseRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public TreatiseRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public TreatiseRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TreatiseRecord#TreatiseRecord(String, String, String, int, LocalDate) TreatiseRecord(String title, String + * authorName, String subject, int pageCount, LocalDate publicationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TreatiseRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 TreatiseRecordBuilder 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 TreatiseRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TreatiseRecord result = builder.build();
    +   * }
    + */ + @Override + public TreatiseRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + TreatiseRecord result = new TreatiseRecord(this.title + .value(), this.authorName.value(), this.subject.value(), this.pageCount.value(), this.publicationDate.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("subject", this.subject) + .append("pageCount", this.pageCount) + .append("publicationDate", this.publicationDate) + .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 TreatiseRecord with(Consumer b) { + TreatiseRecordBuilder builder; + try { + builder = new TreatiseRecordBuilder(TreatiseRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TreatiseRecordBuilder.With' should only be implemented by classes, which could be casted to 'TreatiseRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TreatiseRecordBuilder with() { + try { + return new TreatiseRecordBuilder(TreatiseRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TreatiseRecordBuilder.With' should only be implemented by classes, which could be casted to 'TreatiseRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TypescriptRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TypescriptRecordBuilder.java new file mode 100644 index 00000000..06d1c590 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/TypescriptRecordBuilder.java @@ -0,0 +1,455 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.TypescriptRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.TypescriptRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TypescriptRecord result = TypescriptRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .authorName("example value")
    + *     .authorName("Hello %s", "World")
    + *     .authorName(() -> "example value")
    + *     .authorName(sb -> sb.append("text"))
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .creationDate(LocalDate.now())
    + *     .creationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TypescriptRecord.class) +public class TypescriptRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for authorName: authorName. + */ + private TrackedValue authorName = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for creationDate: creationDate. + */ + private TrackedValue creationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TypescriptRecord}. + */ + public TypescriptRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.TypescriptRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TypescriptRecordBuilder(TypescriptRecord instance) { + this.title = initialValue(instance.title()); + this.authorName = initialValue(instance.authorName()); + this.pageCount = initialValue(instance.pageCount()); + this.creationDate = initialValue(instance.creationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TypescriptRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TypescriptRecordBuilder builder = TypescriptRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.TypescriptRecord} + */ + public static TypescriptRecordBuilder create() { + return new TypescriptRecordBuilder(); + } + + /** + * Sets the value for authorName. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("example value");
    +   * }
    + * + * @param authorName authorName + * @return current instance of builder + */ + public TypescriptRecordBuilder authorName(String authorName) { + this.authorName = changedValue(authorName); + return this; + } + + /** + * Sets the value for authorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(sb -> sb.append("text"));
    +   * }
    + * + * @param authorNameStringBuilderConsumer consumer providing an instance of authorName + * @return current instance of builder + */ + public TypescriptRecordBuilder authorName(Consumer authorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + authorNameStringBuilderConsumer.accept(builder); + this.authorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for authorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName(() -> "example value");
    +   * }
    + * + * @param authorNameSupplier supplier for authorName + * @return current instance of builder + */ + public TypescriptRecordBuilder authorName(Supplier authorNameSupplier) { + this.authorName = changedValue(authorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for authorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.authorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TypescriptRecordBuilder authorName(String format, Object... args) { + this.authorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for creationDate. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(LocalDate.now());
    +   * }
    + * + * @param creationDate creationDate + * @return current instance of builder + */ + public TypescriptRecordBuilder creationDate(LocalDate creationDate) { + this.creationDate = changedValue(creationDate); + return this; + } + + /** + * Sets the value for creationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(() -> LocalDate.now());
    +   * }
    + * + * @param creationDateSupplier supplier for creationDate + * @return current instance of builder + */ + public TypescriptRecordBuilder creationDate(Supplier creationDateSupplier) { + this.creationDate = changedValue(creationDateSupplier.get()); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public TypescriptRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public TypescriptRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public TypescriptRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public TypescriptRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public TypescriptRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TypescriptRecord#TypescriptRecord(String, String, int, LocalDate) + * TypescriptRecord(String title, String authorName, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TypescriptRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 TypescriptRecordBuilder 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 TypescriptRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TypescriptRecord result = builder.build();
    +   * }
    + */ + @Override + public TypescriptRecord build() { + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + TypescriptRecord result = new TypescriptRecord(this.title.value(), + this.authorName.value(), + this.pageCount.value(), + this.creationDate.value()); + 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("title", this.title) + .append("authorName", this.authorName) + .append("pageCount", this.pageCount) + .append("creationDate", this.creationDate) + .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 TypescriptRecord with(Consumer b) { + TypescriptRecordBuilder builder; + try { + builder = new TypescriptRecordBuilder(TypescriptRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TypescriptRecordBuilder.With' should only be implemented by classes, which could be casted to 'TypescriptRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TypescriptRecordBuilder with() { + try { + return new TypescriptRecordBuilder(TypescriptRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TypescriptRecordBuilder.With' should only be implemented by classes, which could be casted to 'TypescriptRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/WorksheetRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/WorksheetRecordBuilder.java new file mode 100644 index 00000000..add75afa --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/WorksheetRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.WorksheetRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.WorksheetRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * WorksheetRecord result = WorksheetRecordBuilder.create()
    + *     .subject("example value")
    + *     .subject("Hello %s", "World")
    + *     .subject(() -> "example value")
    + *     .subject(sb -> sb.append("text"))
    + *     .gradeLevel("example value")
    + *     .gradeLevel("Hello %s", "World")
    + *     .gradeLevel(() -> "example value")
    + *     .gradeLevel(sb -> sb.append("text"))
    + *     .exerciseCount(42)
    + *     .exerciseCount(() -> 42)
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .creationDate(LocalDate.now())
    + *     .creationDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WorksheetRecord.class) +public class WorksheetRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subject: subject. + */ + private TrackedValue subject = unsetValue(); + /** + * Tracked value for gradeLevel: gradeLevel. + */ + private TrackedValue gradeLevel = unsetValue(); + /** + * Tracked value for exerciseCount: exerciseCount. + */ + private TrackedValue exerciseCount = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for creationDate: creationDate. + */ + private TrackedValue creationDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.WorksheetRecord}. + */ + public WorksheetRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.items.WorksheetRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public WorksheetRecordBuilder(WorksheetRecord instance) { + this.subject = initialValue(instance.subject()); + this.gradeLevel = initialValue(instance.gradeLevel()); + this.exerciseCount = initialValue(instance.exerciseCount()); + this.pageCount = initialValue(instance.pageCount()); + this.creationDate = initialValue(instance.creationDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.WorksheetRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * WorksheetRecordBuilder builder = WorksheetRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.WorksheetRecord} + */ + public static WorksheetRecordBuilder create() { + return new WorksheetRecordBuilder(); + } + + /** + * Sets the value for creationDate. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(LocalDate.now());
    +   * }
    + * + * @param creationDate creationDate + * @return current instance of builder + */ + public WorksheetRecordBuilder creationDate(LocalDate creationDate) { + this.creationDate = changedValue(creationDate); + return this; + } + + /** + * Sets the value for creationDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creationDate(() -> LocalDate.now());
    +   * }
    + * + * @param creationDateSupplier supplier for creationDate + * @return current instance of builder + */ + public WorksheetRecordBuilder creationDate(Supplier creationDateSupplier) { + this.creationDate = changedValue(creationDateSupplier.get()); + return this; + } + + /** + * Sets the value for exerciseCount. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exerciseCount(42);
    +   * }
    + * + * @param exerciseCount exerciseCount + * @return current instance of builder + */ + public WorksheetRecordBuilder exerciseCount(int exerciseCount) { + this.exerciseCount = changedValue(exerciseCount); + return this; + } + + /** + * Sets the value for exerciseCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exerciseCount(() -> 42);
    +   * }
    + * + * @param exerciseCountSupplier supplier for exerciseCount + * @return current instance of builder + */ + public WorksheetRecordBuilder exerciseCount(Supplier exerciseCountSupplier) { + this.exerciseCount = changedValue(exerciseCountSupplier.get()); + return this; + } + + /** + * Sets the value for gradeLevel. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel("example value");
    +   * }
    + * + * @param gradeLevel gradeLevel + * @return current instance of builder + */ + public WorksheetRecordBuilder gradeLevel(String gradeLevel) { + this.gradeLevel = changedValue(gradeLevel); + return this; + } + + /** + * Sets the value for gradeLevel by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param gradeLevelStringBuilderConsumer consumer providing an instance of gradeLevel + * @return current instance of builder + */ + public WorksheetRecordBuilder gradeLevel(Consumer gradeLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + gradeLevelStringBuilderConsumer.accept(builder); + this.gradeLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for gradeLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel(() -> "example value");
    +   * }
    + * + * @param gradeLevelSupplier supplier for gradeLevel + * @return current instance of builder + */ + public WorksheetRecordBuilder gradeLevel(Supplier gradeLevelSupplier) { + this.gradeLevel = changedValue(gradeLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for gradeLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WorksheetRecordBuilder gradeLevel(String format, Object... args) { + this.gradeLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public WorksheetRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public WorksheetRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for subject. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("example value");
    +   * }
    + * + * @param subject subject + * @return current instance of builder + */ + public WorksheetRecordBuilder subject(String subject) { + this.subject = changedValue(subject); + return this; + } + + /** + * Sets the value for subject by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(sb -> sb.append("text"));
    +   * }
    + * + * @param subjectStringBuilderConsumer consumer providing an instance of subject + * @return current instance of builder + */ + public WorksheetRecordBuilder subject(Consumer subjectStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subjectStringBuilderConsumer.accept(builder); + this.subject = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subject by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject(() -> "example value");
    +   * }
    + * + * @param subjectSupplier supplier for subject + * @return current instance of builder + */ + public WorksheetRecordBuilder subject(Supplier subjectSupplier) { + this.subject = changedValue(subjectSupplier.get()); + return this; + } + + /** + * Sets the String value for subject by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WorksheetRecord#WorksheetRecord(String, String, int, int, LocalDate) + * WorksheetRecord(String subject, String gradeLevel, int exerciseCount, int pageCount, LocalDate creationDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subject("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WorksheetRecordBuilder subject(String format, Object... args) { + this.subject = changedValue(String.format(format, args)); + 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 WorksheetRecordBuilder 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 WorksheetRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WorksheetRecord result = builder.build();
    +   * }
    + */ + @Override + public WorksheetRecord build() { + if (!this.exerciseCount.isSet()) { + throw new IllegalStateException("Required field 'exerciseCount' must be set before calling build()"); + } + if (this.exerciseCount.value() == null) { + throw new IllegalStateException("Field 'exerciseCount' is marked as non-null but null value was provided"); + } + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + WorksheetRecord result = new WorksheetRecord(this.subject.value(), + this.gradeLevel.value(), + this.exerciseCount.value(), + this.pageCount.value(), + this.creationDate.value()); + 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("subject", this.subject) + .append("gradeLevel", this.gradeLevel) + .append("exerciseCount", this.exerciseCount) + .append("pageCount", this.pageCount) + .append("creationDate", this.creationDate) + .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 WorksheetRecord with(Consumer b) { + WorksheetRecordBuilder builder; + try { + builder = new WorksheetRecordBuilder(WorksheetRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WorksheetRecordBuilder.With' should only be implemented by classes, which could be casted to 'WorksheetRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WorksheetRecordBuilder with() { + try { + return new WorksheetRecordBuilder(WorksheetRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WorksheetRecordBuilder.With' should only be implemented by classes, which could be casted to 'WorksheetRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ZineRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ZineRecordBuilder.java new file mode 100644 index 00000000..05415952 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/items/ZineRecordBuilder.java @@ -0,0 +1,505 @@ +package org.javahelpers.simple.builders.performance_test.library.items; + +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.time.LocalDate; +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.performance_test.library.items.ZineRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.items.ZineRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ZineRecord result = ZineRecordBuilder.create()
    + *     .title("example value")
    + *     .title("Hello %s", "World")
    + *     .title(() -> "example value")
    + *     .title(sb -> sb.append("text"))
    + *     .creator("example value")
    + *     .creator("Hello %s", "World")
    + *     .creator(() -> "example value")
    + *     .creator(sb -> sb.append("text"))
    + *     .issueNumber(42)
    + *     .issueNumber(() -> 42)
    + *     .pageCount(42)
    + *     .pageCount(() -> 42)
    + *     .productionDate(LocalDate.now())
    + *     .productionDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ZineRecord.class) +public class ZineRecordBuilder implements IBuilderBase { + + /** + * Tracked value for title: title. + */ + private TrackedValue title = unsetValue(); + /** + * Tracked value for creator: creator. + */ + private TrackedValue creator = unsetValue(); + /** + * Tracked value for issueNumber: issueNumber. + */ + private TrackedValue issueNumber = unsetValue(); + /** + * Tracked value for pageCount: pageCount. + */ + private TrackedValue pageCount = unsetValue(); + /** + * Tracked value for productionDate: productionDate. + */ + private TrackedValue productionDate = unsetValue(); + + /** + * Empty constructor of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ZineRecord}. + */ + public ZineRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ZineRecord} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public ZineRecordBuilder(ZineRecord instance) { + this.title = initialValue(instance.title()); + this.creator = initialValue(instance.creator()); + this.issueNumber = initialValue(instance.issueNumber()); + this.pageCount = initialValue(instance.pageCount()); + this.productionDate = initialValue(instance.productionDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ZineRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ZineRecordBuilder builder = ZineRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.items.ZineRecord} + */ + public static ZineRecordBuilder create() { + return new ZineRecordBuilder(); + } + + /** + * Sets the value for creator. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator("example value");
    +   * }
    + * + * @param creator creator + * @return current instance of builder + */ + public ZineRecordBuilder creator(String creator) { + this.creator = changedValue(creator); + return this; + } + + /** + * Sets the value for creator by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator(sb -> sb.append("text"));
    +   * }
    + * + * @param creatorStringBuilderConsumer consumer providing an instance of creator + * @return current instance of builder + */ + public ZineRecordBuilder creator(Consumer creatorStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + creatorStringBuilderConsumer.accept(builder); + this.creator = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for creator by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator(() -> "example value");
    +   * }
    + * + * @param creatorSupplier supplier for creator + * @return current instance of builder + */ + public ZineRecordBuilder creator(Supplier creatorSupplier) { + this.creator = changedValue(creatorSupplier.get()); + return this; + } + + /** + * Sets the String value for creator by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.creator("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ZineRecordBuilder creator(String format, Object... args) { + this.creator = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for issueNumber. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issueNumber(42);
    +   * }
    + * + * @param issueNumber issueNumber + * @return current instance of builder + */ + public ZineRecordBuilder issueNumber(int issueNumber) { + this.issueNumber = changedValue(issueNumber); + return this; + } + + /** + * Sets the value for issueNumber by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issueNumber(() -> 42);
    +   * }
    + * + * @param issueNumberSupplier supplier for issueNumber + * @return current instance of builder + */ + public ZineRecordBuilder issueNumber(Supplier issueNumberSupplier) { + this.issueNumber = changedValue(issueNumberSupplier.get()); + return this; + } + + /** + * Sets the value for pageCount. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(42);
    +   * }
    + * + * @param pageCount pageCount + * @return current instance of builder + */ + public ZineRecordBuilder pageCount(int pageCount) { + this.pageCount = changedValue(pageCount); + return this; + } + + /** + * Sets the value for pageCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pageCount(() -> 42);
    +   * }
    + * + * @param pageCountSupplier supplier for pageCount + * @return current instance of builder + */ + public ZineRecordBuilder pageCount(Supplier pageCountSupplier) { + this.pageCount = changedValue(pageCountSupplier.get()); + return this; + } + + /** + * Sets the value for productionDate. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionDate(LocalDate.now());
    +   * }
    + * + * @param productionDate productionDate + * @return current instance of builder + */ + public ZineRecordBuilder productionDate(LocalDate productionDate) { + this.productionDate = changedValue(productionDate); + return this; + } + + /** + * Sets the value for productionDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionDate(() -> LocalDate.now());
    +   * }
    + * + * @param productionDateSupplier supplier for productionDate + * @return current instance of builder + */ + public ZineRecordBuilder productionDate(Supplier productionDateSupplier) { + this.productionDate = changedValue(productionDateSupplier.get()); + return this; + } + + /** + * Sets the value for title. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("example value");
    +   * }
    + * + * @param title title + * @return current instance of builder + */ + public ZineRecordBuilder title(String title) { + this.title = changedValue(title); + return this; + } + + /** + * Sets the value for title by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(sb -> sb.append("text"));
    +   * }
    + * + * @param titleStringBuilderConsumer consumer providing an instance of title + * @return current instance of builder + */ + public ZineRecordBuilder title(Consumer titleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + titleStringBuilderConsumer.accept(builder); + this.title = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for title by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title(() -> "example value");
    +   * }
    + * + * @param titleSupplier supplier for title + * @return current instance of builder + */ + public ZineRecordBuilder title(Supplier titleSupplier) { + this.title = changedValue(titleSupplier.get()); + return this; + } + + /** + * Sets the String value for title by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ZineRecord#ZineRecord(String, String, int, int, LocalDate) + * ZineRecord(String title, String creator, int issueNumber, int pageCount, LocalDate productionDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.title("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ZineRecordBuilder title(String format, Object... args) { + this.title = changedValue(String.format(format, args)); + 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 ZineRecordBuilder 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 ZineRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ZineRecord result = builder.build();
    +   * }
    + */ + @Override + public ZineRecord build() { + if (!this.issueNumber.isSet()) { + throw new IllegalStateException("Required field 'issueNumber' must be set before calling build()"); + } + if (this.issueNumber.value() == null) { + throw new IllegalStateException("Field 'issueNumber' is marked as non-null but null value was provided"); + } + if (!this.pageCount.isSet()) { + throw new IllegalStateException("Required field 'pageCount' must be set before calling build()"); + } + if (this.pageCount.value() == null) { + throw new IllegalStateException("Field 'pageCount' is marked as non-null but null value was provided"); + } + ZineRecord result = new ZineRecord(this.title + .value(), this.creator.value(), this.issueNumber.value(), this.pageCount.value(), this.productionDate.value()); + 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("title", this.title) + .append("creator", this.creator) + .append("issueNumber", this.issueNumber) + .append("pageCount", this.pageCount) + .append("productionDate", this.productionDate) + .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 ZineRecord with(Consumer b) { + ZineRecordBuilder builder; + try { + builder = new ZineRecordBuilder(ZineRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ZineRecordBuilder.With' should only be implemented by classes, which could be casted to 'ZineRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ZineRecordBuilder with() { + try { + return new ZineRecordBuilder(ZineRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ZineRecordBuilder.With' should only be implemented by classes, which could be casted to 'ZineRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/MountRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/MountRecordBuilder.java new file mode 100644 index 00000000..861e5243 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/MountRecordBuilder.java @@ -0,0 +1,551 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.MountRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.MountRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MountRecord result = MountRecordBuilder.create()
    + *     .mountName("example value")
    + *     .mountName("Hello %s", "World")
    + *     .mountName(() -> "example value")
    + *     .mountName(sb -> sb.append("text"))
    + *     .mountType("example value")
    + *     .mountType("Hello %s", "World")
    + *     .mountType(() -> "example value")
    + *     .mountType(sb -> sb.append("text"))
    + *     .weightCapacityKg(3.14)
    + *     .weightCapacityKg(() -> 3.14)
    + *     .hasSwivel(true)
    + *     .hasSwivel(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MountRecord.class) +public class MountRecordBuilder implements IBuilderBase { + + /** + * Tracked value for mountName: mountName. + */ + private TrackedValue mountName = unsetValue(); + /** + * Tracked value for mountType: mountType. + */ + private TrackedValue mountType = unsetValue(); + /** + * Tracked value for weightCapacityKg: weightCapacityKg. + */ + private TrackedValue weightCapacityKg = unsetValue(); + /** + * Tracked value for hasSwivel: hasSwivel. + */ + private TrackedValue hasSwivel = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.MountRecord}. + */ + public MountRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.MountRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public MountRecordBuilder(MountRecord instance) { + this.mountName = initialValue(instance.mountName()); + this.mountType = initialValue(instance.mountType()); + this.weightCapacityKg = initialValue(instance.weightCapacityKg()); + this.hasSwivel = initialValue(instance.hasSwivel()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.MountRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MountRecordBuilder builder = MountRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.MountRecord} + */ + public static MountRecordBuilder create() { + return new MountRecordBuilder(); + } + + /** + * Sets the value for hasSwivel. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSwivel(true);
    +   * }
    + * + * @param hasSwivel hasSwivel + * @return current instance of builder + */ + public MountRecordBuilder hasSwivel(boolean hasSwivel) { + this.hasSwivel = changedValue(hasSwivel); + return this; + } + + /** + * Sets the value for hasSwivel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSwivel(() -> true);
    +   * }
    + * + * @param hasSwivelSupplier supplier for hasSwivel + * @return current instance of builder + */ + public MountRecordBuilder hasSwivel(Supplier hasSwivelSupplier) { + this.hasSwivel = changedValue(hasSwivelSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public MountRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public MountRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public MountRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MountRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for mountName. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountName("example value");
    +   * }
    + * + * @param mountName mountName + * @return current instance of builder + */ + public MountRecordBuilder mountName(String mountName) { + this.mountName = changedValue(mountName); + return this; + } + + /** + * Sets the value for mountName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountName(sb -> sb.append("text"));
    +   * }
    + * + * @param mountNameStringBuilderConsumer consumer providing an instance of mountName + * @return current instance of builder + */ + public MountRecordBuilder mountName(Consumer mountNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + mountNameStringBuilderConsumer.accept(builder); + this.mountName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for mountName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountName(() -> "example value");
    +   * }
    + * + * @param mountNameSupplier supplier for mountName + * @return current instance of builder + */ + public MountRecordBuilder mountName(Supplier mountNameSupplier) { + this.mountName = changedValue(mountNameSupplier.get()); + return this; + } + + /** + * Sets the String value for mountName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MountRecordBuilder mountName(String format, Object... args) { + this.mountName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for mountType. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountType("example value");
    +   * }
    + * + * @param mountType mountType + * @return current instance of builder + */ + public MountRecordBuilder mountType(String mountType) { + this.mountType = changedValue(mountType); + return this; + } + + /** + * Sets the value for mountType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountType(sb -> sb.append("text"));
    +   * }
    + * + * @param mountTypeStringBuilderConsumer consumer providing an instance of mountType + * @return current instance of builder + */ + public MountRecordBuilder mountType(Consumer mountTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + mountTypeStringBuilderConsumer.accept(builder); + this.mountType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for mountType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountType(() -> "example value");
    +   * }
    + * + * @param mountTypeSupplier supplier for mountType + * @return current instance of builder + */ + public MountRecordBuilder mountType(Supplier mountTypeSupplier) { + this.mountType = changedValue(mountTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for mountType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mountType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MountRecordBuilder mountType(String format, Object... args) { + this.mountType = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for weightCapacityKg. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.weightCapacityKg(3.14);
    +   * }
    + * + * @param weightCapacityKg weightCapacityKg + * @return current instance of builder + */ + public MountRecordBuilder weightCapacityKg(double weightCapacityKg) { + this.weightCapacityKg = changedValue(weightCapacityKg); + return this; + } + + /** + * Sets the value for weightCapacityKg by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MountRecord#MountRecord(String, String, double, boolean, String) + * MountRecord(String mountName, String mountType, double weightCapacityKg, boolean hasSwivel, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.weightCapacityKg(() -> 3.14);
    +   * }
    + * + * @param weightCapacityKgSupplier supplier for weightCapacityKg + * @return current instance of builder + */ + public MountRecordBuilder weightCapacityKg(Supplier weightCapacityKgSupplier) { + this.weightCapacityKg = changedValue(weightCapacityKgSupplier.get()); + 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 MountRecordBuilder 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 MountRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MountRecord result = builder.build();
    +   * }
    + */ + @Override + public MountRecord build() { + if (!this.weightCapacityKg.isSet()) { + throw new IllegalStateException("Required field 'weightCapacityKg' must be set before calling build()"); + } + if (this.weightCapacityKg.value() == null) { + throw new IllegalStateException("Field 'weightCapacityKg' is marked as non-null but null value was provided"); + } + if (!this.hasSwivel.isSet()) { + throw new IllegalStateException("Required field 'hasSwivel' must be set before calling build()"); + } + if (this.hasSwivel.value() == null) { + throw new IllegalStateException("Field 'hasSwivel' is marked as non-null but null value was provided"); + } + MountRecord result = new MountRecord(this.mountName + .value(), this.mountType.value(), this.weightCapacityKg.value(), this.hasSwivel.value(), this.material.value()); + 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("mountName", this.mountName) + .append("mountType", this.mountType) + .append("weightCapacityKg", this.weightCapacityKg) + .append("hasSwivel", this.hasSwivel) + .append("material", this.material) + .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 MountRecord with(Consumer b) { + MountRecordBuilder builder; + try { + builder = new MountRecordBuilder(MountRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MountRecordBuilder.With' should only be implemented by classes, which could be casted to 'MountRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MountRecordBuilder with() { + try { + return new MountRecordBuilder(MountRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MountRecordBuilder.With' should only be implemented by classes, which could be casted to 'MountRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PanelRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PanelRecordBuilder.java new file mode 100644 index 00000000..596afba4 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PanelRecordBuilder.java @@ -0,0 +1,511 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PanelRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PanelRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PanelRecord result = PanelRecordBuilder.create()
    + *     .panelName("example value")
    + *     .panelName("Hello %s", "World")
    + *     .panelName(() -> "example value")
    + *     .panelName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .thicknessCm(3.14)
    + *     .thicknessCm(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PanelRecord.class) +public class PanelRecordBuilder implements IBuilderBase { + + /** + * Tracked value for panelName: panelName. + */ + private TrackedValue panelName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for thicknessCm: thicknessCm. + */ + private TrackedValue thicknessCm = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PanelRecord}. + */ + public PanelRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PanelRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PanelRecordBuilder(PanelRecord instance) { + this.panelName = initialValue(instance.panelName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.thicknessCm = initialValue(instance.thicknessCm()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PanelRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PanelRecordBuilder builder = PanelRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PanelRecord} + */ + public static PanelRecordBuilder create() { + return new PanelRecordBuilder(); + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public PanelRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public PanelRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PanelRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PanelRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PanelRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PanelRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for panelName. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.panelName("example value");
    +   * }
    + * + * @param panelName panelName + * @return current instance of builder + */ + public PanelRecordBuilder panelName(String panelName) { + this.panelName = changedValue(panelName); + return this; + } + + /** + * Sets the value for panelName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.panelName(sb -> sb.append("text"));
    +   * }
    + * + * @param panelNameStringBuilderConsumer consumer providing an instance of panelName + * @return current instance of builder + */ + public PanelRecordBuilder panelName(Consumer panelNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + panelNameStringBuilderConsumer.accept(builder); + this.panelName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for panelName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.panelName(() -> "example value");
    +   * }
    + * + * @param panelNameSupplier supplier for panelName + * @return current instance of builder + */ + public PanelRecordBuilder panelName(Supplier panelNameSupplier) { + this.panelName = changedValue(panelNameSupplier.get()); + return this; + } + + /** + * Sets the String value for panelName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.panelName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PanelRecordBuilder panelName(String format, Object... args) { + this.panelName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for thicknessCm. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.thicknessCm(3.14);
    +   * }
    + * + * @param thicknessCm thicknessCm + * @return current instance of builder + */ + public PanelRecordBuilder thicknessCm(double thicknessCm) { + this.thicknessCm = changedValue(thicknessCm); + return this; + } + + /** + * Sets the value for thicknessCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.thicknessCm(() -> 3.14);
    +   * }
    + * + * @param thicknessCmSupplier supplier for thicknessCm + * @return current instance of builder + */ + public PanelRecordBuilder thicknessCm(Supplier thicknessCmSupplier) { + this.thicknessCm = changedValue(thicknessCmSupplier.get()); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public PanelRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PanelRecord#PanelRecord(String, double, double, double, String) + * PanelRecord(String panelName, double widthCm, double heightCm, double thicknessCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public PanelRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 PanelRecordBuilder 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 PanelRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PanelRecord result = builder.build();
    +   * }
    + */ + @Override + public PanelRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.thicknessCm.isSet()) { + throw new IllegalStateException("Required field 'thicknessCm' must be set before calling build()"); + } + if (this.thicknessCm.value() == null) { + throw new IllegalStateException("Field 'thicknessCm' is marked as non-null but null value was provided"); + } + PanelRecord result = new PanelRecord(this.panelName + .value(), this.widthCm.value(), this.heightCm.value(), this.thicknessCm.value(), this.material.value()); + 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("panelName", this.panelName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("thicknessCm", this.thicknessCm) + .append("material", this.material) + .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 PanelRecord with(Consumer b) { + PanelRecordBuilder builder; + try { + builder = new PanelRecordBuilder(PanelRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PanelRecordBuilder.With' should only be implemented by classes, which could be casted to 'PanelRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PanelRecordBuilder with() { + try { + return new PanelRecordBuilder(PanelRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PanelRecordBuilder.With' should only be implemented by classes, which could be casted to 'PanelRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PartitionRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PartitionRecordBuilder.java new file mode 100644 index 00000000..6efb4444 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PartitionRecordBuilder.java @@ -0,0 +1,520 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PartitionRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PartitionRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PartitionRecord result = PartitionRecordBuilder.create()
    + *     .partitionName("example value")
    + *     .partitionName("Hello %s", "World")
    + *     .partitionName(() -> "example value")
    + *     .partitionName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .isMovable(true)
    + *     .isMovable(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PartitionRecord.class) +public class PartitionRecordBuilder implements IBuilderBase { + + /** + * Tracked value for partitionName: partitionName. + */ + private TrackedValue partitionName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for isMovable: isMovable. + */ + private TrackedValue isMovable = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PartitionRecord}. + */ + public PartitionRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PartitionRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PartitionRecordBuilder(PartitionRecord instance) { + this.partitionName = initialValue(instance.partitionName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.isMovable = initialValue(instance.isMovable()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PartitionRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PartitionRecordBuilder builder = PartitionRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PartitionRecord} + */ + public static PartitionRecordBuilder create() { + return new PartitionRecordBuilder(); + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public PartitionRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public PartitionRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for isMovable. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isMovable(true);
    +   * }
    + * + * @param isMovable isMovable + * @return current instance of builder + */ + public PartitionRecordBuilder isMovable(boolean isMovable) { + this.isMovable = changedValue(isMovable); + return this; + } + + /** + * Sets the value for isMovable by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isMovable(() -> true);
    +   * }
    + * + * @param isMovableSupplier supplier for isMovable + * @return current instance of builder + */ + public PartitionRecordBuilder isMovable(Supplier isMovableSupplier) { + this.isMovable = changedValue(isMovableSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PartitionRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PartitionRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PartitionRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PartitionRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for partitionName. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partitionName("example value");
    +   * }
    + * + * @param partitionName partitionName + * @return current instance of builder + */ + public PartitionRecordBuilder partitionName(String partitionName) { + this.partitionName = changedValue(partitionName); + return this; + } + + /** + * Sets the value for partitionName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partitionName(sb -> sb.append("text"));
    +   * }
    + * + * @param partitionNameStringBuilderConsumer consumer providing an instance of partitionName + * @return current instance of builder + */ + public PartitionRecordBuilder partitionName(Consumer partitionNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + partitionNameStringBuilderConsumer.accept(builder); + this.partitionName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for partitionName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partitionName(() -> "example value");
    +   * }
    + * + * @param partitionNameSupplier supplier for partitionName + * @return current instance of builder + */ + public PartitionRecordBuilder partitionName(Supplier partitionNameSupplier) { + this.partitionName = changedValue(partitionNameSupplier.get()); + return this; + } + + /** + * Sets the String value for partitionName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partitionName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PartitionRecordBuilder partitionName(String format, Object... args) { + this.partitionName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public PartitionRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartitionRecord#PartitionRecord(String, double, double, boolean, String) PartitionRecord(String + * partitionName, double widthCm, double heightCm, boolean isMovable, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public PartitionRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 PartitionRecordBuilder 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 PartitionRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PartitionRecord result = builder.build();
    +   * }
    + */ + @Override + public PartitionRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + PartitionRecord result = new PartitionRecord(this.partitionName + .value(), this.widthCm.value(), this.heightCm.value(), this.isMovable.valueOr(true), this.material.value()); + 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("partitionName", this.partitionName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("isMovable", this.isMovable) + .append("material", this.material) + .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 PartitionRecord with(Consumer b) { + PartitionRecordBuilder builder; + try { + builder = new PartitionRecordBuilder(PartitionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PartitionRecordBuilder.With' should only be implemented by classes, which could be casted to 'PartitionRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PartitionRecordBuilder with() { + try { + return new PartitionRecordBuilder(PartitionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PartitionRecordBuilder.With' should only be implemented by classes, which could be casted to 'PartitionRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PassageRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PassageRecordBuilder.java new file mode 100644 index 00000000..d4672112 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PassageRecordBuilder.java @@ -0,0 +1,595 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PassageRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PassageRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PassageRecord result = PassageRecordBuilder.create()
    + *     .passageName("example value")
    + *     .passageName("Hello %s", "World")
    + *     .passageName(() -> "example value")
    + *     .passageName(sb -> sb.append("text"))
    + *     .connectsFrom("example value")
    + *     .connectsFrom("Hello %s", "World")
    + *     .connectsFrom(() -> "example value")
    + *     .connectsFrom(sb -> sb.append("text"))
    + *     .connectsTo("example value")
    + *     .connectsTo("Hello %s", "World")
    + *     .connectsTo(() -> "example value")
    + *     .connectsTo(sb -> sb.append("text"))
    + *     .lengthMeters(3.14)
    + *     .lengthMeters(() -> 3.14)
    + *     .accessLevel("example value")
    + *     .accessLevel("Hello %s", "World")
    + *     .accessLevel(() -> "example value")
    + *     .accessLevel(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PassageRecord.class) +public class PassageRecordBuilder implements IBuilderBase { + + /** + * Tracked value for passageName: passageName. + */ + private TrackedValue passageName = unsetValue(); + /** + * Tracked value for connectsFrom: connectsFrom. + */ + private TrackedValue connectsFrom = unsetValue(); + /** + * Tracked value for connectsTo: connectsTo. + */ + private TrackedValue connectsTo = unsetValue(); + /** + * Tracked value for lengthMeters: lengthMeters. + */ + private TrackedValue lengthMeters = unsetValue(); + /** + * Tracked value for accessLevel: accessLevel. + */ + private TrackedValue accessLevel = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PassageRecord}. + */ + public PassageRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PassageRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PassageRecordBuilder(PassageRecord instance) { + this.passageName = initialValue(instance.passageName()); + this.connectsFrom = initialValue(instance.connectsFrom()); + this.connectsTo = initialValue(instance.connectsTo()); + this.lengthMeters = initialValue(instance.lengthMeters()); + this.accessLevel = initialValue(instance.accessLevel()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PassageRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PassageRecordBuilder builder = PassageRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PassageRecord} + */ + public static PassageRecordBuilder create() { + return new PassageRecordBuilder(); + } + + /** + * Sets the value for accessLevel. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel("example value");
    +   * }
    + * + * @param accessLevel accessLevel + * @return current instance of builder + */ + public PassageRecordBuilder accessLevel(String accessLevel) { + this.accessLevel = changedValue(accessLevel); + return this; + } + + /** + * Sets the value for accessLevel by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param accessLevelStringBuilderConsumer consumer providing an instance of accessLevel + * @return current instance of builder + */ + public PassageRecordBuilder accessLevel(Consumer accessLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + accessLevelStringBuilderConsumer.accept(builder); + this.accessLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for accessLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel(() -> "example value");
    +   * }
    + * + * @param accessLevelSupplier supplier for accessLevel + * @return current instance of builder + */ + public PassageRecordBuilder accessLevel(Supplier accessLevelSupplier) { + this.accessLevel = changedValue(accessLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for accessLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PassageRecordBuilder accessLevel(String format, Object... args) { + this.accessLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for connectsFrom. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsFrom("example value");
    +   * }
    + * + * @param connectsFrom connectsFrom + * @return current instance of builder + */ + public PassageRecordBuilder connectsFrom(String connectsFrom) { + this.connectsFrom = changedValue(connectsFrom); + return this; + } + + /** + * Sets the value for connectsFrom by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsFrom(sb -> sb.append("text"));
    +   * }
    + * + * @param connectsFromStringBuilderConsumer consumer providing an instance of connectsFrom + * @return current instance of builder + */ + public PassageRecordBuilder connectsFrom(Consumer connectsFromStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + connectsFromStringBuilderConsumer.accept(builder); + this.connectsFrom = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for connectsFrom by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsFrom(() -> "example value");
    +   * }
    + * + * @param connectsFromSupplier supplier for connectsFrom + * @return current instance of builder + */ + public PassageRecordBuilder connectsFrom(Supplier connectsFromSupplier) { + this.connectsFrom = changedValue(connectsFromSupplier.get()); + return this; + } + + /** + * Sets the String value for connectsFrom by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsFrom("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PassageRecordBuilder connectsFrom(String format, Object... args) { + this.connectsFrom = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for connectsTo. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsTo("example value");
    +   * }
    + * + * @param connectsTo connectsTo + * @return current instance of builder + */ + public PassageRecordBuilder connectsTo(String connectsTo) { + this.connectsTo = changedValue(connectsTo); + return this; + } + + /** + * Sets the value for connectsTo by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsTo(sb -> sb.append("text"));
    +   * }
    + * + * @param connectsToStringBuilderConsumer consumer providing an instance of connectsTo + * @return current instance of builder + */ + public PassageRecordBuilder connectsTo(Consumer connectsToStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + connectsToStringBuilderConsumer.accept(builder); + this.connectsTo = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for connectsTo by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsTo(() -> "example value");
    +   * }
    + * + * @param connectsToSupplier supplier for connectsTo + * @return current instance of builder + */ + public PassageRecordBuilder connectsTo(Supplier connectsToSupplier) { + this.connectsTo = changedValue(connectsToSupplier.get()); + return this; + } + + /** + * Sets the String value for connectsTo by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.connectsTo("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PassageRecordBuilder connectsTo(String format, Object... args) { + this.connectsTo = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for lengthMeters. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(3.14);
    +   * }
    + * + * @param lengthMeters lengthMeters + * @return current instance of builder + */ + public PassageRecordBuilder lengthMeters(double lengthMeters) { + this.lengthMeters = changedValue(lengthMeters); + return this; + } + + /** + * Sets the value for lengthMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(() -> 3.14);
    +   * }
    + * + * @param lengthMetersSupplier supplier for lengthMeters + * @return current instance of builder + */ + public PassageRecordBuilder lengthMeters(Supplier lengthMetersSupplier) { + this.lengthMeters = changedValue(lengthMetersSupplier.get()); + return this; + } + + /** + * Sets the value for passageName. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.passageName("example value");
    +   * }
    + * + * @param passageName passageName + * @return current instance of builder + */ + public PassageRecordBuilder passageName(String passageName) { + this.passageName = changedValue(passageName); + return this; + } + + /** + * Sets the value for passageName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.passageName(sb -> sb.append("text"));
    +   * }
    + * + * @param passageNameStringBuilderConsumer consumer providing an instance of passageName + * @return current instance of builder + */ + public PassageRecordBuilder passageName(Consumer passageNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + passageNameStringBuilderConsumer.accept(builder); + this.passageName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for passageName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.passageName(() -> "example value");
    +   * }
    + * + * @param passageNameSupplier supplier for passageName + * @return current instance of builder + */ + public PassageRecordBuilder passageName(Supplier passageNameSupplier) { + this.passageName = changedValue(passageNameSupplier.get()); + return this; + } + + /** + * Sets the String value for passageName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PassageRecord#PassageRecord(String, String, String, double, String) + * PassageRecord(String passageName, String connectsFrom, String connectsTo, double lengthMeters, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.passageName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PassageRecordBuilder passageName(String format, Object... args) { + this.passageName = changedValue(String.format(format, args)); + 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 PassageRecordBuilder 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 PassageRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PassageRecord result = builder.build();
    +   * }
    + */ + @Override + public PassageRecord build() { + if (!this.lengthMeters.isSet()) { + throw new IllegalStateException("Required field 'lengthMeters' must be set before calling build()"); + } + if (this.lengthMeters.value() == null) { + throw new IllegalStateException("Field 'lengthMeters' is marked as non-null but null value was provided"); + } + PassageRecord result = new PassageRecord(this.passageName.value(), + this.connectsFrom.value(), + this.connectsTo.value(), + this.lengthMeters.value(), + this.accessLevel.value()); + 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("passageName", this.passageName) + .append("connectsFrom", this.connectsFrom) + .append("connectsTo", this.connectsTo) + .append("lengthMeters", this.lengthMeters) + .append("accessLevel", this.accessLevel) + .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 PassageRecord with(Consumer b) { + PassageRecordBuilder builder; + try { + builder = new PassageRecordBuilder(PassageRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PassageRecordBuilder.With' should only be implemented by classes, which could be casted to 'PassageRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PassageRecordBuilder with() { + try { + return new PassageRecordBuilder(PassageRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PassageRecordBuilder.With' should only be implemented by classes, which could be casted to 'PassageRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PatioRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PatioRecordBuilder.java new file mode 100644 index 00000000..f0775954 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PatioRecordBuilder.java @@ -0,0 +1,468 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PatioRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PatioRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PatioRecord result = PatioRecordBuilder.create()
    + *     .patioName("example value")
    + *     .patioName("Hello %s", "World")
    + *     .patioName(() -> "example value")
    + *     .patioName(sb -> sb.append("text"))
    + *     .areaSquareMeters(3.14)
    + *     .areaSquareMeters(() -> 3.14)
    + *     .hasGarden(true)
    + *     .hasGarden(() -> true)
    + *     .hasSeating(true)
    + *     .hasSeating(() -> true)
    + *     .floorLevel(42)
    + *     .floorLevel(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PatioRecord.class) +public class PatioRecordBuilder implements IBuilderBase { + + /** + * Tracked value for patioName: patioName. + */ + private TrackedValue patioName = unsetValue(); + /** + * Tracked value for areaSquareMeters: areaSquareMeters. + */ + private TrackedValue areaSquareMeters = unsetValue(); + /** + * Tracked value for hasGarden: hasGarden. + */ + private TrackedValue hasGarden = unsetValue(); + /** + * Tracked value for hasSeating: hasSeating. + */ + private TrackedValue hasSeating = unsetValue(); + /** + * Tracked value for floorLevel: floorLevel. + */ + private TrackedValue floorLevel = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PatioRecord}. + */ + public PatioRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PatioRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PatioRecordBuilder(PatioRecord instance) { + this.patioName = initialValue(instance.patioName()); + this.areaSquareMeters = initialValue(instance.areaSquareMeters()); + this.hasGarden = initialValue(instance.hasGarden()); + this.hasSeating = initialValue(instance.hasSeating()); + this.floorLevel = initialValue(instance.floorLevel()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PatioRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PatioRecordBuilder builder = PatioRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PatioRecord} + */ + public static PatioRecordBuilder create() { + return new PatioRecordBuilder(); + } + + /** + * Sets the value for areaSquareMeters. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(3.14);
    +   * }
    + * + * @param areaSquareMeters areaSquareMeters + * @return current instance of builder + */ + public PatioRecordBuilder areaSquareMeters(double areaSquareMeters) { + this.areaSquareMeters = changedValue(areaSquareMeters); + return this; + } + + /** + * Sets the value for areaSquareMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(() -> 3.14);
    +   * }
    + * + * @param areaSquareMetersSupplier supplier for areaSquareMeters + * @return current instance of builder + */ + public PatioRecordBuilder areaSquareMeters(Supplier areaSquareMetersSupplier) { + this.areaSquareMeters = changedValue(areaSquareMetersSupplier.get()); + return this; + } + + /** + * Sets the value for floorLevel. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(42);
    +   * }
    + * + * @param floorLevel floorLevel + * @return current instance of builder + */ + public PatioRecordBuilder floorLevel(int floorLevel) { + this.floorLevel = changedValue(floorLevel); + return this; + } + + /** + * Sets the value for floorLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(() -> 42);
    +   * }
    + * + * @param floorLevelSupplier supplier for floorLevel + * @return current instance of builder + */ + public PatioRecordBuilder floorLevel(Supplier floorLevelSupplier) { + this.floorLevel = changedValue(floorLevelSupplier.get()); + return this; + } + + /** + * Sets the value for hasGarden. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasGarden(true);
    +   * }
    + * + * @param hasGarden hasGarden + * @return current instance of builder + */ + public PatioRecordBuilder hasGarden(boolean hasGarden) { + this.hasGarden = changedValue(hasGarden); + return this; + } + + /** + * Sets the value for hasGarden by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasGarden(() -> true);
    +   * }
    + * + * @param hasGardenSupplier supplier for hasGarden + * @return current instance of builder + */ + public PatioRecordBuilder hasGarden(Supplier hasGardenSupplier) { + this.hasGarden = changedValue(hasGardenSupplier.get()); + return this; + } + + /** + * Sets the value for hasSeating. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSeating(true);
    +   * }
    + * + * @param hasSeating hasSeating + * @return current instance of builder + */ + public PatioRecordBuilder hasSeating(boolean hasSeating) { + this.hasSeating = changedValue(hasSeating); + return this; + } + + /** + * Sets the value for hasSeating by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSeating(() -> true);
    +   * }
    + * + * @param hasSeatingSupplier supplier for hasSeating + * @return current instance of builder + */ + public PatioRecordBuilder hasSeating(Supplier hasSeatingSupplier) { + this.hasSeating = changedValue(hasSeatingSupplier.get()); + return this; + } + + /** + * Sets the value for patioName. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patioName("example value");
    +   * }
    + * + * @param patioName patioName + * @return current instance of builder + */ + public PatioRecordBuilder patioName(String patioName) { + this.patioName = changedValue(patioName); + return this; + } + + /** + * Sets the value for patioName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patioName(sb -> sb.append("text"));
    +   * }
    + * + * @param patioNameStringBuilderConsumer consumer providing an instance of patioName + * @return current instance of builder + */ + public PatioRecordBuilder patioName(Consumer patioNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + patioNameStringBuilderConsumer.accept(builder); + this.patioName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for patioName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patioName(() -> "example value");
    +   * }
    + * + * @param patioNameSupplier supplier for patioName + * @return current instance of builder + */ + public PatioRecordBuilder patioName(Supplier patioNameSupplier) { + this.patioName = changedValue(patioNameSupplier.get()); + return this; + } + + /** + * Sets the String value for patioName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PatioRecord#PatioRecord(String, double, boolean, boolean, int) + * PatioRecord(String patioName, double areaSquareMeters, boolean hasGarden, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patioName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PatioRecordBuilder patioName(String format, Object... args) { + this.patioName = changedValue(String.format(format, args)); + 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 PatioRecordBuilder 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 PatioRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PatioRecord result = builder.build();
    +   * }
    + */ + @Override + public PatioRecord build() { + if (!this.areaSquareMeters.isSet()) { + throw new IllegalStateException("Required field 'areaSquareMeters' must be set before calling build()"); + } + if (this.areaSquareMeters.value() == null) { + throw new IllegalStateException("Field 'areaSquareMeters' is marked as non-null but null value was provided"); + } + if (!this.hasGarden.isSet()) { + throw new IllegalStateException("Required field 'hasGarden' must be set before calling build()"); + } + if (this.hasGarden.value() == null) { + throw new IllegalStateException("Field 'hasGarden' is marked as non-null but null value was provided"); + } + if (!this.floorLevel.isSet()) { + throw new IllegalStateException("Required field 'floorLevel' must be set before calling build()"); + } + if (this.floorLevel.value() == null) { + throw new IllegalStateException("Field 'floorLevel' is marked as non-null but null value was provided"); + } + PatioRecord result = new PatioRecord(this.patioName.value(), + this.areaSquareMeters.value(), + this.hasGarden.value(), + this.hasSeating.valueOr(true), + this.floorLevel.value()); + 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("patioName", this.patioName) + .append("areaSquareMeters", this.areaSquareMeters) + .append("hasGarden", this.hasGarden) + .append("hasSeating", this.hasSeating) + .append("floorLevel", this.floorLevel) + .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 PatioRecord with(Consumer b) { + PatioRecordBuilder builder; + try { + builder = new PatioRecordBuilder(PatioRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PatioRecordBuilder.With' should only be implemented by classes, which could be casted to 'PatioRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PatioRecordBuilder with() { + try { + return new PatioRecordBuilder(PatioRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PatioRecordBuilder.With' should only be implemented by classes, which could be casted to 'PatioRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PedestalRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PedestalRecordBuilder.java new file mode 100644 index 00000000..afcf30cc --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PedestalRecordBuilder.java @@ -0,0 +1,526 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PedestalRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PedestalRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PedestalRecord result = PedestalRecordBuilder.create()
    + *     .pedestalName("example value")
    + *     .pedestalName("Hello %s", "World")
    + *     .pedestalName(() -> "example value")
    + *     .pedestalName(sb -> sb.append("text"))
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .hasGlassCover(true)
    + *     .hasGlassCover(() -> true)
    + *     .hasLighting(true)
    + *     .hasLighting(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PedestalRecord.class) +public class PedestalRecordBuilder implements IBuilderBase { + + /** + * Tracked value for pedestalName: pedestalName. + */ + private TrackedValue pedestalName = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for hasGlassCover: hasGlassCover. + */ + private TrackedValue hasGlassCover = unsetValue(); + /** + * Tracked value for hasLighting: hasLighting. + */ + private TrackedValue hasLighting = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PedestalRecord}. + */ + public PedestalRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PedestalRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PedestalRecordBuilder(PedestalRecord instance) { + this.pedestalName = initialValue(instance.pedestalName()); + this.heightCm = initialValue(instance.heightCm()); + this.hasGlassCover = initialValue(instance.hasGlassCover()); + this.hasLighting = initialValue(instance.hasLighting()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PedestalRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PedestalRecordBuilder builder = PedestalRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PedestalRecord} + */ + public static PedestalRecordBuilder create() { + return new PedestalRecordBuilder(); + } + + /** + * Sets the value for hasGlassCover. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasGlassCover(true);
    +   * }
    + * + * @param hasGlassCover hasGlassCover + * @return current instance of builder + */ + public PedestalRecordBuilder hasGlassCover(boolean hasGlassCover) { + this.hasGlassCover = changedValue(hasGlassCover); + return this; + } + + /** + * Sets the value for hasGlassCover by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasGlassCover(() -> true);
    +   * }
    + * + * @param hasGlassCoverSupplier supplier for hasGlassCover + * @return current instance of builder + */ + public PedestalRecordBuilder hasGlassCover(Supplier hasGlassCoverSupplier) { + this.hasGlassCover = changedValue(hasGlassCoverSupplier.get()); + return this; + } + + /** + * Sets the value for hasLighting. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasLighting(true);
    +   * }
    + * + * @param hasLighting hasLighting + * @return current instance of builder + */ + public PedestalRecordBuilder hasLighting(boolean hasLighting) { + this.hasLighting = changedValue(hasLighting); + return this; + } + + /** + * Sets the value for hasLighting by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasLighting(() -> true);
    +   * }
    + * + * @param hasLightingSupplier supplier for hasLighting + * @return current instance of builder + */ + public PedestalRecordBuilder hasLighting(Supplier hasLightingSupplier) { + this.hasLighting = changedValue(hasLightingSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public PedestalRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public PedestalRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PedestalRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PedestalRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PedestalRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PedestalRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pedestalName. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pedestalName("example value");
    +   * }
    + * + * @param pedestalName pedestalName + * @return current instance of builder + */ + public PedestalRecordBuilder pedestalName(String pedestalName) { + this.pedestalName = changedValue(pedestalName); + return this; + } + + /** + * Sets the value for pedestalName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pedestalName(sb -> sb.append("text"));
    +   * }
    + * + * @param pedestalNameStringBuilderConsumer consumer providing an instance of pedestalName + * @return current instance of builder + */ + public PedestalRecordBuilder pedestalName(Consumer pedestalNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + pedestalNameStringBuilderConsumer.accept(builder); + this.pedestalName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for pedestalName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pedestalName(() -> "example value");
    +   * }
    + * + * @param pedestalNameSupplier supplier for pedestalName + * @return current instance of builder + */ + public PedestalRecordBuilder pedestalName(Supplier pedestalNameSupplier) { + this.pedestalName = changedValue(pedestalNameSupplier.get()); + return this; + } + + /** + * Sets the String value for pedestalName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PedestalRecord#PedestalRecord(String, double, boolean, boolean, String) PedestalRecord(String pedestalName, + * double heightCm, boolean hasGlassCover, boolean hasLighting, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pedestalName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PedestalRecordBuilder pedestalName(String format, Object... args) { + this.pedestalName = changedValue(String.format(format, args)); + 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 PedestalRecordBuilder 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 PedestalRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PedestalRecord result = builder.build();
    +   * }
    + */ + @Override + public PedestalRecord build() { + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasGlassCover.isSet()) { + throw new IllegalStateException("Required field 'hasGlassCover' must be set before calling build()"); + } + if (this.hasGlassCover.value() == null) { + throw new IllegalStateException("Field 'hasGlassCover' is marked as non-null but null value was provided"); + } + if (!this.hasLighting.isSet()) { + throw new IllegalStateException("Required field 'hasLighting' must be set before calling build()"); + } + if (this.hasLighting.value() == null) { + throw new IllegalStateException("Field 'hasLighting' is marked as non-null but null value was provided"); + } + PedestalRecord result = new PedestalRecord(this.pedestalName + .value(), this.heightCm.value(), this.hasGlassCover.value(), this.hasLighting.value(), this.material.value()); + 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("pedestalName", this.pedestalName) + .append("heightCm", this.heightCm) + .append("hasGlassCover", this.hasGlassCover) + .append("hasLighting", this.hasLighting) + .append("material", this.material) + .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 PedestalRecord with(Consumer b) { + PedestalRecordBuilder builder; + try { + builder = new PedestalRecordBuilder(PedestalRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PedestalRecordBuilder.With' should only be implemented by classes, which could be casted to 'PedestalRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PedestalRecordBuilder with() { + try { + return new PedestalRecordBuilder(PedestalRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PedestalRecordBuilder.With' should only be implemented by classes, which could be casted to 'PedestalRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PipeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PipeRecordBuilder.java new file mode 100644 index 00000000..c9be67ad --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PipeRecordBuilder.java @@ -0,0 +1,514 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PipeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PipeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PipeRecord result = PipeRecordBuilder.create()
    + *     .pipeName("example value")
    + *     .pipeName("Hello %s", "World")
    + *     .pipeName(() -> "example value")
    + *     .pipeName(sb -> sb.append("text"))
    + *     .diameterCm(3.14)
    + *     .diameterCm(() -> 3.14)
    + *     .lengthMeters(3.14)
    + *     .lengthMeters(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .hasInsulation(true)
    + *     .hasInsulation(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PipeRecord.class) +public class PipeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for pipeName: pipeName. + */ + private TrackedValue pipeName = unsetValue(); + /** + * Tracked value for diameterCm: diameterCm. + */ + private TrackedValue diameterCm = unsetValue(); + /** + * Tracked value for lengthMeters: lengthMeters. + */ + private TrackedValue lengthMeters = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + /** + * Tracked value for hasInsulation: hasInsulation. + */ + private TrackedValue hasInsulation = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PipeRecord}. + */ + public PipeRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PipeRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PipeRecordBuilder(PipeRecord instance) { + this.pipeName = initialValue(instance.pipeName()); + this.diameterCm = initialValue(instance.diameterCm()); + this.lengthMeters = initialValue(instance.lengthMeters()); + this.material = initialValue(instance.material()); + this.hasInsulation = initialValue(instance.hasInsulation()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PipeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PipeRecordBuilder builder = PipeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PipeRecord} + */ + public static PipeRecordBuilder create() { + return new PipeRecordBuilder(); + } + + /** + * Sets the value for diameterCm. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.diameterCm(3.14);
    +   * }
    + * + * @param diameterCm diameterCm + * @return current instance of builder + */ + public PipeRecordBuilder diameterCm(double diameterCm) { + this.diameterCm = changedValue(diameterCm); + return this; + } + + /** + * Sets the value for diameterCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.diameterCm(() -> 3.14);
    +   * }
    + * + * @param diameterCmSupplier supplier for diameterCm + * @return current instance of builder + */ + public PipeRecordBuilder diameterCm(Supplier diameterCmSupplier) { + this.diameterCm = changedValue(diameterCmSupplier.get()); + return this; + } + + /** + * Sets the value for hasInsulation. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasInsulation(true);
    +   * }
    + * + * @param hasInsulation hasInsulation + * @return current instance of builder + */ + public PipeRecordBuilder hasInsulation(boolean hasInsulation) { + this.hasInsulation = changedValue(hasInsulation); + return this; + } + + /** + * Sets the value for hasInsulation by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasInsulation(() -> true);
    +   * }
    + * + * @param hasInsulationSupplier supplier for hasInsulation + * @return current instance of builder + */ + public PipeRecordBuilder hasInsulation(Supplier hasInsulationSupplier) { + this.hasInsulation = changedValue(hasInsulationSupplier.get()); + return this; + } + + /** + * Sets the value for lengthMeters. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(3.14);
    +   * }
    + * + * @param lengthMeters lengthMeters + * @return current instance of builder + */ + public PipeRecordBuilder lengthMeters(double lengthMeters) { + this.lengthMeters = changedValue(lengthMeters); + return this; + } + + /** + * Sets the value for lengthMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(() -> 3.14);
    +   * }
    + * + * @param lengthMetersSupplier supplier for lengthMeters + * @return current instance of builder + */ + public PipeRecordBuilder lengthMeters(Supplier lengthMetersSupplier) { + this.lengthMeters = changedValue(lengthMetersSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PipeRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PipeRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PipeRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PipeRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pipeName. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pipeName("example value");
    +   * }
    + * + * @param pipeName pipeName + * @return current instance of builder + */ + public PipeRecordBuilder pipeName(String pipeName) { + this.pipeName = changedValue(pipeName); + return this; + } + + /** + * Sets the value for pipeName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pipeName(sb -> sb.append("text"));
    +   * }
    + * + * @param pipeNameStringBuilderConsumer consumer providing an instance of pipeName + * @return current instance of builder + */ + public PipeRecordBuilder pipeName(Consumer pipeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + pipeNameStringBuilderConsumer.accept(builder); + this.pipeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for pipeName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pipeName(() -> "example value");
    +   * }
    + * + * @param pipeNameSupplier supplier for pipeName + * @return current instance of builder + */ + public PipeRecordBuilder pipeName(Supplier pipeNameSupplier) { + this.pipeName = changedValue(pipeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for pipeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PipeRecord#PipeRecord(String, double, double, String, boolean) + * PipeRecord(String pipeName, double diameterCm, double lengthMeters, String material, boolean hasInsulation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pipeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PipeRecordBuilder pipeName(String format, Object... args) { + this.pipeName = changedValue(String.format(format, args)); + 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 PipeRecordBuilder 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 PipeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PipeRecord result = builder.build();
    +   * }
    + */ + @Override + public PipeRecord build() { + if (!this.diameterCm.isSet()) { + throw new IllegalStateException("Required field 'diameterCm' must be set before calling build()"); + } + if (this.diameterCm.value() == null) { + throw new IllegalStateException("Field 'diameterCm' is marked as non-null but null value was provided"); + } + if (!this.lengthMeters.isSet()) { + throw new IllegalStateException("Required field 'lengthMeters' must be set before calling build()"); + } + if (this.lengthMeters.value() == null) { + throw new IllegalStateException("Field 'lengthMeters' is marked as non-null but null value was provided"); + } + if (!this.hasInsulation.isSet()) { + throw new IllegalStateException("Required field 'hasInsulation' must be set before calling build()"); + } + if (this.hasInsulation.value() == null) { + throw new IllegalStateException("Field 'hasInsulation' is marked as non-null but null value was provided"); + } + PipeRecord result = new PipeRecord(this.pipeName.value(), + this.diameterCm.value(), + this.lengthMeters.value(), + this.material.value(), + this.hasInsulation.value()); + 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("pipeName", this.pipeName) + .append("diameterCm", this.diameterCm) + .append("lengthMeters", this.lengthMeters) + .append("material", this.material) + .append("hasInsulation", this.hasInsulation) + .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 PipeRecord with(Consumer b) { + PipeRecordBuilder builder; + try { + builder = new PipeRecordBuilder(PipeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PipeRecordBuilder.With' should only be implemented by classes, which could be casted to 'PipeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PipeRecordBuilder with() { + try { + return new PipeRecordBuilder(PipeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PipeRecordBuilder.With' should only be implemented by classes, which could be casted to 'PipeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlatformRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlatformRecordBuilder.java new file mode 100644 index 00000000..01858365 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlatformRecordBuilder.java @@ -0,0 +1,526 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PlatformRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PlatformRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PlatformRecord result = PlatformRecordBuilder.create()
    + *     .platformName("example value")
    + *     .platformName("Hello %s", "World")
    + *     .platformName(() -> "example value")
    + *     .platformName(sb -> sb.append("text"))
    + *     .areaSquareMeters(3.14)
    + *     .areaSquareMeters(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .hasRamp(true)
    + *     .hasRamp(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PlatformRecord.class) +public class PlatformRecordBuilder implements IBuilderBase { + + /** + * Tracked value for platformName: platformName. + */ + private TrackedValue platformName = unsetValue(); + /** + * Tracked value for areaSquareMeters: areaSquareMeters. + */ + private TrackedValue areaSquareMeters = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for hasRamp: hasRamp. + */ + private TrackedValue hasRamp = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PlatformRecord}. + */ + public PlatformRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PlatformRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PlatformRecordBuilder(PlatformRecord instance) { + this.platformName = initialValue(instance.platformName()); + this.areaSquareMeters = initialValue(instance.areaSquareMeters()); + this.heightCm = initialValue(instance.heightCm()); + this.hasRamp = initialValue(instance.hasRamp()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PlatformRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PlatformRecordBuilder builder = PlatformRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PlatformRecord} + */ + public static PlatformRecordBuilder create() { + return new PlatformRecordBuilder(); + } + + /** + * Sets the value for areaSquareMeters. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(3.14);
    +   * }
    + * + * @param areaSquareMeters areaSquareMeters + * @return current instance of builder + */ + public PlatformRecordBuilder areaSquareMeters(double areaSquareMeters) { + this.areaSquareMeters = changedValue(areaSquareMeters); + return this; + } + + /** + * Sets the value for areaSquareMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(() -> 3.14);
    +   * }
    + * + * @param areaSquareMetersSupplier supplier for areaSquareMeters + * @return current instance of builder + */ + public PlatformRecordBuilder areaSquareMeters(Supplier areaSquareMetersSupplier) { + this.areaSquareMeters = changedValue(areaSquareMetersSupplier.get()); + return this; + } + + /** + * Sets the value for hasRamp. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasRamp(true);
    +   * }
    + * + * @param hasRamp hasRamp + * @return current instance of builder + */ + public PlatformRecordBuilder hasRamp(boolean hasRamp) { + this.hasRamp = changedValue(hasRamp); + return this; + } + + /** + * Sets the value for hasRamp by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasRamp(() -> true);
    +   * }
    + * + * @param hasRampSupplier supplier for hasRamp + * @return current instance of builder + */ + public PlatformRecordBuilder hasRamp(Supplier hasRampSupplier) { + this.hasRamp = changedValue(hasRampSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public PlatformRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public PlatformRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PlatformRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PlatformRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PlatformRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlatformRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for platformName. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName("example value");
    +   * }
    + * + * @param platformName platformName + * @return current instance of builder + */ + public PlatformRecordBuilder platformName(String platformName) { + this.platformName = changedValue(platformName); + return this; + } + + /** + * Sets the value for platformName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName(sb -> sb.append("text"));
    +   * }
    + * + * @param platformNameStringBuilderConsumer consumer providing an instance of platformName + * @return current instance of builder + */ + public PlatformRecordBuilder platformName(Consumer platformNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + platformNameStringBuilderConsumer.accept(builder); + this.platformName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for platformName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName(() -> "example value");
    +   * }
    + * + * @param platformNameSupplier supplier for platformName + * @return current instance of builder + */ + public PlatformRecordBuilder platformName(Supplier platformNameSupplier) { + this.platformName = changedValue(platformNameSupplier.get()); + return this; + } + + /** + * Sets the String value for platformName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PlatformRecord#PlatformRecord(String, double, double, boolean, String) PlatformRecord(String platformName, + * double areaSquareMeters, double heightCm, boolean hasRamp, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlatformRecordBuilder platformName(String format, Object... args) { + this.platformName = changedValue(String.format(format, args)); + 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 PlatformRecordBuilder 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 PlatformRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PlatformRecord result = builder.build();
    +   * }
    + */ + @Override + public PlatformRecord build() { + if (!this.areaSquareMeters.isSet()) { + throw new IllegalStateException("Required field 'areaSquareMeters' must be set before calling build()"); + } + if (this.areaSquareMeters.value() == null) { + throw new IllegalStateException("Field 'areaSquareMeters' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasRamp.isSet()) { + throw new IllegalStateException("Required field 'hasRamp' must be set before calling build()"); + } + if (this.hasRamp.value() == null) { + throw new IllegalStateException("Field 'hasRamp' is marked as non-null but null value was provided"); + } + PlatformRecord result = new PlatformRecord(this.platformName + .value(), this.areaSquareMeters.value(), this.heightCm.value(), this.hasRamp.value(), this.material.value()); + 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("platformName", this.platformName) + .append("areaSquareMeters", this.areaSquareMeters) + .append("heightCm", this.heightCm) + .append("hasRamp", this.hasRamp) + .append("material", this.material) + .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 PlatformRecord with(Consumer b) { + PlatformRecordBuilder builder; + try { + builder = new PlatformRecordBuilder(PlatformRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlatformRecordBuilder.With' should only be implemented by classes, which could be casted to 'PlatformRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PlatformRecordBuilder with() { + try { + return new PlatformRecordBuilder(PlatformRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlatformRecordBuilder.With' should only be implemented by classes, which could be casted to 'PlatformRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlinthRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlinthRecordBuilder.java new file mode 100644 index 00000000..9cfe315c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PlinthRecordBuilder.java @@ -0,0 +1,511 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PlinthRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PlinthRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PlinthRecord result = PlinthRecordBuilder.create()
    + *     .plinthName("example value")
    + *     .plinthName("Hello %s", "World")
    + *     .plinthName(() -> "example value")
    + *     .plinthName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .depthCm(3.14)
    + *     .depthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PlinthRecord.class) +public class PlinthRecordBuilder implements IBuilderBase { + + /** + * Tracked value for plinthName: plinthName. + */ + private TrackedValue plinthName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for depthCm: depthCm. + */ + private TrackedValue depthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PlinthRecord}. + */ + public PlinthRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PlinthRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PlinthRecordBuilder(PlinthRecord instance) { + this.plinthName = initialValue(instance.plinthName()); + this.widthCm = initialValue(instance.widthCm()); + this.depthCm = initialValue(instance.depthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PlinthRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PlinthRecordBuilder builder = PlinthRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PlinthRecord} + */ + public static PlinthRecordBuilder create() { + return new PlinthRecordBuilder(); + } + + /** + * Sets the value for depthCm. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.depthCm(3.14);
    +   * }
    + * + * @param depthCm depthCm + * @return current instance of builder + */ + public PlinthRecordBuilder depthCm(double depthCm) { + this.depthCm = changedValue(depthCm); + return this; + } + + /** + * Sets the value for depthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.depthCm(() -> 3.14);
    +   * }
    + * + * @param depthCmSupplier supplier for depthCm + * @return current instance of builder + */ + public PlinthRecordBuilder depthCm(Supplier depthCmSupplier) { + this.depthCm = changedValue(depthCmSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public PlinthRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public PlinthRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PlinthRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PlinthRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PlinthRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlinthRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for plinthName. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plinthName("example value");
    +   * }
    + * + * @param plinthName plinthName + * @return current instance of builder + */ + public PlinthRecordBuilder plinthName(String plinthName) { + this.plinthName = changedValue(plinthName); + return this; + } + + /** + * Sets the value for plinthName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plinthName(sb -> sb.append("text"));
    +   * }
    + * + * @param plinthNameStringBuilderConsumer consumer providing an instance of plinthName + * @return current instance of builder + */ + public PlinthRecordBuilder plinthName(Consumer plinthNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + plinthNameStringBuilderConsumer.accept(builder); + this.plinthName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for plinthName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plinthName(() -> "example value");
    +   * }
    + * + * @param plinthNameSupplier supplier for plinthName + * @return current instance of builder + */ + public PlinthRecordBuilder plinthName(Supplier plinthNameSupplier) { + this.plinthName = changedValue(plinthNameSupplier.get()); + return this; + } + + /** + * Sets the String value for plinthName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plinthName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlinthRecordBuilder plinthName(String format, Object... args) { + this.plinthName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public PlinthRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlinthRecord#PlinthRecord(String, double, double, double, String) + * PlinthRecord(String plinthName, double widthCm, double depthCm, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public PlinthRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 PlinthRecordBuilder 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 PlinthRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PlinthRecord result = builder.build();
    +   * }
    + */ + @Override + public PlinthRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.depthCm.isSet()) { + throw new IllegalStateException("Required field 'depthCm' must be set before calling build()"); + } + if (this.depthCm.value() == null) { + throw new IllegalStateException("Field 'depthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + PlinthRecord result = new PlinthRecord(this.plinthName + .value(), this.widthCm.value(), this.depthCm.value(), this.heightCm.value(), this.material.value()); + 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("plinthName", this.plinthName) + .append("widthCm", this.widthCm) + .append("depthCm", this.depthCm) + .append("heightCm", this.heightCm) + .append("material", this.material) + .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 PlinthRecord with(Consumer b) { + PlinthRecordBuilder builder; + try { + builder = new PlinthRecordBuilder(PlinthRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlinthRecordBuilder.With' should only be implemented by classes, which could be casted to 'PlinthRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PlinthRecordBuilder with() { + try { + return new PlinthRecordBuilder(PlinthRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlinthRecordBuilder.With' should only be implemented by classes, which could be casted to 'PlinthRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PodiumRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PodiumRecordBuilder.java new file mode 100644 index 00000000..10801faa --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PodiumRecordBuilder.java @@ -0,0 +1,511 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PodiumRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PodiumRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PodiumRecord result = PodiumRecordBuilder.create()
    + *     .podiumName("example value")
    + *     .podiumName("Hello %s", "World")
    + *     .podiumName(() -> "example value")
    + *     .podiumName(sb -> sb.append("text"))
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .hasMicrophone(true)
    + *     .hasMicrophone(() -> true)
    + *     .hasLectern(true)
    + *     .hasLectern(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PodiumRecord.class) +public class PodiumRecordBuilder implements IBuilderBase { + + /** + * Tracked value for podiumName: podiumName. + */ + private TrackedValue podiumName = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for hasMicrophone: hasMicrophone. + */ + private TrackedValue hasMicrophone = unsetValue(); + /** + * Tracked value for hasLectern: hasLectern. + */ + private TrackedValue hasLectern = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PodiumRecord}. + */ + public PodiumRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PodiumRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PodiumRecordBuilder(PodiumRecord instance) { + this.podiumName = initialValue(instance.podiumName()); + this.heightCm = initialValue(instance.heightCm()); + this.hasMicrophone = initialValue(instance.hasMicrophone()); + this.hasLectern = initialValue(instance.hasLectern()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PodiumRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PodiumRecordBuilder builder = PodiumRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PodiumRecord} + */ + public static PodiumRecordBuilder create() { + return new PodiumRecordBuilder(); + } + + /** + * Sets the value for hasLectern. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasLectern(true);
    +   * }
    + * + * @param hasLectern hasLectern + * @return current instance of builder + */ + public PodiumRecordBuilder hasLectern(boolean hasLectern) { + this.hasLectern = changedValue(hasLectern); + return this; + } + + /** + * Sets the value for hasLectern by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasLectern(() -> true);
    +   * }
    + * + * @param hasLecternSupplier supplier for hasLectern + * @return current instance of builder + */ + public PodiumRecordBuilder hasLectern(Supplier hasLecternSupplier) { + this.hasLectern = changedValue(hasLecternSupplier.get()); + return this; + } + + /** + * Sets the value for hasMicrophone. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasMicrophone(true);
    +   * }
    + * + * @param hasMicrophone hasMicrophone + * @return current instance of builder + */ + public PodiumRecordBuilder hasMicrophone(boolean hasMicrophone) { + this.hasMicrophone = changedValue(hasMicrophone); + return this; + } + + /** + * Sets the value for hasMicrophone by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasMicrophone(() -> true);
    +   * }
    + * + * @param hasMicrophoneSupplier supplier for hasMicrophone + * @return current instance of builder + */ + public PodiumRecordBuilder hasMicrophone(Supplier hasMicrophoneSupplier) { + this.hasMicrophone = changedValue(hasMicrophoneSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public PodiumRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public PodiumRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public PodiumRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public PodiumRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public PodiumRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PodiumRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for podiumName. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podiumName("example value");
    +   * }
    + * + * @param podiumName podiumName + * @return current instance of builder + */ + public PodiumRecordBuilder podiumName(String podiumName) { + this.podiumName = changedValue(podiumName); + return this; + } + + /** + * Sets the value for podiumName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podiumName(sb -> sb.append("text"));
    +   * }
    + * + * @param podiumNameStringBuilderConsumer consumer providing an instance of podiumName + * @return current instance of builder + */ + public PodiumRecordBuilder podiumName(Consumer podiumNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + podiumNameStringBuilderConsumer.accept(builder); + this.podiumName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for podiumName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podiumName(() -> "example value");
    +   * }
    + * + * @param podiumNameSupplier supplier for podiumName + * @return current instance of builder + */ + public PodiumRecordBuilder podiumName(Supplier podiumNameSupplier) { + this.podiumName = changedValue(podiumNameSupplier.get()); + return this; + } + + /** + * Sets the String value for podiumName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PodiumRecord#PodiumRecord(String, double, boolean, boolean, String) + * PodiumRecord(String podiumName, double heightCm, boolean hasMicrophone, boolean hasLectern, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.podiumName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PodiumRecordBuilder podiumName(String format, Object... args) { + this.podiumName = changedValue(String.format(format, args)); + 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 PodiumRecordBuilder 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 PodiumRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PodiumRecord result = builder.build();
    +   * }
    + */ + @Override + public PodiumRecord build() { + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasMicrophone.isSet()) { + throw new IllegalStateException("Required field 'hasMicrophone' must be set before calling build()"); + } + if (this.hasMicrophone.value() == null) { + throw new IllegalStateException("Field 'hasMicrophone' is marked as non-null but null value was provided"); + } + if (!this.hasLectern.isSet()) { + throw new IllegalStateException("Required field 'hasLectern' must be set before calling build()"); + } + if (this.hasLectern.value() == null) { + throw new IllegalStateException("Field 'hasLectern' is marked as non-null but null value was provided"); + } + PodiumRecord result = new PodiumRecord(this.podiumName + .value(), this.heightCm.value(), this.hasMicrophone.value(), this.hasLectern.value(), this.material.value()); + 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("podiumName", this.podiumName) + .append("heightCm", this.heightCm) + .append("hasMicrophone", this.hasMicrophone) + .append("hasLectern", this.hasLectern) + .append("material", this.material) + .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 PodiumRecord with(Consumer b) { + PodiumRecordBuilder builder; + try { + builder = new PodiumRecordBuilder(PodiumRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PodiumRecordBuilder.With' should only be implemented by classes, which could be casted to 'PodiumRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PodiumRecordBuilder with() { + try { + return new PodiumRecordBuilder(PodiumRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PodiumRecordBuilder.With' should only be implemented by classes, which could be casted to 'PodiumRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PorchRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PorchRecordBuilder.java new file mode 100644 index 00000000..ce661089 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/PorchRecordBuilder.java @@ -0,0 +1,468 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.PorchRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.PorchRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PorchRecord result = PorchRecordBuilder.create()
    + *     .porchName("example value")
    + *     .porchName("Hello %s", "World")
    + *     .porchName(() -> "example value")
    + *     .porchName(sb -> sb.append("text"))
    + *     .areaSquareMeters(3.14)
    + *     .areaSquareMeters(() -> 3.14)
    + *     .hasRoof(true)
    + *     .hasRoof(() -> true)
    + *     .hasScreens(true)
    + *     .hasScreens(() -> true)
    + *     .floorLevel(42)
    + *     .floorLevel(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PorchRecord.class) +public class PorchRecordBuilder implements IBuilderBase { + + /** + * Tracked value for porchName: porchName. + */ + private TrackedValue porchName = unsetValue(); + /** + * Tracked value for areaSquareMeters: areaSquareMeters. + */ + private TrackedValue areaSquareMeters = unsetValue(); + /** + * Tracked value for hasRoof: hasRoof. + */ + private TrackedValue hasRoof = unsetValue(); + /** + * Tracked value for hasScreens: hasScreens. + */ + private TrackedValue hasScreens = unsetValue(); + /** + * Tracked value for floorLevel: floorLevel. + */ + private TrackedValue floorLevel = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PorchRecord}. + */ + public PorchRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.PorchRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PorchRecordBuilder(PorchRecord instance) { + this.porchName = initialValue(instance.porchName()); + this.areaSquareMeters = initialValue(instance.areaSquareMeters()); + this.hasRoof = initialValue(instance.hasRoof()); + this.hasScreens = initialValue(instance.hasScreens()); + this.floorLevel = initialValue(instance.floorLevel()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PorchRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PorchRecordBuilder builder = PorchRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.PorchRecord} + */ + public static PorchRecordBuilder create() { + return new PorchRecordBuilder(); + } + + /** + * Sets the value for areaSquareMeters. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(3.14);
    +   * }
    + * + * @param areaSquareMeters areaSquareMeters + * @return current instance of builder + */ + public PorchRecordBuilder areaSquareMeters(double areaSquareMeters) { + this.areaSquareMeters = changedValue(areaSquareMeters); + return this; + } + + /** + * Sets the value for areaSquareMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(() -> 3.14);
    +   * }
    + * + * @param areaSquareMetersSupplier supplier for areaSquareMeters + * @return current instance of builder + */ + public PorchRecordBuilder areaSquareMeters(Supplier areaSquareMetersSupplier) { + this.areaSquareMeters = changedValue(areaSquareMetersSupplier.get()); + return this; + } + + /** + * Sets the value for floorLevel. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(42);
    +   * }
    + * + * @param floorLevel floorLevel + * @return current instance of builder + */ + public PorchRecordBuilder floorLevel(int floorLevel) { + this.floorLevel = changedValue(floorLevel); + return this; + } + + /** + * Sets the value for floorLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(() -> 42);
    +   * }
    + * + * @param floorLevelSupplier supplier for floorLevel + * @return current instance of builder + */ + public PorchRecordBuilder floorLevel(Supplier floorLevelSupplier) { + this.floorLevel = changedValue(floorLevelSupplier.get()); + return this; + } + + /** + * Sets the value for hasRoof. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasRoof(true);
    +   * }
    + * + * @param hasRoof hasRoof + * @return current instance of builder + */ + public PorchRecordBuilder hasRoof(boolean hasRoof) { + this.hasRoof = changedValue(hasRoof); + return this; + } + + /** + * Sets the value for hasRoof by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasRoof(() -> true);
    +   * }
    + * + * @param hasRoofSupplier supplier for hasRoof + * @return current instance of builder + */ + public PorchRecordBuilder hasRoof(Supplier hasRoofSupplier) { + this.hasRoof = changedValue(hasRoofSupplier.get()); + return this; + } + + /** + * Sets the value for hasScreens. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasScreens(true);
    +   * }
    + * + * @param hasScreens hasScreens + * @return current instance of builder + */ + public PorchRecordBuilder hasScreens(boolean hasScreens) { + this.hasScreens = changedValue(hasScreens); + return this; + } + + /** + * Sets the value for hasScreens by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasScreens(() -> true);
    +   * }
    + * + * @param hasScreensSupplier supplier for hasScreens + * @return current instance of builder + */ + public PorchRecordBuilder hasScreens(Supplier hasScreensSupplier) { + this.hasScreens = changedValue(hasScreensSupplier.get()); + return this; + } + + /** + * Sets the value for porchName. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.porchName("example value");
    +   * }
    + * + * @param porchName porchName + * @return current instance of builder + */ + public PorchRecordBuilder porchName(String porchName) { + this.porchName = changedValue(porchName); + return this; + } + + /** + * Sets the value for porchName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.porchName(sb -> sb.append("text"));
    +   * }
    + * + * @param porchNameStringBuilderConsumer consumer providing an instance of porchName + * @return current instance of builder + */ + public PorchRecordBuilder porchName(Consumer porchNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + porchNameStringBuilderConsumer.accept(builder); + this.porchName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for porchName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.porchName(() -> "example value");
    +   * }
    + * + * @param porchNameSupplier supplier for porchName + * @return current instance of builder + */ + public PorchRecordBuilder porchName(Supplier porchNameSupplier) { + this.porchName = changedValue(porchNameSupplier.get()); + return this; + } + + /** + * Sets the String value for porchName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PorchRecord#PorchRecord(String, double, boolean, boolean, int) + * PorchRecord(String porchName, double areaSquareMeters, boolean hasRoof, boolean hasScreens, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.porchName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PorchRecordBuilder porchName(String format, Object... args) { + this.porchName = changedValue(String.format(format, args)); + 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 PorchRecordBuilder 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 PorchRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PorchRecord result = builder.build();
    +   * }
    + */ + @Override + public PorchRecord build() { + if (!this.areaSquareMeters.isSet()) { + throw new IllegalStateException("Required field 'areaSquareMeters' must be set before calling build()"); + } + if (this.areaSquareMeters.value() == null) { + throw new IllegalStateException("Field 'areaSquareMeters' is marked as non-null but null value was provided"); + } + if (!this.hasScreens.isSet()) { + throw new IllegalStateException("Required field 'hasScreens' must be set before calling build()"); + } + if (this.hasScreens.value() == null) { + throw new IllegalStateException("Field 'hasScreens' is marked as non-null but null value was provided"); + } + if (!this.floorLevel.isSet()) { + throw new IllegalStateException("Required field 'floorLevel' must be set before calling build()"); + } + if (this.floorLevel.value() == null) { + throw new IllegalStateException("Field 'floorLevel' is marked as non-null but null value was provided"); + } + PorchRecord result = new PorchRecord(this.porchName.value(), + this.areaSquareMeters.value(), + this.hasRoof.valueOr(true), + this.hasScreens.value(), + this.floorLevel.value()); + 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("porchName", this.porchName) + .append("areaSquareMeters", this.areaSquareMeters) + .append("hasRoof", this.hasRoof) + .append("hasScreens", this.hasScreens) + .append("floorLevel", this.floorLevel) + .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 PorchRecord with(Consumer b) { + PorchRecordBuilder builder; + try { + builder = new PorchRecordBuilder(PorchRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PorchRecordBuilder.With' should only be implemented by classes, which could be casted to 'PorchRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PorchRecordBuilder with() { + try { + return new PorchRecordBuilder(PorchRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PorchRecordBuilder.With' should only be implemented by classes, which could be casted to 'PorchRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RackRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RackRecordBuilder.java new file mode 100644 index 00000000..972c70fb --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RackRecordBuilder.java @@ -0,0 +1,514 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.RackRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.RackRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RackRecord result = RackRecordBuilder.create()
    + *     .rackName("example value")
    + *     .rackName("Hello %s", "World")
    + *     .rackName(() -> "example value")
    + *     .rackName(sb -> sb.append("text"))
    + *     .shelfLevels(42)
    + *     .shelfLevels(() -> 42)
    + *     .capacityPerLevel(42)
    + *     .capacityPerLevel(() -> 42)
    + *     .hasWheels(true)
    + *     .hasWheels(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RackRecord.class) +public class RackRecordBuilder implements IBuilderBase { + + /** + * Tracked value for rackName: rackName. + */ + private TrackedValue rackName = unsetValue(); + /** + * Tracked value for shelfLevels: shelfLevels. + */ + private TrackedValue shelfLevels = unsetValue(); + /** + * Tracked value for capacityPerLevel: capacityPerLevel. + */ + private TrackedValue capacityPerLevel = unsetValue(); + /** + * Tracked value for hasWheels: hasWheels. + */ + private TrackedValue hasWheels = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.RackRecord}. + */ + public RackRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.RackRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public RackRecordBuilder(RackRecord instance) { + this.rackName = initialValue(instance.rackName()); + this.shelfLevels = initialValue(instance.shelfLevels()); + this.capacityPerLevel = initialValue(instance.capacityPerLevel()); + this.hasWheels = initialValue(instance.hasWheels()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.RackRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RackRecordBuilder builder = RackRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.RackRecord} + */ + public static RackRecordBuilder create() { + return new RackRecordBuilder(); + } + + /** + * Sets the value for capacityPerLevel. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacityPerLevel(42);
    +   * }
    + * + * @param capacityPerLevel capacityPerLevel + * @return current instance of builder + */ + public RackRecordBuilder capacityPerLevel(int capacityPerLevel) { + this.capacityPerLevel = changedValue(capacityPerLevel); + return this; + } + + /** + * Sets the value for capacityPerLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacityPerLevel(() -> 42);
    +   * }
    + * + * @param capacityPerLevelSupplier supplier for capacityPerLevel + * @return current instance of builder + */ + public RackRecordBuilder capacityPerLevel(Supplier capacityPerLevelSupplier) { + this.capacityPerLevel = changedValue(capacityPerLevelSupplier.get()); + return this; + } + + /** + * Sets the value for hasWheels. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasWheels(true);
    +   * }
    + * + * @param hasWheels hasWheels + * @return current instance of builder + */ + public RackRecordBuilder hasWheels(boolean hasWheels) { + this.hasWheels = changedValue(hasWheels); + return this; + } + + /** + * Sets the value for hasWheels by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasWheels(() -> true);
    +   * }
    + * + * @param hasWheelsSupplier supplier for hasWheels + * @return current instance of builder + */ + public RackRecordBuilder hasWheels(Supplier hasWheelsSupplier) { + this.hasWheels = changedValue(hasWheelsSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public RackRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public RackRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public RackRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RackRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for rackName. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.rackName("example value");
    +   * }
    + * + * @param rackName rackName + * @return current instance of builder + */ + public RackRecordBuilder rackName(String rackName) { + this.rackName = changedValue(rackName); + return this; + } + + /** + * Sets the value for rackName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.rackName(sb -> sb.append("text"));
    +   * }
    + * + * @param rackNameStringBuilderConsumer consumer providing an instance of rackName + * @return current instance of builder + */ + public RackRecordBuilder rackName(Consumer rackNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + rackNameStringBuilderConsumer.accept(builder); + this.rackName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for rackName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.rackName(() -> "example value");
    +   * }
    + * + * @param rackNameSupplier supplier for rackName + * @return current instance of builder + */ + public RackRecordBuilder rackName(Supplier rackNameSupplier) { + this.rackName = changedValue(rackNameSupplier.get()); + return this; + } + + /** + * Sets the String value for rackName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.rackName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RackRecordBuilder rackName(String format, Object... args) { + this.rackName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for shelfLevels. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfLevels(42);
    +   * }
    + * + * @param shelfLevels shelfLevels + * @return current instance of builder + */ + public RackRecordBuilder shelfLevels(int shelfLevels) { + this.shelfLevels = changedValue(shelfLevels); + return this; + } + + /** + * Sets the value for shelfLevels by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RackRecord#RackRecord(String, int, int, boolean, String) + * RackRecord(String rackName, int shelfLevels, int capacityPerLevel, boolean hasWheels, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfLevels(() -> 42);
    +   * }
    + * + * @param shelfLevelsSupplier supplier for shelfLevels + * @return current instance of builder + */ + public RackRecordBuilder shelfLevels(Supplier shelfLevelsSupplier) { + this.shelfLevels = changedValue(shelfLevelsSupplier.get()); + 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 RackRecordBuilder 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 RackRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RackRecord result = builder.build();
    +   * }
    + */ + @Override + public RackRecord build() { + if (!this.shelfLevels.isSet()) { + throw new IllegalStateException("Required field 'shelfLevels' must be set before calling build()"); + } + if (this.shelfLevels.value() == null) { + throw new IllegalStateException("Field 'shelfLevels' is marked as non-null but null value was provided"); + } + if (!this.capacityPerLevel.isSet()) { + throw new IllegalStateException("Required field 'capacityPerLevel' must be set before calling build()"); + } + if (this.capacityPerLevel.value() == null) { + throw new IllegalStateException("Field 'capacityPerLevel' is marked as non-null but null value was provided"); + } + if (!this.hasWheels.isSet()) { + throw new IllegalStateException("Required field 'hasWheels' must be set before calling build()"); + } + if (this.hasWheels.value() == null) { + throw new IllegalStateException("Field 'hasWheels' is marked as non-null but null value was provided"); + } + RackRecord result = new RackRecord(this.rackName.value(), + this.shelfLevels.value(), + this.capacityPerLevel.value(), + this.hasWheels.value(), + this.material.value()); + 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("rackName", this.rackName) + .append("shelfLevels", this.shelfLevels) + .append("capacityPerLevel", this.capacityPerLevel) + .append("hasWheels", this.hasWheels) + .append("material", this.material) + .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 RackRecord with(Consumer b) { + RackRecordBuilder builder; + try { + builder = new RackRecordBuilder(RackRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RackRecordBuilder.With' should only be implemented by classes, which could be casted to 'RackRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RackRecordBuilder with() { + try { + return new RackRecordBuilder(RackRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RackRecordBuilder.With' should only be implemented by classes, which could be casted to 'RackRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RoomRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RoomRecordBuilder.java new file mode 100644 index 00000000..186ef8a6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/RoomRecordBuilder.java @@ -0,0 +1,505 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.RoomRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.RoomRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RoomRecord result = RoomRecordBuilder.create()
    + *     .roomNumber("example value")
    + *     .roomNumber("Hello %s", "World")
    + *     .roomNumber(() -> "example value")
    + *     .roomNumber(sb -> sb.append("text"))
    + *     .roomName("example value")
    + *     .roomName("Hello %s", "World")
    + *     .roomName(() -> "example value")
    + *     .roomName(sb -> sb.append("text"))
    + *     .capacity(42)
    + *     .capacity(() -> 42)
    + *     .floor(42)
    + *     .floor(() -> 42)
    + *     .accessible(true)
    + *     .accessible(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RoomRecord.class) +public class RoomRecordBuilder implements IBuilderBase { + + /** + * Tracked value for roomNumber: roomNumber. + */ + private TrackedValue roomNumber = unsetValue(); + /** + * Tracked value for roomName: roomName. + */ + private TrackedValue roomName = unsetValue(); + /** + * Tracked value for capacity: capacity. + */ + private TrackedValue capacity = unsetValue(); + /** + * Tracked value for floor: floor. + */ + private TrackedValue floor = unsetValue(); + /** + * Tracked value for accessible: accessible. + */ + private TrackedValue accessible = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.RoomRecord}. + */ + public RoomRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.RoomRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public RoomRecordBuilder(RoomRecord instance) { + this.roomNumber = initialValue(instance.roomNumber()); + this.roomName = initialValue(instance.roomName()); + this.capacity = initialValue(instance.capacity()); + this.floor = initialValue(instance.floor()); + this.accessible = initialValue(instance.accessible()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.RoomRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RoomRecordBuilder builder = RoomRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.RoomRecord} + */ + public static RoomRecordBuilder create() { + return new RoomRecordBuilder(); + } + + /** + * Sets the value for accessible. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessible(true);
    +   * }
    + * + * @param accessible accessible + * @return current instance of builder + */ + public RoomRecordBuilder accessible(boolean accessible) { + this.accessible = changedValue(accessible); + return this; + } + + /** + * Sets the value for accessible by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessible(() -> true);
    +   * }
    + * + * @param accessibleSupplier supplier for accessible + * @return current instance of builder + */ + public RoomRecordBuilder accessible(Supplier accessibleSupplier) { + this.accessible = changedValue(accessibleSupplier.get()); + return this; + } + + /** + * Sets the value for capacity. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacity(42);
    +   * }
    + * + * @param capacity capacity + * @return current instance of builder + */ + public RoomRecordBuilder capacity(int capacity) { + this.capacity = changedValue(capacity); + return this; + } + + /** + * Sets the value for capacity by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacity(() -> 42);
    +   * }
    + * + * @param capacitySupplier supplier for capacity + * @return current instance of builder + */ + public RoomRecordBuilder capacity(Supplier capacitySupplier) { + this.capacity = changedValue(capacitySupplier.get()); + return this; + } + + /** + * Sets the value for floor. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floor(42);
    +   * }
    + * + * @param floor floor + * @return current instance of builder + */ + public RoomRecordBuilder floor(int floor) { + this.floor = changedValue(floor); + return this; + } + + /** + * Sets the value for floor by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floor(() -> 42);
    +   * }
    + * + * @param floorSupplier supplier for floor + * @return current instance of builder + */ + public RoomRecordBuilder floor(Supplier floorSupplier) { + this.floor = changedValue(floorSupplier.get()); + return this; + } + + /** + * Sets the value for roomName. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomName("example value");
    +   * }
    + * + * @param roomName roomName + * @return current instance of builder + */ + public RoomRecordBuilder roomName(String roomName) { + this.roomName = changedValue(roomName); + return this; + } + + /** + * Sets the value for roomName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomName(sb -> sb.append("text"));
    +   * }
    + * + * @param roomNameStringBuilderConsumer consumer providing an instance of roomName + * @return current instance of builder + */ + public RoomRecordBuilder roomName(Consumer roomNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + roomNameStringBuilderConsumer.accept(builder); + this.roomName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for roomName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomName(() -> "example value");
    +   * }
    + * + * @param roomNameSupplier supplier for roomName + * @return current instance of builder + */ + public RoomRecordBuilder roomName(Supplier roomNameSupplier) { + this.roomName = changedValue(roomNameSupplier.get()); + return this; + } + + /** + * Sets the String value for roomName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RoomRecordBuilder roomName(String format, Object... args) { + this.roomName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for roomNumber. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomNumber("example value");
    +   * }
    + * + * @param roomNumber roomNumber + * @return current instance of builder + */ + public RoomRecordBuilder roomNumber(String roomNumber) { + this.roomNumber = changedValue(roomNumber); + return this; + } + + /** + * Sets the value for roomNumber by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomNumber(sb -> sb.append("text"));
    +   * }
    + * + * @param roomNumberStringBuilderConsumer consumer providing an instance of roomNumber + * @return current instance of builder + */ + public RoomRecordBuilder roomNumber(Consumer roomNumberStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + roomNumberStringBuilderConsumer.accept(builder); + this.roomNumber = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for roomNumber by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomNumber(() -> "example value");
    +   * }
    + * + * @param roomNumberSupplier supplier for roomNumber + * @return current instance of builder + */ + public RoomRecordBuilder roomNumber(Supplier roomNumberSupplier) { + this.roomNumber = changedValue(roomNumberSupplier.get()); + return this; + } + + /** + * Sets the String value for roomNumber by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RoomRecord#RoomRecord(String, String, int, int, boolean) + * RoomRecord(String roomNumber, String roomName, int capacity, int floor, boolean accessible)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.roomNumber("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RoomRecordBuilder roomNumber(String format, Object... args) { + this.roomNumber = changedValue(String.format(format, args)); + 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 RoomRecordBuilder 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 RoomRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RoomRecord result = builder.build();
    +   * }
    + */ + @Override + public RoomRecord build() { + if (!this.capacity.isSet()) { + throw new IllegalStateException("Required field 'capacity' must be set before calling build()"); + } + if (this.capacity.value() == null) { + throw new IllegalStateException("Field 'capacity' is marked as non-null but null value was provided"); + } + if (!this.floor.isSet()) { + throw new IllegalStateException("Required field 'floor' must be set before calling build()"); + } + if (this.floor.value() == null) { + throw new IllegalStateException("Field 'floor' is marked as non-null but null value was provided"); + } + RoomRecord result = new RoomRecord(this.roomNumber + .value(), this.roomName.value(), this.capacity.value(), this.floor.value(), this.accessible.valueOr(true)); + 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("roomNumber", this.roomNumber) + .append("roomName", this.roomName) + .append("capacity", this.capacity) + .append("floor", this.floor) + .append("accessible", this.accessible) + .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 RoomRecord with(Consumer b) { + RoomRecordBuilder builder; + try { + builder = new RoomRecordBuilder(RoomRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RoomRecordBuilder.With' should only be implemented by classes, which could be casted to 'RoomRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RoomRecordBuilder with() { + try { + return new RoomRecordBuilder(RoomRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RoomRecordBuilder.With' should only be implemented by classes, which could be casted to 'RoomRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ScreenRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ScreenRecordBuilder.java new file mode 100644 index 00000000..50bf0428 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ScreenRecordBuilder.java @@ -0,0 +1,511 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.ScreenRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.ScreenRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ScreenRecord result = ScreenRecordBuilder.create()
    + *     .screenName("example value")
    + *     .screenName("Hello %s", "World")
    + *     .screenName(() -> "example value")
    + *     .screenName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .isFolding(true)
    + *     .isFolding(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScreenRecord.class) +public class ScreenRecordBuilder implements IBuilderBase { + + /** + * Tracked value for screenName: screenName. + */ + private TrackedValue screenName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for isFolding: isFolding. + */ + private TrackedValue isFolding = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.ScreenRecord}. + */ + public ScreenRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.ScreenRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScreenRecordBuilder(ScreenRecord instance) { + this.screenName = initialValue(instance.screenName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.isFolding = initialValue(instance.isFolding()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.ScreenRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ScreenRecordBuilder builder = ScreenRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.ScreenRecord} + */ + public static ScreenRecordBuilder create() { + return new ScreenRecordBuilder(); + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public ScreenRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public ScreenRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for isFolding. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isFolding(true);
    +   * }
    + * + * @param isFolding isFolding + * @return current instance of builder + */ + public ScreenRecordBuilder isFolding(boolean isFolding) { + this.isFolding = changedValue(isFolding); + return this; + } + + /** + * Sets the value for isFolding by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isFolding(() -> true);
    +   * }
    + * + * @param isFoldingSupplier supplier for isFolding + * @return current instance of builder + */ + public ScreenRecordBuilder isFolding(Supplier isFoldingSupplier) { + this.isFolding = changedValue(isFoldingSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public ScreenRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public ScreenRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public ScreenRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScreenRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for screenName. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screenName("example value");
    +   * }
    + * + * @param screenName screenName + * @return current instance of builder + */ + public ScreenRecordBuilder screenName(String screenName) { + this.screenName = changedValue(screenName); + return this; + } + + /** + * Sets the value for screenName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screenName(sb -> sb.append("text"));
    +   * }
    + * + * @param screenNameStringBuilderConsumer consumer providing an instance of screenName + * @return current instance of builder + */ + public ScreenRecordBuilder screenName(Consumer screenNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + screenNameStringBuilderConsumer.accept(builder); + this.screenName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for screenName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screenName(() -> "example value");
    +   * }
    + * + * @param screenNameSupplier supplier for screenName + * @return current instance of builder + */ + public ScreenRecordBuilder screenName(Supplier screenNameSupplier) { + this.screenName = changedValue(screenNameSupplier.get()); + return this; + } + + /** + * Sets the String value for screenName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.screenName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScreenRecordBuilder screenName(String format, Object... args) { + this.screenName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public ScreenRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScreenRecord#ScreenRecord(String, double, double, boolean, String) + * ScreenRecord(String screenName, double widthCm, double heightCm, boolean isFolding, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public ScreenRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 ScreenRecordBuilder 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 ScreenRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScreenRecord result = builder.build();
    +   * }
    + */ + @Override + public ScreenRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.isFolding.isSet()) { + throw new IllegalStateException("Required field 'isFolding' must be set before calling build()"); + } + if (this.isFolding.value() == null) { + throw new IllegalStateException("Field 'isFolding' is marked as non-null but null value was provided"); + } + ScreenRecord result = new ScreenRecord(this.screenName + .value(), this.widthCm.value(), this.heightCm.value(), this.isFolding.value(), this.material.value()); + 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("screenName", this.screenName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("isFolding", this.isFolding) + .append("material", this.material) + .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 ScreenRecord with(Consumer b) { + ScreenRecordBuilder builder; + try { + builder = new ScreenRecordBuilder(ScreenRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScreenRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScreenRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScreenRecordBuilder with() { + try { + return new ScreenRecordBuilder(ScreenRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScreenRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScreenRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SealRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SealRecordBuilder.java new file mode 100644 index 00000000..a136e23b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SealRecordBuilder.java @@ -0,0 +1,548 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.SealRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.SealRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SealRecord result = SealRecordBuilder.create()
    + *     .sealName("example value")
    + *     .sealName("Hello %s", "World")
    + *     .sealName(() -> "example value")
    + *     .sealName(sb -> sb.append("text"))
    + *     .sealType("example value")
    + *     .sealType("Hello %s", "World")
    + *     .sealType(() -> "example value")
    + *     .sealType(sb -> sb.append("text"))
    + *     .lengthMeters(3.14)
    + *     .lengthMeters(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .isWeatherproof(true)
    + *     .isWeatherproof(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SealRecord.class) +public class SealRecordBuilder implements IBuilderBase { + + /** + * Tracked value for sealName: sealName. + */ + private TrackedValue sealName = unsetValue(); + /** + * Tracked value for sealType: sealType. + */ + private TrackedValue sealType = unsetValue(); + /** + * Tracked value for lengthMeters: lengthMeters. + */ + private TrackedValue lengthMeters = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + /** + * Tracked value for isWeatherproof: isWeatherproof. + */ + private TrackedValue isWeatherproof = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SealRecord}. + */ + public SealRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SealRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public SealRecordBuilder(SealRecord instance) { + this.sealName = initialValue(instance.sealName()); + this.sealType = initialValue(instance.sealType()); + this.lengthMeters = initialValue(instance.lengthMeters()); + this.material = initialValue(instance.material()); + this.isWeatherproof = initialValue(instance.isWeatherproof()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SealRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SealRecordBuilder builder = SealRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SealRecord} + */ + public static SealRecordBuilder create() { + return new SealRecordBuilder(); + } + + /** + * Sets the value for isWeatherproof. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isWeatherproof(true);
    +   * }
    + * + * @param isWeatherproof isWeatherproof + * @return current instance of builder + */ + public SealRecordBuilder isWeatherproof(boolean isWeatherproof) { + this.isWeatherproof = changedValue(isWeatherproof); + return this; + } + + /** + * Sets the value for isWeatherproof by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isWeatherproof(() -> true);
    +   * }
    + * + * @param isWeatherproofSupplier supplier for isWeatherproof + * @return current instance of builder + */ + public SealRecordBuilder isWeatherproof(Supplier isWeatherproofSupplier) { + this.isWeatherproof = changedValue(isWeatherproofSupplier.get()); + return this; + } + + /** + * Sets the value for lengthMeters. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(3.14);
    +   * }
    + * + * @param lengthMeters lengthMeters + * @return current instance of builder + */ + public SealRecordBuilder lengthMeters(double lengthMeters) { + this.lengthMeters = changedValue(lengthMeters); + return this; + } + + /** + * Sets the value for lengthMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(() -> 3.14);
    +   * }
    + * + * @param lengthMetersSupplier supplier for lengthMeters + * @return current instance of builder + */ + public SealRecordBuilder lengthMeters(Supplier lengthMetersSupplier) { + this.lengthMeters = changedValue(lengthMetersSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public SealRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public SealRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public SealRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SealRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sealName. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealName("example value");
    +   * }
    + * + * @param sealName sealName + * @return current instance of builder + */ + public SealRecordBuilder sealName(String sealName) { + this.sealName = changedValue(sealName); + return this; + } + + /** + * Sets the value for sealName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealName(sb -> sb.append("text"));
    +   * }
    + * + * @param sealNameStringBuilderConsumer consumer providing an instance of sealName + * @return current instance of builder + */ + public SealRecordBuilder sealName(Consumer sealNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sealNameStringBuilderConsumer.accept(builder); + this.sealName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sealName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealName(() -> "example value");
    +   * }
    + * + * @param sealNameSupplier supplier for sealName + * @return current instance of builder + */ + public SealRecordBuilder sealName(Supplier sealNameSupplier) { + this.sealName = changedValue(sealNameSupplier.get()); + return this; + } + + /** + * Sets the String value for sealName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SealRecordBuilder sealName(String format, Object... args) { + this.sealName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sealType. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealType("example value");
    +   * }
    + * + * @param sealType sealType + * @return current instance of builder + */ + public SealRecordBuilder sealType(String sealType) { + this.sealType = changedValue(sealType); + return this; + } + + /** + * Sets the value for sealType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealType(sb -> sb.append("text"));
    +   * }
    + * + * @param sealTypeStringBuilderConsumer consumer providing an instance of sealType + * @return current instance of builder + */ + public SealRecordBuilder sealType(Consumer sealTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sealTypeStringBuilderConsumer.accept(builder); + this.sealType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sealType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealType(() -> "example value");
    +   * }
    + * + * @param sealTypeSupplier supplier for sealType + * @return current instance of builder + */ + public SealRecordBuilder sealType(Supplier sealTypeSupplier) { + this.sealType = changedValue(sealTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for sealType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SealRecord#SealRecord(String, String, double, String, boolean) + * SealRecord(String sealName, String sealType, double lengthMeters, String material, boolean isWeatherproof)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sealType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SealRecordBuilder sealType(String format, Object... args) { + this.sealType = changedValue(String.format(format, args)); + 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 SealRecordBuilder 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 SealRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SealRecord result = builder.build();
    +   * }
    + */ + @Override + public SealRecord build() { + if (!this.lengthMeters.isSet()) { + throw new IllegalStateException("Required field 'lengthMeters' must be set before calling build()"); + } + if (this.lengthMeters.value() == null) { + throw new IllegalStateException("Field 'lengthMeters' is marked as non-null but null value was provided"); + } + SealRecord result = new SealRecord(this.sealName.value(), + this.sealType.value(), + this.lengthMeters.value(), + this.material.value(), + this.isWeatherproof.valueOr(true)); + 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("sealName", this.sealName) + .append("sealType", this.sealType) + .append("lengthMeters", this.lengthMeters) + .append("material", this.material) + .append("isWeatherproof", this.isWeatherproof) + .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 SealRecord with(Consumer b) { + SealRecordBuilder builder; + try { + builder = new SealRecordBuilder(SealRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SealRecordBuilder.With' should only be implemented by classes, which could be casted to 'SealRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SealRecordBuilder with() { + try { + return new SealRecordBuilder(SealRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SealRecordBuilder.With' should only be implemented by classes, which could be casted to 'SealRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ShelfRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ShelfRecordBuilder.java new file mode 100644 index 00000000..d6bb42df --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/ShelfRecordBuilder.java @@ -0,0 +1,511 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.ShelfRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.ShelfRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ShelfRecord result = ShelfRecordBuilder.create()
    + *     .shelfName("example value")
    + *     .shelfName("Hello %s", "World")
    + *     .shelfName(() -> "example value")
    + *     .shelfName(sb -> sb.append("text"))
    + *     .shelfCount(42)
    + *     .shelfCount(() -> 42)
    + *     .capacityPerShelf(42)
    + *     .capacityPerShelf(() -> 42)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ShelfRecord.class) +public class ShelfRecordBuilder implements IBuilderBase { + + /** + * Tracked value for shelfName: shelfName. + */ + private TrackedValue shelfName = unsetValue(); + /** + * Tracked value for shelfCount: shelfCount. + */ + private TrackedValue shelfCount = unsetValue(); + /** + * Tracked value for capacityPerShelf: capacityPerShelf. + */ + private TrackedValue capacityPerShelf = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.ShelfRecord}. + */ + public ShelfRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.ShelfRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ShelfRecordBuilder(ShelfRecord instance) { + this.shelfName = initialValue(instance.shelfName()); + this.shelfCount = initialValue(instance.shelfCount()); + this.capacityPerShelf = initialValue(instance.capacityPerShelf()); + this.heightCm = initialValue(instance.heightCm()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.ShelfRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ShelfRecordBuilder builder = ShelfRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.ShelfRecord} + */ + public static ShelfRecordBuilder create() { + return new ShelfRecordBuilder(); + } + + /** + * Sets the value for capacityPerShelf. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacityPerShelf(42);
    +   * }
    + * + * @param capacityPerShelf capacityPerShelf + * @return current instance of builder + */ + public ShelfRecordBuilder capacityPerShelf(int capacityPerShelf) { + this.capacityPerShelf = changedValue(capacityPerShelf); + return this; + } + + /** + * Sets the value for capacityPerShelf by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacityPerShelf(() -> 42);
    +   * }
    + * + * @param capacityPerShelfSupplier supplier for capacityPerShelf + * @return current instance of builder + */ + public ShelfRecordBuilder capacityPerShelf(Supplier capacityPerShelfSupplier) { + this.capacityPerShelf = changedValue(capacityPerShelfSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public ShelfRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public ShelfRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public ShelfRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public ShelfRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public ShelfRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShelfRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for shelfCount. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfCount(42);
    +   * }
    + * + * @param shelfCount shelfCount + * @return current instance of builder + */ + public ShelfRecordBuilder shelfCount(int shelfCount) { + this.shelfCount = changedValue(shelfCount); + return this; + } + + /** + * Sets the value for shelfCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfCount(() -> 42);
    +   * }
    + * + * @param shelfCountSupplier supplier for shelfCount + * @return current instance of builder + */ + public ShelfRecordBuilder shelfCount(Supplier shelfCountSupplier) { + this.shelfCount = changedValue(shelfCountSupplier.get()); + return this; + } + + /** + * Sets the value for shelfName. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfName("example value");
    +   * }
    + * + * @param shelfName shelfName + * @return current instance of builder + */ + public ShelfRecordBuilder shelfName(String shelfName) { + this.shelfName = changedValue(shelfName); + return this; + } + + /** + * Sets the value for shelfName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfName(sb -> sb.append("text"));
    +   * }
    + * + * @param shelfNameStringBuilderConsumer consumer providing an instance of shelfName + * @return current instance of builder + */ + public ShelfRecordBuilder shelfName(Consumer shelfNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + shelfNameStringBuilderConsumer.accept(builder); + this.shelfName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for shelfName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfName(() -> "example value");
    +   * }
    + * + * @param shelfNameSupplier supplier for shelfName + * @return current instance of builder + */ + public ShelfRecordBuilder shelfName(Supplier shelfNameSupplier) { + this.shelfName = changedValue(shelfNameSupplier.get()); + return this; + } + + /** + * Sets the String value for shelfName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ShelfRecord#ShelfRecord(String, int, int, double, String) + * ShelfRecord(String shelfName, int shelfCount, int capacityPerShelf, double heightCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shelfName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ShelfRecordBuilder shelfName(String format, Object... args) { + this.shelfName = changedValue(String.format(format, args)); + 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 ShelfRecordBuilder 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 ShelfRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ShelfRecord result = builder.build();
    +   * }
    + */ + @Override + public ShelfRecord build() { + if (!this.shelfCount.isSet()) { + throw new IllegalStateException("Required field 'shelfCount' must be set before calling build()"); + } + if (this.shelfCount.value() == null) { + throw new IllegalStateException("Field 'shelfCount' is marked as non-null but null value was provided"); + } + if (!this.capacityPerShelf.isSet()) { + throw new IllegalStateException("Required field 'capacityPerShelf' must be set before calling build()"); + } + if (this.capacityPerShelf.value() == null) { + throw new IllegalStateException("Field 'capacityPerShelf' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + ShelfRecord result = new ShelfRecord(this.shelfName + .value(), this.shelfCount.value(), this.capacityPerShelf.value(), this.heightCm.value(), this.material.value()); + 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("shelfName", this.shelfName) + .append("shelfCount", this.shelfCount) + .append("capacityPerShelf", this.capacityPerShelf) + .append("heightCm", this.heightCm) + .append("material", this.material) + .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 ShelfRecord with(Consumer b) { + ShelfRecordBuilder builder; + try { + builder = new ShelfRecordBuilder(ShelfRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ShelfRecordBuilder.With' should only be implemented by classes, which could be casted to 'ShelfRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ShelfRecordBuilder with() { + try { + return new ShelfRecordBuilder(ShelfRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ShelfRecordBuilder.With' should only be implemented by classes, which could be casted to 'ShelfRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SignageRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SignageRecordBuilder.java new file mode 100644 index 00000000..98b11bc0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SignageRecordBuilder.java @@ -0,0 +1,512 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.SignageRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.SignageRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SignageRecord result = SignageRecordBuilder.create()
    + *     .signageName("example value")
    + *     .signageName("Hello %s", "World")
    + *     .signageName(() -> "example value")
    + *     .signageName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .hasCorkSurface(true)
    + *     .hasCorkSurface(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SignageRecord.class) +public class SignageRecordBuilder implements IBuilderBase { + + /** + * Tracked value for signageName: signageName. + */ + private TrackedValue signageName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for hasCorkSurface: hasCorkSurface. + */ + private TrackedValue hasCorkSurface = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SignageRecord}. + */ + public SignageRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SignageRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SignageRecordBuilder(SignageRecord instance) { + this.signageName = initialValue(instance.signageName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.hasCorkSurface = initialValue(instance.hasCorkSurface()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SignageRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SignageRecordBuilder builder = SignageRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SignageRecord} + */ + public static SignageRecordBuilder create() { + return new SignageRecordBuilder(); + } + + /** + * Sets the value for hasCorkSurface. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasCorkSurface(true);
    +   * }
    + * + * @param hasCorkSurface hasCorkSurface + * @return current instance of builder + */ + public SignageRecordBuilder hasCorkSurface(boolean hasCorkSurface) { + this.hasCorkSurface = changedValue(hasCorkSurface); + return this; + } + + /** + * Sets the value for hasCorkSurface by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasCorkSurface(() -> true);
    +   * }
    + * + * @param hasCorkSurfaceSupplier supplier for hasCorkSurface + * @return current instance of builder + */ + public SignageRecordBuilder hasCorkSurface(Supplier hasCorkSurfaceSupplier) { + this.hasCorkSurface = changedValue(hasCorkSurfaceSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public SignageRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public SignageRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public SignageRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public SignageRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public SignageRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SignageRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for signageName. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signageName("example value");
    +   * }
    + * + * @param signageName signageName + * @return current instance of builder + */ + public SignageRecordBuilder signageName(String signageName) { + this.signageName = changedValue(signageName); + return this; + } + + /** + * Sets the value for signageName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signageName(sb -> sb.append("text"));
    +   * }
    + * + * @param signageNameStringBuilderConsumer consumer providing an instance of signageName + * @return current instance of builder + */ + public SignageRecordBuilder signageName(Consumer signageNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + signageNameStringBuilderConsumer.accept(builder); + this.signageName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for signageName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signageName(() -> "example value");
    +   * }
    + * + * @param signageNameSupplier supplier for signageName + * @return current instance of builder + */ + public SignageRecordBuilder signageName(Supplier signageNameSupplier) { + this.signageName = changedValue(signageNameSupplier.get()); + return this; + } + + /** + * Sets the String value for signageName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.signageName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SignageRecordBuilder signageName(String format, Object... args) { + this.signageName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public SignageRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SignageRecord#SignageRecord(String, double, double, boolean, String) + * SignageRecord(String signageName, double widthCm, double heightCm, boolean hasCorkSurface, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public SignageRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 SignageRecordBuilder 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 SignageRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SignageRecord result = builder.build();
    +   * }
    + */ + @Override + public SignageRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasCorkSurface.isSet()) { + throw new IllegalStateException("Required field 'hasCorkSurface' must be set before calling build()"); + } + if (this.hasCorkSurface.value() == null) { + throw new IllegalStateException("Field 'hasCorkSurface' is marked as non-null but null value was provided"); + } + SignageRecord result = new SignageRecord(this.signageName + .value(), this.widthCm.value(), this.heightCm.value(), this.hasCorkSurface.value(), this.material.value()); + 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("signageName", this.signageName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("hasCorkSurface", this.hasCorkSurface) + .append("material", this.material) + .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 SignageRecord with(Consumer b) { + SignageRecordBuilder builder; + try { + builder = new SignageRecordBuilder(SignageRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SignageRecordBuilder.With' should only be implemented by classes, which could be casted to 'SignageRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SignageRecordBuilder with() { + try { + return new SignageRecordBuilder(SignageRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SignageRecordBuilder.With' should only be implemented by classes, which could be casted to 'SignageRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SkylightRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SkylightRecordBuilder.java new file mode 100644 index 00000000..930a6ab8 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SkylightRecordBuilder.java @@ -0,0 +1,478 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.SkylightRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.SkylightRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SkylightRecord result = SkylightRecordBuilder.create()
    + *     .skylightName("example value")
    + *     .skylightName("Hello %s", "World")
    + *     .skylightName(() -> "example value")
    + *     .skylightName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .lengthCm(3.14)
    + *     .lengthCm(() -> 3.14)
    + *     .hasBlinds(true)
    + *     .hasBlinds(() -> true)
    + *     .isOperable(true)
    + *     .isOperable(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SkylightRecord.class) +public class SkylightRecordBuilder implements IBuilderBase { + + /** + * Tracked value for skylightName: skylightName. + */ + private TrackedValue skylightName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for lengthCm: lengthCm. + */ + private TrackedValue lengthCm = unsetValue(); + /** + * Tracked value for hasBlinds: hasBlinds. + */ + private TrackedValue hasBlinds = unsetValue(); + /** + * Tracked value for isOperable: isOperable. + */ + private TrackedValue isOperable = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SkylightRecord}. + */ + public SkylightRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SkylightRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SkylightRecordBuilder(SkylightRecord instance) { + this.skylightName = initialValue(instance.skylightName()); + this.widthCm = initialValue(instance.widthCm()); + this.lengthCm = initialValue(instance.lengthCm()); + this.hasBlinds = initialValue(instance.hasBlinds()); + this.isOperable = initialValue(instance.isOperable()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SkylightRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SkylightRecordBuilder builder = SkylightRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SkylightRecord} + */ + public static SkylightRecordBuilder create() { + return new SkylightRecordBuilder(); + } + + /** + * Sets the value for hasBlinds. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasBlinds(true);
    +   * }
    + * + * @param hasBlinds hasBlinds + * @return current instance of builder + */ + public SkylightRecordBuilder hasBlinds(boolean hasBlinds) { + this.hasBlinds = changedValue(hasBlinds); + return this; + } + + /** + * Sets the value for hasBlinds by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasBlinds(() -> true);
    +   * }
    + * + * @param hasBlindsSupplier supplier for hasBlinds + * @return current instance of builder + */ + public SkylightRecordBuilder hasBlinds(Supplier hasBlindsSupplier) { + this.hasBlinds = changedValue(hasBlindsSupplier.get()); + return this; + } + + /** + * Sets the value for isOperable. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isOperable(true);
    +   * }
    + * + * @param isOperable isOperable + * @return current instance of builder + */ + public SkylightRecordBuilder isOperable(boolean isOperable) { + this.isOperable = changedValue(isOperable); + return this; + } + + /** + * Sets the value for isOperable by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isOperable(() -> true);
    +   * }
    + * + * @param isOperableSupplier supplier for isOperable + * @return current instance of builder + */ + public SkylightRecordBuilder isOperable(Supplier isOperableSupplier) { + this.isOperable = changedValue(isOperableSupplier.get()); + return this; + } + + /** + * Sets the value for lengthCm. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthCm(3.14);
    +   * }
    + * + * @param lengthCm lengthCm + * @return current instance of builder + */ + public SkylightRecordBuilder lengthCm(double lengthCm) { + this.lengthCm = changedValue(lengthCm); + return this; + } + + /** + * Sets the value for lengthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthCm(() -> 3.14);
    +   * }
    + * + * @param lengthCmSupplier supplier for lengthCm + * @return current instance of builder + */ + public SkylightRecordBuilder lengthCm(Supplier lengthCmSupplier) { + this.lengthCm = changedValue(lengthCmSupplier.get()); + return this; + } + + /** + * Sets the value for skylightName. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.skylightName("example value");
    +   * }
    + * + * @param skylightName skylightName + * @return current instance of builder + */ + public SkylightRecordBuilder skylightName(String skylightName) { + this.skylightName = changedValue(skylightName); + return this; + } + + /** + * Sets the value for skylightName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.skylightName(sb -> sb.append("text"));
    +   * }
    + * + * @param skylightNameStringBuilderConsumer consumer providing an instance of skylightName + * @return current instance of builder + */ + public SkylightRecordBuilder skylightName(Consumer skylightNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + skylightNameStringBuilderConsumer.accept(builder); + this.skylightName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for skylightName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.skylightName(() -> "example value");
    +   * }
    + * + * @param skylightNameSupplier supplier for skylightName + * @return current instance of builder + */ + public SkylightRecordBuilder skylightName(Supplier skylightNameSupplier) { + this.skylightName = changedValue(skylightNameSupplier.get()); + return this; + } + + /** + * Sets the String value for skylightName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.skylightName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SkylightRecordBuilder skylightName(String format, Object... args) { + this.skylightName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public SkylightRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SkylightRecord#SkylightRecord(String, double, double, boolean, boolean) SkylightRecord(String skylightName, + * double widthCm, double lengthCm, boolean hasBlinds, boolean isOperable)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public SkylightRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 SkylightRecordBuilder 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 SkylightRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SkylightRecord result = builder.build();
    +   * }
    + */ + @Override + public SkylightRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.lengthCm.isSet()) { + throw new IllegalStateException("Required field 'lengthCm' must be set before calling build()"); + } + if (this.lengthCm.value() == null) { + throw new IllegalStateException("Field 'lengthCm' is marked as non-null but null value was provided"); + } + if (!this.hasBlinds.isSet()) { + throw new IllegalStateException("Required field 'hasBlinds' must be set before calling build()"); + } + if (this.hasBlinds.value() == null) { + throw new IllegalStateException("Field 'hasBlinds' is marked as non-null but null value was provided"); + } + SkylightRecord result = new SkylightRecord(this.skylightName + .value(), this.widthCm.value(), this.lengthCm.value(), this.hasBlinds.value(), this.isOperable.valueOr(true)); + 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("skylightName", this.skylightName) + .append("widthCm", this.widthCm) + .append("lengthCm", this.lengthCm) + .append("hasBlinds", this.hasBlinds) + .append("isOperable", this.isOperable) + .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 SkylightRecord with(Consumer b) { + SkylightRecordBuilder builder; + try { + builder = new SkylightRecordBuilder(SkylightRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SkylightRecordBuilder.With' should only be implemented by classes, which could be casted to 'SkylightRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SkylightRecordBuilder with() { + try { + return new SkylightRecordBuilder(SkylightRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SkylightRecordBuilder.With' should only be implemented by classes, which could be casted to 'SkylightRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SocketRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SocketRecordBuilder.java new file mode 100644 index 00000000..990f7bfa --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SocketRecordBuilder.java @@ -0,0 +1,502 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.SocketRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.SocketRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SocketRecord result = SocketRecordBuilder.create()
    + *     .socketName("example value")
    + *     .socketName("Hello %s", "World")
    + *     .socketName(() -> "example value")
    + *     .socketName(sb -> sb.append("text"))
    + *     .socketType("example value")
    + *     .socketType("Hello %s", "World")
    + *     .socketType(() -> "example value")
    + *     .socketType(sb -> sb.append("text"))
    + *     .ratedVoltage(42)
    + *     .ratedVoltage(() -> 42)
    + *     .hasCover(true)
    + *     .hasCover(() -> true)
    + *     .isGrounded(true)
    + *     .isGrounded(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SocketRecord.class) +public class SocketRecordBuilder implements IBuilderBase { + + /** + * Tracked value for socketName: socketName. + */ + private TrackedValue socketName = unsetValue(); + /** + * Tracked value for socketType: socketType. + */ + private TrackedValue socketType = unsetValue(); + /** + * Tracked value for ratedVoltage: ratedVoltage. + */ + private TrackedValue ratedVoltage = unsetValue(); + /** + * Tracked value for hasCover: hasCover. + */ + private TrackedValue hasCover = unsetValue(); + /** + * Tracked value for isGrounded: isGrounded. + */ + private TrackedValue isGrounded = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SocketRecord}. + */ + public SocketRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SocketRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SocketRecordBuilder(SocketRecord instance) { + this.socketName = initialValue(instance.socketName()); + this.socketType = initialValue(instance.socketType()); + this.ratedVoltage = initialValue(instance.ratedVoltage()); + this.hasCover = initialValue(instance.hasCover()); + this.isGrounded = initialValue(instance.isGrounded()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SocketRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SocketRecordBuilder builder = SocketRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SocketRecord} + */ + public static SocketRecordBuilder create() { + return new SocketRecordBuilder(); + } + + /** + * Sets the value for hasCover. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasCover(true);
    +   * }
    + * + * @param hasCover hasCover + * @return current instance of builder + */ + public SocketRecordBuilder hasCover(boolean hasCover) { + this.hasCover = changedValue(hasCover); + return this; + } + + /** + * Sets the value for hasCover by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasCover(() -> true);
    +   * }
    + * + * @param hasCoverSupplier supplier for hasCover + * @return current instance of builder + */ + public SocketRecordBuilder hasCover(Supplier hasCoverSupplier) { + this.hasCover = changedValue(hasCoverSupplier.get()); + return this; + } + + /** + * Sets the value for isGrounded. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isGrounded(true);
    +   * }
    + * + * @param isGrounded isGrounded + * @return current instance of builder + */ + public SocketRecordBuilder isGrounded(boolean isGrounded) { + this.isGrounded = changedValue(isGrounded); + return this; + } + + /** + * Sets the value for isGrounded by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isGrounded(() -> true);
    +   * }
    + * + * @param isGroundedSupplier supplier for isGrounded + * @return current instance of builder + */ + public SocketRecordBuilder isGrounded(Supplier isGroundedSupplier) { + this.isGrounded = changedValue(isGroundedSupplier.get()); + return this; + } + + /** + * Sets the value for ratedVoltage. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ratedVoltage(42);
    +   * }
    + * + * @param ratedVoltage ratedVoltage + * @return current instance of builder + */ + public SocketRecordBuilder ratedVoltage(int ratedVoltage) { + this.ratedVoltage = changedValue(ratedVoltage); + return this; + } + + /** + * Sets the value for ratedVoltage by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ratedVoltage(() -> 42);
    +   * }
    + * + * @param ratedVoltageSupplier supplier for ratedVoltage + * @return current instance of builder + */ + public SocketRecordBuilder ratedVoltage(Supplier ratedVoltageSupplier) { + this.ratedVoltage = changedValue(ratedVoltageSupplier.get()); + return this; + } + + /** + * Sets the value for socketName. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketName("example value");
    +   * }
    + * + * @param socketName socketName + * @return current instance of builder + */ + public SocketRecordBuilder socketName(String socketName) { + this.socketName = changedValue(socketName); + return this; + } + + /** + * Sets the value for socketName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketName(sb -> sb.append("text"));
    +   * }
    + * + * @param socketNameStringBuilderConsumer consumer providing an instance of socketName + * @return current instance of builder + */ + public SocketRecordBuilder socketName(Consumer socketNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + socketNameStringBuilderConsumer.accept(builder); + this.socketName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for socketName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketName(() -> "example value");
    +   * }
    + * + * @param socketNameSupplier supplier for socketName + * @return current instance of builder + */ + public SocketRecordBuilder socketName(Supplier socketNameSupplier) { + this.socketName = changedValue(socketNameSupplier.get()); + return this; + } + + /** + * Sets the String value for socketName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SocketRecordBuilder socketName(String format, Object... args) { + this.socketName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for socketType. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketType("example value");
    +   * }
    + * + * @param socketType socketType + * @return current instance of builder + */ + public SocketRecordBuilder socketType(String socketType) { + this.socketType = changedValue(socketType); + return this; + } + + /** + * Sets the value for socketType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketType(sb -> sb.append("text"));
    +   * }
    + * + * @param socketTypeStringBuilderConsumer consumer providing an instance of socketType + * @return current instance of builder + */ + public SocketRecordBuilder socketType(Consumer socketTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + socketTypeStringBuilderConsumer.accept(builder); + this.socketType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for socketType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketType(() -> "example value");
    +   * }
    + * + * @param socketTypeSupplier supplier for socketType + * @return current instance of builder + */ + public SocketRecordBuilder socketType(Supplier socketTypeSupplier) { + this.socketType = changedValue(socketTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for socketType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SocketRecord#SocketRecord(String, String, int, boolean, boolean) + * SocketRecord(String socketName, String socketType, int ratedVoltage, boolean hasCover, boolean isGrounded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.socketType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SocketRecordBuilder socketType(String format, Object... args) { + this.socketType = changedValue(String.format(format, args)); + 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 SocketRecordBuilder 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 SocketRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SocketRecord result = builder.build();
    +   * }
    + */ + @Override + public SocketRecord build() { + if (!this.ratedVoltage.isSet()) { + throw new IllegalStateException("Required field 'ratedVoltage' must be set before calling build()"); + } + if (this.ratedVoltage.value() == null) { + throw new IllegalStateException("Field 'ratedVoltage' is marked as non-null but null value was provided"); + } + SocketRecord result = new SocketRecord(this.socketName.value(), + this.socketType.value(), + this.ratedVoltage.value(), + this.hasCover.valueOr(true), + this.isGrounded.valueOr(true)); + 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("socketName", this.socketName) + .append("socketType", this.socketType) + .append("ratedVoltage", this.ratedVoltage) + .append("hasCover", this.hasCover) + .append("isGrounded", this.isGrounded) + .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 SocketRecord with(Consumer b) { + SocketRecordBuilder builder; + try { + builder = new SocketRecordBuilder(SocketRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SocketRecordBuilder.With' should only be implemented by classes, which could be casted to 'SocketRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SocketRecordBuilder with() { + try { + return new SocketRecordBuilder(SocketRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SocketRecordBuilder.With' should only be implemented by classes, which could be casted to 'SocketRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StageRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StageRecordBuilder.java new file mode 100644 index 00000000..fa1c77da --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StageRecordBuilder.java @@ -0,0 +1,474 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.StageRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.StageRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * StageRecord result = StageRecordBuilder.create()
    + *     .stageName("example value")
    + *     .stageName("Hello %s", "World")
    + *     .stageName(() -> "example value")
    + *     .stageName(sb -> sb.append("text"))
    + *     .areaSquareMeters(3.14)
    + *     .areaSquareMeters(() -> 3.14)
    + *     .hasCurtains(true)
    + *     .hasCurtains(() -> true)
    + *     .hasLighting(true)
    + *     .hasLighting(() -> true)
    + *     .capacity(42)
    + *     .capacity(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StageRecord.class) +public class StageRecordBuilder implements IBuilderBase { + + /** + * Tracked value for stageName: stageName. + */ + private TrackedValue stageName = unsetValue(); + /** + * Tracked value for areaSquareMeters: areaSquareMeters. + */ + private TrackedValue areaSquareMeters = unsetValue(); + /** + * Tracked value for hasCurtains: hasCurtains. + */ + private TrackedValue hasCurtains = unsetValue(); + /** + * Tracked value for hasLighting: hasLighting. + */ + private TrackedValue hasLighting = unsetValue(); + /** + * Tracked value for capacity: capacity. + */ + private TrackedValue capacity = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.StageRecord}. + */ + public StageRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.StageRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public StageRecordBuilder(StageRecord instance) { + this.stageName = initialValue(instance.stageName()); + this.areaSquareMeters = initialValue(instance.areaSquareMeters()); + this.hasCurtains = initialValue(instance.hasCurtains()); + this.hasLighting = initialValue(instance.hasLighting()); + this.capacity = initialValue(instance.capacity()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.StageRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * StageRecordBuilder builder = StageRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.StageRecord} + */ + public static StageRecordBuilder create() { + return new StageRecordBuilder(); + } + + /** + * Sets the value for areaSquareMeters. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(3.14);
    +   * }
    + * + * @param areaSquareMeters areaSquareMeters + * @return current instance of builder + */ + public StageRecordBuilder areaSquareMeters(double areaSquareMeters) { + this.areaSquareMeters = changedValue(areaSquareMeters); + return this; + } + + /** + * Sets the value for areaSquareMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(() -> 3.14);
    +   * }
    + * + * @param areaSquareMetersSupplier supplier for areaSquareMeters + * @return current instance of builder + */ + public StageRecordBuilder areaSquareMeters(Supplier areaSquareMetersSupplier) { + this.areaSquareMeters = changedValue(areaSquareMetersSupplier.get()); + return this; + } + + /** + * Sets the value for capacity. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacity(42);
    +   * }
    + * + * @param capacity capacity + * @return current instance of builder + */ + public StageRecordBuilder capacity(int capacity) { + this.capacity = changedValue(capacity); + return this; + } + + /** + * Sets the value for capacity by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacity(() -> 42);
    +   * }
    + * + * @param capacitySupplier supplier for capacity + * @return current instance of builder + */ + public StageRecordBuilder capacity(Supplier capacitySupplier) { + this.capacity = changedValue(capacitySupplier.get()); + return this; + } + + /** + * Sets the value for hasCurtains. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasCurtains(true);
    +   * }
    + * + * @param hasCurtains hasCurtains + * @return current instance of builder + */ + public StageRecordBuilder hasCurtains(boolean hasCurtains) { + this.hasCurtains = changedValue(hasCurtains); + return this; + } + + /** + * Sets the value for hasCurtains by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasCurtains(() -> true);
    +   * }
    + * + * @param hasCurtainsSupplier supplier for hasCurtains + * @return current instance of builder + */ + public StageRecordBuilder hasCurtains(Supplier hasCurtainsSupplier) { + this.hasCurtains = changedValue(hasCurtainsSupplier.get()); + return this; + } + + /** + * Sets the value for hasLighting. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasLighting(true);
    +   * }
    + * + * @param hasLighting hasLighting + * @return current instance of builder + */ + public StageRecordBuilder hasLighting(boolean hasLighting) { + this.hasLighting = changedValue(hasLighting); + return this; + } + + /** + * Sets the value for hasLighting by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasLighting(() -> true);
    +   * }
    + * + * @param hasLightingSupplier supplier for hasLighting + * @return current instance of builder + */ + public StageRecordBuilder hasLighting(Supplier hasLightingSupplier) { + this.hasLighting = changedValue(hasLightingSupplier.get()); + return this; + } + + /** + * Sets the value for stageName. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.stageName("example value");
    +   * }
    + * + * @param stageName stageName + * @return current instance of builder + */ + public StageRecordBuilder stageName(String stageName) { + this.stageName = changedValue(stageName); + return this; + } + + /** + * Sets the value for stageName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.stageName(sb -> sb.append("text"));
    +   * }
    + * + * @param stageNameStringBuilderConsumer consumer providing an instance of stageName + * @return current instance of builder + */ + public StageRecordBuilder stageName(Consumer stageNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + stageNameStringBuilderConsumer.accept(builder); + this.stageName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for stageName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.stageName(() -> "example value");
    +   * }
    + * + * @param stageNameSupplier supplier for stageName + * @return current instance of builder + */ + public StageRecordBuilder stageName(Supplier stageNameSupplier) { + this.stageName = changedValue(stageNameSupplier.get()); + return this; + } + + /** + * Sets the String value for stageName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link StageRecord#StageRecord(String, double, boolean, boolean, int) + * StageRecord(String stageName, double areaSquareMeters, boolean hasCurtains, boolean hasLighting, int capacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.stageName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StageRecordBuilder stageName(String format, Object... args) { + this.stageName = changedValue(String.format(format, args)); + 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 StageRecordBuilder 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 StageRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StageRecord result = builder.build();
    +   * }
    + */ + @Override + public StageRecord build() { + if (!this.areaSquareMeters.isSet()) { + throw new IllegalStateException("Required field 'areaSquareMeters' must be set before calling build()"); + } + if (this.areaSquareMeters.value() == null) { + throw new IllegalStateException("Field 'areaSquareMeters' is marked as non-null but null value was provided"); + } + if (!this.hasCurtains.isSet()) { + throw new IllegalStateException("Required field 'hasCurtains' must be set before calling build()"); + } + if (this.hasCurtains.value() == null) { + throw new IllegalStateException("Field 'hasCurtains' is marked as non-null but null value was provided"); + } + if (!this.hasLighting.isSet()) { + throw new IllegalStateException("Required field 'hasLighting' must be set before calling build()"); + } + if (this.hasLighting.value() == null) { + throw new IllegalStateException("Field 'hasLighting' is marked as non-null but null value was provided"); + } + if (!this.capacity.isSet()) { + throw new IllegalStateException("Required field 'capacity' must be set before calling build()"); + } + if (this.capacity.value() == null) { + throw new IllegalStateException("Field 'capacity' is marked as non-null but null value was provided"); + } + StageRecord result = new StageRecord(this.stageName.value(), + this.areaSquareMeters.value(), + this.hasCurtains.value(), + this.hasLighting.value(), + this.capacity.value()); + 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("stageName", this.stageName) + .append("areaSquareMeters", this.areaSquareMeters) + .append("hasCurtains", this.hasCurtains) + .append("hasLighting", this.hasLighting) + .append("capacity", this.capacity) + .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 StageRecord with(Consumer b) { + StageRecordBuilder builder; + try { + builder = new StageRecordBuilder(StageRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StageRecordBuilder.With' should only be implemented by classes, which could be casted to 'StageRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StageRecordBuilder with() { + try { + return new StageRecordBuilder(StageRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StageRecordBuilder.With' should only be implemented by classes, which could be casted to 'StageRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StandRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StandRecordBuilder.java new file mode 100644 index 00000000..be304f60 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/StandRecordBuilder.java @@ -0,0 +1,528 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.StandRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.StandRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * StandRecord result = StandRecordBuilder.create()
    + *     .standName("example value")
    + *     .standName("Hello %s", "World")
    + *     .standName(() -> "example value")
    + *     .standName(sb -> sb.append("text"))
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .hasAdjustableHeight(true)
    + *     .hasAdjustableHeight(() -> true)
    + *     .baseDiameterCm(3.14)
    + *     .baseDiameterCm(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StandRecord.class) +public class StandRecordBuilder implements IBuilderBase { + + /** + * Tracked value for standName: standName. + */ + private TrackedValue standName = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for hasAdjustableHeight: hasAdjustableHeight. + */ + private TrackedValue hasAdjustableHeight = unsetValue(); + /** + * Tracked value for baseDiameterCm: baseDiameterCm. + */ + private TrackedValue baseDiameterCm = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.StandRecord}. + */ + public StandRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.StandRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public StandRecordBuilder(StandRecord instance) { + this.standName = initialValue(instance.standName()); + this.heightCm = initialValue(instance.heightCm()); + this.hasAdjustableHeight = initialValue(instance.hasAdjustableHeight()); + this.baseDiameterCm = initialValue(instance.baseDiameterCm()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.StandRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * StandRecordBuilder builder = StandRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.StandRecord} + */ + public static StandRecordBuilder create() { + return new StandRecordBuilder(); + } + + /** + * Sets the value for baseDiameterCm. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.baseDiameterCm(3.14);
    +   * }
    + * + * @param baseDiameterCm baseDiameterCm + * @return current instance of builder + */ + public StandRecordBuilder baseDiameterCm(double baseDiameterCm) { + this.baseDiameterCm = changedValue(baseDiameterCm); + return this; + } + + /** + * Sets the value for baseDiameterCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.baseDiameterCm(() -> 3.14);
    +   * }
    + * + * @param baseDiameterCmSupplier supplier for baseDiameterCm + * @return current instance of builder + */ + public StandRecordBuilder baseDiameterCm(Supplier baseDiameterCmSupplier) { + this.baseDiameterCm = changedValue(baseDiameterCmSupplier.get()); + return this; + } + + /** + * Sets the value for hasAdjustableHeight. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasAdjustableHeight(true);
    +   * }
    + * + * @param hasAdjustableHeight hasAdjustableHeight + * @return current instance of builder + */ + public StandRecordBuilder hasAdjustableHeight(boolean hasAdjustableHeight) { + this.hasAdjustableHeight = changedValue(hasAdjustableHeight); + return this; + } + + /** + * Sets the value for hasAdjustableHeight by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasAdjustableHeight(() -> true);
    +   * }
    + * + * @param hasAdjustableHeightSupplier supplier for hasAdjustableHeight + * @return current instance of builder + */ + public StandRecordBuilder hasAdjustableHeight(Supplier hasAdjustableHeightSupplier) { + this.hasAdjustableHeight = changedValue(hasAdjustableHeightSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public StandRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public StandRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public StandRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public StandRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public StandRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StandRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for standName. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standName("example value");
    +   * }
    + * + * @param standName standName + * @return current instance of builder + */ + public StandRecordBuilder standName(String standName) { + this.standName = changedValue(standName); + return this; + } + + /** + * Sets the value for standName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standName(sb -> sb.append("text"));
    +   * }
    + * + * @param standNameStringBuilderConsumer consumer providing an instance of standName + * @return current instance of builder + */ + public StandRecordBuilder standName(Consumer standNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + standNameStringBuilderConsumer.accept(builder); + this.standName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for standName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standName(() -> "example value");
    +   * }
    + * + * @param standNameSupplier supplier for standName + * @return current instance of builder + */ + public StandRecordBuilder standName(Supplier standNameSupplier) { + this.standName = changedValue(standNameSupplier.get()); + return this; + } + + /** + * Sets the String value for standName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link StandRecord#StandRecord(String, double, boolean, double, String) + * StandRecord(String standName, double heightCm, boolean hasAdjustableHeight, double baseDiameterCm, String + * material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StandRecordBuilder standName(String format, Object... args) { + this.standName = changedValue(String.format(format, args)); + 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 StandRecordBuilder 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 StandRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StandRecord result = builder.build();
    +   * }
    + */ + @Override + public StandRecord build() { + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasAdjustableHeight.isSet()) { + throw new IllegalStateException("Required field 'hasAdjustableHeight' must be set before calling build()"); + } + if (this.hasAdjustableHeight.value() == null) { + throw new IllegalStateException("Field 'hasAdjustableHeight' is marked as non-null but null value was provided"); + } + if (!this.baseDiameterCm.isSet()) { + throw new IllegalStateException("Required field 'baseDiameterCm' must be set before calling build()"); + } + if (this.baseDiameterCm.value() == null) { + throw new IllegalStateException("Field 'baseDiameterCm' is marked as non-null but null value was provided"); + } + StandRecord result = new StandRecord(this.standName.value(), + this.heightCm.value(), + this.hasAdjustableHeight.value(), + this.baseDiameterCm.value(), + this.material.value()); + 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("standName", this.standName) + .append("heightCm", this.heightCm) + .append("hasAdjustableHeight", this.hasAdjustableHeight) + .append("baseDiameterCm", this.baseDiameterCm) + .append("material", this.material) + .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 StandRecord with(Consumer b) { + StandRecordBuilder builder; + try { + builder = new StandRecordBuilder(StandRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StandRecordBuilder.With' should only be implemented by classes, which could be casted to 'StandRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StandRecordBuilder with() { + try { + return new StandRecordBuilder(StandRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StandRecordBuilder.With' should only be implemented by classes, which could be casted to 'StandRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SwitchRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SwitchRecordBuilder.java new file mode 100644 index 00000000..f757808e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/SwitchRecordBuilder.java @@ -0,0 +1,514 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.SwitchRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.SwitchRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SwitchRecord result = SwitchRecordBuilder.create()
    + *     .switchName("example value")
    + *     .switchName("Hello %s", "World")
    + *     .switchName(() -> "example value")
    + *     .switchName(sb -> sb.append("text"))
    + *     .switchType("example value")
    + *     .switchType("Hello %s", "World")
    + *     .switchType(() -> "example value")
    + *     .switchType(sb -> sb.append("text"))
    + *     .ratedAmperage(42)
    + *     .ratedAmperage(() -> 42)
    + *     .isDimmable(true)
    + *     .isDimmable(() -> true)
    + *     .hasIndicator(true)
    + *     .hasIndicator(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SwitchRecord.class) +public class SwitchRecordBuilder implements IBuilderBase { + + /** + * Tracked value for switchName: switchName. + */ + private TrackedValue switchName = unsetValue(); + /** + * Tracked value for switchType: switchType. + */ + private TrackedValue switchType = unsetValue(); + /** + * Tracked value for ratedAmperage: ratedAmperage. + */ + private TrackedValue ratedAmperage = unsetValue(); + /** + * Tracked value for isDimmable: isDimmable. + */ + private TrackedValue isDimmable = unsetValue(); + /** + * Tracked value for hasIndicator: hasIndicator. + */ + private TrackedValue hasIndicator = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SwitchRecord}. + */ + public SwitchRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.SwitchRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SwitchRecordBuilder(SwitchRecord instance) { + this.switchName = initialValue(instance.switchName()); + this.switchType = initialValue(instance.switchType()); + this.ratedAmperage = initialValue(instance.ratedAmperage()); + this.isDimmable = initialValue(instance.isDimmable()); + this.hasIndicator = initialValue(instance.hasIndicator()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SwitchRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SwitchRecordBuilder builder = SwitchRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.SwitchRecord} + */ + public static SwitchRecordBuilder create() { + return new SwitchRecordBuilder(); + } + + /** + * Sets the value for hasIndicator. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasIndicator(true);
    +   * }
    + * + * @param hasIndicator hasIndicator + * @return current instance of builder + */ + public SwitchRecordBuilder hasIndicator(boolean hasIndicator) { + this.hasIndicator = changedValue(hasIndicator); + return this; + } + + /** + * Sets the value for hasIndicator by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasIndicator(() -> true);
    +   * }
    + * + * @param hasIndicatorSupplier supplier for hasIndicator + * @return current instance of builder + */ + public SwitchRecordBuilder hasIndicator(Supplier hasIndicatorSupplier) { + this.hasIndicator = changedValue(hasIndicatorSupplier.get()); + return this; + } + + /** + * Sets the value for isDimmable. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isDimmable(true);
    +   * }
    + * + * @param isDimmable isDimmable + * @return current instance of builder + */ + public SwitchRecordBuilder isDimmable(boolean isDimmable) { + this.isDimmable = changedValue(isDimmable); + return this; + } + + /** + * Sets the value for isDimmable by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.isDimmable(() -> true);
    +   * }
    + * + * @param isDimmableSupplier supplier for isDimmable + * @return current instance of builder + */ + public SwitchRecordBuilder isDimmable(Supplier isDimmableSupplier) { + this.isDimmable = changedValue(isDimmableSupplier.get()); + return this; + } + + /** + * Sets the value for ratedAmperage. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ratedAmperage(42);
    +   * }
    + * + * @param ratedAmperage ratedAmperage + * @return current instance of builder + */ + public SwitchRecordBuilder ratedAmperage(int ratedAmperage) { + this.ratedAmperage = changedValue(ratedAmperage); + return this; + } + + /** + * Sets the value for ratedAmperage by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ratedAmperage(() -> 42);
    +   * }
    + * + * @param ratedAmperageSupplier supplier for ratedAmperage + * @return current instance of builder + */ + public SwitchRecordBuilder ratedAmperage(Supplier ratedAmperageSupplier) { + this.ratedAmperage = changedValue(ratedAmperageSupplier.get()); + return this; + } + + /** + * Sets the value for switchName. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchName("example value");
    +   * }
    + * + * @param switchName switchName + * @return current instance of builder + */ + public SwitchRecordBuilder switchName(String switchName) { + this.switchName = changedValue(switchName); + return this; + } + + /** + * Sets the value for switchName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchName(sb -> sb.append("text"));
    +   * }
    + * + * @param switchNameStringBuilderConsumer consumer providing an instance of switchName + * @return current instance of builder + */ + public SwitchRecordBuilder switchName(Consumer switchNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + switchNameStringBuilderConsumer.accept(builder); + this.switchName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for switchName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchName(() -> "example value");
    +   * }
    + * + * @param switchNameSupplier supplier for switchName + * @return current instance of builder + */ + public SwitchRecordBuilder switchName(Supplier switchNameSupplier) { + this.switchName = changedValue(switchNameSupplier.get()); + return this; + } + + /** + * Sets the String value for switchName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SwitchRecordBuilder switchName(String format, Object... args) { + this.switchName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for switchType. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchType("example value");
    +   * }
    + * + * @param switchType switchType + * @return current instance of builder + */ + public SwitchRecordBuilder switchType(String switchType) { + this.switchType = changedValue(switchType); + return this; + } + + /** + * Sets the value for switchType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchType(sb -> sb.append("text"));
    +   * }
    + * + * @param switchTypeStringBuilderConsumer consumer providing an instance of switchType + * @return current instance of builder + */ + public SwitchRecordBuilder switchType(Consumer switchTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + switchTypeStringBuilderConsumer.accept(builder); + this.switchType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for switchType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchType(() -> "example value");
    +   * }
    + * + * @param switchTypeSupplier supplier for switchType + * @return current instance of builder + */ + public SwitchRecordBuilder switchType(Supplier switchTypeSupplier) { + this.switchType = changedValue(switchTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for switchType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SwitchRecord#SwitchRecord(String, String, int, boolean, boolean) + * SwitchRecord(String switchName, String switchType, int ratedAmperage, boolean isDimmable, boolean hasIndicator)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.switchType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SwitchRecordBuilder switchType(String format, Object... args) { + this.switchType = changedValue(String.format(format, args)); + 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 SwitchRecordBuilder 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 SwitchRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SwitchRecord result = builder.build();
    +   * }
    + */ + @Override + public SwitchRecord build() { + if (!this.ratedAmperage.isSet()) { + throw new IllegalStateException("Required field 'ratedAmperage' must be set before calling build()"); + } + if (this.ratedAmperage.value() == null) { + throw new IllegalStateException("Field 'ratedAmperage' is marked as non-null but null value was provided"); + } + if (!this.isDimmable.isSet()) { + throw new IllegalStateException("Required field 'isDimmable' must be set before calling build()"); + } + if (this.isDimmable.value() == null) { + throw new IllegalStateException("Field 'isDimmable' is marked as non-null but null value was provided"); + } + if (!this.hasIndicator.isSet()) { + throw new IllegalStateException("Required field 'hasIndicator' must be set before calling build()"); + } + if (this.hasIndicator.value() == null) { + throw new IllegalStateException("Field 'hasIndicator' is marked as non-null but null value was provided"); + } + SwitchRecord result = new SwitchRecord(this.switchName.value(), + this.switchType.value(), + this.ratedAmperage.value(), + this.isDimmable.value(), + this.hasIndicator.value()); + 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("switchName", this.switchName) + .append("switchType", this.switchType) + .append("ratedAmperage", this.ratedAmperage) + .append("isDimmable", this.isDimmable) + .append("hasIndicator", this.hasIndicator) + .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 SwitchRecord with(Consumer b) { + SwitchRecordBuilder builder; + try { + builder = new SwitchRecordBuilder(SwitchRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SwitchRecordBuilder.With' should only be implemented by classes, which could be casted to 'SwitchRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SwitchRecordBuilder with() { + try { + return new SwitchRecordBuilder(SwitchRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SwitchRecordBuilder.With' should only be implemented by classes, which could be casted to 'SwitchRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TableRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TableRecordBuilder.java new file mode 100644 index 00000000..5ccf138e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TableRecordBuilder.java @@ -0,0 +1,511 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.TableRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.TableRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TableRecord result = TableRecordBuilder.create()
    + *     .tableName("example value")
    + *     .tableName("Hello %s", "World")
    + *     .tableName(() -> "example value")
    + *     .tableName(sb -> sb.append("text"))
    + *     .seatingCapacity(42)
    + *     .seatingCapacity(() -> 42)
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .depthCm(3.14)
    + *     .depthCm(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TableRecord.class) +public class TableRecordBuilder implements IBuilderBase { + + /** + * Tracked value for tableName: tableName. + */ + private TrackedValue tableName = unsetValue(); + /** + * Tracked value for seatingCapacity: seatingCapacity. + */ + private TrackedValue seatingCapacity = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for depthCm: depthCm. + */ + private TrackedValue depthCm = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.TableRecord}. + */ + public TableRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.TableRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TableRecordBuilder(TableRecord instance) { + this.tableName = initialValue(instance.tableName()); + this.seatingCapacity = initialValue(instance.seatingCapacity()); + this.widthCm = initialValue(instance.widthCm()); + this.depthCm = initialValue(instance.depthCm()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.TableRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TableRecordBuilder builder = TableRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.TableRecord} + */ + public static TableRecordBuilder create() { + return new TableRecordBuilder(); + } + + /** + * Sets the value for depthCm. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.depthCm(3.14);
    +   * }
    + * + * @param depthCm depthCm + * @return current instance of builder + */ + public TableRecordBuilder depthCm(double depthCm) { + this.depthCm = changedValue(depthCm); + return this; + } + + /** + * Sets the value for depthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.depthCm(() -> 3.14);
    +   * }
    + * + * @param depthCmSupplier supplier for depthCm + * @return current instance of builder + */ + public TableRecordBuilder depthCm(Supplier depthCmSupplier) { + this.depthCm = changedValue(depthCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public TableRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public TableRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public TableRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TableRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for seatingCapacity. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seatingCapacity(42);
    +   * }
    + * + * @param seatingCapacity seatingCapacity + * @return current instance of builder + */ + public TableRecordBuilder seatingCapacity(int seatingCapacity) { + this.seatingCapacity = changedValue(seatingCapacity); + return this; + } + + /** + * Sets the value for seatingCapacity by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seatingCapacity(() -> 42);
    +   * }
    + * + * @param seatingCapacitySupplier supplier for seatingCapacity + * @return current instance of builder + */ + public TableRecordBuilder seatingCapacity(Supplier seatingCapacitySupplier) { + this.seatingCapacity = changedValue(seatingCapacitySupplier.get()); + return this; + } + + /** + * Sets the value for tableName. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tableName("example value");
    +   * }
    + * + * @param tableName tableName + * @return current instance of builder + */ + public TableRecordBuilder tableName(String tableName) { + this.tableName = changedValue(tableName); + return this; + } + + /** + * Sets the value for tableName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tableName(sb -> sb.append("text"));
    +   * }
    + * + * @param tableNameStringBuilderConsumer consumer providing an instance of tableName + * @return current instance of builder + */ + public TableRecordBuilder tableName(Consumer tableNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + tableNameStringBuilderConsumer.accept(builder); + this.tableName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for tableName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tableName(() -> "example value");
    +   * }
    + * + * @param tableNameSupplier supplier for tableName + * @return current instance of builder + */ + public TableRecordBuilder tableName(Supplier tableNameSupplier) { + this.tableName = changedValue(tableNameSupplier.get()); + return this; + } + + /** + * Sets the String value for tableName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tableName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TableRecordBuilder tableName(String format, Object... args) { + this.tableName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public TableRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TableRecord#TableRecord(String, int, double, double, String) + * TableRecord(String tableName, int seatingCapacity, double widthCm, double depthCm, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public TableRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 TableRecordBuilder 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 TableRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TableRecord result = builder.build();
    +   * }
    + */ + @Override + public TableRecord build() { + if (!this.seatingCapacity.isSet()) { + throw new IllegalStateException("Required field 'seatingCapacity' must be set before calling build()"); + } + if (this.seatingCapacity.value() == null) { + throw new IllegalStateException("Field 'seatingCapacity' is marked as non-null but null value was provided"); + } + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.depthCm.isSet()) { + throw new IllegalStateException("Required field 'depthCm' must be set before calling build()"); + } + if (this.depthCm.value() == null) { + throw new IllegalStateException("Field 'depthCm' is marked as non-null but null value was provided"); + } + TableRecord result = new TableRecord(this.tableName + .value(), this.seatingCapacity.value(), this.widthCm.value(), this.depthCm.value(), this.material.value()); + 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("tableName", this.tableName) + .append("seatingCapacity", this.seatingCapacity) + .append("widthCm", this.widthCm) + .append("depthCm", this.depthCm) + .append("material", this.material) + .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 TableRecord with(Consumer b) { + TableRecordBuilder builder; + try { + builder = new TableRecordBuilder(TableRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TableRecordBuilder.With' should only be implemented by classes, which could be casted to 'TableRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TableRecordBuilder with() { + try { + return new TableRecordBuilder(TableRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TableRecordBuilder.With' should only be implemented by classes, which could be casted to 'TableRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TerraceRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TerraceRecordBuilder.java new file mode 100644 index 00000000..63dfa247 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TerraceRecordBuilder.java @@ -0,0 +1,469 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.TerraceRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.TerraceRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TerraceRecord result = TerraceRecordBuilder.create()
    + *     .terraceName("example value")
    + *     .terraceName("Hello %s", "World")
    + *     .terraceName(() -> "example value")
    + *     .terraceName(sb -> sb.append("text"))
    + *     .areaSquareMeters(3.14)
    + *     .areaSquareMeters(() -> 3.14)
    + *     .hasSeating(true)
    + *     .hasSeating(() -> true)
    + *     .hasShade(true)
    + *     .hasShade(() -> true)
    + *     .floorLevel(42)
    + *     .floorLevel(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TerraceRecord.class) +public class TerraceRecordBuilder implements IBuilderBase { + + /** + * Tracked value for terraceName: terraceName. + */ + private TrackedValue terraceName = unsetValue(); + /** + * Tracked value for areaSquareMeters: areaSquareMeters. + */ + private TrackedValue areaSquareMeters = unsetValue(); + /** + * Tracked value for hasSeating: hasSeating. + */ + private TrackedValue hasSeating = unsetValue(); + /** + * Tracked value for hasShade: hasShade. + */ + private TrackedValue hasShade = unsetValue(); + /** + * Tracked value for floorLevel: floorLevel. + */ + private TrackedValue floorLevel = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.TerraceRecord}. + */ + public TerraceRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.TerraceRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TerraceRecordBuilder(TerraceRecord instance) { + this.terraceName = initialValue(instance.terraceName()); + this.areaSquareMeters = initialValue(instance.areaSquareMeters()); + this.hasSeating = initialValue(instance.hasSeating()); + this.hasShade = initialValue(instance.hasShade()); + this.floorLevel = initialValue(instance.floorLevel()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.TerraceRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TerraceRecordBuilder builder = TerraceRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.TerraceRecord} + */ + public static TerraceRecordBuilder create() { + return new TerraceRecordBuilder(); + } + + /** + * Sets the value for areaSquareMeters. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(3.14);
    +   * }
    + * + * @param areaSquareMeters areaSquareMeters + * @return current instance of builder + */ + public TerraceRecordBuilder areaSquareMeters(double areaSquareMeters) { + this.areaSquareMeters = changedValue(areaSquareMeters); + return this; + } + + /** + * Sets the value for areaSquareMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(() -> 3.14);
    +   * }
    + * + * @param areaSquareMetersSupplier supplier for areaSquareMeters + * @return current instance of builder + */ + public TerraceRecordBuilder areaSquareMeters(Supplier areaSquareMetersSupplier) { + this.areaSquareMeters = changedValue(areaSquareMetersSupplier.get()); + return this; + } + + /** + * Sets the value for floorLevel. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(42);
    +   * }
    + * + * @param floorLevel floorLevel + * @return current instance of builder + */ + public TerraceRecordBuilder floorLevel(int floorLevel) { + this.floorLevel = changedValue(floorLevel); + return this; + } + + /** + * Sets the value for floorLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(() -> 42);
    +   * }
    + * + * @param floorLevelSupplier supplier for floorLevel + * @return current instance of builder + */ + public TerraceRecordBuilder floorLevel(Supplier floorLevelSupplier) { + this.floorLevel = changedValue(floorLevelSupplier.get()); + return this; + } + + /** + * Sets the value for hasSeating. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSeating(true);
    +   * }
    + * + * @param hasSeating hasSeating + * @return current instance of builder + */ + public TerraceRecordBuilder hasSeating(boolean hasSeating) { + this.hasSeating = changedValue(hasSeating); + return this; + } + + /** + * Sets the value for hasSeating by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSeating(() -> true);
    +   * }
    + * + * @param hasSeatingSupplier supplier for hasSeating + * @return current instance of builder + */ + public TerraceRecordBuilder hasSeating(Supplier hasSeatingSupplier) { + this.hasSeating = changedValue(hasSeatingSupplier.get()); + return this; + } + + /** + * Sets the value for hasShade. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasShade(true);
    +   * }
    + * + * @param hasShade hasShade + * @return current instance of builder + */ + public TerraceRecordBuilder hasShade(boolean hasShade) { + this.hasShade = changedValue(hasShade); + return this; + } + + /** + * Sets the value for hasShade by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasShade(() -> true);
    +   * }
    + * + * @param hasShadeSupplier supplier for hasShade + * @return current instance of builder + */ + public TerraceRecordBuilder hasShade(Supplier hasShadeSupplier) { + this.hasShade = changedValue(hasShadeSupplier.get()); + return this; + } + + /** + * Sets the value for terraceName. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.terraceName("example value");
    +   * }
    + * + * @param terraceName terraceName + * @return current instance of builder + */ + public TerraceRecordBuilder terraceName(String terraceName) { + this.terraceName = changedValue(terraceName); + return this; + } + + /** + * Sets the value for terraceName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.terraceName(sb -> sb.append("text"));
    +   * }
    + * + * @param terraceNameStringBuilderConsumer consumer providing an instance of terraceName + * @return current instance of builder + */ + public TerraceRecordBuilder terraceName(Consumer terraceNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + terraceNameStringBuilderConsumer.accept(builder); + this.terraceName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for terraceName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.terraceName(() -> "example value");
    +   * }
    + * + * @param terraceNameSupplier supplier for terraceName + * @return current instance of builder + */ + public TerraceRecordBuilder terraceName(Supplier terraceNameSupplier) { + this.terraceName = changedValue(terraceNameSupplier.get()); + return this; + } + + /** + * Sets the String value for terraceName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TerraceRecord#TerraceRecord(String, double, boolean, boolean, int) + * TerraceRecord(String terraceName, double areaSquareMeters, boolean hasSeating, boolean hasShade, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.terraceName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TerraceRecordBuilder terraceName(String format, Object... args) { + this.terraceName = changedValue(String.format(format, args)); + 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 TerraceRecordBuilder 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 TerraceRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TerraceRecord result = builder.build();
    +   * }
    + */ + @Override + public TerraceRecord build() { + if (!this.areaSquareMeters.isSet()) { + throw new IllegalStateException("Required field 'areaSquareMeters' must be set before calling build()"); + } + if (this.areaSquareMeters.value() == null) { + throw new IllegalStateException("Field 'areaSquareMeters' is marked as non-null but null value was provided"); + } + if (!this.hasShade.isSet()) { + throw new IllegalStateException("Required field 'hasShade' must be set before calling build()"); + } + if (this.hasShade.value() == null) { + throw new IllegalStateException("Field 'hasShade' is marked as non-null but null value was provided"); + } + if (!this.floorLevel.isSet()) { + throw new IllegalStateException("Required field 'floorLevel' must be set before calling build()"); + } + if (this.floorLevel.value() == null) { + throw new IllegalStateException("Field 'floorLevel' is marked as non-null but null value was provided"); + } + TerraceRecord result = new TerraceRecord(this.terraceName.value(), + this.areaSquareMeters.value(), + this.hasSeating.valueOr(true), + this.hasShade.value(), + this.floorLevel.value()); + 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("terraceName", this.terraceName) + .append("areaSquareMeters", this.areaSquareMeters) + .append("hasSeating", this.hasSeating) + .append("hasShade", this.hasShade) + .append("floorLevel", this.floorLevel) + .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 TerraceRecord with(Consumer b) { + TerraceRecordBuilder builder; + try { + builder = new TerraceRecordBuilder(TerraceRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TerraceRecordBuilder.With' should only be implemented by classes, which could be casted to 'TerraceRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TerraceRecordBuilder with() { + try { + return new TerraceRecordBuilder(TerraceRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TerraceRecordBuilder.With' should only be implemented by classes, which could be casted to 'TerraceRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TileRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TileRecordBuilder.java new file mode 100644 index 00000000..b48674a7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/TileRecordBuilder.java @@ -0,0 +1,551 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.TileRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.TileRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TileRecord result = TileRecordBuilder.create()
    + *     .tileName("example value")
    + *     .tileName("Hello %s", "World")
    + *     .tileName(() -> "example value")
    + *     .tileName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .finishType("example value")
    + *     .finishType("Hello %s", "World")
    + *     .finishType(() -> "example value")
    + *     .finishType(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TileRecord.class) +public class TileRecordBuilder implements IBuilderBase { + + /** + * Tracked value for tileName: tileName. + */ + private TrackedValue tileName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + /** + * Tracked value for finishType: finishType. + */ + private TrackedValue finishType = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.TileRecord}. + */ + public TileRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.TileRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public TileRecordBuilder(TileRecord instance) { + this.tileName = initialValue(instance.tileName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.material = initialValue(instance.material()); + this.finishType = initialValue(instance.finishType()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.TileRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TileRecordBuilder builder = TileRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.TileRecord} + */ + public static TileRecordBuilder create() { + return new TileRecordBuilder(); + } + + /** + * Sets the value for finishType. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.finishType("example value");
    +   * }
    + * + * @param finishType finishType + * @return current instance of builder + */ + public TileRecordBuilder finishType(String finishType) { + this.finishType = changedValue(finishType); + return this; + } + + /** + * Sets the value for finishType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.finishType(sb -> sb.append("text"));
    +   * }
    + * + * @param finishTypeStringBuilderConsumer consumer providing an instance of finishType + * @return current instance of builder + */ + public TileRecordBuilder finishType(Consumer finishTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + finishTypeStringBuilderConsumer.accept(builder); + this.finishType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for finishType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.finishType(() -> "example value");
    +   * }
    + * + * @param finishTypeSupplier supplier for finishType + * @return current instance of builder + */ + public TileRecordBuilder finishType(Supplier finishTypeSupplier) { + this.finishType = changedValue(finishTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for finishType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.finishType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TileRecordBuilder finishType(String format, Object... args) { + this.finishType = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public TileRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public TileRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public TileRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public TileRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public TileRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TileRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for tileName. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tileName("example value");
    +   * }
    + * + * @param tileName tileName + * @return current instance of builder + */ + public TileRecordBuilder tileName(String tileName) { + this.tileName = changedValue(tileName); + return this; + } + + /** + * Sets the value for tileName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tileName(sb -> sb.append("text"));
    +   * }
    + * + * @param tileNameStringBuilderConsumer consumer providing an instance of tileName + * @return current instance of builder + */ + public TileRecordBuilder tileName(Consumer tileNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + tileNameStringBuilderConsumer.accept(builder); + this.tileName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for tileName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tileName(() -> "example value");
    +   * }
    + * + * @param tileNameSupplier supplier for tileName + * @return current instance of builder + */ + public TileRecordBuilder tileName(Supplier tileNameSupplier) { + this.tileName = changedValue(tileNameSupplier.get()); + return this; + } + + /** + * Sets the String value for tileName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.tileName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TileRecordBuilder tileName(String format, Object... args) { + this.tileName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public TileRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TileRecord#TileRecord(String, double, double, String, String) + * TileRecord(String tileName, double widthCm, double heightCm, String material, String finishType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public TileRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 TileRecordBuilder 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 TileRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TileRecord result = builder.build();
    +   * }
    + */ + @Override + public TileRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + TileRecord result = new TileRecord(this.tileName + .value(), this.widthCm.value(), this.heightCm.value(), this.material.value(), this.finishType.value()); + 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("tileName", this.tileName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("material", this.material) + .append("finishType", this.finishType) + .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 TileRecord with(Consumer b) { + TileRecordBuilder builder; + try { + builder = new TileRecordBuilder(TileRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TileRecordBuilder.With' should only be implemented by classes, which could be casted to 'TileRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TileRecordBuilder with() { + try { + return new TileRecordBuilder(TileRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TileRecordBuilder.With' should only be implemented by classes, which could be casted to 'TileRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VentRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VentRecordBuilder.java new file mode 100644 index 00000000..6f2a3725 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VentRecordBuilder.java @@ -0,0 +1,514 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.VentRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.VentRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * VentRecord result = VentRecordBuilder.create()
    + *     .ventName("example value")
    + *     .ventName("Hello %s", "World")
    + *     .ventName(() -> "example value")
    + *     .ventName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .hasAdjustableLouvers(true)
    + *     .hasAdjustableLouvers(() -> true)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = VentRecord.class) +public class VentRecordBuilder implements IBuilderBase { + + /** + * Tracked value for ventName: ventName. + */ + private TrackedValue ventName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for hasAdjustableLouvers: hasAdjustableLouvers. + */ + private TrackedValue hasAdjustableLouvers = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.VentRecord}. + */ + public VentRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.VentRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public VentRecordBuilder(VentRecord instance) { + this.ventName = initialValue(instance.ventName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.hasAdjustableLouvers = initialValue(instance.hasAdjustableLouvers()); + this.material = initialValue(instance.material()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.VentRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * VentRecordBuilder builder = VentRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.VentRecord} + */ + public static VentRecordBuilder create() { + return new VentRecordBuilder(); + } + + /** + * Sets the value for hasAdjustableLouvers. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasAdjustableLouvers(true);
    +   * }
    + * + * @param hasAdjustableLouvers hasAdjustableLouvers + * @return current instance of builder + */ + public VentRecordBuilder hasAdjustableLouvers(boolean hasAdjustableLouvers) { + this.hasAdjustableLouvers = changedValue(hasAdjustableLouvers); + return this; + } + + /** + * Sets the value for hasAdjustableLouvers by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasAdjustableLouvers(() -> true);
    +   * }
    + * + * @param hasAdjustableLouversSupplier supplier for hasAdjustableLouvers + * @return current instance of builder + */ + public VentRecordBuilder hasAdjustableLouvers(Supplier hasAdjustableLouversSupplier) { + this.hasAdjustableLouvers = changedValue(hasAdjustableLouversSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public VentRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public VentRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public VentRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public VentRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public VentRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VentRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for ventName. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ventName("example value");
    +   * }
    + * + * @param ventName ventName + * @return current instance of builder + */ + public VentRecordBuilder ventName(String ventName) { + this.ventName = changedValue(ventName); + return this; + } + + /** + * Sets the value for ventName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ventName(sb -> sb.append("text"));
    +   * }
    + * + * @param ventNameStringBuilderConsumer consumer providing an instance of ventName + * @return current instance of builder + */ + public VentRecordBuilder ventName(Consumer ventNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + ventNameStringBuilderConsumer.accept(builder); + this.ventName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for ventName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ventName(() -> "example value");
    +   * }
    + * + * @param ventNameSupplier supplier for ventName + * @return current instance of builder + */ + public VentRecordBuilder ventName(Supplier ventNameSupplier) { + this.ventName = changedValue(ventNameSupplier.get()); + return this; + } + + /** + * Sets the String value for ventName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ventName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VentRecordBuilder ventName(String format, Object... args) { + this.ventName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public VentRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VentRecord#VentRecord(String, double, double, boolean, String) + * VentRecord(String ventName, double widthCm, double heightCm, boolean hasAdjustableLouvers, String material)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public VentRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + 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 VentRecordBuilder 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 VentRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * VentRecord result = builder.build();
    +   * }
    + */ + @Override + public VentRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasAdjustableLouvers.isSet()) { + throw new IllegalStateException("Required field 'hasAdjustableLouvers' must be set before calling build()"); + } + if (this.hasAdjustableLouvers.value() == null) { + throw new IllegalStateException("Field 'hasAdjustableLouvers' is marked as non-null but null value was provided"); + } + VentRecord result = new VentRecord(this.ventName.value(), + this.widthCm.value(), + this.heightCm.value(), + this.hasAdjustableLouvers.value(), + this.material.value()); + 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("ventName", this.ventName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("hasAdjustableLouvers", this.hasAdjustableLouvers) + .append("material", this.material) + .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 VentRecord with(Consumer b) { + VentRecordBuilder builder; + try { + builder = new VentRecordBuilder(VentRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VentRecordBuilder.With' should only be implemented by classes, which could be casted to 'VentRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VentRecordBuilder with() { + try { + return new VentRecordBuilder(VentRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VentRecordBuilder.With' should only be implemented by classes, which could be casted to 'VentRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VerandaRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VerandaRecordBuilder.java new file mode 100644 index 00000000..d6151564 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/VerandaRecordBuilder.java @@ -0,0 +1,463 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.VerandaRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.VerandaRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * VerandaRecord result = VerandaRecordBuilder.create()
    + *     .verandaName("example value")
    + *     .verandaName("Hello %s", "World")
    + *     .verandaName(() -> "example value")
    + *     .verandaName(sb -> sb.append("text"))
    + *     .areaSquareMeters(3.14)
    + *     .areaSquareMeters(() -> 3.14)
    + *     .hasRoof(true)
    + *     .hasRoof(() -> true)
    + *     .hasSeating(true)
    + *     .hasSeating(() -> true)
    + *     .floorLevel(42)
    + *     .floorLevel(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = VerandaRecord.class) +public class VerandaRecordBuilder implements IBuilderBase { + + /** + * Tracked value for verandaName: verandaName. + */ + private TrackedValue verandaName = unsetValue(); + /** + * Tracked value for areaSquareMeters: areaSquareMeters. + */ + private TrackedValue areaSquareMeters = unsetValue(); + /** + * Tracked value for hasRoof: hasRoof. + */ + private TrackedValue hasRoof = unsetValue(); + /** + * Tracked value for hasSeating: hasSeating. + */ + private TrackedValue hasSeating = unsetValue(); + /** + * Tracked value for floorLevel: floorLevel. + */ + private TrackedValue floorLevel = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.VerandaRecord}. + */ + public VerandaRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.VerandaRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public VerandaRecordBuilder(VerandaRecord instance) { + this.verandaName = initialValue(instance.verandaName()); + this.areaSquareMeters = initialValue(instance.areaSquareMeters()); + this.hasRoof = initialValue(instance.hasRoof()); + this.hasSeating = initialValue(instance.hasSeating()); + this.floorLevel = initialValue(instance.floorLevel()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.VerandaRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * VerandaRecordBuilder builder = VerandaRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.VerandaRecord} + */ + public static VerandaRecordBuilder create() { + return new VerandaRecordBuilder(); + } + + /** + * Sets the value for areaSquareMeters. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(3.14);
    +   * }
    + * + * @param areaSquareMeters areaSquareMeters + * @return current instance of builder + */ + public VerandaRecordBuilder areaSquareMeters(double areaSquareMeters) { + this.areaSquareMeters = changedValue(areaSquareMeters); + return this; + } + + /** + * Sets the value for areaSquareMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.areaSquareMeters(() -> 3.14);
    +   * }
    + * + * @param areaSquareMetersSupplier supplier for areaSquareMeters + * @return current instance of builder + */ + public VerandaRecordBuilder areaSquareMeters(Supplier areaSquareMetersSupplier) { + this.areaSquareMeters = changedValue(areaSquareMetersSupplier.get()); + return this; + } + + /** + * Sets the value for floorLevel. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(42);
    +   * }
    + * + * @param floorLevel floorLevel + * @return current instance of builder + */ + public VerandaRecordBuilder floorLevel(int floorLevel) { + this.floorLevel = changedValue(floorLevel); + return this; + } + + /** + * Sets the value for floorLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.floorLevel(() -> 42);
    +   * }
    + * + * @param floorLevelSupplier supplier for floorLevel + * @return current instance of builder + */ + public VerandaRecordBuilder floorLevel(Supplier floorLevelSupplier) { + this.floorLevel = changedValue(floorLevelSupplier.get()); + return this; + } + + /** + * Sets the value for hasRoof. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasRoof(true);
    +   * }
    + * + * @param hasRoof hasRoof + * @return current instance of builder + */ + public VerandaRecordBuilder hasRoof(boolean hasRoof) { + this.hasRoof = changedValue(hasRoof); + return this; + } + + /** + * Sets the value for hasRoof by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasRoof(() -> true);
    +   * }
    + * + * @param hasRoofSupplier supplier for hasRoof + * @return current instance of builder + */ + public VerandaRecordBuilder hasRoof(Supplier hasRoofSupplier) { + this.hasRoof = changedValue(hasRoofSupplier.get()); + return this; + } + + /** + * Sets the value for hasSeating. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSeating(true);
    +   * }
    + * + * @param hasSeating hasSeating + * @return current instance of builder + */ + public VerandaRecordBuilder hasSeating(boolean hasSeating) { + this.hasSeating = changedValue(hasSeating); + return this; + } + + /** + * Sets the value for hasSeating by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasSeating(() -> true);
    +   * }
    + * + * @param hasSeatingSupplier supplier for hasSeating + * @return current instance of builder + */ + public VerandaRecordBuilder hasSeating(Supplier hasSeatingSupplier) { + this.hasSeating = changedValue(hasSeatingSupplier.get()); + return this; + } + + /** + * Sets the value for verandaName. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.verandaName("example value");
    +   * }
    + * + * @param verandaName verandaName + * @return current instance of builder + */ + public VerandaRecordBuilder verandaName(String verandaName) { + this.verandaName = changedValue(verandaName); + return this; + } + + /** + * Sets the value for verandaName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.verandaName(sb -> sb.append("text"));
    +   * }
    + * + * @param verandaNameStringBuilderConsumer consumer providing an instance of verandaName + * @return current instance of builder + */ + public VerandaRecordBuilder verandaName(Consumer verandaNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + verandaNameStringBuilderConsumer.accept(builder); + this.verandaName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for verandaName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.verandaName(() -> "example value");
    +   * }
    + * + * @param verandaNameSupplier supplier for verandaName + * @return current instance of builder + */ + public VerandaRecordBuilder verandaName(Supplier verandaNameSupplier) { + this.verandaName = changedValue(verandaNameSupplier.get()); + return this; + } + + /** + * Sets the String value for verandaName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link VerandaRecord#VerandaRecord(String, double, boolean, boolean, int) + * VerandaRecord(String verandaName, double areaSquareMeters, boolean hasRoof, boolean hasSeating, int floorLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.verandaName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VerandaRecordBuilder verandaName(String format, Object... args) { + this.verandaName = changedValue(String.format(format, args)); + 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 VerandaRecordBuilder 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 VerandaRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * VerandaRecord result = builder.build();
    +   * }
    + */ + @Override + public VerandaRecord build() { + if (!this.areaSquareMeters.isSet()) { + throw new IllegalStateException("Required field 'areaSquareMeters' must be set before calling build()"); + } + if (this.areaSquareMeters.value() == null) { + throw new IllegalStateException("Field 'areaSquareMeters' is marked as non-null but null value was provided"); + } + if (!this.floorLevel.isSet()) { + throw new IllegalStateException("Required field 'floorLevel' must be set before calling build()"); + } + if (this.floorLevel.value() == null) { + throw new IllegalStateException("Field 'floorLevel' is marked as non-null but null value was provided"); + } + VerandaRecord result = new VerandaRecord(this.verandaName.value(), + this.areaSquareMeters.value(), + this.hasRoof.valueOr(true), + this.hasSeating.valueOr(true), + this.floorLevel.value()); + 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("verandaName", this.verandaName) + .append("areaSquareMeters", this.areaSquareMeters) + .append("hasRoof", this.hasRoof) + .append("hasSeating", this.hasSeating) + .append("floorLevel", this.floorLevel) + .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 VerandaRecord with(Consumer b) { + VerandaRecordBuilder builder; + try { + builder = new VerandaRecordBuilder(VerandaRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VerandaRecordBuilder.With' should only be implemented by classes, which could be casted to 'VerandaRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VerandaRecordBuilder with() { + try { + return new VerandaRecordBuilder(VerandaRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VerandaRecordBuilder.With' should only be implemented by classes, which could be casted to 'VerandaRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WindowRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WindowRecordBuilder.java new file mode 100644 index 00000000..af0827d4 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WindowRecordBuilder.java @@ -0,0 +1,465 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.WindowRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.WindowRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * WindowRecord result = WindowRecordBuilder.create()
    + *     .windowName("example value")
    + *     .windowName("Hello %s", "World")
    + *     .windowName(() -> "example value")
    + *     .windowName(sb -> sb.append("text"))
    + *     .widthCm(3.14)
    + *     .widthCm(() -> 3.14)
    + *     .heightCm(3.14)
    + *     .heightCm(() -> 3.14)
    + *     .canOpen(true)
    + *     .canOpen(() -> true)
    + *     .hasBlinds(true)
    + *     .hasBlinds(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WindowRecord.class) +public class WindowRecordBuilder implements IBuilderBase { + + /** + * Tracked value for windowName: windowName. + */ + private TrackedValue windowName = unsetValue(); + /** + * Tracked value for widthCm: widthCm. + */ + private TrackedValue widthCm = unsetValue(); + /** + * Tracked value for heightCm: heightCm. + */ + private TrackedValue heightCm = unsetValue(); + /** + * Tracked value for canOpen: canOpen. + */ + private TrackedValue canOpen = unsetValue(); + /** + * Tracked value for hasBlinds: hasBlinds. + */ + private TrackedValue hasBlinds = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.WindowRecord}. + */ + public WindowRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.WindowRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public WindowRecordBuilder(WindowRecord instance) { + this.windowName = initialValue(instance.windowName()); + this.widthCm = initialValue(instance.widthCm()); + this.heightCm = initialValue(instance.heightCm()); + this.canOpen = initialValue(instance.canOpen()); + this.hasBlinds = initialValue(instance.hasBlinds()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.WindowRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * WindowRecordBuilder builder = WindowRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.WindowRecord} + */ + public static WindowRecordBuilder create() { + return new WindowRecordBuilder(); + } + + /** + * Sets the value for canOpen. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.canOpen(true);
    +   * }
    + * + * @param canOpen canOpen + * @return current instance of builder + */ + public WindowRecordBuilder canOpen(boolean canOpen) { + this.canOpen = changedValue(canOpen); + return this; + } + + /** + * Sets the value for canOpen by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.canOpen(() -> true);
    +   * }
    + * + * @param canOpenSupplier supplier for canOpen + * @return current instance of builder + */ + public WindowRecordBuilder canOpen(Supplier canOpenSupplier) { + this.canOpen = changedValue(canOpenSupplier.get()); + return this; + } + + /** + * Sets the value for hasBlinds. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasBlinds(true);
    +   * }
    + * + * @param hasBlinds hasBlinds + * @return current instance of builder + */ + public WindowRecordBuilder hasBlinds(boolean hasBlinds) { + this.hasBlinds = changedValue(hasBlinds); + return this; + } + + /** + * Sets the value for hasBlinds by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hasBlinds(() -> true);
    +   * }
    + * + * @param hasBlindsSupplier supplier for hasBlinds + * @return current instance of builder + */ + public WindowRecordBuilder hasBlinds(Supplier hasBlindsSupplier) { + this.hasBlinds = changedValue(hasBlindsSupplier.get()); + return this; + } + + /** + * Sets the value for heightCm. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(3.14);
    +   * }
    + * + * @param heightCm heightCm + * @return current instance of builder + */ + public WindowRecordBuilder heightCm(double heightCm) { + this.heightCm = changedValue(heightCm); + return this; + } + + /** + * Sets the value for heightCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.heightCm(() -> 3.14);
    +   * }
    + * + * @param heightCmSupplier supplier for heightCm + * @return current instance of builder + */ + public WindowRecordBuilder heightCm(Supplier heightCmSupplier) { + this.heightCm = changedValue(heightCmSupplier.get()); + return this; + } + + /** + * Sets the value for widthCm. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(3.14);
    +   * }
    + * + * @param widthCm widthCm + * @return current instance of builder + */ + public WindowRecordBuilder widthCm(double widthCm) { + this.widthCm = changedValue(widthCm); + return this; + } + + /** + * Sets the value for widthCm by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.widthCm(() -> 3.14);
    +   * }
    + * + * @param widthCmSupplier supplier for widthCm + * @return current instance of builder + */ + public WindowRecordBuilder widthCm(Supplier widthCmSupplier) { + this.widthCm = changedValue(widthCmSupplier.get()); + return this; + } + + /** + * Sets the value for windowName. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.windowName("example value");
    +   * }
    + * + * @param windowName windowName + * @return current instance of builder + */ + public WindowRecordBuilder windowName(String windowName) { + this.windowName = changedValue(windowName); + return this; + } + + /** + * Sets the value for windowName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.windowName(sb -> sb.append("text"));
    +   * }
    + * + * @param windowNameStringBuilderConsumer consumer providing an instance of windowName + * @return current instance of builder + */ + public WindowRecordBuilder windowName(Consumer windowNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + windowNameStringBuilderConsumer.accept(builder); + this.windowName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for windowName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.windowName(() -> "example value");
    +   * }
    + * + * @param windowNameSupplier supplier for windowName + * @return current instance of builder + */ + public WindowRecordBuilder windowName(Supplier windowNameSupplier) { + this.windowName = changedValue(windowNameSupplier.get()); + return this; + } + + /** + * Sets the String value for windowName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WindowRecord#WindowRecord(String, double, double, boolean, boolean) + * WindowRecord(String windowName, double widthCm, double heightCm, boolean canOpen, boolean hasBlinds)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.windowName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WindowRecordBuilder windowName(String format, Object... args) { + this.windowName = changedValue(String.format(format, args)); + 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 WindowRecordBuilder 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 WindowRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WindowRecord result = builder.build();
    +   * }
    + */ + @Override + public WindowRecord build() { + if (!this.widthCm.isSet()) { + throw new IllegalStateException("Required field 'widthCm' must be set before calling build()"); + } + if (this.widthCm.value() == null) { + throw new IllegalStateException("Field 'widthCm' is marked as non-null but null value was provided"); + } + if (!this.heightCm.isSet()) { + throw new IllegalStateException("Required field 'heightCm' must be set before calling build()"); + } + if (this.heightCm.value() == null) { + throw new IllegalStateException("Field 'heightCm' is marked as non-null but null value was provided"); + } + if (!this.hasBlinds.isSet()) { + throw new IllegalStateException("Required field 'hasBlinds' must be set before calling build()"); + } + if (this.hasBlinds.value() == null) { + throw new IllegalStateException("Field 'hasBlinds' is marked as non-null but null value was provided"); + } + WindowRecord result = new WindowRecord(this.windowName + .value(), this.widthCm.value(), this.heightCm.value(), this.canOpen.valueOr(true), this.hasBlinds.value()); + 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("windowName", this.windowName) + .append("widthCm", this.widthCm) + .append("heightCm", this.heightCm) + .append("canOpen", this.canOpen) + .append("hasBlinds", this.hasBlinds) + .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 WindowRecord with(Consumer b) { + WindowRecordBuilder builder; + try { + builder = new WindowRecordBuilder(WindowRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WindowRecordBuilder.With' should only be implemented by classes, which could be casted to 'WindowRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WindowRecordBuilder with() { + try { + return new WindowRecordBuilder(WindowRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WindowRecordBuilder.With' should only be implemented by classes, which could be casted to 'WindowRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WireRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WireRecordBuilder.java new file mode 100644 index 00000000..c01fd85c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/locations/WireRecordBuilder.java @@ -0,0 +1,551 @@ +package org.javahelpers.simple.builders.performance_test.library.locations; + +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.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.performance_test.library.locations.WireRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.locations.WireRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * WireRecord result = WireRecordBuilder.create()
    + *     .wireName("example value")
    + *     .wireName("Hello %s", "World")
    + *     .wireName(() -> "example value")
    + *     .wireName(sb -> sb.append("text"))
    + *     .gauge("example value")
    + *     .gauge("Hello %s", "World")
    + *     .gauge(() -> "example value")
    + *     .gauge(sb -> sb.append("text"))
    + *     .lengthMeters(3.14)
    + *     .lengthMeters(() -> 3.14)
    + *     .material("example value")
    + *     .material("Hello %s", "World")
    + *     .material(() -> "example value")
    + *     .material(sb -> sb.append("text"))
    + *     .ratedVoltage(42)
    + *     .ratedVoltage(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WireRecord.class) +public class WireRecordBuilder implements IBuilderBase { + + /** + * Tracked value for wireName: wireName. + */ + private TrackedValue wireName = unsetValue(); + /** + * Tracked value for gauge: gauge. + */ + private TrackedValue gauge = unsetValue(); + /** + * Tracked value for lengthMeters: lengthMeters. + */ + private TrackedValue lengthMeters = unsetValue(); + /** + * Tracked value for material: material. + */ + private TrackedValue material = unsetValue(); + /** + * Tracked value for ratedVoltage: ratedVoltage. + */ + private TrackedValue ratedVoltage = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.locations.WireRecord}. + */ + public WireRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.WireRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public WireRecordBuilder(WireRecord instance) { + this.wireName = initialValue(instance.wireName()); + this.gauge = initialValue(instance.gauge()); + this.lengthMeters = initialValue(instance.lengthMeters()); + this.material = initialValue(instance.material()); + this.ratedVoltage = initialValue(instance.ratedVoltage()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.WireRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * WireRecordBuilder builder = WireRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.locations.WireRecord} + */ + public static WireRecordBuilder create() { + return new WireRecordBuilder(); + } + + /** + * Sets the value for gauge. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gauge("example value");
    +   * }
    + * + * @param gauge gauge + * @return current instance of builder + */ + public WireRecordBuilder gauge(String gauge) { + this.gauge = changedValue(gauge); + return this; + } + + /** + * Sets the value for gauge by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gauge(sb -> sb.append("text"));
    +   * }
    + * + * @param gaugeStringBuilderConsumer consumer providing an instance of gauge + * @return current instance of builder + */ + public WireRecordBuilder gauge(Consumer gaugeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + gaugeStringBuilderConsumer.accept(builder); + this.gauge = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for gauge by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gauge(() -> "example value");
    +   * }
    + * + * @param gaugeSupplier supplier for gauge + * @return current instance of builder + */ + public WireRecordBuilder gauge(Supplier gaugeSupplier) { + this.gauge = changedValue(gaugeSupplier.get()); + return this; + } + + /** + * Sets the String value for gauge by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gauge("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WireRecordBuilder gauge(String format, Object... args) { + this.gauge = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for lengthMeters. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(3.14);
    +   * }
    + * + * @param lengthMeters lengthMeters + * @return current instance of builder + */ + public WireRecordBuilder lengthMeters(double lengthMeters) { + this.lengthMeters = changedValue(lengthMeters); + return this; + } + + /** + * Sets the value for lengthMeters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lengthMeters(() -> 3.14);
    +   * }
    + * + * @param lengthMetersSupplier supplier for lengthMeters + * @return current instance of builder + */ + public WireRecordBuilder lengthMeters(Supplier lengthMetersSupplier) { + this.lengthMeters = changedValue(lengthMetersSupplier.get()); + return this; + } + + /** + * Sets the value for material. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("example value");
    +   * }
    + * + * @param material material + * @return current instance of builder + */ + public WireRecordBuilder material(String material) { + this.material = changedValue(material); + return this; + } + + /** + * Sets the value for material by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(sb -> sb.append("text"));
    +   * }
    + * + * @param materialStringBuilderConsumer consumer providing an instance of material + * @return current instance of builder + */ + public WireRecordBuilder material(Consumer materialStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + materialStringBuilderConsumer.accept(builder); + this.material = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for material by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material(() -> "example value");
    +   * }
    + * + * @param materialSupplier supplier for material + * @return current instance of builder + */ + public WireRecordBuilder material(Supplier materialSupplier) { + this.material = changedValue(materialSupplier.get()); + return this; + } + + /** + * Sets the String value for material by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.material("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WireRecordBuilder material(String format, Object... args) { + this.material = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for ratedVoltage. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ratedVoltage(42);
    +   * }
    + * + * @param ratedVoltage ratedVoltage + * @return current instance of builder + */ + public WireRecordBuilder ratedVoltage(int ratedVoltage) { + this.ratedVoltage = changedValue(ratedVoltage); + return this; + } + + /** + * Sets the value for ratedVoltage by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ratedVoltage(() -> 42);
    +   * }
    + * + * @param ratedVoltageSupplier supplier for ratedVoltage + * @return current instance of builder + */ + public WireRecordBuilder ratedVoltage(Supplier ratedVoltageSupplier) { + this.ratedVoltage = changedValue(ratedVoltageSupplier.get()); + return this; + } + + /** + * Sets the value for wireName. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wireName("example value");
    +   * }
    + * + * @param wireName wireName + * @return current instance of builder + */ + public WireRecordBuilder wireName(String wireName) { + this.wireName = changedValue(wireName); + return this; + } + + /** + * Sets the value for wireName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wireName(sb -> sb.append("text"));
    +   * }
    + * + * @param wireNameStringBuilderConsumer consumer providing an instance of wireName + * @return current instance of builder + */ + public WireRecordBuilder wireName(Consumer wireNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + wireNameStringBuilderConsumer.accept(builder); + this.wireName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for wireName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wireName(() -> "example value");
    +   * }
    + * + * @param wireNameSupplier supplier for wireName + * @return current instance of builder + */ + public WireRecordBuilder wireName(Supplier wireNameSupplier) { + this.wireName = changedValue(wireNameSupplier.get()); + return this; + } + + /** + * Sets the String value for wireName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link WireRecord#WireRecord(String, String, double, String, int) + * WireRecord(String wireName, String gauge, double lengthMeters, String material, int ratedVoltage)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wireName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WireRecordBuilder wireName(String format, Object... args) { + this.wireName = changedValue(String.format(format, args)); + 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 WireRecordBuilder 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 WireRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WireRecord result = builder.build();
    +   * }
    + */ + @Override + public WireRecord build() { + if (!this.lengthMeters.isSet()) { + throw new IllegalStateException("Required field 'lengthMeters' must be set before calling build()"); + } + if (this.lengthMeters.value() == null) { + throw new IllegalStateException("Field 'lengthMeters' is marked as non-null but null value was provided"); + } + if (!this.ratedVoltage.isSet()) { + throw new IllegalStateException("Required field 'ratedVoltage' must be set before calling build()"); + } + if (this.ratedVoltage.value() == null) { + throw new IllegalStateException("Field 'ratedVoltage' is marked as non-null but null value was provided"); + } + WireRecord result = new WireRecord(this.wireName + .value(), this.gauge.value(), this.lengthMeters.value(), this.material.value(), this.ratedVoltage.value()); + 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("wireName", this.wireName) + .append("gauge", this.gauge) + .append("lengthMeters", this.lengthMeters) + .append("material", this.material) + .append("ratedVoltage", this.ratedVoltage) + .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 WireRecord with(Consumer b) { + WireRecordBuilder builder; + try { + builder = new WireRecordBuilder(WireRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WireRecordBuilder.With' should only be implemented by classes, which could be casted to 'WireRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WireRecordBuilder with() { + try { + return new WireRecordBuilder(WireRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WireRecordBuilder.With' should only be implemented by classes, which could be casted to 'WireRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MapPublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MapPublisherBuilder.java new file mode 100644 index 00000000..26cb1606 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MapPublisherBuilder.java @@ -0,0 +1,715 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MapPublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MapPublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * MapPublisher result = MapPublisherBuilder.create()
    + *     .coverageRegions(List.of("example value"))
    + *     .coverageRegions(() -> List.of("example value"))
    + *     .coverageRegions(t -> t.add("example value"))
    + *     .coverageRegions("example value", "example value")
    + *     .add2CoverageRegions("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .digitalMaps(42)
    + *     .digitalMaps(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .mapTitles(42)
    + *     .mapTitles(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MapPublisher.class) +public class MapPublisherBuilder implements IBuilderBase { + + /** + * Tracked value for coverageRegions: coverageRegions. + */ + private TrackedValue> coverageRegions = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for digitalMaps: digitalMaps. + */ + private TrackedValue digitalMaps = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for mapTitles: mapTitles. + */ + private TrackedValue mapTitles = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MapPublisher}. + */ + public MapPublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MapPublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public MapPublisherBuilder(MapPublisher instance) { + this.coverageRegions = initialValue(instance.getCoverageRegions()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.digitalMaps = initialValue(instance.getDigitalMaps()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.mapTitles = initialValue(instance.getMapTitles()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MapPublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * MapPublisherBuilder builder = MapPublisherBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MapPublisher} + */ + public static MapPublisherBuilder create() { + return new MapPublisherBuilder(); + } + + /** + * Adds a single element to coverageRegions. + *

    + * Generated from setter {@link MapPublisher#setCoverageRegions(List) setCoverageRegions(List + * coverageRegions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2CoverageRegions("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MapPublisherBuilder add2CoverageRegions(String element) { + List newCollection; + if (this.coverageRegions.isSet()) { + newCollection = new ArrayList<>(this.coverageRegions.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.coverageRegions = changedValue(newCollection); + return this; + } + + /** + * Sets the value for coverageRegions. + *

    + * Generated from setter {@link MapPublisher#setCoverageRegions(List) setCoverageRegions(List + * coverageRegions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.coverageRegions("example value", "example value");
    +   * }
    + * + * @param coverageRegions coverageRegions + * @return current instance of builder + */ + public MapPublisherBuilder coverageRegions(String... coverageRegions) { + this.coverageRegions = changedValue(List.of(coverageRegions)); + return this; + } + + /** + * Sets the value for coverageRegions. + *

    + * Generated from setter {@link MapPublisher#setCoverageRegions(List) setCoverageRegions(List + * coverageRegions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.coverageRegions(List.of("example value"));
    +   * }
    + * + * @param coverageRegions coverageRegions + * @return current instance of builder + */ + public MapPublisherBuilder coverageRegions(List coverageRegions) { + this.coverageRegions = changedValue(coverageRegions); + return this; + } + + /** + * Sets the value for coverageRegions using a builder consumer that produces the value. + *

    + * Generated from setter {@link MapPublisher#setCoverageRegions(List) setCoverageRegions(List + * coverageRegions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.coverageRegions(t -> t.add("example value"));
    +   * }
    + * + * @param coverageRegionsBuilderConsumer consumer providing an instance of a builder for coverageRegions + * @return current instance of builder + */ + public MapPublisherBuilder coverageRegions(Consumer> coverageRegionsBuilderConsumer) { + ArrayListBuilder builder = this.coverageRegions.isSet() + ? new ArrayListBuilder(this.coverageRegions.value()) + : new ArrayListBuilder(); + coverageRegionsBuilderConsumer.accept(builder); + this.coverageRegions = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for coverageRegions by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setCoverageRegions(List) setCoverageRegions(List + * coverageRegions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.coverageRegions(() -> List.of("example value"));
    +   * }
    + * + * @param coverageRegionsSupplier supplier for coverageRegions + * @return current instance of builder + */ + public MapPublisherBuilder coverageRegions(Supplier> coverageRegionsSupplier) { + this.coverageRegions = changedValue(coverageRegionsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MapPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MapPublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MapPublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for digitalMaps. + *

    + * Generated from setter {@link MapPublisher#setDigitalMaps(int) setDigitalMaps(int digitalMaps)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.digitalMaps(42);
    +   * }
    + * + * @param digitalMaps digitalMaps + * @return current instance of builder + */ + public MapPublisherBuilder digitalMaps(int digitalMaps) { + this.digitalMaps = changedValue(digitalMaps); + return this; + } + + /** + * Sets the value for digitalMaps by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setDigitalMaps(int) setDigitalMaps(int digitalMaps)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.digitalMaps(() -> 42);
    +   * }
    + * + * @param digitalMapsSupplier supplier for digitalMaps + * @return current instance of builder + */ + public MapPublisherBuilder digitalMaps(Supplier digitalMapsSupplier) { + this.digitalMaps = changedValue(digitalMapsSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MapPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MapPublisherBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MapPublisherBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MapPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MapPublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MapPublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for mapTitles. + *

    + * Generated from setter {@link MapPublisher#setMapTitles(int) setMapTitles(int mapTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mapTitles(42);
    +   * }
    + * + * @param mapTitles mapTitles + * @return current instance of builder + */ + public MapPublisherBuilder mapTitles(int mapTitles) { + this.mapTitles = changedValue(mapTitles); + return this; + } + + /** + * Sets the value for mapTitles by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setMapTitles(int) setMapTitles(int mapTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mapTitles(() -> 42);
    +   * }
    + * + * @param mapTitlesSupplier supplier for mapTitles + * @return current instance of builder + */ + public MapPublisherBuilder mapTitles(Supplier mapTitlesSupplier) { + this.mapTitles = changedValue(mapTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MapPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MapPublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MapPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MapPublisherBuilder 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. + *

    + * Generated from setter {@link MapPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MapPublisherBuilder 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. + *

    + * Generated from setter {@link MapPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MapPublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MapPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MapPublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MapPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MapPublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MapPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MapPublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MapPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MapPublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MapPublisherBuilder 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 MapPublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MapPublisher result = builder.build();
    +   * }
    + */ + @Override + public MapPublisher build() { + if (this.digitalMaps.isSet() && this.digitalMaps.value() == null) { + throw new IllegalStateException("Field 'digitalMaps' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.mapTitles.isSet() && this.mapTitles.value() == null) { + throw new IllegalStateException("Field 'mapTitles' is marked as non-null but null value was provided"); + } + MapPublisher result = new MapPublisher(); + this.coverageRegions.ifSet(result::setCoverageRegions); + this.createdAt.ifSet(result::setCreatedAt); + this.digitalMaps.ifSet(result::setDigitalMaps); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.mapTitles.ifSet(result::setMapTitles); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("coverageRegions", this.coverageRegions) + .append("createdAt", this.createdAt) + .append("digitalMaps", this.digitalMaps) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("mapTitles", this.mapTitles) + .append("name", this.name) + .append("status", this.status) + .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 MapPublisher with(Consumer b) { + MapPublisherBuilder builder; + try { + builder = new MapPublisherBuilder(MapPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MapPublisherBuilder.With' should only be implemented by classes, which could be casted to 'MapPublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MapPublisherBuilder with() { + try { + return new MapPublisherBuilder(MapPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MapPublisherBuilder.With' should only be implemented by classes, which could be casted to 'MapPublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MaritimeMuseumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MaritimeMuseumBuilder.java new file mode 100644 index 00000000..12425c96 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MaritimeMuseumBuilder.java @@ -0,0 +1,639 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.MaritimeMuseum}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MaritimeMuseum 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. + * + *

    Example:

    + * + *
    {@code
    + * MaritimeMuseum result = MaritimeMuseumBuilder.create()
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .collectionSize(42)
    + *     .collectionSize(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .vesselCount(42)
    + *     .vesselCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MaritimeMuseum.class) +public class MaritimeMuseumBuilder implements IBuilderBase { + + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for collectionSize: collectionSize. + */ + private TrackedValue collectionSize = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for vesselCount: vesselCount. + */ + private TrackedValue vesselCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MaritimeMuseum}. + */ + public MaritimeMuseumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MaritimeMuseum} by a instance. + * + * @param instance object instance for initialisiation + */ + public MaritimeMuseumBuilder(MaritimeMuseum instance) { + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.collectionSize = initialValue(instance.getCollectionSize()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.vesselCount = initialValue(instance.getVesselCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MaritimeMuseum}. + * + *

    Example:

    + * + *
    {@code
    +   * MaritimeMuseumBuilder builder = MaritimeMuseumBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MaritimeMuseum} + */ + public static MaritimeMuseumBuilder create() { + return new MaritimeMuseumBuilder(); + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link MaritimeMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public MaritimeMuseumBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public MaritimeMuseumBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for collectionSize. + *

    + * Generated from setter {@link MaritimeMuseum#setCollectionSize(int) setCollectionSize(int collectionSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.collectionSize(42);
    +   * }
    + * + * @param collectionSize collectionSize + * @return current instance of builder + */ + public MaritimeMuseumBuilder collectionSize(int collectionSize) { + this.collectionSize = changedValue(collectionSize); + return this; + } + + /** + * Sets the value for collectionSize by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setCollectionSize(int) setCollectionSize(int collectionSize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.collectionSize(() -> 42);
    +   * }
    + * + * @param collectionSizeSupplier supplier for collectionSize + * @return current instance of builder + */ + public MaritimeMuseumBuilder collectionSize(Supplier collectionSizeSupplier) { + this.collectionSize = changedValue(collectionSizeSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MaritimeMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MaritimeMuseumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MaritimeMuseumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MaritimeMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MaritimeMuseumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MaritimeMuseumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MaritimeMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MaritimeMuseumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MaritimeMuseumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MaritimeMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MaritimeMuseumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MaritimeMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MaritimeMuseumBuilder 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. + *

    + * Generated from setter {@link MaritimeMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MaritimeMuseumBuilder 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. + *

    + * Generated from setter {@link MaritimeMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MaritimeMuseumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MaritimeMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MaritimeMuseumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MaritimeMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MaritimeMuseumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MaritimeMuseumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MaritimeMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MaritimeMuseumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for vesselCount. + *

    + * Generated from setter {@link MaritimeMuseum#setVesselCount(int) setVesselCount(int vesselCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.vesselCount(42);
    +   * }
    + * + * @param vesselCount vesselCount + * @return current instance of builder + */ + public MaritimeMuseumBuilder vesselCount(int vesselCount) { + this.vesselCount = changedValue(vesselCount); + return this; + } + + /** + * Sets the value for vesselCount by invoking the provided supplier. + *

    + * Generated from setter {@link MaritimeMuseum#setVesselCount(int) setVesselCount(int vesselCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.vesselCount(() -> 42);
    +   * }
    + * + * @param vesselCountSupplier supplier for vesselCount + * @return current instance of builder + */ + public MaritimeMuseumBuilder vesselCount(Supplier vesselCountSupplier) { + this.vesselCount = changedValue(vesselCountSupplier.get()); + 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 MaritimeMuseumBuilder 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 MaritimeMuseumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MaritimeMuseum result = builder.build();
    +   * }
    + */ + @Override + public MaritimeMuseum build() { + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.collectionSize.isSet() && this.collectionSize.value() == null) { + throw new IllegalStateException("Field 'collectionSize' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.vesselCount.isSet() && this.vesselCount.value() == null) { + throw new IllegalStateException("Field 'vesselCount' is marked as non-null but null value was provided"); + } + MaritimeMuseum result = new MaritimeMuseum(); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.collectionSize.ifSet(result::setCollectionSize); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.vesselCount.ifSet(result::setVesselCount); + 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("annualVisitors", this.annualVisitors) + .append("collectionSize", this.collectionSize) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .append("vesselCount", this.vesselCount) + .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 MaritimeMuseum with(Consumer b) { + MaritimeMuseumBuilder builder; + try { + builder = new MaritimeMuseumBuilder(MaritimeMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MaritimeMuseumBuilder.With' should only be implemented by classes, which could be casted to 'MaritimeMuseum'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MaritimeMuseumBuilder with() { + try { + return new MaritimeMuseumBuilder(MaritimeMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MaritimeMuseumBuilder.With' should only be implemented by classes, which could be casted to 'MaritimeMuseum'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MediaProviderBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MediaProviderBuilder.java new file mode 100644 index 00000000..5a114d1e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MediaProviderBuilder.java @@ -0,0 +1,710 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MediaProvider}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MediaProvider 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. + * + *

    Example:

    + * + *
    {@code
    + * MediaProvider result = MediaProviderBuilder.create()
    + *     .availableTitles(42L)
    + *     .availableTitles(() -> 42L)
    + *     .clientCount(42)
    + *     .clientCount(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .mediaTypes(List.of("example value"))
    + *     .mediaTypes(() -> List.of("example value"))
    + *     .mediaTypes(t -> t.add("example value"))
    + *     .mediaTypes("example value", "example value")
    + *     .add2MediaTypes("example value")
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MediaProvider.class) +public class MediaProviderBuilder implements IBuilderBase { + + /** + * Tracked value for availableTitles: availableTitles. + */ + private TrackedValue availableTitles = unsetValue(); + /** + * Tracked value for clientCount: clientCount. + */ + private TrackedValue clientCount = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for mediaTypes: mediaTypes. + */ + private TrackedValue> mediaTypes = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MediaProvider}. + */ + public MediaProviderBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MediaProvider} by a instance. + * + * @param instance object instance for initialisiation + */ + public MediaProviderBuilder(MediaProvider instance) { + this.availableTitles = initialValue(instance.getAvailableTitles()); + this.clientCount = initialValue(instance.getClientCount()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.mediaTypes = initialValue(instance.getMediaTypes()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MediaProvider}. + * + *

    Example:

    + * + *
    {@code
    +   * MediaProviderBuilder builder = MediaProviderBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MediaProvider} + */ + public static MediaProviderBuilder create() { + return new MediaProviderBuilder(); + } + + /** + * Adds a single element to mediaTypes. + *

    + * Generated from setter {@link MediaProvider#setMediaTypes(List) setMediaTypes(List mediaTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2MediaTypes("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MediaProviderBuilder add2MediaTypes(String element) { + List newCollection; + if (this.mediaTypes.isSet()) { + newCollection = new ArrayList<>(this.mediaTypes.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.mediaTypes = changedValue(newCollection); + return this; + } + + /** + * Sets the value for availableTitles. + *

    + * Generated from setter {@link MediaProvider#setAvailableTitles(long) setAvailableTitles(long availableTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.availableTitles(42L);
    +   * }
    + * + * @param availableTitles availableTitles + * @return current instance of builder + */ + public MediaProviderBuilder availableTitles(long availableTitles) { + this.availableTitles = changedValue(availableTitles); + return this; + } + + /** + * Sets the value for availableTitles by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setAvailableTitles(long) setAvailableTitles(long availableTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.availableTitles(() -> 42L);
    +   * }
    + * + * @param availableTitlesSupplier supplier for availableTitles + * @return current instance of builder + */ + public MediaProviderBuilder availableTitles(Supplier availableTitlesSupplier) { + this.availableTitles = changedValue(availableTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for clientCount. + *

    + * Generated from setter {@link MediaProvider#setClientCount(int) setClientCount(int clientCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientCount(42);
    +   * }
    + * + * @param clientCount clientCount + * @return current instance of builder + */ + public MediaProviderBuilder clientCount(int clientCount) { + this.clientCount = changedValue(clientCount); + return this; + } + + /** + * Sets the value for clientCount by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setClientCount(int) setClientCount(int clientCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientCount(() -> 42);
    +   * }
    + * + * @param clientCountSupplier supplier for clientCount + * @return current instance of builder + */ + public MediaProviderBuilder clientCount(Supplier clientCountSupplier) { + this.clientCount = changedValue(clientCountSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MediaProvider#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MediaProviderBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MediaProviderBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MediaProvider#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MediaProviderBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MediaProviderBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MediaProvider#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MediaProviderBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MediaProviderBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for mediaTypes. + *

    + * Generated from setter {@link MediaProvider#setMediaTypes(List) setMediaTypes(List mediaTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaTypes("example value", "example value");
    +   * }
    + * + * @param mediaTypes mediaTypes + * @return current instance of builder + */ + public MediaProviderBuilder mediaTypes(String... mediaTypes) { + this.mediaTypes = changedValue(List.of(mediaTypes)); + return this; + } + + /** + * Sets the value for mediaTypes. + *

    + * Generated from setter {@link MediaProvider#setMediaTypes(List) setMediaTypes(List mediaTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaTypes(List.of("example value"));
    +   * }
    + * + * @param mediaTypes mediaTypes + * @return current instance of builder + */ + public MediaProviderBuilder mediaTypes(List mediaTypes) { + this.mediaTypes = changedValue(mediaTypes); + return this; + } + + /** + * Sets the value for mediaTypes using a builder consumer that produces the value. + *

    + * Generated from setter {@link MediaProvider#setMediaTypes(List) setMediaTypes(List mediaTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaTypes(t -> t.add("example value"));
    +   * }
    + * + * @param mediaTypesBuilderConsumer consumer providing an instance of a builder for mediaTypes + * @return current instance of builder + */ + public MediaProviderBuilder mediaTypes(Consumer> mediaTypesBuilderConsumer) { + ArrayListBuilder builder = this.mediaTypes.isSet() + ? new ArrayListBuilder(this.mediaTypes.value()) + : new ArrayListBuilder(); + mediaTypesBuilderConsumer.accept(builder); + this.mediaTypes = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for mediaTypes by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setMediaTypes(List) setMediaTypes(List mediaTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaTypes(() -> List.of("example value"));
    +   * }
    + * + * @param mediaTypesSupplier supplier for mediaTypes + * @return current instance of builder + */ + public MediaProviderBuilder mediaTypes(Supplier> mediaTypesSupplier) { + this.mediaTypes = changedValue(mediaTypesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MediaProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MediaProviderBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MediaProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MediaProviderBuilder 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. + *

    + * Generated from setter {@link MediaProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MediaProviderBuilder 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. + *

    + * Generated from setter {@link MediaProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MediaProviderBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MediaProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MediaProviderBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MediaProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MediaProviderBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MediaProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MediaProviderBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MediaProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MediaProviderBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MediaProviderBuilder 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 MediaProviderBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MediaProvider result = builder.build();
    +   * }
    + */ + @Override + public MediaProvider build() { + if (this.availableTitles.isSet() && this.availableTitles.value() == null) { + throw new IllegalStateException("Field 'availableTitles' is marked as non-null but null value was provided"); + } + if (this.clientCount.isSet() && this.clientCount.value() == null) { + throw new IllegalStateException("Field 'clientCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + MediaProvider result = new MediaProvider(); + this.availableTitles.ifSet(result::setAvailableTitles); + this.clientCount.ifSet(result::setClientCount); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.mediaTypes.ifSet(result::setMediaTypes); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("availableTitles", this.availableTitles) + .append("clientCount", this.clientCount) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("mediaTypes", this.mediaTypes) + .append("name", this.name) + .append("status", this.status) + .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 MediaProvider with(Consumer b) { + MediaProviderBuilder builder; + try { + builder = new MediaProviderBuilder(MediaProvider.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MediaProviderBuilder.With' should only be implemented by classes, which could be casted to 'MediaProvider'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MediaProviderBuilder with() { + try { + return new MediaProviderBuilder(MediaProvider.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MediaProviderBuilder.With' should only be implemented by classes, which could be casted to 'MediaProvider'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MedicalLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MedicalLibraryBuilder.java new file mode 100644 index 00000000..9160f638 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MedicalLibraryBuilder.java @@ -0,0 +1,687 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.MedicalLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MedicalLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * MedicalLibrary result = MedicalLibraryBuilder.create()
    + *     .affiliatedHospital("example value")
    + *     .affiliatedHospital("Hello %s", "World")
    + *     .affiliatedHospital(() -> "example value")
    + *     .affiliatedHospital(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .journalSubscriptions(42)
    + *     .journalSubscriptions(() -> 42)
    + *     .medicalVolumes(42L)
    + *     .medicalVolumes(() -> 42L)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MedicalLibrary.class) +public class MedicalLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for affiliatedHospital: affiliatedHospital. + */ + private TrackedValue affiliatedHospital = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for journalSubscriptions: journalSubscriptions. + */ + private TrackedValue journalSubscriptions = unsetValue(); + /** + * Tracked value for medicalVolumes: medicalVolumes. + */ + private TrackedValue medicalVolumes = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MedicalLibrary}. + */ + public MedicalLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MedicalLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public MedicalLibraryBuilder(MedicalLibrary instance) { + this.affiliatedHospital = initialValue(instance.getAffiliatedHospital()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.journalSubscriptions = initialValue(instance.getJournalSubscriptions()); + this.medicalVolumes = initialValue(instance.getMedicalVolumes()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MedicalLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * MedicalLibraryBuilder builder = MedicalLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MedicalLibrary} + */ + public static MedicalLibraryBuilder create() { + return new MedicalLibraryBuilder(); + } + + /** + * Sets the value for affiliatedHospital. + *

    + * Generated from setter {@link MedicalLibrary#setAffiliatedHospital(String) setAffiliatedHospital(String + * affiliatedHospital)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.affiliatedHospital("example value");
    +   * }
    + * + * @param affiliatedHospital affiliatedHospital + * @return current instance of builder + */ + public MedicalLibraryBuilder affiliatedHospital(String affiliatedHospital) { + this.affiliatedHospital = changedValue(affiliatedHospital); + return this; + } + + /** + * Sets the value for affiliatedHospital by executing the provided consumer. + *

    + * Generated from setter {@link MedicalLibrary#setAffiliatedHospital(String) setAffiliatedHospital(String + * affiliatedHospital)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.affiliatedHospital(sb -> sb.append("text"));
    +   * }
    + * + * @param affiliatedHospitalStringBuilderConsumer consumer providing an instance of affiliatedHospital + * @return current instance of builder + */ + public MedicalLibraryBuilder affiliatedHospital(Consumer affiliatedHospitalStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + affiliatedHospitalStringBuilderConsumer.accept(builder); + this.affiliatedHospital = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for affiliatedHospital by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setAffiliatedHospital(String) setAffiliatedHospital(String + * affiliatedHospital)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.affiliatedHospital(() -> "example value");
    +   * }
    + * + * @param affiliatedHospitalSupplier supplier for affiliatedHospital + * @return current instance of builder + */ + public MedicalLibraryBuilder affiliatedHospital(Supplier affiliatedHospitalSupplier) { + this.affiliatedHospital = changedValue(affiliatedHospitalSupplier.get()); + return this; + } + + /** + * Sets the String value for affiliatedHospital by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MedicalLibrary#setAffiliatedHospital(String) setAffiliatedHospital(String + * affiliatedHospital)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.affiliatedHospital("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MedicalLibraryBuilder affiliatedHospital(String format, Object... args) { + this.affiliatedHospital = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MedicalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MedicalLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MedicalLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MedicalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MedicalLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MedicalLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MedicalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MedicalLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MedicalLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for journalSubscriptions. + *

    + * Generated from setter {@link MedicalLibrary#setJournalSubscriptions(int) setJournalSubscriptions(int + * journalSubscriptions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalSubscriptions(42);
    +   * }
    + * + * @param journalSubscriptions journalSubscriptions + * @return current instance of builder + */ + public MedicalLibraryBuilder journalSubscriptions(int journalSubscriptions) { + this.journalSubscriptions = changedValue(journalSubscriptions); + return this; + } + + /** + * Sets the value for journalSubscriptions by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setJournalSubscriptions(int) setJournalSubscriptions(int + * journalSubscriptions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalSubscriptions(() -> 42);
    +   * }
    + * + * @param journalSubscriptionsSupplier supplier for journalSubscriptions + * @return current instance of builder + */ + public MedicalLibraryBuilder journalSubscriptions(Supplier journalSubscriptionsSupplier) { + this.journalSubscriptions = changedValue(journalSubscriptionsSupplier.get()); + return this; + } + + /** + * Sets the value for medicalVolumes. + *

    + * Generated from setter {@link MedicalLibrary#setMedicalVolumes(long) setMedicalVolumes(long medicalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.medicalVolumes(42L);
    +   * }
    + * + * @param medicalVolumes medicalVolumes + * @return current instance of builder + */ + public MedicalLibraryBuilder medicalVolumes(long medicalVolumes) { + this.medicalVolumes = changedValue(medicalVolumes); + return this; + } + + /** + * Sets the value for medicalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setMedicalVolumes(long) setMedicalVolumes(long medicalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.medicalVolumes(() -> 42L);
    +   * }
    + * + * @param medicalVolumesSupplier supplier for medicalVolumes + * @return current instance of builder + */ + public MedicalLibraryBuilder medicalVolumes(Supplier medicalVolumesSupplier) { + this.medicalVolumes = changedValue(medicalVolumesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MedicalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MedicalLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MedicalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MedicalLibraryBuilder 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. + *

    + * Generated from setter {@link MedicalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MedicalLibraryBuilder 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. + *

    + * Generated from setter {@link MedicalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MedicalLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MedicalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MedicalLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MedicalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MedicalLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MedicalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MedicalLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MedicalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MedicalLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MedicalLibraryBuilder 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 MedicalLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MedicalLibrary result = builder.build();
    +   * }
    + */ + @Override + public MedicalLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.journalSubscriptions.isSet() && this.journalSubscriptions.value() == null) { + throw new IllegalStateException("Field 'journalSubscriptions' is marked as non-null but null value was provided"); + } + if (this.medicalVolumes.isSet() && this.medicalVolumes.value() == null) { + throw new IllegalStateException("Field 'medicalVolumes' is marked as non-null but null value was provided"); + } + MedicalLibrary result = new MedicalLibrary(); + this.affiliatedHospital.ifSet(result::setAffiliatedHospital); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.journalSubscriptions.ifSet(result::setJournalSubscriptions); + this.medicalVolumes.ifSet(result::setMedicalVolumes); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("affiliatedHospital", this.affiliatedHospital) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("journalSubscriptions", this.journalSubscriptions) + .append("medicalVolumes", this.medicalVolumes) + .append("name", this.name) + .append("status", this.status) + .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 MedicalLibrary with(Consumer b) { + MedicalLibraryBuilder builder; + try { + builder = new MedicalLibraryBuilder(MedicalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MedicalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'MedicalLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MedicalLibraryBuilder with() { + try { + return new MedicalLibraryBuilder(MedicalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MedicalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'MedicalLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MembershipRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MembershipRecordBuilder.java new file mode 100644 index 00000000..2dbbb3db --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MembershipRecordBuilder.java @@ -0,0 +1,558 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.MembershipRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MembershipRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MembershipRecord result = MembershipRecordBuilder.create()
    + *     .memberName("example value")
    + *     .memberName("Hello %s", "World")
    + *     .memberName(() -> "example value")
    + *     .memberName(sb -> sb.append("text"))
    + *     .organization("example value")
    + *     .organization("Hello %s", "World")
    + *     .organization(() -> "example value")
    + *     .organization(sb -> sb.append("text"))
    + *     .memberType("example value")
    + *     .memberType("Hello %s", "World")
    + *     .memberType(() -> "example value")
    + *     .memberType(sb -> sb.append("text"))
    + *     .joinDate(LocalDate.now())
    + *     .joinDate(() -> LocalDate.now())
    + *     .active(true)
    + *     .active(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MembershipRecord.class) +public class MembershipRecordBuilder implements IBuilderBase { + + /** + * Tracked value for memberName: memberName. + */ + private TrackedValue memberName = unsetValue(); + /** + * Tracked value for organization: organization. + */ + private TrackedValue organization = unsetValue(); + /** + * Tracked value for memberType: memberType. + */ + private TrackedValue memberType = unsetValue(); + /** + * Tracked value for joinDate: joinDate. + */ + private TrackedValue joinDate = unsetValue(); + /** + * Tracked value for active: active. + */ + private TrackedValue active = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MembershipRecord}. + */ + public MembershipRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MembershipRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public MembershipRecordBuilder(MembershipRecord instance) { + this.memberName = initialValue(instance.memberName()); + this.organization = initialValue(instance.organization()); + this.memberType = initialValue(instance.memberType()); + this.joinDate = initialValue(instance.joinDate()); + this.active = initialValue(instance.active()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MembershipRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MembershipRecordBuilder builder = MembershipRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MembershipRecord} + */ + public static MembershipRecordBuilder create() { + return new MembershipRecordBuilder(); + } + + /** + * Sets the value for active. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(true);
    +   * }
    + * + * @param active active + * @return current instance of builder + */ + public MembershipRecordBuilder active(boolean active) { + this.active = changedValue(active); + return this; + } + + /** + * Sets the value for active by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(() -> true);
    +   * }
    + * + * @param activeSupplier supplier for active + * @return current instance of builder + */ + public MembershipRecordBuilder active(Supplier activeSupplier) { + this.active = changedValue(activeSupplier.get()); + return this; + } + + /** + * Sets the value for joinDate. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.joinDate(LocalDate.now());
    +   * }
    + * + * @param joinDate joinDate + * @return current instance of builder + */ + public MembershipRecordBuilder joinDate(LocalDate joinDate) { + this.joinDate = changedValue(joinDate); + return this; + } + + /** + * Sets the value for joinDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.joinDate(() -> LocalDate.now());
    +   * }
    + * + * @param joinDateSupplier supplier for joinDate + * @return current instance of builder + */ + public MembershipRecordBuilder joinDate(Supplier joinDateSupplier) { + this.joinDate = changedValue(joinDateSupplier.get()); + return this; + } + + /** + * Sets the value for memberName. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberName("example value");
    +   * }
    + * + * @param memberName memberName + * @return current instance of builder + */ + public MembershipRecordBuilder memberName(String memberName) { + this.memberName = changedValue(memberName); + return this; + } + + /** + * Sets the value for memberName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberName(sb -> sb.append("text"));
    +   * }
    + * + * @param memberNameStringBuilderConsumer consumer providing an instance of memberName + * @return current instance of builder + */ + public MembershipRecordBuilder memberName(Consumer memberNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + memberNameStringBuilderConsumer.accept(builder); + this.memberName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for memberName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberName(() -> "example value");
    +   * }
    + * + * @param memberNameSupplier supplier for memberName + * @return current instance of builder + */ + public MembershipRecordBuilder memberName(Supplier memberNameSupplier) { + this.memberName = changedValue(memberNameSupplier.get()); + return this; + } + + /** + * Sets the String value for memberName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MembershipRecordBuilder memberName(String format, Object... args) { + this.memberName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for memberType. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberType("example value");
    +   * }
    + * + * @param memberType memberType + * @return current instance of builder + */ + public MembershipRecordBuilder memberType(String memberType) { + this.memberType = changedValue(memberType); + return this; + } + + /** + * Sets the value for memberType by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberType(sb -> sb.append("text"));
    +   * }
    + * + * @param memberTypeStringBuilderConsumer consumer providing an instance of memberType + * @return current instance of builder + */ + public MembershipRecordBuilder memberType(Consumer memberTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + memberTypeStringBuilderConsumer.accept(builder); + this.memberType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for memberType by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberType(() -> "example value");
    +   * }
    + * + * @param memberTypeSupplier supplier for memberType + * @return current instance of builder + */ + public MembershipRecordBuilder memberType(Supplier memberTypeSupplier) { + this.memberType = changedValue(memberTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for memberType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MembershipRecordBuilder memberType(String format, Object... args) { + this.memberType = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for organization. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("example value");
    +   * }
    + * + * @param organization organization + * @return current instance of builder + */ + public MembershipRecordBuilder organization(String organization) { + this.organization = changedValue(organization); + return this; + } + + /** + * Sets the value for organization by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(sb -> sb.append("text"));
    +   * }
    + * + * @param organizationStringBuilderConsumer consumer providing an instance of organization + * @return current instance of builder + */ + public MembershipRecordBuilder organization(Consumer organizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizationStringBuilderConsumer.accept(builder); + this.organization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organization by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(() -> "example value");
    +   * }
    + * + * @param organizationSupplier supplier for organization + * @return current instance of builder + */ + public MembershipRecordBuilder organization(Supplier organizationSupplier) { + this.organization = changedValue(organizationSupplier.get()); + return this; + } + + /** + * Sets the String value for organization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link MembershipRecord#MembershipRecord(String, String, String, LocalDate, boolean) MembershipRecord(String + * memberName, String organization, String memberType, LocalDate joinDate, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MembershipRecordBuilder organization(String format, Object... args) { + this.organization = changedValue(String.format(format, args)); + 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 MembershipRecordBuilder 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 MembershipRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MembershipRecord result = builder.build();
    +   * }
    + */ + @Override + public MembershipRecord build() { + MembershipRecord result = new MembershipRecord(this.memberName + .value(), this.organization.value(), this.memberType.value(), this.joinDate.value(), this.active.valueOr(true)); + 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("memberName", this.memberName) + .append("organization", this.organization) + .append("memberType", this.memberType) + .append("joinDate", this.joinDate) + .append("active", this.active) + .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 MembershipRecord with(Consumer b) { + MembershipRecordBuilder builder; + try { + builder = new MembershipRecordBuilder(MembershipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MembershipRecordBuilder.With' should only be implemented by classes, which could be casted to 'MembershipRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MembershipRecordBuilder with() { + try { + return new MembershipRecordBuilder(MembershipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MembershipRecordBuilder.With' should only be implemented by classes, which could be casted to 'MembershipRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MemorialFundBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MemorialFundBuilder.java new file mode 100644 index 00000000..24e178c7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MemorialFundBuilder.java @@ -0,0 +1,678 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.MemorialFund}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MemorialFund 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. + * + *

    Example:

    + * + *
    {@code
    + * MemorialFund result = MemorialFundBuilder.create()
    + *     .annualDistribution(BigDecimal.valueOf(3.14))
    + *     .annualDistribution(() -> BigDecimal.valueOf(3.14))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .fundValue(BigDecimal.valueOf(3.14))
    + *     .fundValue(() -> BigDecimal.valueOf(3.14))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memorialName("example value")
    + *     .memorialName("Hello %s", "World")
    + *     .memorialName(() -> "example value")
    + *     .memorialName(sb -> sb.append("text"))
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MemorialFund.class) +public class MemorialFundBuilder implements IBuilderBase { + + /** + * Tracked value for annualDistribution: annualDistribution. + */ + private TrackedValue annualDistribution = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for fundValue: fundValue. + */ + private TrackedValue fundValue = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memorialName: memorialName. + */ + private TrackedValue memorialName = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MemorialFund}. + */ + public MemorialFundBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MemorialFund} by a instance. + * + * @param instance object instance for initialisiation + */ + public MemorialFundBuilder(MemorialFund instance) { + this.annualDistribution = initialValue(instance.getAnnualDistribution()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.fundValue = initialValue(instance.getFundValue()); + this.id = initialValue(instance.getId()); + this.memorialName = initialValue(instance.getMemorialName()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MemorialFund}. + * + *

    Example:

    + * + *
    {@code
    +   * MemorialFundBuilder builder = MemorialFundBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MemorialFund} + */ + public static MemorialFundBuilder create() { + return new MemorialFundBuilder(); + } + + /** + * Sets the value for annualDistribution. + *

    + * Generated from setter {@link MemorialFund#setAnnualDistribution(BigDecimal) setAnnualDistribution(BigDecimal + * annualDistribution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualDistribution(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualDistribution annualDistribution + * @return current instance of builder + */ + public MemorialFundBuilder annualDistribution(BigDecimal annualDistribution) { + this.annualDistribution = changedValue(annualDistribution); + return this; + } + + /** + * Sets the value for annualDistribution by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setAnnualDistribution(BigDecimal) setAnnualDistribution(BigDecimal + * annualDistribution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualDistribution(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualDistributionSupplier supplier for annualDistribution + * @return current instance of builder + */ + public MemorialFundBuilder annualDistribution(Supplier annualDistributionSupplier) { + this.annualDistribution = changedValue(annualDistributionSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MemorialFund#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MemorialFundBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MemorialFundBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MemorialFund#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MemorialFundBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MemorialFundBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for fundValue. + *

    + * Generated from setter {@link MemorialFund#setFundValue(BigDecimal) setFundValue(BigDecimal fundValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fundValue(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param fundValue fundValue + * @return current instance of builder + */ + public MemorialFundBuilder fundValue(BigDecimal fundValue) { + this.fundValue = changedValue(fundValue); + return this; + } + + /** + * Sets the value for fundValue by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setFundValue(BigDecimal) setFundValue(BigDecimal fundValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fundValue(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param fundValueSupplier supplier for fundValue + * @return current instance of builder + */ + public MemorialFundBuilder fundValue(Supplier fundValueSupplier) { + this.fundValue = changedValue(fundValueSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MemorialFund#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MemorialFundBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MemorialFundBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memorialName. + *

    + * Generated from setter {@link MemorialFund#setMemorialName(String) setMemorialName(String memorialName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memorialName("example value");
    +   * }
    + * + * @param memorialName memorialName + * @return current instance of builder + */ + public MemorialFundBuilder memorialName(String memorialName) { + this.memorialName = changedValue(memorialName); + return this; + } + + /** + * Sets the value for memorialName by executing the provided consumer. + *

    + * Generated from setter {@link MemorialFund#setMemorialName(String) setMemorialName(String memorialName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memorialName(sb -> sb.append("text"));
    +   * }
    + * + * @param memorialNameStringBuilderConsumer consumer providing an instance of memorialName + * @return current instance of builder + */ + public MemorialFundBuilder memorialName(Consumer memorialNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + memorialNameStringBuilderConsumer.accept(builder); + this.memorialName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for memorialName by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setMemorialName(String) setMemorialName(String memorialName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memorialName(() -> "example value");
    +   * }
    + * + * @param memorialNameSupplier supplier for memorialName + * @return current instance of builder + */ + public MemorialFundBuilder memorialName(Supplier memorialNameSupplier) { + this.memorialName = changedValue(memorialNameSupplier.get()); + return this; + } + + /** + * Sets the String value for memorialName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MemorialFund#setMemorialName(String) setMemorialName(String memorialName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memorialName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MemorialFundBuilder memorialName(String format, Object... args) { + this.memorialName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MemorialFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MemorialFundBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MemorialFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MemorialFundBuilder 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. + *

    + * Generated from setter {@link MemorialFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MemorialFundBuilder 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. + *

    + * Generated from setter {@link MemorialFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MemorialFundBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MemorialFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MemorialFundBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MemorialFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MemorialFundBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MemorialFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MemorialFundBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MemorialFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MemorialFundBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MemorialFundBuilder 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 MemorialFundBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MemorialFund result = builder.build();
    +   * }
    + */ + @Override + public MemorialFund build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + MemorialFund result = new MemorialFund(); + this.annualDistribution.ifSet(result::setAnnualDistribution); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.fundValue.ifSet(result::setFundValue); + this.id.ifSet(result::setId); + this.memorialName.ifSet(result::setMemorialName); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualDistribution", this.annualDistribution) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("fundValue", this.fundValue) + .append("id", this.id) + .append("memorialName", this.memorialName) + .append("name", this.name) + .append("status", this.status) + .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 MemorialFund with(Consumer b) { + MemorialFundBuilder builder; + try { + builder = new MemorialFundBuilder(MemorialFund.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MemorialFundBuilder.With' should only be implemented by classes, which could be casted to 'MemorialFund'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MemorialFundBuilder with() { + try { + return new MemorialFundBuilder(MemorialFund.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MemorialFundBuilder.With' should only be implemented by classes, which could be casted to 'MemorialFund'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MetadataStandardsBodyBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MetadataStandardsBodyBuilder.java new file mode 100644 index 00000000..d5719b73 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MetadataStandardsBodyBuilder.java @@ -0,0 +1,718 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MetadataStandardsBody}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MetadataStandardsBody 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. + * + *

    Example:

    + * + *
    {@code
    + * MetadataStandardsBody result = MetadataStandardsBodyBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .standardsDeveloped(List.of("example value"))
    + *     .standardsDeveloped(() -> List.of("example value"))
    + *     .standardsDeveloped(t -> t.add("example value"))
    + *     .standardsDeveloped("example value", "example value")
    + *     .add2StandardsDeveloped("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .workingGroups(42)
    + *     .workingGroups(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MetadataStandardsBody.class) +public class MetadataStandardsBodyBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for standardsDeveloped: standardsDeveloped. + */ + private TrackedValue> standardsDeveloped = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for workingGroups: workingGroups. + */ + private TrackedValue workingGroups = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MetadataStandardsBody}. + */ + public MetadataStandardsBodyBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MetadataStandardsBody} by a instance. + * + * @param instance object instance for initialisiation + */ + public MetadataStandardsBodyBuilder(MetadataStandardsBody instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberCount = initialValue(instance.getMemberCount()); + this.name = initialValue(instance.getName()); + this.standardsDeveloped = initialValue(instance.getStandardsDeveloped()); + this.status = initialValue(instance.getStatus()); + this.workingGroups = initialValue(instance.getWorkingGroups()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MetadataStandardsBody}. + * + *

    Example:

    + * + *
    {@code
    +   * MetadataStandardsBodyBuilder builder = MetadataStandardsBodyBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MetadataStandardsBody} + */ + public static MetadataStandardsBodyBuilder create() { + return new MetadataStandardsBodyBuilder(); + } + + /** + * Adds a single element to standardsDeveloped. + *

    + * Generated from setter {@link MetadataStandardsBody#setStandardsDeveloped(List) setStandardsDeveloped(List + * standardsDeveloped)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2StandardsDeveloped("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder add2StandardsDeveloped(String element) { + List newCollection; + if (this.standardsDeveloped.isSet()) { + newCollection = new ArrayList<>(this.standardsDeveloped.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.standardsDeveloped = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MetadataStandardsBody#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MetadataStandardsBody#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MetadataStandardsBody#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from setter {@link MetadataStandardsBody#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MetadataStandardsBody#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MetadataStandardsBody#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder 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. + *

    + * Generated from setter {@link MetadataStandardsBody#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder 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. + *

    + * Generated from setter {@link MetadataStandardsBody#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for standardsDeveloped. + *

    + * Generated from setter {@link MetadataStandardsBody#setStandardsDeveloped(List) setStandardsDeveloped(List + * standardsDeveloped)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standardsDeveloped("example value", "example value");
    +   * }
    + * + * @param standardsDeveloped standardsDeveloped + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder standardsDeveloped(String... standardsDeveloped) { + this.standardsDeveloped = changedValue(List.of(standardsDeveloped)); + return this; + } + + /** + * Sets the value for standardsDeveloped. + *

    + * Generated from setter {@link MetadataStandardsBody#setStandardsDeveloped(List) setStandardsDeveloped(List + * standardsDeveloped)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standardsDeveloped(List.of("example value"));
    +   * }
    + * + * @param standardsDeveloped standardsDeveloped + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder standardsDeveloped(List standardsDeveloped) { + this.standardsDeveloped = changedValue(standardsDeveloped); + return this; + } + + /** + * Sets the value for standardsDeveloped using a builder consumer that produces the value. + *

    + * Generated from setter {@link MetadataStandardsBody#setStandardsDeveloped(List) setStandardsDeveloped(List + * standardsDeveloped)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standardsDeveloped(t -> t.add("example value"));
    +   * }
    + * + * @param standardsDevelopedBuilderConsumer consumer providing an instance of a builder for standardsDeveloped + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder standardsDeveloped( + Consumer> standardsDevelopedBuilderConsumer) { + ArrayListBuilder builder = this.standardsDeveloped.isSet() + ? new ArrayListBuilder(this.standardsDeveloped.value()) + : new ArrayListBuilder(); + standardsDevelopedBuilderConsumer.accept(builder); + this.standardsDeveloped = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for standardsDeveloped by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setStandardsDeveloped(List) setStandardsDeveloped(List + * standardsDeveloped)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standardsDeveloped(() -> List.of("example value"));
    +   * }
    + * + * @param standardsDevelopedSupplier supplier for standardsDeveloped + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder standardsDeveloped(Supplier> standardsDevelopedSupplier) { + this.standardsDeveloped = changedValue(standardsDevelopedSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MetadataStandardsBody#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MetadataStandardsBody#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MetadataStandardsBody#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for workingGroups. + *

    + * Generated from setter {@link MetadataStandardsBody#setWorkingGroups(int) setWorkingGroups(int workingGroups)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workingGroups(42);
    +   * }
    + * + * @param workingGroups workingGroups + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder workingGroups(int workingGroups) { + this.workingGroups = changedValue(workingGroups); + return this; + } + + /** + * Sets the value for workingGroups by invoking the provided supplier. + *

    + * Generated from setter {@link MetadataStandardsBody#setWorkingGroups(int) setWorkingGroups(int workingGroups)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.workingGroups(() -> 42);
    +   * }
    + * + * @param workingGroupsSupplier supplier for workingGroups + * @return current instance of builder + */ + public MetadataStandardsBodyBuilder workingGroups(Supplier workingGroupsSupplier) { + this.workingGroups = changedValue(workingGroupsSupplier.get()); + 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 MetadataStandardsBodyBuilder 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 MetadataStandardsBodyBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MetadataStandardsBody result = builder.build();
    +   * }
    + */ + @Override + public MetadataStandardsBody build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberCount.isSet() && this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + if (this.workingGroups.isSet() && this.workingGroups.value() == null) { + throw new IllegalStateException("Field 'workingGroups' is marked as non-null but null value was provided"); + } + MetadataStandardsBody result = new MetadataStandardsBody(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberCount.ifSet(result::setMemberCount); + this.name.ifSet(result::setName); + this.standardsDeveloped.ifSet(result::setStandardsDeveloped); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.workingGroups.ifSet(result::setWorkingGroups); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberCount", this.memberCount) + .append("name", this.name) + .append("standardsDeveloped", this.standardsDeveloped) + .append("status", this.status) + .append("workingGroups", this.workingGroups) + .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 MetadataStandardsBody with(Consumer b) { + MetadataStandardsBodyBuilder builder; + try { + builder = new MetadataStandardsBodyBuilder(MetadataStandardsBody.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MetadataStandardsBodyBuilder.With' should only be implemented by classes, which could be casted to 'MetadataStandardsBody'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MetadataStandardsBodyBuilder with() { + try { + return new MetadataStandardsBodyBuilder(MetadataStandardsBody.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MetadataStandardsBodyBuilder.With' should only be implemented by classes, which could be casted to 'MetadataStandardsBody'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MinistryOfCultureBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MinistryOfCultureBuilder.java new file mode 100644 index 00000000..eb62f755 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MinistryOfCultureBuilder.java @@ -0,0 +1,756 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MinistryOfCulture}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MinistryOfCulture 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. + * + *

    Example:

    + * + *
    {@code
    + * MinistryOfCulture result = MinistryOfCultureBuilder.create()
    + *     .budget(BigDecimal.valueOf(3.14))
    + *     .budget(() -> BigDecimal.valueOf(3.14))
    + *     .country("example value")
    + *     .country("Hello %s", "World")
    + *     .country(() -> "example value")
    + *     .country(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .culturalPrograms(List.of("example value"))
    + *     .culturalPrograms(() -> List.of("example value"))
    + *     .culturalPrograms(t -> t.add("example value"))
    + *     .culturalPrograms("example value", "example value")
    + *     .add2CulturalPrograms("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MinistryOfCulture.class) +public class MinistryOfCultureBuilder implements IBuilderBase { + + /** + * Tracked value for budget: budget. + */ + private TrackedValue budget = unsetValue(); + /** + * Tracked value for country: country. + */ + private TrackedValue country = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for culturalPrograms: culturalPrograms. + */ + private TrackedValue> culturalPrograms = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MinistryOfCulture}. + */ + public MinistryOfCultureBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MinistryOfCulture} by a instance. + * + * @param instance object instance for initialisiation + */ + public MinistryOfCultureBuilder(MinistryOfCulture instance) { + this.budget = initialValue(instance.getBudget()); + this.country = initialValue(instance.getCountry()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.culturalPrograms = initialValue(instance.getCulturalPrograms()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MinistryOfCulture}. + * + *

    Example:

    + * + *
    {@code
    +   * MinistryOfCultureBuilder builder = MinistryOfCultureBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MinistryOfCulture} + */ + public static MinistryOfCultureBuilder create() { + return new MinistryOfCultureBuilder(); + } + + /** + * Adds a single element to culturalPrograms. + *

    + * Generated from setter {@link MinistryOfCulture#setCulturalPrograms(List) setCulturalPrograms(List + * culturalPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2CulturalPrograms("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MinistryOfCultureBuilder add2CulturalPrograms(String element) { + List newCollection; + if (this.culturalPrograms.isSet()) { + newCollection = new ArrayList<>(this.culturalPrograms.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.culturalPrograms = changedValue(newCollection); + return this; + } + + /** + * Sets the value for budget. + *

    + * Generated from setter {@link MinistryOfCulture#setBudget(BigDecimal) setBudget(BigDecimal budget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budget budget + * @return current instance of builder + */ + public MinistryOfCultureBuilder budget(BigDecimal budget) { + this.budget = changedValue(budget); + return this; + } + + /** + * Sets the value for budget by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setBudget(BigDecimal) setBudget(BigDecimal budget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budgetSupplier supplier for budget + * @return current instance of builder + */ + public MinistryOfCultureBuilder budget(Supplier budgetSupplier) { + this.budget = changedValue(budgetSupplier.get()); + return this; + } + + /** + * Sets the value for country. + *

    + * Generated from setter {@link MinistryOfCulture#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("example value");
    +   * }
    + * + * @param country country + * @return current instance of builder + */ + public MinistryOfCultureBuilder country(String country) { + this.country = changedValue(country); + return this; + } + + /** + * Sets the value for country by executing the provided consumer. + *

    + * Generated from setter {@link MinistryOfCulture#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(sb -> sb.append("text"));
    +   * }
    + * + * @param countryStringBuilderConsumer consumer providing an instance of country + * @return current instance of builder + */ + public MinistryOfCultureBuilder country(Consumer countryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + countryStringBuilderConsumer.accept(builder); + this.country = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for country by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(() -> "example value");
    +   * }
    + * + * @param countrySupplier supplier for country + * @return current instance of builder + */ + public MinistryOfCultureBuilder country(Supplier countrySupplier) { + this.country = changedValue(countrySupplier.get()); + return this; + } + + /** + * Sets the String value for country by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MinistryOfCulture#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MinistryOfCultureBuilder country(String format, Object... args) { + this.country = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MinistryOfCulture#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MinistryOfCultureBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MinistryOfCultureBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for culturalPrograms. + *

    + * Generated from setter {@link MinistryOfCulture#setCulturalPrograms(List) setCulturalPrograms(List + * culturalPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalPrograms("example value", "example value");
    +   * }
    + * + * @param culturalPrograms culturalPrograms + * @return current instance of builder + */ + public MinistryOfCultureBuilder culturalPrograms(String... culturalPrograms) { + this.culturalPrograms = changedValue(List.of(culturalPrograms)); + return this; + } + + /** + * Sets the value for culturalPrograms. + *

    + * Generated from setter {@link MinistryOfCulture#setCulturalPrograms(List) setCulturalPrograms(List + * culturalPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalPrograms(List.of("example value"));
    +   * }
    + * + * @param culturalPrograms culturalPrograms + * @return current instance of builder + */ + public MinistryOfCultureBuilder culturalPrograms(List culturalPrograms) { + this.culturalPrograms = changedValue(culturalPrograms); + return this; + } + + /** + * Sets the value for culturalPrograms using a builder consumer that produces the value. + *

    + * Generated from setter {@link MinistryOfCulture#setCulturalPrograms(List) setCulturalPrograms(List + * culturalPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalPrograms(t -> t.add("example value"));
    +   * }
    + * + * @param culturalProgramsBuilderConsumer consumer providing an instance of a builder for culturalPrograms + * @return current instance of builder + */ + public MinistryOfCultureBuilder culturalPrograms(Consumer> culturalProgramsBuilderConsumer) { + ArrayListBuilder builder = this.culturalPrograms.isSet() + ? new ArrayListBuilder(this.culturalPrograms.value()) + : new ArrayListBuilder(); + culturalProgramsBuilderConsumer.accept(builder); + this.culturalPrograms = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for culturalPrograms by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setCulturalPrograms(List) setCulturalPrograms(List + * culturalPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalPrograms(() -> List.of("example value"));
    +   * }
    + * + * @param culturalProgramsSupplier supplier for culturalPrograms + * @return current instance of builder + */ + public MinistryOfCultureBuilder culturalPrograms(Supplier> culturalProgramsSupplier) { + this.culturalPrograms = changedValue(culturalProgramsSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MinistryOfCulture#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MinistryOfCultureBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MinistryOfCultureBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MinistryOfCulture#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MinistryOfCultureBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MinistryOfCultureBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MinistryOfCulture#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MinistryOfCultureBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MinistryOfCulture#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MinistryOfCultureBuilder 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. + *

    + * Generated from setter {@link MinistryOfCulture#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MinistryOfCultureBuilder 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. + *

    + * Generated from setter {@link MinistryOfCulture#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MinistryOfCultureBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MinistryOfCulture#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MinistryOfCultureBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MinistryOfCulture#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MinistryOfCultureBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MinistryOfCulture#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MinistryOfCultureBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MinistryOfCulture#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MinistryOfCultureBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MinistryOfCultureBuilder 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 MinistryOfCultureBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MinistryOfCulture result = builder.build();
    +   * }
    + */ + @Override + public MinistryOfCulture build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + MinistryOfCulture result = new MinistryOfCulture(); + this.budget.ifSet(result::setBudget); + this.country.ifSet(result::setCountry); + this.createdAt.ifSet(result::setCreatedAt); + this.culturalPrograms.ifSet(result::setCulturalPrograms); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("budget", this.budget) + .append("country", this.country) + .append("createdAt", this.createdAt) + .append("culturalPrograms", this.culturalPrograms) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .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 MinistryOfCulture with(Consumer b) { + MinistryOfCultureBuilder builder; + try { + builder = new MinistryOfCultureBuilder(MinistryOfCulture.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MinistryOfCultureBuilder.With' should only be implemented by classes, which could be casted to 'MinistryOfCulture'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MinistryOfCultureBuilder with() { + try { + return new MinistryOfCultureBuilder(MinistryOfCulture.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MinistryOfCultureBuilder.With' should only be implemented by classes, which could be casted to 'MinistryOfCulture'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalArchiveBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalArchiveBuilder.java new file mode 100644 index 00000000..d1992d10 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalArchiveBuilder.java @@ -0,0 +1,752 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MunicipalArchive}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalArchive 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. + * + *

    Example:

    + * + *
    {@code
    + * MunicipalArchive result = MunicipalArchiveBuilder.create()
    + *     .city("example value")
    + *     .city("Hello %s", "World")
    + *     .city(() -> "example value")
    + *     .city(sb -> sb.append("text"))
    + *     .collections(List.of("example value"))
    + *     .collections(() -> List.of("example value"))
    + *     .collections(t -> t.add("example value"))
    + *     .collections("example value", "example value")
    + *     .add2Collections("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .documentCount(42L)
    + *     .documentCount(() -> 42L)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MunicipalArchive.class) +public class MunicipalArchiveBuilder implements IBuilderBase { + + /** + * Tracked value for city: city. + */ + private TrackedValue city = unsetValue(); + /** + * Tracked value for collections: collections. + */ + private TrackedValue> collections = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for documentCount: documentCount. + */ + private TrackedValue documentCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalArchive}. + */ + public MunicipalArchiveBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalArchive} by a instance. + * + * @param instance object instance for initialisiation + */ + public MunicipalArchiveBuilder(MunicipalArchive instance) { + this.city = initialValue(instance.getCity()); + this.collections = initialValue(instance.getCollections()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.documentCount = initialValue(instance.getDocumentCount()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalArchive}. + * + *

    Example:

    + * + *
    {@code
    +   * MunicipalArchiveBuilder builder = MunicipalArchiveBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalArchive} + */ + public static MunicipalArchiveBuilder create() { + return new MunicipalArchiveBuilder(); + } + + /** + * Adds a single element to collections. + *

    + * Generated from setter {@link MunicipalArchive#setCollections(List) setCollections(List collections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Collections("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MunicipalArchiveBuilder add2Collections(String element) { + List newCollection; + if (this.collections.isSet()) { + newCollection = new ArrayList<>(this.collections.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.collections = changedValue(newCollection); + return this; + } + + /** + * Sets the value for city. + *

    + * Generated from setter {@link MunicipalArchive#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city("example value");
    +   * }
    + * + * @param city city + * @return current instance of builder + */ + public MunicipalArchiveBuilder city(String city) { + this.city = changedValue(city); + return this; + } + + /** + * Sets the value for city by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalArchive#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city(sb -> sb.append("text"));
    +   * }
    + * + * @param cityStringBuilderConsumer consumer providing an instance of city + * @return current instance of builder + */ + public MunicipalArchiveBuilder city(Consumer cityStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + cityStringBuilderConsumer.accept(builder); + this.city = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for city by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city(() -> "example value");
    +   * }
    + * + * @param citySupplier supplier for city + * @return current instance of builder + */ + public MunicipalArchiveBuilder city(Supplier citySupplier) { + this.city = changedValue(citySupplier.get()); + return this; + } + + /** + * Sets the String value for city by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MunicipalArchive#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalArchiveBuilder city(String format, Object... args) { + this.city = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for collections. + *

    + * Generated from setter {@link MunicipalArchive#setCollections(List) setCollections(List collections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.collections("example value", "example value");
    +   * }
    + * + * @param collections collections + * @return current instance of builder + */ + public MunicipalArchiveBuilder collections(String... collections) { + this.collections = changedValue(List.of(collections)); + return this; + } + + /** + * Sets the value for collections. + *

    + * Generated from setter {@link MunicipalArchive#setCollections(List) setCollections(List collections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.collections(List.of("example value"));
    +   * }
    + * + * @param collections collections + * @return current instance of builder + */ + public MunicipalArchiveBuilder collections(List collections) { + this.collections = changedValue(collections); + return this; + } + + /** + * Sets the value for collections using a builder consumer that produces the value. + *

    + * Generated from setter {@link MunicipalArchive#setCollections(List) setCollections(List collections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.collections(t -> t.add("example value"));
    +   * }
    + * + * @param collectionsBuilderConsumer consumer providing an instance of a builder for collections + * @return current instance of builder + */ + public MunicipalArchiveBuilder collections(Consumer> collectionsBuilderConsumer) { + ArrayListBuilder builder = this.collections.isSet() + ? new ArrayListBuilder(this.collections.value()) + : new ArrayListBuilder(); + collectionsBuilderConsumer.accept(builder); + this.collections = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for collections by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setCollections(List) setCollections(List collections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.collections(() -> List.of("example value"));
    +   * }
    + * + * @param collectionsSupplier supplier for collections + * @return current instance of builder + */ + public MunicipalArchiveBuilder collections(Supplier> collectionsSupplier) { + this.collections = changedValue(collectionsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MunicipalArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MunicipalArchiveBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MunicipalArchiveBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for documentCount. + *

    + * Generated from setter {@link MunicipalArchive#setDocumentCount(long) setDocumentCount(long documentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.documentCount(42L);
    +   * }
    + * + * @param documentCount documentCount + * @return current instance of builder + */ + public MunicipalArchiveBuilder documentCount(long documentCount) { + this.documentCount = changedValue(documentCount); + return this; + } + + /** + * Sets the value for documentCount by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setDocumentCount(long) setDocumentCount(long documentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.documentCount(() -> 42L);
    +   * }
    + * + * @param documentCountSupplier supplier for documentCount + * @return current instance of builder + */ + public MunicipalArchiveBuilder documentCount(Supplier documentCountSupplier) { + this.documentCount = changedValue(documentCountSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MunicipalArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MunicipalArchiveBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MunicipalArchiveBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MunicipalArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MunicipalArchiveBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MunicipalArchiveBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MunicipalArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MunicipalArchiveBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MunicipalArchiveBuilder 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. + *

    + * Generated from setter {@link MunicipalArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MunicipalArchiveBuilder 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. + *

    + * Generated from setter {@link MunicipalArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalArchiveBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MunicipalArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MunicipalArchiveBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MunicipalArchiveBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MunicipalArchiveBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MunicipalArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalArchiveBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MunicipalArchiveBuilder 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 MunicipalArchiveBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MunicipalArchive result = builder.build();
    +   * }
    + */ + @Override + public MunicipalArchive build() { + if (this.documentCount.isSet() && this.documentCount.value() == null) { + throw new IllegalStateException("Field 'documentCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + MunicipalArchive result = new MunicipalArchive(); + this.city.ifSet(result::setCity); + this.collections.ifSet(result::setCollections); + this.createdAt.ifSet(result::setCreatedAt); + this.documentCount.ifSet(result::setDocumentCount); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("city", this.city) + .append("collections", this.collections) + .append("createdAt", this.createdAt) + .append("documentCount", this.documentCount) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .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 MunicipalArchive with(Consumer b) { + MunicipalArchiveBuilder builder; + try { + builder = new MunicipalArchiveBuilder(MunicipalArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MunicipalArchiveBuilder.With' should only be implemented by classes, which could be casted to 'MunicipalArchive'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MunicipalArchiveBuilder with() { + try { + return new MunicipalArchiveBuilder(MunicipalArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MunicipalArchiveBuilder.With' should only be implemented by classes, which could be casted to 'MunicipalArchive'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalCulturalOfficeBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalCulturalOfficeBuilder.java new file mode 100644 index 00000000..dd02fa95 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalCulturalOfficeBuilder.java @@ -0,0 +1,758 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MunicipalCulturalOffice}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalCulturalOffice 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. + * + *

    Example:

    + * + *
    {@code
    + * MunicipalCulturalOffice result = MunicipalCulturalOfficeBuilder.create()
    + *     .budget(BigDecimal.valueOf(3.14))
    + *     .budget(() -> BigDecimal.valueOf(3.14))
    + *     .city("example value")
    + *     .city("Hello %s", "World")
    + *     .city(() -> "example value")
    + *     .city(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .culturalInitiatives(List.of("example value"))
    + *     .culturalInitiatives(() -> List.of("example value"))
    + *     .culturalInitiatives(t -> t.add("example value"))
    + *     .culturalInitiatives("example value", "example value")
    + *     .add2CulturalInitiatives("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MunicipalCulturalOffice.class) +public class MunicipalCulturalOfficeBuilder implements IBuilderBase { + + /** + * Tracked value for budget: budget. + */ + private TrackedValue budget = unsetValue(); + /** + * Tracked value for city: city. + */ + private TrackedValue city = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for culturalInitiatives: culturalInitiatives. + */ + private TrackedValue> culturalInitiatives = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalCulturalOffice}. + */ + public MunicipalCulturalOfficeBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalCulturalOffice} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public MunicipalCulturalOfficeBuilder(MunicipalCulturalOffice instance) { + this.budget = initialValue(instance.getBudget()); + this.city = initialValue(instance.getCity()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.culturalInitiatives = initialValue(instance.getCulturalInitiatives()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalCulturalOffice}. + * + *

    Example:

    + * + *
    {@code
    +   * MunicipalCulturalOfficeBuilder builder = MunicipalCulturalOfficeBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalCulturalOffice} + */ + public static MunicipalCulturalOfficeBuilder create() { + return new MunicipalCulturalOfficeBuilder(); + } + + /** + * Adds a single element to culturalInitiatives. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCulturalInitiatives(List) + * setCulturalInitiatives(List culturalInitiatives)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2CulturalInitiatives("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder add2CulturalInitiatives(String element) { + List newCollection; + if (this.culturalInitiatives.isSet()) { + newCollection = new ArrayList<>(this.culturalInitiatives.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.culturalInitiatives = changedValue(newCollection); + return this; + } + + /** + * Sets the value for budget. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setBudget(BigDecimal) setBudget(BigDecimal budget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budget budget + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder budget(BigDecimal budget) { + this.budget = changedValue(budget); + return this; + } + + /** + * Sets the value for budget by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setBudget(BigDecimal) setBudget(BigDecimal budget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budgetSupplier supplier for budget + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder budget(Supplier budgetSupplier) { + this.budget = changedValue(budgetSupplier.get()); + return this; + } + + /** + * Sets the value for city. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city("example value");
    +   * }
    + * + * @param city city + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder city(String city) { + this.city = changedValue(city); + return this; + } + + /** + * Sets the value for city by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city(sb -> sb.append("text"));
    +   * }
    + * + * @param cityStringBuilderConsumer consumer providing an instance of city + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder city(Consumer cityStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + cityStringBuilderConsumer.accept(builder); + this.city = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for city by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city(() -> "example value");
    +   * }
    + * + * @param citySupplier supplier for city + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder city(Supplier citySupplier) { + this.city = changedValue(citySupplier.get()); + return this; + } + + /** + * Sets the String value for city by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder city(String format, Object... args) { + this.city = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for culturalInitiatives. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCulturalInitiatives(List) + * setCulturalInitiatives(List culturalInitiatives)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalInitiatives("example value", "example value");
    +   * }
    + * + * @param culturalInitiatives culturalInitiatives + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder culturalInitiatives(String... culturalInitiatives) { + this.culturalInitiatives = changedValue(List.of(culturalInitiatives)); + return this; + } + + /** + * Sets the value for culturalInitiatives. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCulturalInitiatives(List) + * setCulturalInitiatives(List culturalInitiatives)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalInitiatives(List.of("example value"));
    +   * }
    + * + * @param culturalInitiatives culturalInitiatives + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder culturalInitiatives(List culturalInitiatives) { + this.culturalInitiatives = changedValue(culturalInitiatives); + return this; + } + + /** + * Sets the value for culturalInitiatives using a builder consumer that produces the value. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCulturalInitiatives(List) + * setCulturalInitiatives(List culturalInitiatives)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalInitiatives(t -> t.add("example value"));
    +   * }
    + * + * @param culturalInitiativesBuilderConsumer consumer providing an instance of a builder for culturalInitiatives + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder culturalInitiatives( + Consumer> culturalInitiativesBuilderConsumer) { + ArrayListBuilder builder = this.culturalInitiatives.isSet() + ? new ArrayListBuilder(this.culturalInitiatives.value()) + : new ArrayListBuilder(); + culturalInitiativesBuilderConsumer.accept(builder); + this.culturalInitiatives = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for culturalInitiatives by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setCulturalInitiatives(List) + * setCulturalInitiatives(List culturalInitiatives)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.culturalInitiatives(() -> List.of("example value"));
    +   * }
    + * + * @param culturalInitiativesSupplier supplier for culturalInitiatives + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder culturalInitiatives(Supplier> culturalInitiativesSupplier) { + this.culturalInitiatives = changedValue(culturalInitiativesSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder 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. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder 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. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MunicipalCulturalOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalCulturalOfficeBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MunicipalCulturalOfficeBuilder 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 MunicipalCulturalOfficeBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MunicipalCulturalOffice result = builder.build();
    +   * }
    + */ + @Override + public MunicipalCulturalOffice build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + MunicipalCulturalOffice result = new MunicipalCulturalOffice(); + this.budget.ifSet(result::setBudget); + this.city.ifSet(result::setCity); + this.createdAt.ifSet(result::setCreatedAt); + this.culturalInitiatives.ifSet(result::setCulturalInitiatives); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("budget", this.budget) + .append("city", this.city) + .append("createdAt", this.createdAt) + .append("culturalInitiatives", this.culturalInitiatives) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .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 MunicipalCulturalOffice with(Consumer b) { + MunicipalCulturalOfficeBuilder builder; + try { + builder = new MunicipalCulturalOfficeBuilder(MunicipalCulturalOffice.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MunicipalCulturalOfficeBuilder.With' should only be implemented by classes, which could be casted to 'MunicipalCulturalOffice'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MunicipalCulturalOfficeBuilder with() { + try { + return new MunicipalCulturalOfficeBuilder(MunicipalCulturalOffice.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MunicipalCulturalOfficeBuilder.With' should only be implemented by classes, which could be casted to 'MunicipalCulturalOffice'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalLibraryBuilder.java new file mode 100644 index 00000000..0bef307c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MunicipalLibraryBuilder.java @@ -0,0 +1,681 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.MunicipalLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * MunicipalLibrary result = MunicipalLibraryBuilder.create()
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .city("example value")
    + *     .city("Hello %s", "World")
    + *     .city(() -> "example value")
    + *     .city(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalVolumes(42L)
    + *     .totalVolumes(() -> 42L)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MunicipalLibrary.class) +public class MunicipalLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for city: city. + */ + private TrackedValue city = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalVolumes: totalVolumes. + */ + private TrackedValue totalVolumes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalLibrary}. + */ + public MunicipalLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public MunicipalLibraryBuilder(MunicipalLibrary instance) { + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.city = initialValue(instance.getCity()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.totalVolumes = initialValue(instance.getTotalVolumes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * MunicipalLibraryBuilder builder = MunicipalLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MunicipalLibrary} + */ + public static MunicipalLibraryBuilder create() { + return new MunicipalLibraryBuilder(); + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link MunicipalLibrary#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public MunicipalLibraryBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public MunicipalLibraryBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for city. + *

    + * Generated from setter {@link MunicipalLibrary#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city("example value");
    +   * }
    + * + * @param city city + * @return current instance of builder + */ + public MunicipalLibraryBuilder city(String city) { + this.city = changedValue(city); + return this; + } + + /** + * Sets the value for city by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalLibrary#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city(sb -> sb.append("text"));
    +   * }
    + * + * @param cityStringBuilderConsumer consumer providing an instance of city + * @return current instance of builder + */ + public MunicipalLibraryBuilder city(Consumer cityStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + cityStringBuilderConsumer.accept(builder); + this.city = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for city by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city(() -> "example value");
    +   * }
    + * + * @param citySupplier supplier for city + * @return current instance of builder + */ + public MunicipalLibraryBuilder city(Supplier citySupplier) { + this.city = changedValue(citySupplier.get()); + return this; + } + + /** + * Sets the String value for city by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MunicipalLibrary#setCity(String) setCity(String city)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.city("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalLibraryBuilder city(String format, Object... args) { + this.city = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MunicipalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MunicipalLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MunicipalLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MunicipalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MunicipalLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MunicipalLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MunicipalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MunicipalLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MunicipalLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MunicipalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MunicipalLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MunicipalLibraryBuilder 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. + *

    + * Generated from setter {@link MunicipalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MunicipalLibraryBuilder 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. + *

    + * Generated from setter {@link MunicipalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MunicipalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MunicipalLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MunicipalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MunicipalLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MunicipalLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MunicipalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MunicipalLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalVolumes. + *

    + * Generated from setter {@link MunicipalLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(42L);
    +   * }
    + * + * @param totalVolumes totalVolumes + * @return current instance of builder + */ + public MunicipalLibraryBuilder totalVolumes(long totalVolumes) { + this.totalVolumes = changedValue(totalVolumes); + return this; + } + + /** + * Sets the value for totalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link MunicipalLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(() -> 42L);
    +   * }
    + * + * @param totalVolumesSupplier supplier for totalVolumes + * @return current instance of builder + */ + public MunicipalLibraryBuilder totalVolumes(Supplier totalVolumesSupplier) { + this.totalVolumes = changedValue(totalVolumesSupplier.get()); + 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 MunicipalLibraryBuilder 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 MunicipalLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MunicipalLibrary result = builder.build();
    +   * }
    + */ + @Override + public MunicipalLibrary build() { + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.totalVolumes.isSet() && this.totalVolumes.value() == null) { + throw new IllegalStateException("Field 'totalVolumes' is marked as non-null but null value was provided"); + } + MunicipalLibrary result = new MunicipalLibrary(); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.city.ifSet(result::setCity); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalVolumes.ifSet(result::setTotalVolumes); + 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("annualVisitors", this.annualVisitors) + .append("city", this.city) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .append("totalVolumes", this.totalVolumes) + .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 MunicipalLibrary with(Consumer b) { + MunicipalLibraryBuilder builder; + try { + builder = new MunicipalLibraryBuilder(MunicipalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MunicipalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'MunicipalLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MunicipalLibraryBuilder with() { + try { + return new MunicipalLibraryBuilder(MunicipalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MunicipalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'MunicipalLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MuseumAssociationBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MuseumAssociationBuilder.java new file mode 100644 index 00000000..f7ad461a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MuseumAssociationBuilder.java @@ -0,0 +1,721 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MuseumAssociation}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MuseumAssociation 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. + * + *

    Example:

    + * + *
    {@code
    + * MuseumAssociation result = MuseumAssociationBuilder.create()
    + *     .accreditationProgram(true)
    + *     .accreditationProgram(() -> true)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .exhibitionPrograms(List.of("example value"))
    + *     .exhibitionPrograms(() -> List.of("example value"))
    + *     .exhibitionPrograms(t -> t.add("example value"))
    + *     .exhibitionPrograms("example value", "example value")
    + *     .add2ExhibitionPrograms("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberMuseums(42)
    + *     .memberMuseums(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MuseumAssociation.class) +public class MuseumAssociationBuilder implements IBuilderBase { + + /** + * Tracked value for accreditationProgram: accreditationProgram. + */ + private TrackedValue accreditationProgram = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for exhibitionPrograms: exhibitionPrograms. + */ + private TrackedValue> exhibitionPrograms = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberMuseums: memberMuseums. + */ + private TrackedValue memberMuseums = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MuseumAssociation}. + */ + public MuseumAssociationBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MuseumAssociation} by a instance. + * + * @param instance object instance for initialisiation + */ + public MuseumAssociationBuilder(MuseumAssociation instance) { + this.accreditationProgram = initialValue(instance.isAccreditationProgram()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.exhibitionPrograms = initialValue(instance.getExhibitionPrograms()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberMuseums = initialValue(instance.getMemberMuseums()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MuseumAssociation}. + * + *

    Example:

    + * + *
    {@code
    +   * MuseumAssociationBuilder builder = MuseumAssociationBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MuseumAssociation} + */ + public static MuseumAssociationBuilder create() { + return new MuseumAssociationBuilder(); + } + + /** + * Sets the value for accreditationProgram. + *

    + * Generated from setter {@link MuseumAssociation#setAccreditationProgram(boolean) setAccreditationProgram(boolean + * accreditationProgram)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accreditationProgram(true);
    +   * }
    + * + * @param accreditationProgram accreditationProgram + * @return current instance of builder + */ + public MuseumAssociationBuilder accreditationProgram(boolean accreditationProgram) { + this.accreditationProgram = changedValue(accreditationProgram); + return this; + } + + /** + * Sets the value for accreditationProgram by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setAccreditationProgram(boolean) setAccreditationProgram(boolean + * accreditationProgram)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accreditationProgram(() -> true);
    +   * }
    + * + * @param accreditationProgramSupplier supplier for accreditationProgram + * @return current instance of builder + */ + public MuseumAssociationBuilder accreditationProgram(Supplier accreditationProgramSupplier) { + this.accreditationProgram = changedValue(accreditationProgramSupplier.get()); + return this; + } + + /** + * Adds a single element to exhibitionPrograms. + *

    + * Generated from setter {@link MuseumAssociation#setExhibitionPrograms(List) setExhibitionPrograms(List + * exhibitionPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ExhibitionPrograms("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MuseumAssociationBuilder add2ExhibitionPrograms(String element) { + List newCollection; + if (this.exhibitionPrograms.isSet()) { + newCollection = new ArrayList<>(this.exhibitionPrograms.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.exhibitionPrograms = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MuseumAssociation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MuseumAssociationBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MuseumAssociationBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for exhibitionPrograms. + *

    + * Generated from setter {@link MuseumAssociation#setExhibitionPrograms(List) setExhibitionPrograms(List + * exhibitionPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitionPrograms("example value", "example value");
    +   * }
    + * + * @param exhibitionPrograms exhibitionPrograms + * @return current instance of builder + */ + public MuseumAssociationBuilder exhibitionPrograms(String... exhibitionPrograms) { + this.exhibitionPrograms = changedValue(List.of(exhibitionPrograms)); + return this; + } + + /** + * Sets the value for exhibitionPrograms. + *

    + * Generated from setter {@link MuseumAssociation#setExhibitionPrograms(List) setExhibitionPrograms(List + * exhibitionPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitionPrograms(List.of("example value"));
    +   * }
    + * + * @param exhibitionPrograms exhibitionPrograms + * @return current instance of builder + */ + public MuseumAssociationBuilder exhibitionPrograms(List exhibitionPrograms) { + this.exhibitionPrograms = changedValue(exhibitionPrograms); + return this; + } + + /** + * Sets the value for exhibitionPrograms using a builder consumer that produces the value. + *

    + * Generated from setter {@link MuseumAssociation#setExhibitionPrograms(List) setExhibitionPrograms(List + * exhibitionPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitionPrograms(t -> t.add("example value"));
    +   * }
    + * + * @param exhibitionProgramsBuilderConsumer consumer providing an instance of a builder for exhibitionPrograms + * @return current instance of builder + */ + public MuseumAssociationBuilder exhibitionPrograms( + Consumer> exhibitionProgramsBuilderConsumer) { + ArrayListBuilder builder = this.exhibitionPrograms.isSet() + ? new ArrayListBuilder(this.exhibitionPrograms.value()) + : new ArrayListBuilder(); + exhibitionProgramsBuilderConsumer.accept(builder); + this.exhibitionPrograms = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for exhibitionPrograms by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setExhibitionPrograms(List) setExhibitionPrograms(List + * exhibitionPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitionPrograms(() -> List.of("example value"));
    +   * }
    + * + * @param exhibitionProgramsSupplier supplier for exhibitionPrograms + * @return current instance of builder + */ + public MuseumAssociationBuilder exhibitionPrograms(Supplier> exhibitionProgramsSupplier) { + this.exhibitionPrograms = changedValue(exhibitionProgramsSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MuseumAssociation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MuseumAssociationBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MuseumAssociationBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MuseumAssociation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MuseumAssociationBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MuseumAssociationBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberMuseums. + *

    + * Generated from setter {@link MuseumAssociation#setMemberMuseums(int) setMemberMuseums(int memberMuseums)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberMuseums(42);
    +   * }
    + * + * @param memberMuseums memberMuseums + * @return current instance of builder + */ + public MuseumAssociationBuilder memberMuseums(int memberMuseums) { + this.memberMuseums = changedValue(memberMuseums); + return this; + } + + /** + * Sets the value for memberMuseums by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setMemberMuseums(int) setMemberMuseums(int memberMuseums)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberMuseums(() -> 42);
    +   * }
    + * + * @param memberMuseumsSupplier supplier for memberMuseums + * @return current instance of builder + */ + public MuseumAssociationBuilder memberMuseums(Supplier memberMuseumsSupplier) { + this.memberMuseums = changedValue(memberMuseumsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MuseumAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MuseumAssociationBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MuseumAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MuseumAssociationBuilder 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. + *

    + * Generated from setter {@link MuseumAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MuseumAssociationBuilder 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. + *

    + * Generated from setter {@link MuseumAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MuseumAssociationBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MuseumAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MuseumAssociationBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MuseumAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MuseumAssociationBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MuseumAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MuseumAssociationBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MuseumAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MuseumAssociationBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MuseumAssociationBuilder 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 MuseumAssociationBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MuseumAssociation result = builder.build();
    +   * }
    + */ + @Override + public MuseumAssociation build() { + if (this.accreditationProgram.isSet() && this.accreditationProgram.value() == null) { + throw new IllegalStateException("Field 'accreditationProgram' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberMuseums.isSet() && this.memberMuseums.value() == null) { + throw new IllegalStateException("Field 'memberMuseums' is marked as non-null but null value was provided"); + } + MuseumAssociation result = new MuseumAssociation(); + this.accreditationProgram.ifSet(result::setAccreditationProgram); + this.createdAt.ifSet(result::setCreatedAt); + this.exhibitionPrograms.ifSet(result::setExhibitionPrograms); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberMuseums.ifSet(result::setMemberMuseums); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("accreditationProgram", this.accreditationProgram) + .append("createdAt", this.createdAt) + .append("exhibitionPrograms", this.exhibitionPrograms) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberMuseums", this.memberMuseums) + .append("name", this.name) + .append("status", this.status) + .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 MuseumAssociation with(Consumer b) { + MuseumAssociationBuilder builder; + try { + builder = new MuseumAssociationBuilder(MuseumAssociation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MuseumAssociationBuilder.With' should only be implemented by classes, which could be casted to 'MuseumAssociation'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MuseumAssociationBuilder with() { + try { + return new MuseumAssociationBuilder(MuseumAssociation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MuseumAssociationBuilder.With' should only be implemented by classes, which could be casted to 'MuseumAssociation'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicDistributorBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicDistributorBuilder.java new file mode 100644 index 00000000..91b12e98 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicDistributorBuilder.java @@ -0,0 +1,711 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MusicDistributor}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MusicDistributor 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. + * + *

    Example:

    + * + *
    {@code
    + * MusicDistributor result = MusicDistributorBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .dailyShipments(42)
    + *     .dailyShipments(() -> 42)
    + *     .formats(List.of("example value"))
    + *     .formats(() -> List.of("example value"))
    + *     .formats(t -> t.add("example value"))
    + *     .formats("example value", "example value")
    + *     .add2Formats("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .labelClients(42)
    + *     .labelClients(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MusicDistributor.class) +public class MusicDistributorBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for dailyShipments: dailyShipments. + */ + private TrackedValue dailyShipments = unsetValue(); + /** + * Tracked value for formats: formats. + */ + private TrackedValue> formats = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for labelClients: labelClients. + */ + private TrackedValue labelClients = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicDistributor}. + */ + public MusicDistributorBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicDistributor} by a instance. + * + * @param instance object instance for initialisiation + */ + public MusicDistributorBuilder(MusicDistributor instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.dailyShipments = initialValue(instance.getDailyShipments()); + this.formats = initialValue(instance.getFormats()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.labelClients = initialValue(instance.getLabelClients()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicDistributor}. + * + *

    Example:

    + * + *
    {@code
    +   * MusicDistributorBuilder builder = MusicDistributorBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicDistributor} + */ + public static MusicDistributorBuilder create() { + return new MusicDistributorBuilder(); + } + + /** + * Adds a single element to formats. + *

    + * Generated from setter {@link MusicDistributor#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Formats("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MusicDistributorBuilder add2Formats(String element) { + List newCollection; + if (this.formats.isSet()) { + newCollection = new ArrayList<>(this.formats.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.formats = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MusicDistributor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MusicDistributorBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MusicDistributorBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for dailyShipments. + *

    + * Generated from setter {@link MusicDistributor#setDailyShipments(int) setDailyShipments(int dailyShipments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dailyShipments(42);
    +   * }
    + * + * @param dailyShipments dailyShipments + * @return current instance of builder + */ + public MusicDistributorBuilder dailyShipments(int dailyShipments) { + this.dailyShipments = changedValue(dailyShipments); + return this; + } + + /** + * Sets the value for dailyShipments by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setDailyShipments(int) setDailyShipments(int dailyShipments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dailyShipments(() -> 42);
    +   * }
    + * + * @param dailyShipmentsSupplier supplier for dailyShipments + * @return current instance of builder + */ + public MusicDistributorBuilder dailyShipments(Supplier dailyShipmentsSupplier) { + this.dailyShipments = changedValue(dailyShipmentsSupplier.get()); + return this; + } + + /** + * Sets the value for formats. + *

    + * Generated from setter {@link MusicDistributor#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats("example value", "example value");
    +   * }
    + * + * @param formats formats + * @return current instance of builder + */ + public MusicDistributorBuilder formats(String... formats) { + this.formats = changedValue(List.of(formats)); + return this; + } + + /** + * Sets the value for formats. + *

    + * Generated from setter {@link MusicDistributor#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats(List.of("example value"));
    +   * }
    + * + * @param formats formats + * @return current instance of builder + */ + public MusicDistributorBuilder formats(List formats) { + this.formats = changedValue(formats); + return this; + } + + /** + * Sets the value for formats using a builder consumer that produces the value. + *

    + * Generated from setter {@link MusicDistributor#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats(t -> t.add("example value"));
    +   * }
    + * + * @param formatsBuilderConsumer consumer providing an instance of a builder for formats + * @return current instance of builder + */ + public MusicDistributorBuilder formats(Consumer> formatsBuilderConsumer) { + ArrayListBuilder builder = this.formats.isSet() + ? new ArrayListBuilder(this.formats.value()) + : new ArrayListBuilder(); + formatsBuilderConsumer.accept(builder); + this.formats = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for formats by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats(() -> List.of("example value"));
    +   * }
    + * + * @param formatsSupplier supplier for formats + * @return current instance of builder + */ + public MusicDistributorBuilder formats(Supplier> formatsSupplier) { + this.formats = changedValue(formatsSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MusicDistributor#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MusicDistributorBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MusicDistributorBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MusicDistributor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MusicDistributorBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MusicDistributorBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for labelClients. + *

    + * Generated from setter {@link MusicDistributor#setLabelClients(int) setLabelClients(int labelClients)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labelClients(42);
    +   * }
    + * + * @param labelClients labelClients + * @return current instance of builder + */ + public MusicDistributorBuilder labelClients(int labelClients) { + this.labelClients = changedValue(labelClients); + return this; + } + + /** + * Sets the value for labelClients by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setLabelClients(int) setLabelClients(int labelClients)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labelClients(() -> 42);
    +   * }
    + * + * @param labelClientsSupplier supplier for labelClients + * @return current instance of builder + */ + public MusicDistributorBuilder labelClients(Supplier labelClientsSupplier) { + this.labelClients = changedValue(labelClientsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MusicDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MusicDistributorBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MusicDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MusicDistributorBuilder 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. + *

    + * Generated from setter {@link MusicDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MusicDistributorBuilder 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. + *

    + * Generated from setter {@link MusicDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicDistributorBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MusicDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MusicDistributorBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MusicDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MusicDistributorBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MusicDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MusicDistributorBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MusicDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicDistributorBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MusicDistributorBuilder 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 MusicDistributorBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MusicDistributor result = builder.build();
    +   * }
    + */ + @Override + public MusicDistributor build() { + if (this.dailyShipments.isSet() && this.dailyShipments.value() == null) { + throw new IllegalStateException("Field 'dailyShipments' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.labelClients.isSet() && this.labelClients.value() == null) { + throw new IllegalStateException("Field 'labelClients' is marked as non-null but null value was provided"); + } + MusicDistributor result = new MusicDistributor(); + this.createdAt.ifSet(result::setCreatedAt); + this.dailyShipments.ifSet(result::setDailyShipments); + this.formats.ifSet(result::setFormats); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.labelClients.ifSet(result::setLabelClients); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("dailyShipments", this.dailyShipments) + .append("formats", this.formats) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("labelClients", this.labelClients) + .append("name", this.name) + .append("status", this.status) + .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 MusicDistributor with(Consumer b) { + MusicDistributorBuilder builder; + try { + builder = new MusicDistributorBuilder(MusicDistributor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MusicDistributorBuilder.With' should only be implemented by classes, which could be casted to 'MusicDistributor'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MusicDistributorBuilder with() { + try { + return new MusicDistributorBuilder(MusicDistributor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MusicDistributorBuilder.With' should only be implemented by classes, which could be casted to 'MusicDistributor'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicPublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicPublisherBuilder.java new file mode 100644 index 00000000..25b11a87 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicPublisherBuilder.java @@ -0,0 +1,753 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MusicPublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MusicPublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * MusicPublisher result = MusicPublisherBuilder.create()
    + *     .catalogTitles(List.of("example value"))
    + *     .catalogTitles(() -> List.of("example value"))
    + *     .catalogTitles(t -> t.add("example value"))
    + *     .catalogTitles("example value", "example value")
    + *     .add2CatalogTitles("example value")
    + *     .composersPublished(42)
    + *     .composersPublished(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .royaltySystem("example value")
    + *     .royaltySystem("Hello %s", "World")
    + *     .royaltySystem(() -> "example value")
    + *     .royaltySystem(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MusicPublisher.class) +public class MusicPublisherBuilder implements IBuilderBase { + + /** + * Tracked value for catalogTitles: catalogTitles. + */ + private TrackedValue> catalogTitles = unsetValue(); + /** + * Tracked value for composersPublished: composersPublished. + */ + private TrackedValue composersPublished = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for royaltySystem: royaltySystem. + */ + private TrackedValue royaltySystem = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicPublisher}. + */ + public MusicPublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicPublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public MusicPublisherBuilder(MusicPublisher instance) { + this.catalogTitles = initialValue(instance.getCatalogTitles()); + this.composersPublished = initialValue(instance.getComposersPublished()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.royaltySystem = initialValue(instance.getRoyaltySystem()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicPublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * MusicPublisherBuilder builder = MusicPublisherBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicPublisher} + */ + public static MusicPublisherBuilder create() { + return new MusicPublisherBuilder(); + } + + /** + * Adds a single element to catalogTitles. + *

    + * Generated from setter {@link MusicPublisher#setCatalogTitles(List) setCatalogTitles(List catalogTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2CatalogTitles("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MusicPublisherBuilder add2CatalogTitles(String element) { + List newCollection; + if (this.catalogTitles.isSet()) { + newCollection = new ArrayList<>(this.catalogTitles.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.catalogTitles = changedValue(newCollection); + return this; + } + + /** + * Sets the value for catalogTitles. + *

    + * Generated from setter {@link MusicPublisher#setCatalogTitles(List) setCatalogTitles(List catalogTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogTitles("example value", "example value");
    +   * }
    + * + * @param catalogTitles catalogTitles + * @return current instance of builder + */ + public MusicPublisherBuilder catalogTitles(String... catalogTitles) { + this.catalogTitles = changedValue(List.of(catalogTitles)); + return this; + } + + /** + * Sets the value for catalogTitles. + *

    + * Generated from setter {@link MusicPublisher#setCatalogTitles(List) setCatalogTitles(List catalogTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogTitles(List.of("example value"));
    +   * }
    + * + * @param catalogTitles catalogTitles + * @return current instance of builder + */ + public MusicPublisherBuilder catalogTitles(List catalogTitles) { + this.catalogTitles = changedValue(catalogTitles); + return this; + } + + /** + * Sets the value for catalogTitles using a builder consumer that produces the value. + *

    + * Generated from setter {@link MusicPublisher#setCatalogTitles(List) setCatalogTitles(List catalogTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogTitles(t -> t.add("example value"));
    +   * }
    + * + * @param catalogTitlesBuilderConsumer consumer providing an instance of a builder for catalogTitles + * @return current instance of builder + */ + public MusicPublisherBuilder catalogTitles(Consumer> catalogTitlesBuilderConsumer) { + ArrayListBuilder builder = this.catalogTitles.isSet() + ? new ArrayListBuilder(this.catalogTitles.value()) + : new ArrayListBuilder(); + catalogTitlesBuilderConsumer.accept(builder); + this.catalogTitles = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for catalogTitles by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setCatalogTitles(List) setCatalogTitles(List catalogTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.catalogTitles(() -> List.of("example value"));
    +   * }
    + * + * @param catalogTitlesSupplier supplier for catalogTitles + * @return current instance of builder + */ + public MusicPublisherBuilder catalogTitles(Supplier> catalogTitlesSupplier) { + this.catalogTitles = changedValue(catalogTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for composersPublished. + *

    + * Generated from setter {@link MusicPublisher#setComposersPublished(int) setComposersPublished(int + * composersPublished)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.composersPublished(42);
    +   * }
    + * + * @param composersPublished composersPublished + * @return current instance of builder + */ + public MusicPublisherBuilder composersPublished(int composersPublished) { + this.composersPublished = changedValue(composersPublished); + return this; + } + + /** + * Sets the value for composersPublished by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setComposersPublished(int) setComposersPublished(int + * composersPublished)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.composersPublished(() -> 42);
    +   * }
    + * + * @param composersPublishedSupplier supplier for composersPublished + * @return current instance of builder + */ + public MusicPublisherBuilder composersPublished(Supplier composersPublishedSupplier) { + this.composersPublished = changedValue(composersPublishedSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MusicPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MusicPublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MusicPublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MusicPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MusicPublisherBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MusicPublisherBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MusicPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MusicPublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MusicPublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MusicPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MusicPublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MusicPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MusicPublisherBuilder 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. + *

    + * Generated from setter {@link MusicPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MusicPublisherBuilder 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. + *

    + * Generated from setter {@link MusicPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicPublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for royaltySystem. + *

    + * Generated from setter {@link MusicPublisher#setRoyaltySystem(String) setRoyaltySystem(String royaltySystem)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.royaltySystem("example value");
    +   * }
    + * + * @param royaltySystem royaltySystem + * @return current instance of builder + */ + public MusicPublisherBuilder royaltySystem(String royaltySystem) { + this.royaltySystem = changedValue(royaltySystem); + return this; + } + + /** + * Sets the value for royaltySystem by executing the provided consumer. + *

    + * Generated from setter {@link MusicPublisher#setRoyaltySystem(String) setRoyaltySystem(String royaltySystem)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.royaltySystem(sb -> sb.append("text"));
    +   * }
    + * + * @param royaltySystemStringBuilderConsumer consumer providing an instance of royaltySystem + * @return current instance of builder + */ + public MusicPublisherBuilder royaltySystem(Consumer royaltySystemStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + royaltySystemStringBuilderConsumer.accept(builder); + this.royaltySystem = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for royaltySystem by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setRoyaltySystem(String) setRoyaltySystem(String royaltySystem)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.royaltySystem(() -> "example value");
    +   * }
    + * + * @param royaltySystemSupplier supplier for royaltySystem + * @return current instance of builder + */ + public MusicPublisherBuilder royaltySystem(Supplier royaltySystemSupplier) { + this.royaltySystem = changedValue(royaltySystemSupplier.get()); + return this; + } + + /** + * Sets the String value for royaltySystem by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MusicPublisher#setRoyaltySystem(String) setRoyaltySystem(String royaltySystem)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.royaltySystem("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicPublisherBuilder royaltySystem(String format, Object... args) { + this.royaltySystem = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MusicPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MusicPublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MusicPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MusicPublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MusicPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MusicPublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MusicPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicPublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 MusicPublisherBuilder 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 MusicPublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MusicPublisher result = builder.build();
    +   * }
    + */ + @Override + public MusicPublisher build() { + if (this.composersPublished.isSet() && this.composersPublished.value() == null) { + throw new IllegalStateException("Field 'composersPublished' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + MusicPublisher result = new MusicPublisher(); + this.catalogTitles.ifSet(result::setCatalogTitles); + this.composersPublished.ifSet(result::setComposersPublished); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.royaltySystem.ifSet(result::setRoyaltySystem); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("catalogTitles", this.catalogTitles) + .append("composersPublished", this.composersPublished) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("royaltySystem", this.royaltySystem) + .append("status", this.status) + .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 MusicPublisher with(Consumer b) { + MusicPublisherBuilder builder; + try { + builder = new MusicPublisherBuilder(MusicPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MusicPublisherBuilder.With' should only be implemented by classes, which could be casted to 'MusicPublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MusicPublisherBuilder with() { + try { + return new MusicPublisherBuilder(MusicPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MusicPublisherBuilder.With' should only be implemented by classes, which could be casted to 'MusicPublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicSchoolBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicSchoolBuilder.java new file mode 100644 index 00000000..0a31047c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/MusicSchoolBuilder.java @@ -0,0 +1,710 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.MusicSchool}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.MusicSchool 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. + * + *

    Example:

    + * + *
    {@code
    + * MusicSchool result = MusicSchoolBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .instruments(List.of("example value"))
    + *     .instruments(() -> List.of("example value"))
    + *     .instruments(t -> t.add("example value"))
    + *     .instruments("example value", "example value")
    + *     .add2Instruments("example value")
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .performanceSpaces(42)
    + *     .performanceSpaces(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .studentCount(42)
    + *     .studentCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MusicSchool.class) +public class MusicSchoolBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for instruments: instruments. + */ + private TrackedValue> instruments = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for performanceSpaces: performanceSpaces. + */ + private TrackedValue performanceSpaces = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for studentCount: studentCount. + */ + private TrackedValue studentCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicSchool}. + */ + public MusicSchoolBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicSchool} by a instance. + * + * @param instance object instance for initialisiation + */ + public MusicSchoolBuilder(MusicSchool instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.instruments = initialValue(instance.getInstruments()); + this.name = initialValue(instance.getName()); + this.performanceSpaces = initialValue(instance.getPerformanceSpaces()); + this.status = initialValue(instance.getStatus()); + this.studentCount = initialValue(instance.getStudentCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicSchool}. + * + *

    Example:

    + * + *
    {@code
    +   * MusicSchoolBuilder builder = MusicSchoolBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.MusicSchool} + */ + public static MusicSchoolBuilder create() { + return new MusicSchoolBuilder(); + } + + /** + * Adds a single element to instruments. + *

    + * Generated from setter {@link MusicSchool#setInstruments(List) setInstruments(List instruments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Instruments("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public MusicSchoolBuilder add2Instruments(String element) { + List newCollection; + if (this.instruments.isSet()) { + newCollection = new ArrayList<>(this.instruments.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.instruments = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link MusicSchool#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public MusicSchoolBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public MusicSchoolBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link MusicSchool#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public MusicSchoolBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public MusicSchoolBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link MusicSchool#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public MusicSchoolBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public MusicSchoolBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for instruments. + *

    + * Generated from setter {@link MusicSchool#setInstruments(List) setInstruments(List instruments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instruments("example value", "example value");
    +   * }
    + * + * @param instruments instruments + * @return current instance of builder + */ + public MusicSchoolBuilder instruments(String... instruments) { + this.instruments = changedValue(List.of(instruments)); + return this; + } + + /** + * Sets the value for instruments. + *

    + * Generated from setter {@link MusicSchool#setInstruments(List) setInstruments(List instruments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instruments(List.of("example value"));
    +   * }
    + * + * @param instruments instruments + * @return current instance of builder + */ + public MusicSchoolBuilder instruments(List instruments) { + this.instruments = changedValue(instruments); + return this; + } + + /** + * Sets the value for instruments using a builder consumer that produces the value. + *

    + * Generated from setter {@link MusicSchool#setInstruments(List) setInstruments(List instruments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instruments(t -> t.add("example value"));
    +   * }
    + * + * @param instrumentsBuilderConsumer consumer providing an instance of a builder for instruments + * @return current instance of builder + */ + public MusicSchoolBuilder instruments(Consumer> instrumentsBuilderConsumer) { + ArrayListBuilder builder = this.instruments.isSet() + ? new ArrayListBuilder(this.instruments.value()) + : new ArrayListBuilder(); + instrumentsBuilderConsumer.accept(builder); + this.instruments = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for instruments by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setInstruments(List) setInstruments(List instruments)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instruments(() -> List.of("example value"));
    +   * }
    + * + * @param instrumentsSupplier supplier for instruments + * @return current instance of builder + */ + public MusicSchoolBuilder instruments(Supplier> instrumentsSupplier) { + this.instruments = changedValue(instrumentsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link MusicSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public MusicSchoolBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link MusicSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public MusicSchoolBuilder 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. + *

    + * Generated from setter {@link MusicSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public MusicSchoolBuilder 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. + *

    + * Generated from setter {@link MusicSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicSchoolBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for performanceSpaces. + *

    + * Generated from setter {@link MusicSchool#setPerformanceSpaces(int) setPerformanceSpaces(int performanceSpaces)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceSpaces(42);
    +   * }
    + * + * @param performanceSpaces performanceSpaces + * @return current instance of builder + */ + public MusicSchoolBuilder performanceSpaces(int performanceSpaces) { + this.performanceSpaces = changedValue(performanceSpaces); + return this; + } + + /** + * Sets the value for performanceSpaces by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setPerformanceSpaces(int) setPerformanceSpaces(int performanceSpaces)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceSpaces(() -> 42);
    +   * }
    + * + * @param performanceSpacesSupplier supplier for performanceSpaces + * @return current instance of builder + */ + public MusicSchoolBuilder performanceSpaces(Supplier performanceSpacesSupplier) { + this.performanceSpaces = changedValue(performanceSpacesSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link MusicSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public MusicSchoolBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link MusicSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public MusicSchoolBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public MusicSchoolBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link MusicSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MusicSchoolBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for studentCount. + *

    + * Generated from setter {@link MusicSchool#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(42);
    +   * }
    + * + * @param studentCount studentCount + * @return current instance of builder + */ + public MusicSchoolBuilder studentCount(int studentCount) { + this.studentCount = changedValue(studentCount); + return this; + } + + /** + * Sets the value for studentCount by invoking the provided supplier. + *

    + * Generated from setter {@link MusicSchool#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(() -> 42);
    +   * }
    + * + * @param studentCountSupplier supplier for studentCount + * @return current instance of builder + */ + public MusicSchoolBuilder studentCount(Supplier studentCountSupplier) { + this.studentCount = changedValue(studentCountSupplier.get()); + 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 MusicSchoolBuilder 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 MusicSchoolBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MusicSchool result = builder.build();
    +   * }
    + */ + @Override + public MusicSchool build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.performanceSpaces.isSet() && this.performanceSpaces.value() == null) { + throw new IllegalStateException("Field 'performanceSpaces' is marked as non-null but null value was provided"); + } + if (this.studentCount.isSet() && this.studentCount.value() == null) { + throw new IllegalStateException("Field 'studentCount' is marked as non-null but null value was provided"); + } + MusicSchool result = new MusicSchool(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.instruments.ifSet(result::setInstruments); + this.name.ifSet(result::setName); + this.performanceSpaces.ifSet(result::setPerformanceSpaces); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.studentCount.ifSet(result::setStudentCount); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("instruments", this.instruments) + .append("name", this.name) + .append("performanceSpaces", this.performanceSpaces) + .append("status", this.status) + .append("studentCount", this.studentCount) + .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 MusicSchool with(Consumer b) { + MusicSchoolBuilder builder; + try { + builder = new MusicSchoolBuilder(MusicSchool.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MusicSchoolBuilder.With' should only be implemented by classes, which could be casted to 'MusicSchool'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MusicSchoolBuilder with() { + try { + return new MusicSchoolBuilder(MusicSchool.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MusicSchoolBuilder.With' should only be implemented by classes, which could be casted to 'MusicSchool'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NameAuthorityBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NameAuthorityBuilder.java new file mode 100644 index 00000000..6565dabd --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NameAuthorityBuilder.java @@ -0,0 +1,641 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.NameAuthority}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.NameAuthority 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. + * + *

    Example:

    + * + *
    {@code
    + * NameAuthority result = NameAuthorityBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .nameRecords(42L)
    + *     .nameRecords(() -> 42L)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .updatesPerYear(42)
    + *     .updatesPerYear(() -> 42)
    + *     .variantsPerRecord(3.14)
    + *     .variantsPerRecord(() -> 3.14)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NameAuthority.class) +public class NameAuthorityBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for nameRecords: nameRecords. + */ + private TrackedValue nameRecords = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for updatesPerYear: updatesPerYear. + */ + private TrackedValue updatesPerYear = unsetValue(); + /** + * Tracked value for variantsPerRecord: variantsPerRecord. + */ + private TrackedValue variantsPerRecord = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NameAuthority}. + */ + public NameAuthorityBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NameAuthority} by a instance. + * + * @param instance object instance for initialisiation + */ + public NameAuthorityBuilder(NameAuthority instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.nameRecords = initialValue(instance.getNameRecords()); + this.status = initialValue(instance.getStatus()); + this.updatesPerYear = initialValue(instance.getUpdatesPerYear()); + this.variantsPerRecord = initialValue(instance.getVariantsPerRecord()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NameAuthority}. + * + *

    Example:

    + * + *
    {@code
    +   * NameAuthorityBuilder builder = NameAuthorityBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.NameAuthority} + */ + public static NameAuthorityBuilder create() { + return new NameAuthorityBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link NameAuthority#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public NameAuthorityBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public NameAuthorityBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link NameAuthority#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public NameAuthorityBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public NameAuthorityBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link NameAuthority#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public NameAuthorityBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public NameAuthorityBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link NameAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public NameAuthorityBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link NameAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public NameAuthorityBuilder 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. + *

    + * Generated from setter {@link NameAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public NameAuthorityBuilder 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. + *

    + * Generated from setter {@link NameAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NameAuthorityBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for nameRecords. + *

    + * Generated from setter {@link NameAuthority#setNameRecords(long) setNameRecords(long nameRecords)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.nameRecords(42L);
    +   * }
    + * + * @param nameRecords nameRecords + * @return current instance of builder + */ + public NameAuthorityBuilder nameRecords(long nameRecords) { + this.nameRecords = changedValue(nameRecords); + return this; + } + + /** + * Sets the value for nameRecords by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setNameRecords(long) setNameRecords(long nameRecords)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.nameRecords(() -> 42L);
    +   * }
    + * + * @param nameRecordsSupplier supplier for nameRecords + * @return current instance of builder + */ + public NameAuthorityBuilder nameRecords(Supplier nameRecordsSupplier) { + this.nameRecords = changedValue(nameRecordsSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link NameAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public NameAuthorityBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link NameAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public NameAuthorityBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public NameAuthorityBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link NameAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NameAuthorityBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for updatesPerYear. + *

    + * Generated from setter {@link NameAuthority#setUpdatesPerYear(int) setUpdatesPerYear(int updatesPerYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.updatesPerYear(42);
    +   * }
    + * + * @param updatesPerYear updatesPerYear + * @return current instance of builder + */ + public NameAuthorityBuilder updatesPerYear(int updatesPerYear) { + this.updatesPerYear = changedValue(updatesPerYear); + return this; + } + + /** + * Sets the value for updatesPerYear by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setUpdatesPerYear(int) setUpdatesPerYear(int updatesPerYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.updatesPerYear(() -> 42);
    +   * }
    + * + * @param updatesPerYearSupplier supplier for updatesPerYear + * @return current instance of builder + */ + public NameAuthorityBuilder updatesPerYear(Supplier updatesPerYearSupplier) { + this.updatesPerYear = changedValue(updatesPerYearSupplier.get()); + return this; + } + + /** + * Sets the value for variantsPerRecord. + *

    + * Generated from setter {@link NameAuthority#setVariantsPerRecord(double) setVariantsPerRecord(double + * variantsPerRecord)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.variantsPerRecord(3.14);
    +   * }
    + * + * @param variantsPerRecord variantsPerRecord + * @return current instance of builder + */ + public NameAuthorityBuilder variantsPerRecord(double variantsPerRecord) { + this.variantsPerRecord = changedValue(variantsPerRecord); + return this; + } + + /** + * Sets the value for variantsPerRecord by invoking the provided supplier. + *

    + * Generated from setter {@link NameAuthority#setVariantsPerRecord(double) setVariantsPerRecord(double + * variantsPerRecord)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.variantsPerRecord(() -> 3.14);
    +   * }
    + * + * @param variantsPerRecordSupplier supplier for variantsPerRecord + * @return current instance of builder + */ + public NameAuthorityBuilder variantsPerRecord(Supplier variantsPerRecordSupplier) { + this.variantsPerRecord = changedValue(variantsPerRecordSupplier.get()); + 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 NameAuthorityBuilder 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 NameAuthorityBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NameAuthority result = builder.build();
    +   * }
    + */ + @Override + public NameAuthority build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.nameRecords.isSet() && this.nameRecords.value() == null) { + throw new IllegalStateException("Field 'nameRecords' is marked as non-null but null value was provided"); + } + if (this.updatesPerYear.isSet() && this.updatesPerYear.value() == null) { + throw new IllegalStateException("Field 'updatesPerYear' is marked as non-null but null value was provided"); + } + if (this.variantsPerRecord.isSet() && this.variantsPerRecord.value() == null) { + throw new IllegalStateException("Field 'variantsPerRecord' is marked as non-null but null value was provided"); + } + NameAuthority result = new NameAuthority(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.nameRecords.ifSet(result::setNameRecords); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.updatesPerYear.ifSet(result::setUpdatesPerYear); + this.variantsPerRecord.ifSet(result::setVariantsPerRecord); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("nameRecords", this.nameRecords) + .append("status", this.status) + .append("updatesPerYear", this.updatesPerYear) + .append("variantsPerRecord", this.variantsPerRecord) + .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 NameAuthority with(Consumer b) { + NameAuthorityBuilder builder; + try { + builder = new NameAuthorityBuilder(NameAuthority.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NameAuthorityBuilder.With' should only be implemented by classes, which could be casted to 'NameAuthority'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NameAuthorityBuilder with() { + try { + return new NameAuthorityBuilder(NameAuthority.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NameAuthorityBuilder.With' should only be implemented by classes, which could be casted to 'NameAuthority'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalEndowmentBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalEndowmentBuilder.java new file mode 100644 index 00000000..f15ac299 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalEndowmentBuilder.java @@ -0,0 +1,682 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.NationalEndowment}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.NationalEndowment 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. + * + *

    Example:

    + * + *
    {@code
    + * NationalEndowment result = NationalEndowmentBuilder.create()
    + *     .annualBudget(BigDecimal.valueOf(3.14))
    + *     .annualBudget(() -> BigDecimal.valueOf(3.14))
    + *     .country("example value")
    + *     .country("Hello %s", "World")
    + *     .country(() -> "example value")
    + *     .country(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .grantsAwarded(42)
    + *     .grantsAwarded(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NationalEndowment.class) +public class NationalEndowmentBuilder implements IBuilderBase { + + /** + * Tracked value for annualBudget: annualBudget. + */ + private TrackedValue annualBudget = unsetValue(); + /** + * Tracked value for country: country. + */ + private TrackedValue country = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for grantsAwarded: grantsAwarded. + */ + private TrackedValue grantsAwarded = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalEndowment}. + */ + public NationalEndowmentBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalEndowment} by a instance. + * + * @param instance object instance for initialisiation + */ + public NationalEndowmentBuilder(NationalEndowment instance) { + this.annualBudget = initialValue(instance.getAnnualBudget()); + this.country = initialValue(instance.getCountry()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.grantsAwarded = initialValue(instance.getGrantsAwarded()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalEndowment}. + * + *

    Example:

    + * + *
    {@code
    +   * NationalEndowmentBuilder builder = NationalEndowmentBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalEndowment} + */ + public static NationalEndowmentBuilder create() { + return new NationalEndowmentBuilder(); + } + + /** + * Sets the value for annualBudget. + *

    + * Generated from setter {@link NationalEndowment#setAnnualBudget(BigDecimal) setAnnualBudget(BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualBudget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualBudget annualBudget + * @return current instance of builder + */ + public NationalEndowmentBuilder annualBudget(BigDecimal annualBudget) { + this.annualBudget = changedValue(annualBudget); + return this; + } + + /** + * Sets the value for annualBudget by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setAnnualBudget(BigDecimal) setAnnualBudget(BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualBudget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualBudgetSupplier supplier for annualBudget + * @return current instance of builder + */ + public NationalEndowmentBuilder annualBudget(Supplier annualBudgetSupplier) { + this.annualBudget = changedValue(annualBudgetSupplier.get()); + return this; + } + + /** + * Sets the value for country. + *

    + * Generated from setter {@link NationalEndowment#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("example value");
    +   * }
    + * + * @param country country + * @return current instance of builder + */ + public NationalEndowmentBuilder country(String country) { + this.country = changedValue(country); + return this; + } + + /** + * Sets the value for country by executing the provided consumer. + *

    + * Generated from setter {@link NationalEndowment#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(sb -> sb.append("text"));
    +   * }
    + * + * @param countryStringBuilderConsumer consumer providing an instance of country + * @return current instance of builder + */ + public NationalEndowmentBuilder country(Consumer countryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + countryStringBuilderConsumer.accept(builder); + this.country = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for country by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(() -> "example value");
    +   * }
    + * + * @param countrySupplier supplier for country + * @return current instance of builder + */ + public NationalEndowmentBuilder country(Supplier countrySupplier) { + this.country = changedValue(countrySupplier.get()); + return this; + } + + /** + * Sets the String value for country by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link NationalEndowment#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NationalEndowmentBuilder country(String format, Object... args) { + this.country = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link NationalEndowment#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public NationalEndowmentBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public NationalEndowmentBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link NationalEndowment#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public NationalEndowmentBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public NationalEndowmentBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for grantsAwarded. + *

    + * Generated from setter {@link NationalEndowment#setGrantsAwarded(int) setGrantsAwarded(int grantsAwarded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.grantsAwarded(42);
    +   * }
    + * + * @param grantsAwarded grantsAwarded + * @return current instance of builder + */ + public NationalEndowmentBuilder grantsAwarded(int grantsAwarded) { + this.grantsAwarded = changedValue(grantsAwarded); + return this; + } + + /** + * Sets the value for grantsAwarded by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setGrantsAwarded(int) setGrantsAwarded(int grantsAwarded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.grantsAwarded(() -> 42);
    +   * }
    + * + * @param grantsAwardedSupplier supplier for grantsAwarded + * @return current instance of builder + */ + public NationalEndowmentBuilder grantsAwarded(Supplier grantsAwardedSupplier) { + this.grantsAwarded = changedValue(grantsAwardedSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link NationalEndowment#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public NationalEndowmentBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public NationalEndowmentBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link NationalEndowment#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public NationalEndowmentBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link NationalEndowment#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public NationalEndowmentBuilder 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. + *

    + * Generated from setter {@link NationalEndowment#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public NationalEndowmentBuilder 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. + *

    + * Generated from setter {@link NationalEndowment#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NationalEndowmentBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link NationalEndowment#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public NationalEndowmentBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link NationalEndowment#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public NationalEndowmentBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link NationalEndowment#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public NationalEndowmentBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link NationalEndowment#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NationalEndowmentBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 NationalEndowmentBuilder 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 NationalEndowmentBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NationalEndowment result = builder.build();
    +   * }
    + */ + @Override + public NationalEndowment build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.grantsAwarded.isSet() && this.grantsAwarded.value() == null) { + throw new IllegalStateException("Field 'grantsAwarded' is marked as non-null but null value was provided"); + } + NationalEndowment result = new NationalEndowment(); + this.annualBudget.ifSet(result::setAnnualBudget); + this.country.ifSet(result::setCountry); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.grantsAwarded.ifSet(result::setGrantsAwarded); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualBudget", this.annualBudget) + .append("country", this.country) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("grantsAwarded", this.grantsAwarded) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .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 NationalEndowment with(Consumer b) { + NationalEndowmentBuilder builder; + try { + builder = new NationalEndowmentBuilder(NationalEndowment.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NationalEndowmentBuilder.With' should only be implemented by classes, which could be casted to 'NationalEndowment'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NationalEndowmentBuilder with() { + try { + return new NationalEndowmentBuilder(NationalEndowment.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NationalEndowmentBuilder.With' should only be implemented by classes, which could be casted to 'NationalEndowment'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalLibraryBuilder.java new file mode 100644 index 00000000..2d63cca7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NationalLibraryBuilder.java @@ -0,0 +1,680 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.NationalLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.NationalLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * NationalLibrary result = NationalLibraryBuilder.create()
    + *     .country("example value")
    + *     .country("Hello %s", "World")
    + *     .country(() -> "example value")
    + *     .country(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .legalDeposit(true)
    + *     .legalDeposit(() -> true)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalVolumes(42L)
    + *     .totalVolumes(() -> 42L)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NationalLibrary.class) +public class NationalLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for country: country. + */ + private TrackedValue country = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for legalDeposit: legalDeposit. + */ + private TrackedValue legalDeposit = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalVolumes: totalVolumes. + */ + private TrackedValue totalVolumes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalLibrary}. + */ + public NationalLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public NationalLibraryBuilder(NationalLibrary instance) { + this.country = initialValue(instance.getCountry()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.legalDeposit = initialValue(instance.isLegalDeposit()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.totalVolumes = initialValue(instance.getTotalVolumes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * NationalLibraryBuilder builder = NationalLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.NationalLibrary} + */ + public static NationalLibraryBuilder create() { + return new NationalLibraryBuilder(); + } + + /** + * Sets the value for country. + *

    + * Generated from setter {@link NationalLibrary#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("example value");
    +   * }
    + * + * @param country country + * @return current instance of builder + */ + public NationalLibraryBuilder country(String country) { + this.country = changedValue(country); + return this; + } + + /** + * Sets the value for country by executing the provided consumer. + *

    + * Generated from setter {@link NationalLibrary#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(sb -> sb.append("text"));
    +   * }
    + * + * @param countryStringBuilderConsumer consumer providing an instance of country + * @return current instance of builder + */ + public NationalLibraryBuilder country(Consumer countryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + countryStringBuilderConsumer.accept(builder); + this.country = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for country by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(() -> "example value");
    +   * }
    + * + * @param countrySupplier supplier for country + * @return current instance of builder + */ + public NationalLibraryBuilder country(Supplier countrySupplier) { + this.country = changedValue(countrySupplier.get()); + return this; + } + + /** + * Sets the String value for country by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link NationalLibrary#setCountry(String) setCountry(String country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NationalLibraryBuilder country(String format, Object... args) { + this.country = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link NationalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public NationalLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public NationalLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link NationalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public NationalLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public NationalLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link NationalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public NationalLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public NationalLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for legalDeposit. + *

    + * Generated from setter {@link NationalLibrary#setLegalDeposit(boolean) setLegalDeposit(boolean legalDeposit)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.legalDeposit(true);
    +   * }
    + * + * @param legalDeposit legalDeposit + * @return current instance of builder + */ + public NationalLibraryBuilder legalDeposit(boolean legalDeposit) { + this.legalDeposit = changedValue(legalDeposit); + return this; + } + + /** + * Sets the value for legalDeposit by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setLegalDeposit(boolean) setLegalDeposit(boolean legalDeposit)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.legalDeposit(() -> true);
    +   * }
    + * + * @param legalDepositSupplier supplier for legalDeposit + * @return current instance of builder + */ + public NationalLibraryBuilder legalDeposit(Supplier legalDepositSupplier) { + this.legalDeposit = changedValue(legalDepositSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link NationalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public NationalLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link NationalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public NationalLibraryBuilder 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. + *

    + * Generated from setter {@link NationalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public NationalLibraryBuilder 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. + *

    + * Generated from setter {@link NationalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NationalLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link NationalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public NationalLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link NationalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public NationalLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public NationalLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link NationalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NationalLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalVolumes. + *

    + * Generated from setter {@link NationalLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(42L);
    +   * }
    + * + * @param totalVolumes totalVolumes + * @return current instance of builder + */ + public NationalLibraryBuilder totalVolumes(long totalVolumes) { + this.totalVolumes = changedValue(totalVolumes); + return this; + } + + /** + * Sets the value for totalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link NationalLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(() -> 42L);
    +   * }
    + * + * @param totalVolumesSupplier supplier for totalVolumes + * @return current instance of builder + */ + public NationalLibraryBuilder totalVolumes(Supplier totalVolumesSupplier) { + this.totalVolumes = changedValue(totalVolumesSupplier.get()); + 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 NationalLibraryBuilder 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 NationalLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NationalLibrary result = builder.build();
    +   * }
    + */ + @Override + public NationalLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.legalDeposit.isSet() && this.legalDeposit.value() == null) { + throw new IllegalStateException("Field 'legalDeposit' is marked as non-null but null value was provided"); + } + if (this.totalVolumes.isSet() && this.totalVolumes.value() == null) { + throw new IllegalStateException("Field 'totalVolumes' is marked as non-null but null value was provided"); + } + NationalLibrary result = new NationalLibrary(); + this.country.ifSet(result::setCountry); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.legalDeposit.ifSet(result::setLegalDeposit); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalVolumes.ifSet(result::setTotalVolumes); + 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("country", this.country) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("legalDeposit", this.legalDeposit) + .append("name", this.name) + .append("status", this.status) + .append("totalVolumes", this.totalVolumes) + .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 NationalLibrary with(Consumer b) { + NationalLibraryBuilder builder; + try { + builder = new NationalLibraryBuilder(NationalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NationalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'NationalLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NationalLibraryBuilder with() { + try { + return new NationalLibraryBuilder(NationalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NationalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'NationalLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NaturalHistoryMuseumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NaturalHistoryMuseumBuilder.java new file mode 100644 index 00000000..14f312dc --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NaturalHistoryMuseumBuilder.java @@ -0,0 +1,717 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.NaturalHistoryMuseum}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.NaturalHistoryMuseum 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. + * + *

    Example:

    + * + *
    {@code
    + * NaturalHistoryMuseum result = NaturalHistoryMuseumBuilder.create()
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .researchAreas(List.of("example value"))
    + *     .researchAreas(() -> List.of("example value"))
    + *     .researchAreas(t -> t.add("example value"))
    + *     .researchAreas("example value", "example value")
    + *     .add2ResearchAreas("example value")
    + *     .specimenCount(42L)
    + *     .specimenCount(() -> 42L)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NaturalHistoryMuseum.class) +public class NaturalHistoryMuseumBuilder implements IBuilderBase { + + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for researchAreas: researchAreas. + */ + private TrackedValue> researchAreas = unsetValue(); + /** + * Tracked value for specimenCount: specimenCount. + */ + private TrackedValue specimenCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NaturalHistoryMuseum}. + */ + public NaturalHistoryMuseumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NaturalHistoryMuseum} by a instance. + * + * @param instance object instance for initialisiation + */ + public NaturalHistoryMuseumBuilder(NaturalHistoryMuseum instance) { + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.researchAreas = initialValue(instance.getResearchAreas()); + this.specimenCount = initialValue(instance.getSpecimenCount()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NaturalHistoryMuseum}. + * + *

    Example:

    + * + *
    {@code
    +   * NaturalHistoryMuseumBuilder builder = NaturalHistoryMuseumBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NaturalHistoryMuseum} + */ + public static NaturalHistoryMuseumBuilder create() { + return new NaturalHistoryMuseumBuilder(); + } + + /** + * Adds a single element to researchAreas. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ResearchAreas("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder add2ResearchAreas(String element) { + List newCollection; + if (this.researchAreas.isSet()) { + newCollection = new ArrayList<>(this.researchAreas.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.researchAreas = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder 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. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder 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. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researchAreas. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas("example value", "example value");
    +   * }
    + * + * @param researchAreas researchAreas + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder researchAreas(String... researchAreas) { + this.researchAreas = changedValue(List.of(researchAreas)); + return this; + } + + /** + * Sets the value for researchAreas. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(List.of("example value"));
    +   * }
    + * + * @param researchAreas researchAreas + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder researchAreas(List researchAreas) { + this.researchAreas = changedValue(researchAreas); + return this; + } + + /** + * Sets the value for researchAreas using a builder consumer that produces the value. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(t -> t.add("example value"));
    +   * }
    + * + * @param researchAreasBuilderConsumer consumer providing an instance of a builder for researchAreas + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder researchAreas(Consumer> researchAreasBuilderConsumer) { + ArrayListBuilder builder = this.researchAreas.isSet() + ? new ArrayListBuilder(this.researchAreas.value()) + : new ArrayListBuilder(); + researchAreasBuilderConsumer.accept(builder); + this.researchAreas = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for researchAreas by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(() -> List.of("example value"));
    +   * }
    + * + * @param researchAreasSupplier supplier for researchAreas + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder researchAreas(Supplier> researchAreasSupplier) { + this.researchAreas = changedValue(researchAreasSupplier.get()); + return this; + } + + /** + * Sets the value for specimenCount. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setSpecimenCount(long) setSpecimenCount(long specimenCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specimenCount(42L);
    +   * }
    + * + * @param specimenCount specimenCount + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder specimenCount(long specimenCount) { + this.specimenCount = changedValue(specimenCount); + return this; + } + + /** + * Sets the value for specimenCount by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setSpecimenCount(long) setSpecimenCount(long specimenCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specimenCount(() -> 42L);
    +   * }
    + * + * @param specimenCountSupplier supplier for specimenCount + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder specimenCount(Supplier specimenCountSupplier) { + this.specimenCount = changedValue(specimenCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link NaturalHistoryMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NaturalHistoryMuseumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 NaturalHistoryMuseumBuilder 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 NaturalHistoryMuseumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NaturalHistoryMuseum result = builder.build();
    +   * }
    + */ + @Override + public NaturalHistoryMuseum build() { + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.specimenCount.isSet() && this.specimenCount.value() == null) { + throw new IllegalStateException("Field 'specimenCount' is marked as non-null but null value was provided"); + } + NaturalHistoryMuseum result = new NaturalHistoryMuseum(); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.researchAreas.ifSet(result::setResearchAreas); + this.specimenCount.ifSet(result::setSpecimenCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualVisitors", this.annualVisitors) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("researchAreas", this.researchAreas) + .append("specimenCount", this.specimenCount) + .append("status", this.status) + .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 NaturalHistoryMuseum with(Consumer b) { + NaturalHistoryMuseumBuilder builder; + try { + builder = new NaturalHistoryMuseumBuilder(NaturalHistoryMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NaturalHistoryMuseumBuilder.With' should only be implemented by classes, which could be casted to 'NaturalHistoryMuseum'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NaturalHistoryMuseumBuilder with() { + try { + return new NaturalHistoryMuseumBuilder(NaturalHistoryMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NaturalHistoryMuseumBuilder.With' should only be implemented by classes, which could be casted to 'NaturalHistoryMuseum'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NetworkRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NetworkRecordBuilder.java new file mode 100644 index 00000000..cad9ad26 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/NetworkRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.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.performance_test.library.organizations.NetworkRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.NetworkRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * NetworkRecord result = NetworkRecordBuilder.create()
    + *     .networkName("example value")
    + *     .networkName("Hello %s", "World")
    + *     .networkName(() -> "example value")
    + *     .networkName(sb -> sb.append("text"))
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .focusArea("example value")
    + *     .focusArea("Hello %s", "World")
    + *     .focusArea(() -> "example value")
    + *     .focusArea(sb -> sb.append("text"))
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .active(true)
    + *     .active(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = NetworkRecord.class) +public class NetworkRecordBuilder implements IBuilderBase { + + /** + * Tracked value for networkName: networkName. + */ + private TrackedValue networkName = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for focusArea: focusArea. + */ + private TrackedValue focusArea = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for active: active. + */ + private TrackedValue active = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NetworkRecord}. + */ + public NetworkRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NetworkRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public NetworkRecordBuilder(NetworkRecord instance) { + this.networkName = initialValue(instance.networkName()); + this.memberCount = initialValue(instance.memberCount()); + this.focusArea = initialValue(instance.focusArea()); + this.foundedYear = initialValue(instance.foundedYear()); + this.active = initialValue(instance.active()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.NetworkRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * NetworkRecordBuilder builder = NetworkRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.NetworkRecord} + */ + public static NetworkRecordBuilder create() { + return new NetworkRecordBuilder(); + } + + /** + * Sets the value for active. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(true);
    +   * }
    + * + * @param active active + * @return current instance of builder + */ + public NetworkRecordBuilder active(boolean active) { + this.active = changedValue(active); + return this; + } + + /** + * Sets the value for active by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(() -> true);
    +   * }
    + * + * @param activeSupplier supplier for active + * @return current instance of builder + */ + public NetworkRecordBuilder active(Supplier activeSupplier) { + this.active = changedValue(activeSupplier.get()); + return this; + } + + /** + * Sets the value for focusArea. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea("example value");
    +   * }
    + * + * @param focusArea focusArea + * @return current instance of builder + */ + public NetworkRecordBuilder focusArea(String focusArea) { + this.focusArea = changedValue(focusArea); + return this; + } + + /** + * Sets the value for focusArea by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea(sb -> sb.append("text"));
    +   * }
    + * + * @param focusAreaStringBuilderConsumer consumer providing an instance of focusArea + * @return current instance of builder + */ + public NetworkRecordBuilder focusArea(Consumer focusAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + focusAreaStringBuilderConsumer.accept(builder); + this.focusArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for focusArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea(() -> "example value");
    +   * }
    + * + * @param focusAreaSupplier supplier for focusArea + * @return current instance of builder + */ + public NetworkRecordBuilder focusArea(Supplier focusAreaSupplier) { + this.focusArea = changedValue(focusAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for focusArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NetworkRecordBuilder focusArea(String format, Object... args) { + this.focusArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public NetworkRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public NetworkRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public NetworkRecordBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public NetworkRecordBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for networkName. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.networkName("example value");
    +   * }
    + * + * @param networkName networkName + * @return current instance of builder + */ + public NetworkRecordBuilder networkName(String networkName) { + this.networkName = changedValue(networkName); + return this; + } + + /** + * Sets the value for networkName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.networkName(sb -> sb.append("text"));
    +   * }
    + * + * @param networkNameStringBuilderConsumer consumer providing an instance of networkName + * @return current instance of builder + */ + public NetworkRecordBuilder networkName(Consumer networkNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + networkNameStringBuilderConsumer.accept(builder); + this.networkName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for networkName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.networkName(() -> "example value");
    +   * }
    + * + * @param networkNameSupplier supplier for networkName + * @return current instance of builder + */ + public NetworkRecordBuilder networkName(Supplier networkNameSupplier) { + this.networkName = changedValue(networkNameSupplier.get()); + return this; + } + + /** + * Sets the String value for networkName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link NetworkRecord#NetworkRecord(String, int, String, int, boolean) + * NetworkRecord(String networkName, int memberCount, String focusArea, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.networkName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public NetworkRecordBuilder networkName(String format, Object... args) { + this.networkName = changedValue(String.format(format, args)); + 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 NetworkRecordBuilder 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 NetworkRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * NetworkRecord result = builder.build();
    +   * }
    + */ + @Override + public NetworkRecord build() { + if (!this.memberCount.isSet()) { + throw new IllegalStateException("Required field 'memberCount' must be set before calling build()"); + } + if (this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + NetworkRecord result = new NetworkRecord(this.networkName.value(), + this.memberCount.value(), + this.focusArea.value(), + this.foundedYear.value(), + this.active.valueOr(true)); + 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("networkName", this.networkName) + .append("memberCount", this.memberCount) + .append("focusArea", this.focusArea) + .append("foundedYear", this.foundedYear) + .append("active", this.active) + .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 NetworkRecord with(Consumer b) { + NetworkRecordBuilder builder; + try { + builder = new NetworkRecordBuilder(NetworkRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NetworkRecordBuilder.With' should only be implemented by classes, which could be casted to 'NetworkRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default NetworkRecordBuilder with() { + try { + return new NetworkRecordBuilder(NetworkRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'NetworkRecordBuilder.With' should only be implemented by classes, which could be casted to 'NetworkRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/OnlineBookstoreBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/OnlineBookstoreBuilder.java new file mode 100644 index 00000000..6401cb47 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/OnlineBookstoreBuilder.java @@ -0,0 +1,680 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.OnlineBookstore}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.OnlineBookstore 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. + * + *

    Example:

    + * + *
    {@code
    + * OnlineBookstore result = OnlineBookstoreBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .dailyOrders(42)
    + *     .dailyOrders(() -> 42)
    + *     .digitalCatalog(42L)
    + *     .digitalCatalog(() -> 42L)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .storeName("example value")
    + *     .storeName("Hello %s", "World")
    + *     .storeName(() -> "example value")
    + *     .storeName(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = OnlineBookstore.class) +public class OnlineBookstoreBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for dailyOrders: dailyOrders. + */ + private TrackedValue dailyOrders = unsetValue(); + /** + * Tracked value for digitalCatalog: digitalCatalog. + */ + private TrackedValue digitalCatalog = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for storeName: storeName. + */ + private TrackedValue storeName = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.OnlineBookstore}. + */ + public OnlineBookstoreBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.OnlineBookstore} by a instance. + * + * @param instance object instance for initialisiation + */ + public OnlineBookstoreBuilder(OnlineBookstore instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.dailyOrders = initialValue(instance.getDailyOrders()); + this.digitalCatalog = initialValue(instance.getDigitalCatalog()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.storeName = initialValue(instance.getStoreName()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.OnlineBookstore}. + * + *

    Example:

    + * + *
    {@code
    +   * OnlineBookstoreBuilder builder = OnlineBookstoreBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.OnlineBookstore} + */ + public static OnlineBookstoreBuilder create() { + return new OnlineBookstoreBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link OnlineBookstore#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public OnlineBookstoreBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public OnlineBookstoreBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for dailyOrders. + *

    + * Generated from setter {@link OnlineBookstore#setDailyOrders(int) setDailyOrders(int dailyOrders)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dailyOrders(42);
    +   * }
    + * + * @param dailyOrders dailyOrders + * @return current instance of builder + */ + public OnlineBookstoreBuilder dailyOrders(int dailyOrders) { + this.dailyOrders = changedValue(dailyOrders); + return this; + } + + /** + * Sets the value for dailyOrders by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setDailyOrders(int) setDailyOrders(int dailyOrders)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dailyOrders(() -> 42);
    +   * }
    + * + * @param dailyOrdersSupplier supplier for dailyOrders + * @return current instance of builder + */ + public OnlineBookstoreBuilder dailyOrders(Supplier dailyOrdersSupplier) { + this.dailyOrders = changedValue(dailyOrdersSupplier.get()); + return this; + } + + /** + * Sets the value for digitalCatalog. + *

    + * Generated from setter {@link OnlineBookstore#setDigitalCatalog(long) setDigitalCatalog(long digitalCatalog)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.digitalCatalog(42L);
    +   * }
    + * + * @param digitalCatalog digitalCatalog + * @return current instance of builder + */ + public OnlineBookstoreBuilder digitalCatalog(long digitalCatalog) { + this.digitalCatalog = changedValue(digitalCatalog); + return this; + } + + /** + * Sets the value for digitalCatalog by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setDigitalCatalog(long) setDigitalCatalog(long digitalCatalog)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.digitalCatalog(() -> 42L);
    +   * }
    + * + * @param digitalCatalogSupplier supplier for digitalCatalog + * @return current instance of builder + */ + public OnlineBookstoreBuilder digitalCatalog(Supplier digitalCatalogSupplier) { + this.digitalCatalog = changedValue(digitalCatalogSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link OnlineBookstore#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public OnlineBookstoreBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public OnlineBookstoreBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link OnlineBookstore#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public OnlineBookstoreBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public OnlineBookstoreBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link OnlineBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public OnlineBookstoreBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link OnlineBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public OnlineBookstoreBuilder 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. + *

    + * Generated from setter {@link OnlineBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public OnlineBookstoreBuilder 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. + *

    + * Generated from setter {@link OnlineBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OnlineBookstoreBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link OnlineBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public OnlineBookstoreBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link OnlineBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public OnlineBookstoreBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public OnlineBookstoreBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link OnlineBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OnlineBookstoreBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for storeName. + *

    + * Generated from setter {@link OnlineBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName("example value");
    +   * }
    + * + * @param storeName storeName + * @return current instance of builder + */ + public OnlineBookstoreBuilder storeName(String storeName) { + this.storeName = changedValue(storeName); + return this; + } + + /** + * Sets the value for storeName by executing the provided consumer. + *

    + * Generated from setter {@link OnlineBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName(sb -> sb.append("text"));
    +   * }
    + * + * @param storeNameStringBuilderConsumer consumer providing an instance of storeName + * @return current instance of builder + */ + public OnlineBookstoreBuilder storeName(Consumer storeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + storeNameStringBuilderConsumer.accept(builder); + this.storeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for storeName by invoking the provided supplier. + *

    + * Generated from setter {@link OnlineBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName(() -> "example value");
    +   * }
    + * + * @param storeNameSupplier supplier for storeName + * @return current instance of builder + */ + public OnlineBookstoreBuilder storeName(Supplier storeNameSupplier) { + this.storeName = changedValue(storeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for storeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link OnlineBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OnlineBookstoreBuilder storeName(String format, Object... args) { + this.storeName = changedValue(String.format(format, args)); + 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 OnlineBookstoreBuilder 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 OnlineBookstoreBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * OnlineBookstore result = builder.build();
    +   * }
    + */ + @Override + public OnlineBookstore build() { + if (this.dailyOrders.isSet() && this.dailyOrders.value() == null) { + throw new IllegalStateException("Field 'dailyOrders' is marked as non-null but null value was provided"); + } + if (this.digitalCatalog.isSet() && this.digitalCatalog.value() == null) { + throw new IllegalStateException("Field 'digitalCatalog' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + OnlineBookstore result = new OnlineBookstore(); + this.createdAt.ifSet(result::setCreatedAt); + this.dailyOrders.ifSet(result::setDailyOrders); + this.digitalCatalog.ifSet(result::setDigitalCatalog); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.storeName.ifSet(result::setStoreName); + 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("createdAt", this.createdAt) + .append("dailyOrders", this.dailyOrders) + .append("digitalCatalog", this.digitalCatalog) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .append("storeName", this.storeName) + .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 OnlineBookstore with(Consumer b) { + OnlineBookstoreBuilder builder; + try { + builder = new OnlineBookstoreBuilder(OnlineBookstore.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OnlineBookstoreBuilder.With' should only be implemented by classes, which could be casted to 'OnlineBookstore'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default OnlineBookstoreBuilder with() { + try { + return new OnlineBookstoreBuilder(OnlineBookstore.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OnlineBookstoreBuilder.With' should only be implemented by classes, which could be casted to 'OnlineBookstore'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PartnershipRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PartnershipRecordBuilder.java new file mode 100644 index 00000000..8ede1ec7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PartnershipRecordBuilder.java @@ -0,0 +1,607 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.PartnershipRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PartnershipRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PartnershipRecord result = PartnershipRecordBuilder.create()
    + *     .partnershipName("example value")
    + *     .partnershipName("Hello %s", "World")
    + *     .partnershipName(() -> "example value")
    + *     .partnershipName(sb -> sb.append("text"))
    + *     .partnerA("example value")
    + *     .partnerA("Hello %s", "World")
    + *     .partnerA(() -> "example value")
    + *     .partnerA(sb -> sb.append("text"))
    + *     .partnerB("example value")
    + *     .partnerB("Hello %s", "World")
    + *     .partnerB(() -> "example value")
    + *     .partnerB(sb -> sb.append("text"))
    + *     .agreementDate(LocalDate.now())
    + *     .agreementDate(() -> LocalDate.now())
    + *     .duration("example value")
    + *     .duration("Hello %s", "World")
    + *     .duration(() -> "example value")
    + *     .duration(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PartnershipRecord.class) +public class PartnershipRecordBuilder implements IBuilderBase { + + /** + * Tracked value for partnershipName: partnershipName. + */ + private TrackedValue partnershipName = unsetValue(); + /** + * Tracked value for partnerA: partnerA. + */ + private TrackedValue partnerA = unsetValue(); + /** + * Tracked value for partnerB: partnerB. + */ + private TrackedValue partnerB = unsetValue(); + /** + * Tracked value for agreementDate: agreementDate. + */ + private TrackedValue agreementDate = unsetValue(); + /** + * Tracked value for duration: duration. + */ + private TrackedValue duration = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PartnershipRecord}. + */ + public PartnershipRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PartnershipRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PartnershipRecordBuilder(PartnershipRecord instance) { + this.partnershipName = initialValue(instance.partnershipName()); + this.partnerA = initialValue(instance.partnerA()); + this.partnerB = initialValue(instance.partnerB()); + this.agreementDate = initialValue(instance.agreementDate()); + this.duration = initialValue(instance.duration()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PartnershipRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PartnershipRecordBuilder builder = PartnershipRecordBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PartnershipRecord} + */ + public static PartnershipRecordBuilder create() { + return new PartnershipRecordBuilder(); + } + + /** + * Sets the value for agreementDate. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.agreementDate(LocalDate.now());
    +   * }
    + * + * @param agreementDate agreementDate + * @return current instance of builder + */ + public PartnershipRecordBuilder agreementDate(LocalDate agreementDate) { + this.agreementDate = changedValue(agreementDate); + return this; + } + + /** + * Sets the value for agreementDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.agreementDate(() -> LocalDate.now());
    +   * }
    + * + * @param agreementDateSupplier supplier for agreementDate + * @return current instance of builder + */ + public PartnershipRecordBuilder agreementDate(Supplier agreementDateSupplier) { + this.agreementDate = changedValue(agreementDateSupplier.get()); + return this; + } + + /** + * Sets the value for duration. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.duration("example value");
    +   * }
    + * + * @param duration duration + * @return current instance of builder + */ + public PartnershipRecordBuilder duration(String duration) { + this.duration = changedValue(duration); + return this; + } + + /** + * Sets the value for duration by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.duration(sb -> sb.append("text"));
    +   * }
    + * + * @param durationStringBuilderConsumer consumer providing an instance of duration + * @return current instance of builder + */ + public PartnershipRecordBuilder duration(Consumer durationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + durationStringBuilderConsumer.accept(builder); + this.duration = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for duration by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.duration(() -> "example value");
    +   * }
    + * + * @param durationSupplier supplier for duration + * @return current instance of builder + */ + public PartnershipRecordBuilder duration(Supplier durationSupplier) { + this.duration = changedValue(durationSupplier.get()); + return this; + } + + /** + * Sets the String value for duration by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.duration("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PartnershipRecordBuilder duration(String format, Object... args) { + this.duration = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for partnerA. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerA("example value");
    +   * }
    + * + * @param partnerA partnerA + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerA(String partnerA) { + this.partnerA = changedValue(partnerA); + return this; + } + + /** + * Sets the value for partnerA by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerA(sb -> sb.append("text"));
    +   * }
    + * + * @param partnerAStringBuilderConsumer consumer providing an instance of partnerA + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerA(Consumer partnerAStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + partnerAStringBuilderConsumer.accept(builder); + this.partnerA = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for partnerA by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerA(() -> "example value");
    +   * }
    + * + * @param partnerASupplier supplier for partnerA + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerA(Supplier partnerASupplier) { + this.partnerA = changedValue(partnerASupplier.get()); + return this; + } + + /** + * Sets the String value for partnerA by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerA("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerA(String format, Object... args) { + this.partnerA = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for partnerB. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerB("example value");
    +   * }
    + * + * @param partnerB partnerB + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerB(String partnerB) { + this.partnerB = changedValue(partnerB); + return this; + } + + /** + * Sets the value for partnerB by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerB(sb -> sb.append("text"));
    +   * }
    + * + * @param partnerBStringBuilderConsumer consumer providing an instance of partnerB + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerB(Consumer partnerBStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + partnerBStringBuilderConsumer.accept(builder); + this.partnerB = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for partnerB by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerB(() -> "example value");
    +   * }
    + * + * @param partnerBSupplier supplier for partnerB + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerB(Supplier partnerBSupplier) { + this.partnerB = changedValue(partnerBSupplier.get()); + return this; + } + + /** + * Sets the String value for partnerB by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnerB("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PartnershipRecordBuilder partnerB(String format, Object... args) { + this.partnerB = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for partnershipName. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnershipName("example value");
    +   * }
    + * + * @param partnershipName partnershipName + * @return current instance of builder + */ + public PartnershipRecordBuilder partnershipName(String partnershipName) { + this.partnershipName = changedValue(partnershipName); + return this; + } + + /** + * Sets the value for partnershipName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnershipName(sb -> sb.append("text"));
    +   * }
    + * + * @param partnershipNameStringBuilderConsumer consumer providing an instance of partnershipName + * @return current instance of builder + */ + public PartnershipRecordBuilder partnershipName(Consumer partnershipNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + partnershipNameStringBuilderConsumer.accept(builder); + this.partnershipName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for partnershipName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnershipName(() -> "example value");
    +   * }
    + * + * @param partnershipNameSupplier supplier for partnershipName + * @return current instance of builder + */ + public PartnershipRecordBuilder partnershipName(Supplier partnershipNameSupplier) { + this.partnershipName = changedValue(partnershipNameSupplier.get()); + return this; + } + + /** + * Sets the String value for partnershipName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PartnershipRecord#PartnershipRecord(String, String, String, LocalDate, String) PartnershipRecord(String + * partnershipName, String partnerA, String partnerB, LocalDate agreementDate, String duration)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.partnershipName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PartnershipRecordBuilder partnershipName(String format, Object... args) { + this.partnershipName = changedValue(String.format(format, args)); + 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 PartnershipRecordBuilder 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 PartnershipRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PartnershipRecord result = builder.build();
    +   * }
    + */ + @Override + public PartnershipRecord build() { + PartnershipRecord result = new PartnershipRecord(this.partnershipName + .value(), this.partnerA.value(), this.partnerB.value(), this.agreementDate.value(), this.duration.value()); + 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("partnershipName", this.partnershipName) + .append("partnerA", this.partnerA) + .append("partnerB", this.partnerB) + .append("agreementDate", this.agreementDate) + .append("duration", this.duration) + .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 PartnershipRecord with(Consumer b) { + PartnershipRecordBuilder builder; + try { + builder = new PartnershipRecordBuilder(PartnershipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PartnershipRecordBuilder.With' should only be implemented by classes, which could be casted to 'PartnershipRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PartnershipRecordBuilder with() { + try { + return new PartnershipRecordBuilder(PartnershipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PartnershipRecordBuilder.With' should only be implemented by classes, which could be casted to 'PartnershipRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PerformingArtsCenterBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PerformingArtsCenterBuilder.java new file mode 100644 index 00000000..6bbad90a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PerformingArtsCenterBuilder.java @@ -0,0 +1,721 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.PerformingArtsCenter}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PerformingArtsCenter 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. + * + *

    Example:

    + * + *
    {@code
    + * PerformingArtsCenter result = PerformingArtsCenterBuilder.create()
    + *     .annualPerformances(42)
    + *     .annualPerformances(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .residentCompanies(List.of("example value"))
    + *     .residentCompanies(() -> List.of("example value"))
    + *     .residentCompanies(t -> t.add("example value"))
    + *     .residentCompanies("example value", "example value")
    + *     .add2ResidentCompanies("example value")
    + *     .seatingCapacity(42)
    + *     .seatingCapacity(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PerformingArtsCenter.class) +public class PerformingArtsCenterBuilder implements IBuilderBase { + + /** + * Tracked value for annualPerformances: annualPerformances. + */ + private TrackedValue annualPerformances = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for residentCompanies: residentCompanies. + */ + private TrackedValue> residentCompanies = unsetValue(); + /** + * Tracked value for seatingCapacity: seatingCapacity. + */ + private TrackedValue seatingCapacity = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PerformingArtsCenter}. + */ + public PerformingArtsCenterBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PerformingArtsCenter} by a instance. + * + * @param instance object instance for initialisiation + */ + public PerformingArtsCenterBuilder(PerformingArtsCenter instance) { + this.annualPerformances = initialValue(instance.getAnnualPerformances()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.residentCompanies = initialValue(instance.getResidentCompanies()); + this.seatingCapacity = initialValue(instance.getSeatingCapacity()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PerformingArtsCenter}. + * + *

    Example:

    + * + *
    {@code
    +   * PerformingArtsCenterBuilder builder = PerformingArtsCenterBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PerformingArtsCenter} + */ + public static PerformingArtsCenterBuilder create() { + return new PerformingArtsCenterBuilder(); + } + + /** + * Adds a single element to residentCompanies. + *

    + * Generated from setter {@link PerformingArtsCenter#setResidentCompanies(List) setResidentCompanies(List + * residentCompanies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ResidentCompanies("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PerformingArtsCenterBuilder add2ResidentCompanies(String element) { + List newCollection; + if (this.residentCompanies.isSet()) { + newCollection = new ArrayList<>(this.residentCompanies.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.residentCompanies = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualPerformances. + *

    + * Generated from setter {@link PerformingArtsCenter#setAnnualPerformances(int) setAnnualPerformances(int + * annualPerformances)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualPerformances(42);
    +   * }
    + * + * @param annualPerformances annualPerformances + * @return current instance of builder + */ + public PerformingArtsCenterBuilder annualPerformances(int annualPerformances) { + this.annualPerformances = changedValue(annualPerformances); + return this; + } + + /** + * Sets the value for annualPerformances by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setAnnualPerformances(int) setAnnualPerformances(int + * annualPerformances)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualPerformances(() -> 42);
    +   * }
    + * + * @param annualPerformancesSupplier supplier for annualPerformances + * @return current instance of builder + */ + public PerformingArtsCenterBuilder annualPerformances(Supplier annualPerformancesSupplier) { + this.annualPerformances = changedValue(annualPerformancesSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PerformingArtsCenter#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PerformingArtsCenterBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PerformingArtsCenterBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PerformingArtsCenter#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PerformingArtsCenterBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PerformingArtsCenterBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PerformingArtsCenter#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PerformingArtsCenterBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PerformingArtsCenterBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PerformingArtsCenter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PerformingArtsCenterBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PerformingArtsCenter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PerformingArtsCenterBuilder 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. + *

    + * Generated from setter {@link PerformingArtsCenter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PerformingArtsCenterBuilder 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. + *

    + * Generated from setter {@link PerformingArtsCenter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PerformingArtsCenterBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for residentCompanies. + *

    + * Generated from setter {@link PerformingArtsCenter#setResidentCompanies(List) setResidentCompanies(List + * residentCompanies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentCompanies("example value", "example value");
    +   * }
    + * + * @param residentCompanies residentCompanies + * @return current instance of builder + */ + public PerformingArtsCenterBuilder residentCompanies(String... residentCompanies) { + this.residentCompanies = changedValue(List.of(residentCompanies)); + return this; + } + + /** + * Sets the value for residentCompanies. + *

    + * Generated from setter {@link PerformingArtsCenter#setResidentCompanies(List) setResidentCompanies(List + * residentCompanies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentCompanies(List.of("example value"));
    +   * }
    + * + * @param residentCompanies residentCompanies + * @return current instance of builder + */ + public PerformingArtsCenterBuilder residentCompanies(List residentCompanies) { + this.residentCompanies = changedValue(residentCompanies); + return this; + } + + /** + * Sets the value for residentCompanies using a builder consumer that produces the value. + *

    + * Generated from setter {@link PerformingArtsCenter#setResidentCompanies(List) setResidentCompanies(List + * residentCompanies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentCompanies(t -> t.add("example value"));
    +   * }
    + * + * @param residentCompaniesBuilderConsumer consumer providing an instance of a builder for residentCompanies + * @return current instance of builder + */ + public PerformingArtsCenterBuilder residentCompanies( + Consumer> residentCompaniesBuilderConsumer) { + ArrayListBuilder builder = this.residentCompanies.isSet() + ? new ArrayListBuilder(this.residentCompanies.value()) + : new ArrayListBuilder(); + residentCompaniesBuilderConsumer.accept(builder); + this.residentCompanies = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for residentCompanies by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setResidentCompanies(List) setResidentCompanies(List + * residentCompanies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentCompanies(() -> List.of("example value"));
    +   * }
    + * + * @param residentCompaniesSupplier supplier for residentCompanies + * @return current instance of builder + */ + public PerformingArtsCenterBuilder residentCompanies(Supplier> residentCompaniesSupplier) { + this.residentCompanies = changedValue(residentCompaniesSupplier.get()); + return this; + } + + /** + * Sets the value for seatingCapacity. + *

    + * Generated from setter {@link PerformingArtsCenter#setSeatingCapacity(int) setSeatingCapacity(int seatingCapacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seatingCapacity(42);
    +   * }
    + * + * @param seatingCapacity seatingCapacity + * @return current instance of builder + */ + public PerformingArtsCenterBuilder seatingCapacity(int seatingCapacity) { + this.seatingCapacity = changedValue(seatingCapacity); + return this; + } + + /** + * Sets the value for seatingCapacity by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setSeatingCapacity(int) setSeatingCapacity(int seatingCapacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seatingCapacity(() -> 42);
    +   * }
    + * + * @param seatingCapacitySupplier supplier for seatingCapacity + * @return current instance of builder + */ + public PerformingArtsCenterBuilder seatingCapacity(Supplier seatingCapacitySupplier) { + this.seatingCapacity = changedValue(seatingCapacitySupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PerformingArtsCenter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PerformingArtsCenterBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PerformingArtsCenter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PerformingArtsCenterBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PerformingArtsCenter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PerformingArtsCenterBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PerformingArtsCenter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PerformingArtsCenterBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PerformingArtsCenterBuilder 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 PerformingArtsCenterBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PerformingArtsCenter result = builder.build();
    +   * }
    + */ + @Override + public PerformingArtsCenter build() { + if (this.annualPerformances.isSet() && this.annualPerformances.value() == null) { + throw new IllegalStateException("Field 'annualPerformances' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.seatingCapacity.isSet() && this.seatingCapacity.value() == null) { + throw new IllegalStateException("Field 'seatingCapacity' is marked as non-null but null value was provided"); + } + PerformingArtsCenter result = new PerformingArtsCenter(); + this.annualPerformances.ifSet(result::setAnnualPerformances); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.residentCompanies.ifSet(result::setResidentCompanies); + this.seatingCapacity.ifSet(result::setSeatingCapacity); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualPerformances", this.annualPerformances) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("residentCompanies", this.residentCompanies) + .append("seatingCapacity", this.seatingCapacity) + .append("status", this.status) + .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 PerformingArtsCenter with(Consumer b) { + PerformingArtsCenterBuilder builder; + try { + builder = new PerformingArtsCenterBuilder(PerformingArtsCenter.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PerformingArtsCenterBuilder.With' should only be implemented by classes, which could be casted to 'PerformingArtsCenter'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PerformingArtsCenterBuilder with() { + try { + return new PerformingArtsCenterBuilder(PerformingArtsCenter.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PerformingArtsCenterBuilder.With' should only be implemented by classes, which could be casted to 'PerformingArtsCenter'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PermitRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PermitRecordBuilder.java new file mode 100644 index 00000000..cb700a6e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PermitRecordBuilder.java @@ -0,0 +1,557 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.PermitRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PermitRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PermitRecord result = PermitRecordBuilder.create()
    + *     .permitName("example value")
    + *     .permitName("Hello %s", "World")
    + *     .permitName(() -> "example value")
    + *     .permitName(sb -> sb.append("text"))
    + *     .permitType("example value")
    + *     .permitType("Hello %s", "World")
    + *     .permitType(() -> "example value")
    + *     .permitType(sb -> sb.append("text"))
    + *     .issuer("example value")
    + *     .issuer("Hello %s", "World")
    + *     .issuer(() -> "example value")
    + *     .issuer(sb -> sb.append("text"))
    + *     .issueDate(LocalDate.now())
    + *     .issueDate(() -> LocalDate.now())
    + *     .expiryDate(LocalDate.now())
    + *     .expiryDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PermitRecord.class) +public class PermitRecordBuilder implements IBuilderBase { + + /** + * Tracked value for permitName: permitName. + */ + private TrackedValue permitName = unsetValue(); + /** + * Tracked value for permitType: permitType. + */ + private TrackedValue permitType = unsetValue(); + /** + * Tracked value for issuer: issuer. + */ + private TrackedValue issuer = unsetValue(); + /** + * Tracked value for issueDate: issueDate. + */ + private TrackedValue issueDate = unsetValue(); + /** + * Tracked value for expiryDate: expiryDate. + */ + private TrackedValue expiryDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PermitRecord}. + */ + public PermitRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PermitRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PermitRecordBuilder(PermitRecord instance) { + this.permitName = initialValue(instance.permitName()); + this.permitType = initialValue(instance.permitType()); + this.issuer = initialValue(instance.issuer()); + this.issueDate = initialValue(instance.issueDate()); + this.expiryDate = initialValue(instance.expiryDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PermitRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PermitRecordBuilder builder = PermitRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.PermitRecord} + */ + public static PermitRecordBuilder create() { + return new PermitRecordBuilder(); + } + + /** + * Sets the value for expiryDate. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expiryDate(LocalDate.now());
    +   * }
    + * + * @param expiryDate expiryDate + * @return current instance of builder + */ + public PermitRecordBuilder expiryDate(LocalDate expiryDate) { + this.expiryDate = changedValue(expiryDate); + return this; + } + + /** + * Sets the value for expiryDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expiryDate(() -> LocalDate.now());
    +   * }
    + * + * @param expiryDateSupplier supplier for expiryDate + * @return current instance of builder + */ + public PermitRecordBuilder expiryDate(Supplier expiryDateSupplier) { + this.expiryDate = changedValue(expiryDateSupplier.get()); + return this; + } + + /** + * Sets the value for issueDate. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issueDate(LocalDate.now());
    +   * }
    + * + * @param issueDate issueDate + * @return current instance of builder + */ + public PermitRecordBuilder issueDate(LocalDate issueDate) { + this.issueDate = changedValue(issueDate); + return this; + } + + /** + * Sets the value for issueDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issueDate(() -> LocalDate.now());
    +   * }
    + * + * @param issueDateSupplier supplier for issueDate + * @return current instance of builder + */ + public PermitRecordBuilder issueDate(Supplier issueDateSupplier) { + this.issueDate = changedValue(issueDateSupplier.get()); + return this; + } + + /** + * Sets the value for issuer. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issuer("example value");
    +   * }
    + * + * @param issuer issuer + * @return current instance of builder + */ + public PermitRecordBuilder issuer(String issuer) { + this.issuer = changedValue(issuer); + return this; + } + + /** + * Sets the value for issuer by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issuer(sb -> sb.append("text"));
    +   * }
    + * + * @param issuerStringBuilderConsumer consumer providing an instance of issuer + * @return current instance of builder + */ + public PermitRecordBuilder issuer(Consumer issuerStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + issuerStringBuilderConsumer.accept(builder); + this.issuer = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for issuer by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issuer(() -> "example value");
    +   * }
    + * + * @param issuerSupplier supplier for issuer + * @return current instance of builder + */ + public PermitRecordBuilder issuer(Supplier issuerSupplier) { + this.issuer = changedValue(issuerSupplier.get()); + return this; + } + + /** + * Sets the String value for issuer by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.issuer("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PermitRecordBuilder issuer(String format, Object... args) { + this.issuer = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for permitName. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitName("example value");
    +   * }
    + * + * @param permitName permitName + * @return current instance of builder + */ + public PermitRecordBuilder permitName(String permitName) { + this.permitName = changedValue(permitName); + return this; + } + + /** + * Sets the value for permitName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitName(sb -> sb.append("text"));
    +   * }
    + * + * @param permitNameStringBuilderConsumer consumer providing an instance of permitName + * @return current instance of builder + */ + public PermitRecordBuilder permitName(Consumer permitNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + permitNameStringBuilderConsumer.accept(builder); + this.permitName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for permitName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitName(() -> "example value");
    +   * }
    + * + * @param permitNameSupplier supplier for permitName + * @return current instance of builder + */ + public PermitRecordBuilder permitName(Supplier permitNameSupplier) { + this.permitName = changedValue(permitNameSupplier.get()); + return this; + } + + /** + * Sets the String value for permitName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PermitRecordBuilder permitName(String format, Object... args) { + this.permitName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for permitType. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitType("example value");
    +   * }
    + * + * @param permitType permitType + * @return current instance of builder + */ + public PermitRecordBuilder permitType(String permitType) { + this.permitType = changedValue(permitType); + return this; + } + + /** + * Sets the value for permitType by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitType(sb -> sb.append("text"));
    +   * }
    + * + * @param permitTypeStringBuilderConsumer consumer providing an instance of permitType + * @return current instance of builder + */ + public PermitRecordBuilder permitType(Consumer permitTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + permitTypeStringBuilderConsumer.accept(builder); + this.permitType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for permitType by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitType(() -> "example value");
    +   * }
    + * + * @param permitTypeSupplier supplier for permitType + * @return current instance of builder + */ + public PermitRecordBuilder permitType(Supplier permitTypeSupplier) { + this.permitType = changedValue(permitTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for permitType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PermitRecord#PermitRecord(String, String, String, LocalDate, LocalDate) PermitRecord(String permitName, + * String permitType, String issuer, LocalDate issueDate, LocalDate expiryDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.permitType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PermitRecordBuilder permitType(String format, Object... args) { + this.permitType = changedValue(String.format(format, args)); + 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 PermitRecordBuilder 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 PermitRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PermitRecord result = builder.build();
    +   * }
    + */ + @Override + public PermitRecord build() { + PermitRecord result = new PermitRecord(this.permitName + .value(), this.permitType.value(), this.issuer.value(), this.issueDate.value(), this.expiryDate.value()); + 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("permitName", this.permitName) + .append("permitType", this.permitType) + .append("issuer", this.issuer) + .append("issueDate", this.issueDate) + .append("expiryDate", this.expiryDate) + .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 PermitRecord with(Consumer b) { + PermitRecordBuilder builder; + try { + builder = new PermitRecordBuilder(PermitRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PermitRecordBuilder.With' should only be implemented by classes, which could be casted to 'PermitRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PermitRecordBuilder with() { + try { + return new PermitRecordBuilder(PermitRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PermitRecordBuilder.With' should only be implemented by classes, which could be casted to 'PermitRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PhotographyArchiveBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PhotographyArchiveBuilder.java new file mode 100644 index 00000000..f89a2da6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PhotographyArchiveBuilder.java @@ -0,0 +1,753 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.PhotographyArchive}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PhotographyArchive 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. + * + *

    Example:

    + * + *
    {@code
    + * PhotographyArchive result = PhotographyArchiveBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .dateRange("example value")
    + *     .dateRange("Hello %s", "World")
    + *     .dateRange(() -> "example value")
    + *     .dateRange(sb -> sb.append("text"))
    + *     .formats(List.of("example value"))
    + *     .formats(() -> List.of("example value"))
    + *     .formats(t -> t.add("example value"))
    + *     .formats("example value", "example value")
    + *     .add2Formats("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .photoCount(42L)
    + *     .photoCount(() -> 42L)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PhotographyArchive.class) +public class PhotographyArchiveBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for dateRange: dateRange. + */ + private TrackedValue dateRange = unsetValue(); + /** + * Tracked value for formats: formats. + */ + private TrackedValue> formats = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for photoCount: photoCount. + */ + private TrackedValue photoCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PhotographyArchive}. + */ + public PhotographyArchiveBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PhotographyArchive} by a instance. + * + * @param instance object instance for initialisiation + */ + public PhotographyArchiveBuilder(PhotographyArchive instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.dateRange = initialValue(instance.getDateRange()); + this.formats = initialValue(instance.getFormats()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.photoCount = initialValue(instance.getPhotoCount()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PhotographyArchive}. + * + *

    Example:

    + * + *
    {@code
    +   * PhotographyArchiveBuilder builder = PhotographyArchiveBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PhotographyArchive} + */ + public static PhotographyArchiveBuilder create() { + return new PhotographyArchiveBuilder(); + } + + /** + * Adds a single element to formats. + *

    + * Generated from setter {@link PhotographyArchive#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Formats("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PhotographyArchiveBuilder add2Formats(String element) { + List newCollection; + if (this.formats.isSet()) { + newCollection = new ArrayList<>(this.formats.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.formats = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PhotographyArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PhotographyArchiveBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PhotographyArchiveBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for dateRange. + *

    + * Generated from setter {@link PhotographyArchive#setDateRange(String) setDateRange(String dateRange)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dateRange("example value");
    +   * }
    + * + * @param dateRange dateRange + * @return current instance of builder + */ + public PhotographyArchiveBuilder dateRange(String dateRange) { + this.dateRange = changedValue(dateRange); + return this; + } + + /** + * Sets the value for dateRange by executing the provided consumer. + *

    + * Generated from setter {@link PhotographyArchive#setDateRange(String) setDateRange(String dateRange)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dateRange(sb -> sb.append("text"));
    +   * }
    + * + * @param dateRangeStringBuilderConsumer consumer providing an instance of dateRange + * @return current instance of builder + */ + public PhotographyArchiveBuilder dateRange(Consumer dateRangeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + dateRangeStringBuilderConsumer.accept(builder); + this.dateRange = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for dateRange by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setDateRange(String) setDateRange(String dateRange)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dateRange(() -> "example value");
    +   * }
    + * + * @param dateRangeSupplier supplier for dateRange + * @return current instance of builder + */ + public PhotographyArchiveBuilder dateRange(Supplier dateRangeSupplier) { + this.dateRange = changedValue(dateRangeSupplier.get()); + return this; + } + + /** + * Sets the String value for dateRange by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PhotographyArchive#setDateRange(String) setDateRange(String dateRange)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.dateRange("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PhotographyArchiveBuilder dateRange(String format, Object... args) { + this.dateRange = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for formats. + *

    + * Generated from setter {@link PhotographyArchive#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats("example value", "example value");
    +   * }
    + * + * @param formats formats + * @return current instance of builder + */ + public PhotographyArchiveBuilder formats(String... formats) { + this.formats = changedValue(List.of(formats)); + return this; + } + + /** + * Sets the value for formats. + *

    + * Generated from setter {@link PhotographyArchive#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats(List.of("example value"));
    +   * }
    + * + * @param formats formats + * @return current instance of builder + */ + public PhotographyArchiveBuilder formats(List formats) { + this.formats = changedValue(formats); + return this; + } + + /** + * Sets the value for formats using a builder consumer that produces the value. + *

    + * Generated from setter {@link PhotographyArchive#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats(t -> t.add("example value"));
    +   * }
    + * + * @param formatsBuilderConsumer consumer providing an instance of a builder for formats + * @return current instance of builder + */ + public PhotographyArchiveBuilder formats(Consumer> formatsBuilderConsumer) { + ArrayListBuilder builder = this.formats.isSet() + ? new ArrayListBuilder(this.formats.value()) + : new ArrayListBuilder(); + formatsBuilderConsumer.accept(builder); + this.formats = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for formats by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setFormats(List) setFormats(List formats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.formats(() -> List.of("example value"));
    +   * }
    + * + * @param formatsSupplier supplier for formats + * @return current instance of builder + */ + public PhotographyArchiveBuilder formats(Supplier> formatsSupplier) { + this.formats = changedValue(formatsSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PhotographyArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PhotographyArchiveBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PhotographyArchiveBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PhotographyArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PhotographyArchiveBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PhotographyArchiveBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PhotographyArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PhotographyArchiveBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PhotographyArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PhotographyArchiveBuilder 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. + *

    + * Generated from setter {@link PhotographyArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PhotographyArchiveBuilder 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. + *

    + * Generated from setter {@link PhotographyArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PhotographyArchiveBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for photoCount. + *

    + * Generated from setter {@link PhotographyArchive#setPhotoCount(long) setPhotoCount(long photoCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photoCount(42L);
    +   * }
    + * + * @param photoCount photoCount + * @return current instance of builder + */ + public PhotographyArchiveBuilder photoCount(long photoCount) { + this.photoCount = changedValue(photoCount); + return this; + } + + /** + * Sets the value for photoCount by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setPhotoCount(long) setPhotoCount(long photoCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.photoCount(() -> 42L);
    +   * }
    + * + * @param photoCountSupplier supplier for photoCount + * @return current instance of builder + */ + public PhotographyArchiveBuilder photoCount(Supplier photoCountSupplier) { + this.photoCount = changedValue(photoCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PhotographyArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PhotographyArchiveBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PhotographyArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PhotographyArchiveBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PhotographyArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PhotographyArchiveBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PhotographyArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PhotographyArchiveBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PhotographyArchiveBuilder 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 PhotographyArchiveBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PhotographyArchive result = builder.build();
    +   * }
    + */ + @Override + public PhotographyArchive build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.photoCount.isSet() && this.photoCount.value() == null) { + throw new IllegalStateException("Field 'photoCount' is marked as non-null but null value was provided"); + } + PhotographyArchive result = new PhotographyArchive(); + this.createdAt.ifSet(result::setCreatedAt); + this.dateRange.ifSet(result::setDateRange); + this.formats.ifSet(result::setFormats); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.photoCount.ifSet(result::setPhotoCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("dateRange", this.dateRange) + .append("formats", this.formats) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("photoCount", this.photoCount) + .append("status", this.status) + .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 PhotographyArchive with(Consumer b) { + PhotographyArchiveBuilder builder; + try { + builder = new PhotographyArchiveBuilder(PhotographyArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PhotographyArchiveBuilder.With' should only be implemented by classes, which could be casted to 'PhotographyArchive'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PhotographyArchiveBuilder with() { + try { + return new PhotographyArchiveBuilder(PhotographyArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PhotographyArchiveBuilder.With' should only be implemented by classes, which could be casted to 'PhotographyArchive'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PlanetariumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PlanetariumBuilder.java new file mode 100644 index 00000000..c9325d55 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PlanetariumBuilder.java @@ -0,0 +1,639 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.Planetarium}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.Planetarium 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. + * + *

    Example:

    + * + *
    {@code
    + * Planetarium result = PlanetariumBuilder.create()
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .seatingCapacity(42)
    + *     .seatingCapacity(() -> 42)
    + *     .showsPerWeek(42)
    + *     .showsPerWeek(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Planetarium.class) +public class PlanetariumBuilder implements IBuilderBase { + + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for seatingCapacity: seatingCapacity. + */ + private TrackedValue seatingCapacity = unsetValue(); + /** + * Tracked value for showsPerWeek: showsPerWeek. + */ + private TrackedValue showsPerWeek = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Planetarium}. + */ + public PlanetariumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Planetarium} by a instance. + * + * @param instance object instance for initialisiation + */ + public PlanetariumBuilder(Planetarium instance) { + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.seatingCapacity = initialValue(instance.getSeatingCapacity()); + this.showsPerWeek = initialValue(instance.getShowsPerWeek()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Planetarium}. + * + *

    Example:

    + * + *
    {@code
    +   * PlanetariumBuilder builder = PlanetariumBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.Planetarium} + */ + public static PlanetariumBuilder create() { + return new PlanetariumBuilder(); + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link Planetarium#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public PlanetariumBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public PlanetariumBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Planetarium#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PlanetariumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PlanetariumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link Planetarium#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PlanetariumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PlanetariumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Planetarium#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PlanetariumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PlanetariumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Planetarium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PlanetariumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Planetarium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PlanetariumBuilder 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. + *

    + * Generated from setter {@link Planetarium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PlanetariumBuilder 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. + *

    + * Generated from setter {@link Planetarium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlanetariumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for seatingCapacity. + *

    + * Generated from setter {@link Planetarium#setSeatingCapacity(int) setSeatingCapacity(int seatingCapacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seatingCapacity(42);
    +   * }
    + * + * @param seatingCapacity seatingCapacity + * @return current instance of builder + */ + public PlanetariumBuilder seatingCapacity(int seatingCapacity) { + this.seatingCapacity = changedValue(seatingCapacity); + return this; + } + + /** + * Sets the value for seatingCapacity by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setSeatingCapacity(int) setSeatingCapacity(int seatingCapacity)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.seatingCapacity(() -> 42);
    +   * }
    + * + * @param seatingCapacitySupplier supplier for seatingCapacity + * @return current instance of builder + */ + public PlanetariumBuilder seatingCapacity(Supplier seatingCapacitySupplier) { + this.seatingCapacity = changedValue(seatingCapacitySupplier.get()); + return this; + } + + /** + * Sets the value for showsPerWeek. + *

    + * Generated from setter {@link Planetarium#setShowsPerWeek(int) setShowsPerWeek(int showsPerWeek)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showsPerWeek(42);
    +   * }
    + * + * @param showsPerWeek showsPerWeek + * @return current instance of builder + */ + public PlanetariumBuilder showsPerWeek(int showsPerWeek) { + this.showsPerWeek = changedValue(showsPerWeek); + return this; + } + + /** + * Sets the value for showsPerWeek by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setShowsPerWeek(int) setShowsPerWeek(int showsPerWeek)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.showsPerWeek(() -> 42);
    +   * }
    + * + * @param showsPerWeekSupplier supplier for showsPerWeek + * @return current instance of builder + */ + public PlanetariumBuilder showsPerWeek(Supplier showsPerWeekSupplier) { + this.showsPerWeek = changedValue(showsPerWeekSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Planetarium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PlanetariumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Planetarium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PlanetariumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Planetarium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PlanetariumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Planetarium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlanetariumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PlanetariumBuilder 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 PlanetariumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Planetarium result = builder.build();
    +   * }
    + */ + @Override + public Planetarium build() { + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.seatingCapacity.isSet() && this.seatingCapacity.value() == null) { + throw new IllegalStateException("Field 'seatingCapacity' is marked as non-null but null value was provided"); + } + if (this.showsPerWeek.isSet() && this.showsPerWeek.value() == null) { + throw new IllegalStateException("Field 'showsPerWeek' is marked as non-null but null value was provided"); + } + Planetarium result = new Planetarium(); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.seatingCapacity.ifSet(result::setSeatingCapacity); + this.showsPerWeek.ifSet(result::setShowsPerWeek); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualVisitors", this.annualVisitors) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("seatingCapacity", this.seatingCapacity) + .append("showsPerWeek", this.showsPerWeek) + .append("status", this.status) + .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 Planetarium with(Consumer b) { + PlanetariumBuilder builder; + try { + builder = new PlanetariumBuilder(Planetarium.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlanetariumBuilder.With' should only be implemented by classes, which could be casted to 'Planetarium'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PlanetariumBuilder with() { + try { + return new PlanetariumBuilder(Planetarium.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlanetariumBuilder.With' should only be implemented by classes, which could be casted to 'Planetarium'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PoetryPressBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PoetryPressBuilder.java new file mode 100644 index 00000000..e16aad3f --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PoetryPressBuilder.java @@ -0,0 +1,710 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +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.builders.HashSetBuilder; +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.performance_test.library.organizations.PoetryPress}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PoetryPress 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. + * + *

    Example:

    + * + *
    {@code
    + * PoetryPress result = PoetryPressBuilder.create()
    + *     .annualCollections(42)
    + *     .annualCollections(() -> 42)
    + *     .awardsWon(Set.of("example value"))
    + *     .awardsWon(() -> Set.of("example value"))
    + *     .awardsWon(t -> t.add("example value"))
    + *     .awardsWon("example value", "example value")
    + *     .add2AwardsWon("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .poetsPublished(42)
    + *     .poetsPublished(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PoetryPress.class) +public class PoetryPressBuilder implements IBuilderBase { + + /** + * Tracked value for annualCollections: annualCollections. + */ + private TrackedValue annualCollections = unsetValue(); + /** + * Tracked value for awardsWon: awardsWon. + */ + private TrackedValue> awardsWon = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for poetsPublished: poetsPublished. + */ + private TrackedValue poetsPublished = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PoetryPress}. + */ + public PoetryPressBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PoetryPress} by a instance. + * + * @param instance object instance for initialisiation + */ + public PoetryPressBuilder(PoetryPress instance) { + this.annualCollections = initialValue(instance.getAnnualCollections()); + this.awardsWon = initialValue(instance.getAwardsWon()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.poetsPublished = initialValue(instance.getPoetsPublished()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PoetryPress}. + * + *

    Example:

    + * + *
    {@code
    +   * PoetryPressBuilder builder = PoetryPressBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.PoetryPress} + */ + public static PoetryPressBuilder create() { + return new PoetryPressBuilder(); + } + + /** + * Adds a single element to awardsWon. + *

    + * Generated from setter {@link PoetryPress#setAwardsWon(Set) setAwardsWon(Set awardsWon)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2AwardsWon("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PoetryPressBuilder add2AwardsWon(String element) { + Set newCollection; + if (this.awardsWon.isSet()) { + newCollection = new HashSet<>(this.awardsWon.value()); + } else { + newCollection = new HashSet<>(); + } + newCollection.add(element); + this.awardsWon = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualCollections. + *

    + * Generated from setter {@link PoetryPress#setAnnualCollections(int) setAnnualCollections(int annualCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualCollections(42);
    +   * }
    + * + * @param annualCollections annualCollections + * @return current instance of builder + */ + public PoetryPressBuilder annualCollections(int annualCollections) { + this.annualCollections = changedValue(annualCollections); + return this; + } + + /** + * Sets the value for annualCollections by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setAnnualCollections(int) setAnnualCollections(int annualCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualCollections(() -> 42);
    +   * }
    + * + * @param annualCollectionsSupplier supplier for annualCollections + * @return current instance of builder + */ + public PoetryPressBuilder annualCollections(Supplier annualCollectionsSupplier) { + this.annualCollections = changedValue(annualCollectionsSupplier.get()); + return this; + } + + /** + * Sets the value for awardsWon. + *

    + * Generated from setter {@link PoetryPress#setAwardsWon(Set) setAwardsWon(Set awardsWon)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.awardsWon("example value", "example value");
    +   * }
    + * + * @param awardsWon awardsWon + * @return current instance of builder + */ + public PoetryPressBuilder awardsWon(String... awardsWon) { + this.awardsWon = changedValue(Set.of(awardsWon)); + return this; + } + + /** + * Sets the value for awardsWon. + *

    + * Generated from setter {@link PoetryPress#setAwardsWon(Set) setAwardsWon(Set awardsWon)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.awardsWon(Set.of("example value"));
    +   * }
    + * + * @param awardsWon awardsWon + * @return current instance of builder + */ + public PoetryPressBuilder awardsWon(Set awardsWon) { + this.awardsWon = changedValue(awardsWon); + return this; + } + + /** + * Sets the value for awardsWon using a builder consumer that produces the value. + *

    + * Generated from setter {@link PoetryPress#setAwardsWon(Set) setAwardsWon(Set awardsWon)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.awardsWon(t -> t.add("example value"));
    +   * }
    + * + * @param awardsWonBuilderConsumer consumer providing an instance of a builder for awardsWon + * @return current instance of builder + */ + public PoetryPressBuilder awardsWon(Consumer> awardsWonBuilderConsumer) { + HashSetBuilder builder = this.awardsWon.isSet() + ? new HashSetBuilder(this.awardsWon.value()) + : new HashSetBuilder(); + awardsWonBuilderConsumer.accept(builder); + this.awardsWon = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for awardsWon by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setAwardsWon(Set) setAwardsWon(Set awardsWon)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.awardsWon(() -> Set.of("example value"));
    +   * }
    + * + * @param awardsWonSupplier supplier for awardsWon + * @return current instance of builder + */ + public PoetryPressBuilder awardsWon(Supplier> awardsWonSupplier) { + this.awardsWon = changedValue(awardsWonSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PoetryPress#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PoetryPressBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PoetryPressBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PoetryPress#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PoetryPressBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PoetryPressBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PoetryPress#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PoetryPressBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PoetryPressBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PoetryPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PoetryPressBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PoetryPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PoetryPressBuilder 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. + *

    + * Generated from setter {@link PoetryPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PoetryPressBuilder 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. + *

    + * Generated from setter {@link PoetryPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PoetryPressBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for poetsPublished. + *

    + * Generated from setter {@link PoetryPress#setPoetsPublished(int) setPoetsPublished(int poetsPublished)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poetsPublished(42);
    +   * }
    + * + * @param poetsPublished poetsPublished + * @return current instance of builder + */ + public PoetryPressBuilder poetsPublished(int poetsPublished) { + this.poetsPublished = changedValue(poetsPublished); + return this; + } + + /** + * Sets the value for poetsPublished by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setPoetsPublished(int) setPoetsPublished(int poetsPublished)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.poetsPublished(() -> 42);
    +   * }
    + * + * @param poetsPublishedSupplier supplier for poetsPublished + * @return current instance of builder + */ + public PoetryPressBuilder poetsPublished(Supplier poetsPublishedSupplier) { + this.poetsPublished = changedValue(poetsPublishedSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PoetryPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PoetryPressBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PoetryPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PoetryPressBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PoetryPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PoetryPressBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PoetryPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PoetryPressBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PoetryPressBuilder 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 PoetryPressBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PoetryPress result = builder.build();
    +   * }
    + */ + @Override + public PoetryPress build() { + if (this.annualCollections.isSet() && this.annualCollections.value() == null) { + throw new IllegalStateException("Field 'annualCollections' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.poetsPublished.isSet() && this.poetsPublished.value() == null) { + throw new IllegalStateException("Field 'poetsPublished' is marked as non-null but null value was provided"); + } + PoetryPress result = new PoetryPress(); + this.annualCollections.ifSet(result::setAnnualCollections); + this.awardsWon.ifSet(result::setAwardsWon); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.poetsPublished.ifSet(result::setPoetsPublished); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualCollections", this.annualCollections) + .append("awardsWon", this.awardsWon) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("poetsPublished", this.poetsPublished) + .append("status", this.status) + .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 PoetryPress with(Consumer b) { + PoetryPressBuilder builder; + try { + builder = new PoetryPressBuilder(PoetryPress.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PoetryPressBuilder.With' should only be implemented by classes, which could be casted to 'PoetryPress'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PoetryPressBuilder with() { + try { + return new PoetryPressBuilder(PoetryPress.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PoetryPressBuilder.With' should only be implemented by classes, which could be casted to 'PoetryPress'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationNetworkBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationNetworkBuilder.java new file mode 100644 index 00000000..7a38fcf6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationNetworkBuilder.java @@ -0,0 +1,647 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.PreservationNetwork}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PreservationNetwork 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. + * + *

    Example:

    + * + *
    {@code
    + * PreservationNetwork result = PreservationNetworkBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberInstitutions(42)
    + *     .memberInstitutions(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .preservationProjects(42)
    + *     .preservationProjects(() -> 42)
    + *     .sharedFacilities(42)
    + *     .sharedFacilities(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PreservationNetwork.class) +public class PreservationNetworkBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberInstitutions: memberInstitutions. + */ + private TrackedValue memberInstitutions = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for preservationProjects: preservationProjects. + */ + private TrackedValue preservationProjects = unsetValue(); + /** + * Tracked value for sharedFacilities: sharedFacilities. + */ + private TrackedValue sharedFacilities = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationNetwork}. + */ + public PreservationNetworkBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationNetwork} by a instance. + * + * @param instance object instance for initialisiation + */ + public PreservationNetworkBuilder(PreservationNetwork instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberInstitutions = initialValue(instance.getMemberInstitutions()); + this.name = initialValue(instance.getName()); + this.preservationProjects = initialValue(instance.getPreservationProjects()); + this.sharedFacilities = initialValue(instance.getSharedFacilities()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationNetwork}. + * + *

    Example:

    + * + *
    {@code
    +   * PreservationNetworkBuilder builder = PreservationNetworkBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationNetwork} + */ + public static PreservationNetworkBuilder create() { + return new PreservationNetworkBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PreservationNetwork#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PreservationNetworkBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PreservationNetworkBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PreservationNetwork#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PreservationNetworkBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PreservationNetworkBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PreservationNetwork#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PreservationNetworkBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PreservationNetworkBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberInstitutions. + *

    + * Generated from setter {@link PreservationNetwork#setMemberInstitutions(int) setMemberInstitutions(int + * memberInstitutions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberInstitutions(42);
    +   * }
    + * + * @param memberInstitutions memberInstitutions + * @return current instance of builder + */ + public PreservationNetworkBuilder memberInstitutions(int memberInstitutions) { + this.memberInstitutions = changedValue(memberInstitutions); + return this; + } + + /** + * Sets the value for memberInstitutions by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setMemberInstitutions(int) setMemberInstitutions(int + * memberInstitutions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberInstitutions(() -> 42);
    +   * }
    + * + * @param memberInstitutionsSupplier supplier for memberInstitutions + * @return current instance of builder + */ + public PreservationNetworkBuilder memberInstitutions(Supplier memberInstitutionsSupplier) { + this.memberInstitutions = changedValue(memberInstitutionsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PreservationNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PreservationNetworkBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PreservationNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PreservationNetworkBuilder 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. + *

    + * Generated from setter {@link PreservationNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PreservationNetworkBuilder 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. + *

    + * Generated from setter {@link PreservationNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PreservationNetworkBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for preservationProjects. + *

    + * Generated from setter {@link PreservationNetwork#setPreservationProjects(int) setPreservationProjects(int + * preservationProjects)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.preservationProjects(42);
    +   * }
    + * + * @param preservationProjects preservationProjects + * @return current instance of builder + */ + public PreservationNetworkBuilder preservationProjects(int preservationProjects) { + this.preservationProjects = changedValue(preservationProjects); + return this; + } + + /** + * Sets the value for preservationProjects by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setPreservationProjects(int) setPreservationProjects(int + * preservationProjects)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.preservationProjects(() -> 42);
    +   * }
    + * + * @param preservationProjectsSupplier supplier for preservationProjects + * @return current instance of builder + */ + public PreservationNetworkBuilder preservationProjects(Supplier preservationProjectsSupplier) { + this.preservationProjects = changedValue(preservationProjectsSupplier.get()); + return this; + } + + /** + * Sets the value for sharedFacilities. + *

    + * Generated from setter {@link PreservationNetwork#setSharedFacilities(int) setSharedFacilities(int + * sharedFacilities)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sharedFacilities(42);
    +   * }
    + * + * @param sharedFacilities sharedFacilities + * @return current instance of builder + */ + public PreservationNetworkBuilder sharedFacilities(int sharedFacilities) { + this.sharedFacilities = changedValue(sharedFacilities); + return this; + } + + /** + * Sets the value for sharedFacilities by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setSharedFacilities(int) setSharedFacilities(int + * sharedFacilities)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sharedFacilities(() -> 42);
    +   * }
    + * + * @param sharedFacilitiesSupplier supplier for sharedFacilities + * @return current instance of builder + */ + public PreservationNetworkBuilder sharedFacilities(Supplier sharedFacilitiesSupplier) { + this.sharedFacilities = changedValue(sharedFacilitiesSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PreservationNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PreservationNetworkBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PreservationNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PreservationNetworkBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PreservationNetworkBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PreservationNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PreservationNetworkBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PreservationNetworkBuilder 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 PreservationNetworkBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PreservationNetwork result = builder.build();
    +   * }
    + */ + @Override + public PreservationNetwork build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberInstitutions.isSet() && this.memberInstitutions.value() == null) { + throw new IllegalStateException("Field 'memberInstitutions' is marked as non-null but null value was provided"); + } + if (this.preservationProjects.isSet() && this.preservationProjects.value() == null) { + throw new IllegalStateException("Field 'preservationProjects' is marked as non-null but null value was provided"); + } + if (this.sharedFacilities.isSet() && this.sharedFacilities.value() == null) { + throw new IllegalStateException("Field 'sharedFacilities' is marked as non-null but null value was provided"); + } + PreservationNetwork result = new PreservationNetwork(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberInstitutions.ifSet(result::setMemberInstitutions); + this.name.ifSet(result::setName); + this.preservationProjects.ifSet(result::setPreservationProjects); + this.sharedFacilities.ifSet(result::setSharedFacilities); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberInstitutions", this.memberInstitutions) + .append("name", this.name) + .append("preservationProjects", this.preservationProjects) + .append("sharedFacilities", this.sharedFacilities) + .append("status", this.status) + .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 PreservationNetwork with(Consumer b) { + PreservationNetworkBuilder builder; + try { + builder = new PreservationNetworkBuilder(PreservationNetwork.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PreservationNetworkBuilder.With' should only be implemented by classes, which could be casted to 'PreservationNetwork'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PreservationNetworkBuilder with() { + try { + return new PreservationNetworkBuilder(PreservationNetwork.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PreservationNetworkBuilder.With' should only be implemented by classes, which could be casted to 'PreservationNetwork'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationOfficeBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationOfficeBuilder.java new file mode 100644 index 00000000..94bf5790 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PreservationOfficeBuilder.java @@ -0,0 +1,755 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.PreservationOffice}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PreservationOffice 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. + * + *

    Example:

    + * + *
    {@code
    + * PreservationOffice result = PreservationOfficeBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .guidelines(List.of("example value"))
    + *     .guidelines(() -> List.of("example value"))
    + *     .guidelines(t -> t.add("example value"))
    + *     .guidelines("example value", "example value")
    + *     .add2Guidelines("example value")
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .jurisdiction("example value")
    + *     .jurisdiction("Hello %s", "World")
    + *     .jurisdiction(() -> "example value")
    + *     .jurisdiction(sb -> sb.append("text"))
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .preservationProjects(42)
    + *     .preservationProjects(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PreservationOffice.class) +public class PreservationOfficeBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for guidelines: guidelines. + */ + private TrackedValue> guidelines = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for jurisdiction: jurisdiction. + */ + private TrackedValue jurisdiction = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for preservationProjects: preservationProjects. + */ + private TrackedValue preservationProjects = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationOffice}. + */ + public PreservationOfficeBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationOffice} by a instance. + * + * @param instance object instance for initialisiation + */ + public PreservationOfficeBuilder(PreservationOffice instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.guidelines = initialValue(instance.getGuidelines()); + this.id = initialValue(instance.getId()); + this.jurisdiction = initialValue(instance.getJurisdiction()); + this.name = initialValue(instance.getName()); + this.preservationProjects = initialValue(instance.getPreservationProjects()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationOffice}. + * + *

    Example:

    + * + *
    {@code
    +   * PreservationOfficeBuilder builder = PreservationOfficeBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PreservationOffice} + */ + public static PreservationOfficeBuilder create() { + return new PreservationOfficeBuilder(); + } + + /** + * Adds a single element to guidelines. + *

    + * Generated from setter {@link PreservationOffice#setGuidelines(List) setGuidelines(List guidelines)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Guidelines("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PreservationOfficeBuilder add2Guidelines(String element) { + List newCollection; + if (this.guidelines.isSet()) { + newCollection = new ArrayList<>(this.guidelines.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.guidelines = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PreservationOffice#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PreservationOfficeBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PreservationOfficeBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PreservationOffice#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PreservationOfficeBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PreservationOfficeBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for guidelines. + *

    + * Generated from setter {@link PreservationOffice#setGuidelines(List) setGuidelines(List guidelines)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.guidelines("example value", "example value");
    +   * }
    + * + * @param guidelines guidelines + * @return current instance of builder + */ + public PreservationOfficeBuilder guidelines(String... guidelines) { + this.guidelines = changedValue(List.of(guidelines)); + return this; + } + + /** + * Sets the value for guidelines. + *

    + * Generated from setter {@link PreservationOffice#setGuidelines(List) setGuidelines(List guidelines)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.guidelines(List.of("example value"));
    +   * }
    + * + * @param guidelines guidelines + * @return current instance of builder + */ + public PreservationOfficeBuilder guidelines(List guidelines) { + this.guidelines = changedValue(guidelines); + return this; + } + + /** + * Sets the value for guidelines using a builder consumer that produces the value. + *

    + * Generated from setter {@link PreservationOffice#setGuidelines(List) setGuidelines(List guidelines)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.guidelines(t -> t.add("example value"));
    +   * }
    + * + * @param guidelinesBuilderConsumer consumer providing an instance of a builder for guidelines + * @return current instance of builder + */ + public PreservationOfficeBuilder guidelines(Consumer> guidelinesBuilderConsumer) { + ArrayListBuilder builder = this.guidelines.isSet() + ? new ArrayListBuilder(this.guidelines.value()) + : new ArrayListBuilder(); + guidelinesBuilderConsumer.accept(builder); + this.guidelines = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for guidelines by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setGuidelines(List) setGuidelines(List guidelines)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.guidelines(() -> List.of("example value"));
    +   * }
    + * + * @param guidelinesSupplier supplier for guidelines + * @return current instance of builder + */ + public PreservationOfficeBuilder guidelines(Supplier> guidelinesSupplier) { + this.guidelines = changedValue(guidelinesSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PreservationOffice#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PreservationOfficeBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PreservationOfficeBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for jurisdiction. + *

    + * Generated from setter {@link PreservationOffice#setJurisdiction(String) setJurisdiction(String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction("example value");
    +   * }
    + * + * @param jurisdiction jurisdiction + * @return current instance of builder + */ + public PreservationOfficeBuilder jurisdiction(String jurisdiction) { + this.jurisdiction = changedValue(jurisdiction); + return this; + } + + /** + * Sets the value for jurisdiction by executing the provided consumer. + *

    + * Generated from setter {@link PreservationOffice#setJurisdiction(String) setJurisdiction(String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction(sb -> sb.append("text"));
    +   * }
    + * + * @param jurisdictionStringBuilderConsumer consumer providing an instance of jurisdiction + * @return current instance of builder + */ + public PreservationOfficeBuilder jurisdiction(Consumer jurisdictionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + jurisdictionStringBuilderConsumer.accept(builder); + this.jurisdiction = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for jurisdiction by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setJurisdiction(String) setJurisdiction(String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction(() -> "example value");
    +   * }
    + * + * @param jurisdictionSupplier supplier for jurisdiction + * @return current instance of builder + */ + public PreservationOfficeBuilder jurisdiction(Supplier jurisdictionSupplier) { + this.jurisdiction = changedValue(jurisdictionSupplier.get()); + return this; + } + + /** + * Sets the String value for jurisdiction by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PreservationOffice#setJurisdiction(String) setJurisdiction(String jurisdiction)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jurisdiction("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PreservationOfficeBuilder jurisdiction(String format, Object... args) { + this.jurisdiction = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PreservationOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PreservationOfficeBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PreservationOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PreservationOfficeBuilder 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. + *

    + * Generated from setter {@link PreservationOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PreservationOfficeBuilder 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. + *

    + * Generated from setter {@link PreservationOffice#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PreservationOfficeBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for preservationProjects. + *

    + * Generated from setter {@link PreservationOffice#setPreservationProjects(int) setPreservationProjects(int + * preservationProjects)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.preservationProjects(42);
    +   * }
    + * + * @param preservationProjects preservationProjects + * @return current instance of builder + */ + public PreservationOfficeBuilder preservationProjects(int preservationProjects) { + this.preservationProjects = changedValue(preservationProjects); + return this; + } + + /** + * Sets the value for preservationProjects by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setPreservationProjects(int) setPreservationProjects(int + * preservationProjects)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.preservationProjects(() -> 42);
    +   * }
    + * + * @param preservationProjectsSupplier supplier for preservationProjects + * @return current instance of builder + */ + public PreservationOfficeBuilder preservationProjects(Supplier preservationProjectsSupplier) { + this.preservationProjects = changedValue(preservationProjectsSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PreservationOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PreservationOfficeBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PreservationOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PreservationOfficeBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PreservationOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PreservationOfficeBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PreservationOffice#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PreservationOfficeBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PreservationOfficeBuilder 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 PreservationOfficeBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PreservationOffice result = builder.build();
    +   * }
    + */ + @Override + public PreservationOffice build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.preservationProjects.isSet() && this.preservationProjects.value() == null) { + throw new IllegalStateException("Field 'preservationProjects' is marked as non-null but null value was provided"); + } + PreservationOffice result = new PreservationOffice(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.guidelines.ifSet(result::setGuidelines); + this.id.ifSet(result::setId); + this.jurisdiction.ifSet(result::setJurisdiction); + this.name.ifSet(result::setName); + this.preservationProjects.ifSet(result::setPreservationProjects); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("guidelines", this.guidelines) + .append("id", this.id) + .append("jurisdiction", this.jurisdiction) + .append("name", this.name) + .append("preservationProjects", this.preservationProjects) + .append("status", this.status) + .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 PreservationOffice with(Consumer b) { + PreservationOfficeBuilder builder; + try { + builder = new PreservationOfficeBuilder(PreservationOffice.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PreservationOfficeBuilder.With' should only be implemented by classes, which could be casted to 'PreservationOffice'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PreservationOfficeBuilder with() { + try { + return new PreservationOfficeBuilder(PreservationOffice.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PreservationOfficeBuilder.With' should only be implemented by classes, which could be casted to 'PreservationOffice'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PressRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PressRecordBuilder.java new file mode 100644 index 00000000..03cb5a18 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PressRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.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.performance_test.library.organizations.PressRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PressRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PressRecord result = PressRecordBuilder.create()
    + *     .pressName("example value")
    + *     .pressName("Hello %s", "World")
    + *     .pressName(() -> "example value")
    + *     .pressName(sb -> sb.append("text"))
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .totalTitles(42)
    + *     .totalTitles(() -> 42)
    + *     .headquarters("example value")
    + *     .headquarters("Hello %s", "World")
    + *     .headquarters(() -> "example value")
    + *     .headquarters(sb -> sb.append("text"))
    + *     .active(true)
    + *     .active(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PressRecord.class) +public class PressRecordBuilder implements IBuilderBase { + + /** + * Tracked value for pressName: pressName. + */ + private TrackedValue pressName = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for totalTitles: totalTitles. + */ + private TrackedValue totalTitles = unsetValue(); + /** + * Tracked value for headquarters: headquarters. + */ + private TrackedValue headquarters = unsetValue(); + /** + * Tracked value for active: active. + */ + private TrackedValue active = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PressRecord}. + */ + public PressRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PressRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PressRecordBuilder(PressRecord instance) { + this.pressName = initialValue(instance.pressName()); + this.foundedYear = initialValue(instance.foundedYear()); + this.totalTitles = initialValue(instance.totalTitles()); + this.headquarters = initialValue(instance.headquarters()); + this.active = initialValue(instance.active()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PressRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PressRecordBuilder builder = PressRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.PressRecord} + */ + public static PressRecordBuilder create() { + return new PressRecordBuilder(); + } + + /** + * Sets the value for active. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(true);
    +   * }
    + * + * @param active active + * @return current instance of builder + */ + public PressRecordBuilder active(boolean active) { + this.active = changedValue(active); + return this; + } + + /** + * Sets the value for active by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(() -> true);
    +   * }
    + * + * @param activeSupplier supplier for active + * @return current instance of builder + */ + public PressRecordBuilder active(Supplier activeSupplier) { + this.active = changedValue(activeSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PressRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PressRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for headquarters. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headquarters("example value");
    +   * }
    + * + * @param headquarters headquarters + * @return current instance of builder + */ + public PressRecordBuilder headquarters(String headquarters) { + this.headquarters = changedValue(headquarters); + return this; + } + + /** + * Sets the value for headquarters by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headquarters(sb -> sb.append("text"));
    +   * }
    + * + * @param headquartersStringBuilderConsumer consumer providing an instance of headquarters + * @return current instance of builder + */ + public PressRecordBuilder headquarters(Consumer headquartersStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + headquartersStringBuilderConsumer.accept(builder); + this.headquarters = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for headquarters by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headquarters(() -> "example value");
    +   * }
    + * + * @param headquartersSupplier supplier for headquarters + * @return current instance of builder + */ + public PressRecordBuilder headquarters(Supplier headquartersSupplier) { + this.headquarters = changedValue(headquartersSupplier.get()); + return this; + } + + /** + * Sets the String value for headquarters by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headquarters("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PressRecordBuilder headquarters(String format, Object... args) { + this.headquarters = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pressName. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pressName("example value");
    +   * }
    + * + * @param pressName pressName + * @return current instance of builder + */ + public PressRecordBuilder pressName(String pressName) { + this.pressName = changedValue(pressName); + return this; + } + + /** + * Sets the value for pressName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pressName(sb -> sb.append("text"));
    +   * }
    + * + * @param pressNameStringBuilderConsumer consumer providing an instance of pressName + * @return current instance of builder + */ + public PressRecordBuilder pressName(Consumer pressNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + pressNameStringBuilderConsumer.accept(builder); + this.pressName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for pressName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pressName(() -> "example value");
    +   * }
    + * + * @param pressNameSupplier supplier for pressName + * @return current instance of builder + */ + public PressRecordBuilder pressName(Supplier pressNameSupplier) { + this.pressName = changedValue(pressNameSupplier.get()); + return this; + } + + /** + * Sets the String value for pressName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pressName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PressRecordBuilder pressName(String format, Object... args) { + this.pressName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalTitles. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalTitles(42);
    +   * }
    + * + * @param totalTitles totalTitles + * @return current instance of builder + */ + public PressRecordBuilder totalTitles(int totalTitles) { + this.totalTitles = changedValue(totalTitles); + return this; + } + + /** + * Sets the value for totalTitles by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PressRecord#PressRecord(String, int, int, String, boolean) + * PressRecord(String pressName, int foundedYear, int totalTitles, String headquarters, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalTitles(() -> 42);
    +   * }
    + * + * @param totalTitlesSupplier supplier for totalTitles + * @return current instance of builder + */ + public PressRecordBuilder totalTitles(Supplier totalTitlesSupplier) { + this.totalTitles = changedValue(totalTitlesSupplier.get()); + 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 PressRecordBuilder 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 PressRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PressRecord result = builder.build();
    +   * }
    + */ + @Override + public PressRecord build() { + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (!this.totalTitles.isSet()) { + throw new IllegalStateException("Required field 'totalTitles' must be set before calling build()"); + } + if (this.totalTitles.value() == null) { + throw new IllegalStateException("Field 'totalTitles' is marked as non-null but null value was provided"); + } + PressRecord result = new PressRecord(this.pressName.value(), + this.foundedYear.value(), + this.totalTitles.value(), + this.headquarters.value(), + this.active.valueOr(true)); + 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("pressName", this.pressName) + .append("foundedYear", this.foundedYear) + .append("totalTitles", this.totalTitles) + .append("headquarters", this.headquarters) + .append("active", this.active) + .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 PressRecord with(Consumer b) { + PressRecordBuilder builder; + try { + builder = new PressRecordBuilder(PressRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PressRecordBuilder.With' should only be implemented by classes, which could be casted to 'PressRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PressRecordBuilder with() { + try { + return new PressRecordBuilder(PressRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PressRecordBuilder.With' should only be implemented by classes, which could be casted to 'PressRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalPublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalPublisherBuilder.java new file mode 100644 index 00000000..ffd9b675 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalPublisherBuilder.java @@ -0,0 +1,795 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; +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.builders.ArrayListBuilder; +import org.javahelpers.simple.builders.core.builders.HashSetBuilder; +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.performance_test.library.organizations.ProfessionalPublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalPublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * ProfessionalPublisher result = ProfessionalPublisherBuilder.create()
    + *     .annualTitles(42)
    + *     .annualTitles(() -> 42)
    + *     .certificationPrograms(Set.of("example value"))
    + *     .certificationPrograms(() -> Set.of("example value"))
    + *     .certificationPrograms(t -> t.add("example value"))
    + *     .certificationPrograms("example value", "example value")
    + *     .add2CertificationPrograms("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .professionalFields(List.of("example value"))
    + *     .professionalFields(() -> List.of("example value"))
    + *     .professionalFields(t -> t.add("example value"))
    + *     .professionalFields("example value", "example value")
    + *     .add2ProfessionalFields("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ProfessionalPublisher.class) +public class ProfessionalPublisherBuilder implements IBuilderBase { + + /** + * Tracked value for annualTitles: annualTitles. + */ + private TrackedValue annualTitles = unsetValue(); + /** + * Tracked value for certificationPrograms: certificationPrograms. + */ + private TrackedValue> certificationPrograms = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for professionalFields: professionalFields. + */ + private TrackedValue> professionalFields = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalPublisher}. + */ + public ProfessionalPublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalPublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public ProfessionalPublisherBuilder(ProfessionalPublisher instance) { + this.annualTitles = initialValue(instance.getAnnualTitles()); + this.certificationPrograms = initialValue(instance.getCertificationPrograms()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.professionalFields = initialValue(instance.getProfessionalFields()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalPublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * ProfessionalPublisherBuilder builder = ProfessionalPublisherBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalPublisher} + */ + public static ProfessionalPublisherBuilder create() { + return new ProfessionalPublisherBuilder(); + } + + /** + * Adds a single element to certificationPrograms. + *

    + * Generated from setter {@link ProfessionalPublisher#setCertificationPrograms(Set) + * setCertificationPrograms(Set certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2CertificationPrograms("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ProfessionalPublisherBuilder add2CertificationPrograms(String element) { + Set newCollection; + if (this.certificationPrograms.isSet()) { + newCollection = new HashSet<>(this.certificationPrograms.value()); + } else { + newCollection = new HashSet<>(); + } + newCollection.add(element); + this.certificationPrograms = changedValue(newCollection); + return this; + } + + /** + * Adds a single element to professionalFields. + *

    + * Generated from setter {@link ProfessionalPublisher#setProfessionalFields(List) setProfessionalFields(List + * professionalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ProfessionalFields("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ProfessionalPublisherBuilder add2ProfessionalFields(String element) { + List newCollection; + if (this.professionalFields.isSet()) { + newCollection = new ArrayList<>(this.professionalFields.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.professionalFields = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualTitles. + *

    + * Generated from setter {@link ProfessionalPublisher#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(42);
    +   * }
    + * + * @param annualTitles annualTitles + * @return current instance of builder + */ + public ProfessionalPublisherBuilder annualTitles(int annualTitles) { + this.annualTitles = changedValue(annualTitles); + return this; + } + + /** + * Sets the value for annualTitles by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(() -> 42);
    +   * }
    + * + * @param annualTitlesSupplier supplier for annualTitles + * @return current instance of builder + */ + public ProfessionalPublisherBuilder annualTitles(Supplier annualTitlesSupplier) { + this.annualTitles = changedValue(annualTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for certificationPrograms. + *

    + * Generated from setter {@link ProfessionalPublisher#setCertificationPrograms(Set) + * setCertificationPrograms(Set certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms("example value", "example value");
    +   * }
    + * + * @param certificationPrograms certificationPrograms + * @return current instance of builder + */ + public ProfessionalPublisherBuilder certificationPrograms(String... certificationPrograms) { + this.certificationPrograms = changedValue(Set.of(certificationPrograms)); + return this; + } + + /** + * Sets the value for certificationPrograms. + *

    + * Generated from setter {@link ProfessionalPublisher#setCertificationPrograms(Set) + * setCertificationPrograms(Set certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(Set.of("example value"));
    +   * }
    + * + * @param certificationPrograms certificationPrograms + * @return current instance of builder + */ + public ProfessionalPublisherBuilder certificationPrograms(Set certificationPrograms) { + this.certificationPrograms = changedValue(certificationPrograms); + return this; + } + + /** + * Sets the value for certificationPrograms using a builder consumer that produces the value. + *

    + * Generated from setter {@link ProfessionalPublisher#setCertificationPrograms(Set) + * setCertificationPrograms(Set certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(t -> t.add("example value"));
    +   * }
    + * + * @param certificationProgramsBuilderConsumer consumer providing an instance of a builder for certificationPrograms + * @return current instance of builder + */ + public ProfessionalPublisherBuilder certificationPrograms( + Consumer> certificationProgramsBuilderConsumer) { + HashSetBuilder builder = this.certificationPrograms.isSet() + ? new HashSetBuilder(this.certificationPrograms.value()) + : new HashSetBuilder(); + certificationProgramsBuilderConsumer.accept(builder); + this.certificationPrograms = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for certificationPrograms by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setCertificationPrograms(Set) + * setCertificationPrograms(Set certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(() -> Set.of("example value"));
    +   * }
    + * + * @param certificationProgramsSupplier supplier for certificationPrograms + * @return current instance of builder + */ + public ProfessionalPublisherBuilder certificationPrograms(Supplier> certificationProgramsSupplier) { + this.certificationPrograms = changedValue(certificationProgramsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ProfessionalPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ProfessionalPublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ProfessionalPublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ProfessionalPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ProfessionalPublisherBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ProfessionalPublisherBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ProfessionalPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ProfessionalPublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ProfessionalPublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ProfessionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ProfessionalPublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ProfessionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ProfessionalPublisherBuilder 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. + *

    + * Generated from setter {@link ProfessionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ProfessionalPublisherBuilder 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. + *

    + * Generated from setter {@link ProfessionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProfessionalPublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for professionalFields. + *

    + * Generated from setter {@link ProfessionalPublisher#setProfessionalFields(List) setProfessionalFields(List + * professionalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalFields("example value", "example value");
    +   * }
    + * + * @param professionalFields professionalFields + * @return current instance of builder + */ + public ProfessionalPublisherBuilder professionalFields(String... professionalFields) { + this.professionalFields = changedValue(List.of(professionalFields)); + return this; + } + + /** + * Sets the value for professionalFields. + *

    + * Generated from setter {@link ProfessionalPublisher#setProfessionalFields(List) setProfessionalFields(List + * professionalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalFields(List.of("example value"));
    +   * }
    + * + * @param professionalFields professionalFields + * @return current instance of builder + */ + public ProfessionalPublisherBuilder professionalFields(List professionalFields) { + this.professionalFields = changedValue(professionalFields); + return this; + } + + /** + * Sets the value for professionalFields using a builder consumer that produces the value. + *

    + * Generated from setter {@link ProfessionalPublisher#setProfessionalFields(List) setProfessionalFields(List + * professionalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalFields(t -> t.add("example value"));
    +   * }
    + * + * @param professionalFieldsBuilderConsumer consumer providing an instance of a builder for professionalFields + * @return current instance of builder + */ + public ProfessionalPublisherBuilder professionalFields( + Consumer> professionalFieldsBuilderConsumer) { + ArrayListBuilder builder = this.professionalFields.isSet() + ? new ArrayListBuilder(this.professionalFields.value()) + : new ArrayListBuilder(); + professionalFieldsBuilderConsumer.accept(builder); + this.professionalFields = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for professionalFields by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setProfessionalFields(List) setProfessionalFields(List + * professionalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalFields(() -> List.of("example value"));
    +   * }
    + * + * @param professionalFieldsSupplier supplier for professionalFields + * @return current instance of builder + */ + public ProfessionalPublisherBuilder professionalFields(Supplier> professionalFieldsSupplier) { + this.professionalFields = changedValue(professionalFieldsSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ProfessionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ProfessionalPublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ProfessionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ProfessionalPublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ProfessionalPublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ProfessionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProfessionalPublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ProfessionalPublisherBuilder 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 ProfessionalPublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ProfessionalPublisher result = builder.build();
    +   * }
    + */ + @Override + public ProfessionalPublisher build() { + if (this.annualTitles.isSet() && this.annualTitles.value() == null) { + throw new IllegalStateException("Field 'annualTitles' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + ProfessionalPublisher result = new ProfessionalPublisher(); + this.annualTitles.ifSet(result::setAnnualTitles); + this.certificationPrograms.ifSet(result::setCertificationPrograms); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.professionalFields.ifSet(result::setProfessionalFields); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualTitles", this.annualTitles) + .append("certificationPrograms", this.certificationPrograms) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("professionalFields", this.professionalFields) + .append("status", this.status) + .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 ProfessionalPublisher with(Consumer b) { + ProfessionalPublisherBuilder builder; + try { + builder = new ProfessionalPublisherBuilder(ProfessionalPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProfessionalPublisherBuilder.With' should only be implemented by classes, which could be casted to 'ProfessionalPublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ProfessionalPublisherBuilder with() { + try { + return new ProfessionalPublisherBuilder(ProfessionalPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProfessionalPublisherBuilder.With' should only be implemented by classes, which could be casted to 'ProfessionalPublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalSchoolBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalSchoolBuilder.java new file mode 100644 index 00000000..f7199013 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProfessionalSchoolBuilder.java @@ -0,0 +1,727 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.ProfessionalSchool}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalSchool 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. + * + *

    Example:

    + * + *
    {@code
    + * ProfessionalSchool result = ProfessionalSchoolBuilder.create()
    + *     .accreditation("example value")
    + *     .accreditation("Hello %s", "World")
    + *     .accreditation(() -> "example value")
    + *     .accreditation(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .professionalField("example value")
    + *     .professionalField("Hello %s", "World")
    + *     .professionalField(() -> "example value")
    + *     .professionalField(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .studentCount(42)
    + *     .studentCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ProfessionalSchool.class) +public class ProfessionalSchoolBuilder implements IBuilderBase { + + /** + * Tracked value for accreditation: accreditation. + */ + private TrackedValue accreditation = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for professionalField: professionalField. + */ + private TrackedValue professionalField = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for studentCount: studentCount. + */ + private TrackedValue studentCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalSchool}. + */ + public ProfessionalSchoolBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalSchool} by a instance. + * + * @param instance object instance for initialisiation + */ + public ProfessionalSchoolBuilder(ProfessionalSchool instance) { + this.accreditation = initialValue(instance.getAccreditation()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.professionalField = initialValue(instance.getProfessionalField()); + this.status = initialValue(instance.getStatus()); + this.studentCount = initialValue(instance.getStudentCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalSchool}. + * + *

    Example:

    + * + *
    {@code
    +   * ProfessionalSchoolBuilder builder = ProfessionalSchoolBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProfessionalSchool} + */ + public static ProfessionalSchoolBuilder create() { + return new ProfessionalSchoolBuilder(); + } + + /** + * Sets the value for accreditation. + *

    + * Generated from setter {@link ProfessionalSchool#setAccreditation(String) setAccreditation(String accreditation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accreditation("example value");
    +   * }
    + * + * @param accreditation accreditation + * @return current instance of builder + */ + public ProfessionalSchoolBuilder accreditation(String accreditation) { + this.accreditation = changedValue(accreditation); + return this; + } + + /** + * Sets the value for accreditation by executing the provided consumer. + *

    + * Generated from setter {@link ProfessionalSchool#setAccreditation(String) setAccreditation(String accreditation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accreditation(sb -> sb.append("text"));
    +   * }
    + * + * @param accreditationStringBuilderConsumer consumer providing an instance of accreditation + * @return current instance of builder + */ + public ProfessionalSchoolBuilder accreditation(Consumer accreditationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + accreditationStringBuilderConsumer.accept(builder); + this.accreditation = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for accreditation by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setAccreditation(String) setAccreditation(String accreditation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accreditation(() -> "example value");
    +   * }
    + * + * @param accreditationSupplier supplier for accreditation + * @return current instance of builder + */ + public ProfessionalSchoolBuilder accreditation(Supplier accreditationSupplier) { + this.accreditation = changedValue(accreditationSupplier.get()); + return this; + } + + /** + * Sets the String value for accreditation by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ProfessionalSchool#setAccreditation(String) setAccreditation(String accreditation)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accreditation("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProfessionalSchoolBuilder accreditation(String format, Object... args) { + this.accreditation = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ProfessionalSchool#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ProfessionalSchoolBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ProfessionalSchoolBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ProfessionalSchool#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ProfessionalSchoolBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ProfessionalSchoolBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ProfessionalSchool#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ProfessionalSchoolBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ProfessionalSchoolBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ProfessionalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ProfessionalSchoolBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ProfessionalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ProfessionalSchoolBuilder 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. + *

    + * Generated from setter {@link ProfessionalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ProfessionalSchoolBuilder 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. + *

    + * Generated from setter {@link ProfessionalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProfessionalSchoolBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for professionalField. + *

    + * Generated from setter {@link ProfessionalSchool#setProfessionalField(String) setProfessionalField(String + * professionalField)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalField("example value");
    +   * }
    + * + * @param professionalField professionalField + * @return current instance of builder + */ + public ProfessionalSchoolBuilder professionalField(String professionalField) { + this.professionalField = changedValue(professionalField); + return this; + } + + /** + * Sets the value for professionalField by executing the provided consumer. + *

    + * Generated from setter {@link ProfessionalSchool#setProfessionalField(String) setProfessionalField(String + * professionalField)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalField(sb -> sb.append("text"));
    +   * }
    + * + * @param professionalFieldStringBuilderConsumer consumer providing an instance of professionalField + * @return current instance of builder + */ + public ProfessionalSchoolBuilder professionalField(Consumer professionalFieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + professionalFieldStringBuilderConsumer.accept(builder); + this.professionalField = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for professionalField by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setProfessionalField(String) setProfessionalField(String + * professionalField)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalField(() -> "example value");
    +   * }
    + * + * @param professionalFieldSupplier supplier for professionalField + * @return current instance of builder + */ + public ProfessionalSchoolBuilder professionalField(Supplier professionalFieldSupplier) { + this.professionalField = changedValue(professionalFieldSupplier.get()); + return this; + } + + /** + * Sets the String value for professionalField by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ProfessionalSchool#setProfessionalField(String) setProfessionalField(String + * professionalField)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.professionalField("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProfessionalSchoolBuilder professionalField(String format, Object... args) { + this.professionalField = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ProfessionalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ProfessionalSchoolBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ProfessionalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ProfessionalSchoolBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ProfessionalSchoolBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ProfessionalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProfessionalSchoolBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for studentCount. + *

    + * Generated from setter {@link ProfessionalSchool#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(42);
    +   * }
    + * + * @param studentCount studentCount + * @return current instance of builder + */ + public ProfessionalSchoolBuilder studentCount(int studentCount) { + this.studentCount = changedValue(studentCount); + return this; + } + + /** + * Sets the value for studentCount by invoking the provided supplier. + *

    + * Generated from setter {@link ProfessionalSchool#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(() -> 42);
    +   * }
    + * + * @param studentCountSupplier supplier for studentCount + * @return current instance of builder + */ + public ProfessionalSchoolBuilder studentCount(Supplier studentCountSupplier) { + this.studentCount = changedValue(studentCountSupplier.get()); + 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 ProfessionalSchoolBuilder 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 ProfessionalSchoolBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ProfessionalSchool result = builder.build();
    +   * }
    + */ + @Override + public ProfessionalSchool build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.studentCount.isSet() && this.studentCount.value() == null) { + throw new IllegalStateException("Field 'studentCount' is marked as non-null but null value was provided"); + } + ProfessionalSchool result = new ProfessionalSchool(); + this.accreditation.ifSet(result::setAccreditation); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.professionalField.ifSet(result::setProfessionalField); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.studentCount.ifSet(result::setStudentCount); + 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("accreditation", this.accreditation) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("professionalField", this.professionalField) + .append("status", this.status) + .append("studentCount", this.studentCount) + .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 ProfessionalSchool with(Consumer b) { + ProfessionalSchoolBuilder builder; + try { + builder = new ProfessionalSchoolBuilder(ProfessionalSchool.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProfessionalSchoolBuilder.With' should only be implemented by classes, which could be casted to 'ProfessionalSchool'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ProfessionalSchoolBuilder with() { + try { + return new ProfessionalSchoolBuilder(ProfessionalSchool.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProfessionalSchoolBuilder.With' should only be implemented by classes, which could be casted to 'ProfessionalSchool'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProgramRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProgramRecordBuilder.java new file mode 100644 index 00000000..94b56225 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProgramRecordBuilder.java @@ -0,0 +1,518 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.ProgramRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ProgramRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ProgramRecord result = ProgramRecordBuilder.create()
    + *     .programName("example value")
    + *     .programName("Hello %s", "World")
    + *     .programName(() -> "example value")
    + *     .programName(sb -> sb.append("text"))
    + *     .organizingBody("example value")
    + *     .organizingBody("Hello %s", "World")
    + *     .organizingBody(() -> "example value")
    + *     .organizingBody(sb -> sb.append("text"))
    + *     .participantCount(42)
    + *     .participantCount(() -> 42)
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .active(true)
    + *     .active(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ProgramRecord.class) +public class ProgramRecordBuilder implements IBuilderBase { + + /** + * Tracked value for programName: programName. + */ + private TrackedValue programName = unsetValue(); + /** + * Tracked value for organizingBody: organizingBody. + */ + private TrackedValue organizingBody = unsetValue(); + /** + * Tracked value for participantCount: participantCount. + */ + private TrackedValue participantCount = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + /** + * Tracked value for active: active. + */ + private TrackedValue active = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProgramRecord}. + */ + public ProgramRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProgramRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ProgramRecordBuilder(ProgramRecord instance) { + this.programName = initialValue(instance.programName()); + this.organizingBody = initialValue(instance.organizingBody()); + this.participantCount = initialValue(instance.participantCount()); + this.startDate = initialValue(instance.startDate()); + this.active = initialValue(instance.active()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProgramRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ProgramRecordBuilder builder = ProgramRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProgramRecord} + */ + public static ProgramRecordBuilder create() { + return new ProgramRecordBuilder(); + } + + /** + * Sets the value for active. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(true);
    +   * }
    + * + * @param active active + * @return current instance of builder + */ + public ProgramRecordBuilder active(boolean active) { + this.active = changedValue(active); + return this; + } + + /** + * Sets the value for active by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(() -> true);
    +   * }
    + * + * @param activeSupplier supplier for active + * @return current instance of builder + */ + public ProgramRecordBuilder active(Supplier activeSupplier) { + this.active = changedValue(activeSupplier.get()); + return this; + } + + /** + * Sets the value for organizingBody. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizingBody("example value");
    +   * }
    + * + * @param organizingBody organizingBody + * @return current instance of builder + */ + public ProgramRecordBuilder organizingBody(String organizingBody) { + this.organizingBody = changedValue(organizingBody); + return this; + } + + /** + * Sets the value for organizingBody by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizingBody(sb -> sb.append("text"));
    +   * }
    + * + * @param organizingBodyStringBuilderConsumer consumer providing an instance of organizingBody + * @return current instance of builder + */ + public ProgramRecordBuilder organizingBody(Consumer organizingBodyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizingBodyStringBuilderConsumer.accept(builder); + this.organizingBody = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organizingBody by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizingBody(() -> "example value");
    +   * }
    + * + * @param organizingBodySupplier supplier for organizingBody + * @return current instance of builder + */ + public ProgramRecordBuilder organizingBody(Supplier organizingBodySupplier) { + this.organizingBody = changedValue(organizingBodySupplier.get()); + return this; + } + + /** + * Sets the String value for organizingBody by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organizingBody("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProgramRecordBuilder organizingBody(String format, Object... args) { + this.organizingBody = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for participantCount. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.participantCount(42);
    +   * }
    + * + * @param participantCount participantCount + * @return current instance of builder + */ + public ProgramRecordBuilder participantCount(int participantCount) { + this.participantCount = changedValue(participantCount); + return this; + } + + /** + * Sets the value for participantCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.participantCount(() -> 42);
    +   * }
    + * + * @param participantCountSupplier supplier for participantCount + * @return current instance of builder + */ + public ProgramRecordBuilder participantCount(Supplier participantCountSupplier) { + this.participantCount = changedValue(participantCountSupplier.get()); + return this; + } + + /** + * Sets the value for programName. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.programName("example value");
    +   * }
    + * + * @param programName programName + * @return current instance of builder + */ + public ProgramRecordBuilder programName(String programName) { + this.programName = changedValue(programName); + return this; + } + + /** + * Sets the value for programName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.programName(sb -> sb.append("text"));
    +   * }
    + * + * @param programNameStringBuilderConsumer consumer providing an instance of programName + * @return current instance of builder + */ + public ProgramRecordBuilder programName(Consumer programNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + programNameStringBuilderConsumer.accept(builder); + this.programName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for programName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.programName(() -> "example value");
    +   * }
    + * + * @param programNameSupplier supplier for programName + * @return current instance of builder + */ + public ProgramRecordBuilder programName(Supplier programNameSupplier) { + this.programName = changedValue(programNameSupplier.get()); + return this; + } + + /** + * Sets the String value for programName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.programName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProgramRecordBuilder programName(String format, Object... args) { + this.programName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public ProgramRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ProgramRecord#ProgramRecord(String, String, int, LocalDate, boolean) + * ProgramRecord(String programName, String organizingBody, int participantCount, LocalDate startDate, boolean + * active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public ProgramRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + 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 ProgramRecordBuilder 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 ProgramRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ProgramRecord result = builder.build();
    +   * }
    + */ + @Override + public ProgramRecord build() { + if (!this.participantCount.isSet()) { + throw new IllegalStateException("Required field 'participantCount' must be set before calling build()"); + } + if (this.participantCount.value() == null) { + throw new IllegalStateException("Field 'participantCount' is marked as non-null but null value was provided"); + } + ProgramRecord result = new ProgramRecord(this.programName.value(), + this.organizingBody.value(), + this.participantCount.value(), + this.startDate.value(), + this.active.valueOr(true)); + 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("programName", this.programName) + .append("organizingBody", this.organizingBody) + .append("participantCount", this.participantCount) + .append("startDate", this.startDate) + .append("active", this.active) + .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 ProgramRecord with(Consumer b) { + ProgramRecordBuilder builder; + try { + builder = new ProgramRecordBuilder(ProgramRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProgramRecordBuilder.With' should only be implemented by classes, which could be casted to 'ProgramRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ProgramRecordBuilder with() { + try { + return new ProgramRecordBuilder(ProgramRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProgramRecordBuilder.With' should only be implemented by classes, which could be casted to 'ProgramRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProjectRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProjectRecordBuilder.java new file mode 100644 index 00000000..2d49c3cb --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ProjectRecordBuilder.java @@ -0,0 +1,510 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +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.performance_test.library.organizations.ProjectRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ProjectRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ProjectRecord result = ProjectRecordBuilder.create()
    + *     .projectName("example value")
    + *     .projectName("Hello %s", "World")
    + *     .projectName(() -> "example value")
    + *     .projectName(sb -> sb.append("text"))
    + *     .leadOrganization("example value")
    + *     .leadOrganization("Hello %s", "World")
    + *     .leadOrganization(() -> "example value")
    + *     .leadOrganization(sb -> sb.append("text"))
    + *     .budget(BigDecimal.valueOf(3.14))
    + *     .budget(() -> BigDecimal.valueOf(3.14))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .endDate(LocalDate.now())
    + *     .endDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ProjectRecord.class) +public class ProjectRecordBuilder implements IBuilderBase { + + /** + * Tracked value for projectName: projectName. + */ + private TrackedValue projectName = unsetValue(); + /** + * Tracked value for leadOrganization: leadOrganization. + */ + private TrackedValue leadOrganization = unsetValue(); + /** + * Tracked value for budget: budget. + */ + private TrackedValue budget = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + /** + * Tracked value for endDate: endDate. + */ + private TrackedValue endDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProjectRecord}. + */ + public ProjectRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProjectRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ProjectRecordBuilder(ProjectRecord instance) { + this.projectName = initialValue(instance.projectName()); + this.leadOrganization = initialValue(instance.leadOrganization()); + this.budget = initialValue(instance.budget()); + this.startDate = initialValue(instance.startDate()); + this.endDate = initialValue(instance.endDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProjectRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ProjectRecordBuilder builder = ProjectRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.ProjectRecord} + */ + public static ProjectRecordBuilder create() { + return new ProjectRecordBuilder(); + } + + /** + * Sets the value for budget. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budget budget + * @return current instance of builder + */ + public ProjectRecordBuilder budget(BigDecimal budget) { + this.budget = changedValue(budget); + return this; + } + + /** + * Sets the value for budget by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budgetSupplier supplier for budget + * @return current instance of builder + */ + public ProjectRecordBuilder budget(Supplier budgetSupplier) { + this.budget = changedValue(budgetSupplier.get()); + return this; + } + + /** + * Sets the value for endDate. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endDate(LocalDate.now());
    +   * }
    + * + * @param endDate endDate + * @return current instance of builder + */ + public ProjectRecordBuilder endDate(LocalDate endDate) { + this.endDate = changedValue(endDate); + return this; + } + + /** + * Sets the value for endDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endDate(() -> LocalDate.now());
    +   * }
    + * + * @param endDateSupplier supplier for endDate + * @return current instance of builder + */ + public ProjectRecordBuilder endDate(Supplier endDateSupplier) { + this.endDate = changedValue(endDateSupplier.get()); + return this; + } + + /** + * Sets the value for leadOrganization. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.leadOrganization("example value");
    +   * }
    + * + * @param leadOrganization leadOrganization + * @return current instance of builder + */ + public ProjectRecordBuilder leadOrganization(String leadOrganization) { + this.leadOrganization = changedValue(leadOrganization); + return this; + } + + /** + * Sets the value for leadOrganization by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.leadOrganization(sb -> sb.append("text"));
    +   * }
    + * + * @param leadOrganizationStringBuilderConsumer consumer providing an instance of leadOrganization + * @return current instance of builder + */ + public ProjectRecordBuilder leadOrganization(Consumer leadOrganizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + leadOrganizationStringBuilderConsumer.accept(builder); + this.leadOrganization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for leadOrganization by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.leadOrganization(() -> "example value");
    +   * }
    + * + * @param leadOrganizationSupplier supplier for leadOrganization + * @return current instance of builder + */ + public ProjectRecordBuilder leadOrganization(Supplier leadOrganizationSupplier) { + this.leadOrganization = changedValue(leadOrganizationSupplier.get()); + return this; + } + + /** + * Sets the String value for leadOrganization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.leadOrganization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProjectRecordBuilder leadOrganization(String format, Object... args) { + this.leadOrganization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for projectName. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.projectName("example value");
    +   * }
    + * + * @param projectName projectName + * @return current instance of builder + */ + public ProjectRecordBuilder projectName(String projectName) { + this.projectName = changedValue(projectName); + return this; + } + + /** + * Sets the value for projectName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.projectName(sb -> sb.append("text"));
    +   * }
    + * + * @param projectNameStringBuilderConsumer consumer providing an instance of projectName + * @return current instance of builder + */ + public ProjectRecordBuilder projectName(Consumer projectNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + projectNameStringBuilderConsumer.accept(builder); + this.projectName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for projectName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.projectName(() -> "example value");
    +   * }
    + * + * @param projectNameSupplier supplier for projectName + * @return current instance of builder + */ + public ProjectRecordBuilder projectName(Supplier projectNameSupplier) { + this.projectName = changedValue(projectNameSupplier.get()); + return this; + } + + /** + * Sets the String value for projectName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.projectName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProjectRecordBuilder projectName(String format, Object... args) { + this.projectName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public ProjectRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ProjectRecord#ProjectRecord(String, String, BigDecimal, LocalDate, LocalDate) ProjectRecord(String + * projectName, String leadOrganization, BigDecimal budget, LocalDate startDate, LocalDate endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public ProjectRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + 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 ProjectRecordBuilder 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 ProjectRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ProjectRecord result = builder.build();
    +   * }
    + */ + @Override + public ProjectRecord build() { + ProjectRecord result = new ProjectRecord(this.projectName + .value(), this.leadOrganization.value(), this.budget.value(), this.startDate.value(), this.endDate.value()); + 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("projectName", this.projectName) + .append("leadOrganization", this.leadOrganization) + .append("budget", this.budget) + .append("startDate", this.startDate) + .append("endDate", this.endDate) + .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 ProjectRecord with(Consumer b) { + ProjectRecordBuilder builder; + try { + builder = new ProjectRecordBuilder(ProjectRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProjectRecordBuilder.With' should only be implemented by classes, which could be casted to 'ProjectRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ProjectRecordBuilder with() { + try { + return new ProjectRecordBuilder(ProjectRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProjectRecordBuilder.With' should only be implemented by classes, which could be casted to 'ProjectRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublisherRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublisherRecordBuilder.java new file mode 100644 index 00000000..347254f3 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublisherRecordBuilder.java @@ -0,0 +1,524 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.PublisherRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PublisherRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PublisherRecord result = PublisherRecordBuilder.create()
    + *     .publisherName("example value")
    + *     .publisherName("Hello %s", "World")
    + *     .publisherName(() -> "example value")
    + *     .publisherName(sb -> sb.append("text"))
    + *     .establishedDate(LocalDate.now())
    + *     .establishedDate(() -> LocalDate.now())
    + *     .imprintCount(42)
    + *     .imprintCount(() -> 42)
    + *     .annualOutput(42)
    + *     .annualOutput(() -> 42)
    + *     .country("example value")
    + *     .country("Hello %s", "World")
    + *     .country(() -> "example value")
    + *     .country(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PublisherRecord.class) +public class PublisherRecordBuilder implements IBuilderBase { + + /** + * Tracked value for publisherName: publisherName. + */ + private TrackedValue publisherName = unsetValue(); + /** + * Tracked value for establishedDate: establishedDate. + */ + private TrackedValue establishedDate = unsetValue(); + /** + * Tracked value for imprintCount: imprintCount. + */ + private TrackedValue imprintCount = unsetValue(); + /** + * Tracked value for annualOutput: annualOutput. + */ + private TrackedValue annualOutput = unsetValue(); + /** + * Tracked value for country: country. + */ + private TrackedValue country = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublisherRecord}. + */ + public PublisherRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublisherRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PublisherRecordBuilder(PublisherRecord instance) { + this.publisherName = initialValue(instance.publisherName()); + this.establishedDate = initialValue(instance.establishedDate()); + this.imprintCount = initialValue(instance.imprintCount()); + this.annualOutput = initialValue(instance.annualOutput()); + this.country = initialValue(instance.country()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublisherRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PublisherRecordBuilder builder = PublisherRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublisherRecord} + */ + public static PublisherRecordBuilder create() { + return new PublisherRecordBuilder(); + } + + /** + * Sets the value for annualOutput. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualOutput(42);
    +   * }
    + * + * @param annualOutput annualOutput + * @return current instance of builder + */ + public PublisherRecordBuilder annualOutput(int annualOutput) { + this.annualOutput = changedValue(annualOutput); + return this; + } + + /** + * Sets the value for annualOutput by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualOutput(() -> 42);
    +   * }
    + * + * @param annualOutputSupplier supplier for annualOutput + * @return current instance of builder + */ + public PublisherRecordBuilder annualOutput(Supplier annualOutputSupplier) { + this.annualOutput = changedValue(annualOutputSupplier.get()); + return this; + } + + /** + * Sets the value for country. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("example value");
    +   * }
    + * + * @param country country + * @return current instance of builder + */ + public PublisherRecordBuilder country(String country) { + this.country = changedValue(country); + return this; + } + + /** + * Sets the value for country by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(sb -> sb.append("text"));
    +   * }
    + * + * @param countryStringBuilderConsumer consumer providing an instance of country + * @return current instance of builder + */ + public PublisherRecordBuilder country(Consumer countryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + countryStringBuilderConsumer.accept(builder); + this.country = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for country by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(() -> "example value");
    +   * }
    + * + * @param countrySupplier supplier for country + * @return current instance of builder + */ + public PublisherRecordBuilder country(Supplier countrySupplier) { + this.country = changedValue(countrySupplier.get()); + return this; + } + + /** + * Sets the String value for country by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublisherRecordBuilder country(String format, Object... args) { + this.country = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for establishedDate. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.establishedDate(LocalDate.now());
    +   * }
    + * + * @param establishedDate establishedDate + * @return current instance of builder + */ + public PublisherRecordBuilder establishedDate(LocalDate establishedDate) { + this.establishedDate = changedValue(establishedDate); + return this; + } + + /** + * Sets the value for establishedDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.establishedDate(() -> LocalDate.now());
    +   * }
    + * + * @param establishedDateSupplier supplier for establishedDate + * @return current instance of builder + */ + public PublisherRecordBuilder establishedDate(Supplier establishedDateSupplier) { + this.establishedDate = changedValue(establishedDateSupplier.get()); + return this; + } + + /** + * Sets the value for imprintCount. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.imprintCount(42);
    +   * }
    + * + * @param imprintCount imprintCount + * @return current instance of builder + */ + public PublisherRecordBuilder imprintCount(int imprintCount) { + this.imprintCount = changedValue(imprintCount); + return this; + } + + /** + * Sets the value for imprintCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.imprintCount(() -> 42);
    +   * }
    + * + * @param imprintCountSupplier supplier for imprintCount + * @return current instance of builder + */ + public PublisherRecordBuilder imprintCount(Supplier imprintCountSupplier) { + this.imprintCount = changedValue(imprintCountSupplier.get()); + return this; + } + + /** + * Sets the value for publisherName. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisherName("example value");
    +   * }
    + * + * @param publisherName publisherName + * @return current instance of builder + */ + public PublisherRecordBuilder publisherName(String publisherName) { + this.publisherName = changedValue(publisherName); + return this; + } + + /** + * Sets the value for publisherName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisherName(sb -> sb.append("text"));
    +   * }
    + * + * @param publisherNameStringBuilderConsumer consumer providing an instance of publisherName + * @return current instance of builder + */ + public PublisherRecordBuilder publisherName(Consumer publisherNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + publisherNameStringBuilderConsumer.accept(builder); + this.publisherName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for publisherName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisherName(() -> "example value");
    +   * }
    + * + * @param publisherNameSupplier supplier for publisherName + * @return current instance of builder + */ + public PublisherRecordBuilder publisherName(Supplier publisherNameSupplier) { + this.publisherName = changedValue(publisherNameSupplier.get()); + return this; + } + + /** + * Sets the String value for publisherName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PublisherRecord#PublisherRecord(String, LocalDate, int, int, String) + * PublisherRecord(String publisherName, LocalDate establishedDate, int imprintCount, int annualOutput, String + * country)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisherName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublisherRecordBuilder publisherName(String format, Object... args) { + this.publisherName = changedValue(String.format(format, args)); + 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 PublisherRecordBuilder 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 PublisherRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PublisherRecord result = builder.build();
    +   * }
    + */ + @Override + public PublisherRecord build() { + if (!this.imprintCount.isSet()) { + throw new IllegalStateException("Required field 'imprintCount' must be set before calling build()"); + } + if (this.imprintCount.value() == null) { + throw new IllegalStateException("Field 'imprintCount' is marked as non-null but null value was provided"); + } + if (!this.annualOutput.isSet()) { + throw new IllegalStateException("Required field 'annualOutput' must be set before calling build()"); + } + if (this.annualOutput.value() == null) { + throw new IllegalStateException("Field 'annualOutput' is marked as non-null but null value was provided"); + } + PublisherRecord result = new PublisherRecord(this.publisherName.value(), + this.establishedDate.value(), + this.imprintCount.value(), + this.annualOutput.value(), + this.country.value()); + 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("publisherName", this.publisherName) + .append("establishedDate", this.establishedDate) + .append("imprintCount", this.imprintCount) + .append("annualOutput", this.annualOutput) + .append("country", this.country) + .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 PublisherRecord with(Consumer b) { + PublisherRecordBuilder builder; + try { + builder = new PublisherRecordBuilder(PublisherRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublisherRecordBuilder.With' should only be implemented by classes, which could be casted to 'PublisherRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PublisherRecordBuilder with() { + try { + return new PublisherRecordBuilder(PublisherRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublisherRecordBuilder.With' should only be implemented by classes, which could be casted to 'PublisherRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishersAssociationBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishersAssociationBuilder.java new file mode 100644 index 00000000..c70f2347 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishersAssociationBuilder.java @@ -0,0 +1,761 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.PublishersAssociation}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PublishersAssociation 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. + * + *

    Example:

    + * + *
    {@code
    + * PublishersAssociation result = PublishersAssociationBuilder.create()
    + *     .annualReport("example value")
    + *     .annualReport("Hello %s", "World")
    + *     .annualReport(() -> "example value")
    + *     .annualReport(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .industryStandards(List.of("example value"))
    + *     .industryStandards(() -> List.of("example value"))
    + *     .industryStandards(t -> t.add("example value"))
    + *     .industryStandards("example value", "example value")
    + *     .add2IndustryStandards("example value")
    + *     .memberPublishers(42)
    + *     .memberPublishers(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PublishersAssociation.class) +public class PublishersAssociationBuilder implements IBuilderBase { + + /** + * Tracked value for annualReport: annualReport. + */ + private TrackedValue annualReport = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for industryStandards: industryStandards. + */ + private TrackedValue> industryStandards = unsetValue(); + /** + * Tracked value for memberPublishers: memberPublishers. + */ + private TrackedValue memberPublishers = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishersAssociation}. + */ + public PublishersAssociationBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishersAssociation} by a instance. + * + * @param instance object instance for initialisiation + */ + public PublishersAssociationBuilder(PublishersAssociation instance) { + this.annualReport = initialValue(instance.getAnnualReport()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.industryStandards = initialValue(instance.getIndustryStandards()); + this.memberPublishers = initialValue(instance.getMemberPublishers()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishersAssociation}. + * + *

    Example:

    + * + *
    {@code
    +   * PublishersAssociationBuilder builder = PublishersAssociationBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishersAssociation} + */ + public static PublishersAssociationBuilder create() { + return new PublishersAssociationBuilder(); + } + + /** + * Adds a single element to industryStandards. + *

    + * Generated from setter {@link PublishersAssociation#setIndustryStandards(List) setIndustryStandards(List + * industryStandards)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2IndustryStandards("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PublishersAssociationBuilder add2IndustryStandards(String element) { + List newCollection; + if (this.industryStandards.isSet()) { + newCollection = new ArrayList<>(this.industryStandards.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.industryStandards = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualReport. + *

    + * Generated from setter {@link PublishersAssociation#setAnnualReport(String) setAnnualReport(String annualReport)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualReport("example value");
    +   * }
    + * + * @param annualReport annualReport + * @return current instance of builder + */ + public PublishersAssociationBuilder annualReport(String annualReport) { + this.annualReport = changedValue(annualReport); + return this; + } + + /** + * Sets the value for annualReport by executing the provided consumer. + *

    + * Generated from setter {@link PublishersAssociation#setAnnualReport(String) setAnnualReport(String annualReport)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualReport(sb -> sb.append("text"));
    +   * }
    + * + * @param annualReportStringBuilderConsumer consumer providing an instance of annualReport + * @return current instance of builder + */ + public PublishersAssociationBuilder annualReport(Consumer annualReportStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + annualReportStringBuilderConsumer.accept(builder); + this.annualReport = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for annualReport by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setAnnualReport(String) setAnnualReport(String annualReport)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualReport(() -> "example value");
    +   * }
    + * + * @param annualReportSupplier supplier for annualReport + * @return current instance of builder + */ + public PublishersAssociationBuilder annualReport(Supplier annualReportSupplier) { + this.annualReport = changedValue(annualReportSupplier.get()); + return this; + } + + /** + * Sets the String value for annualReport by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PublishersAssociation#setAnnualReport(String) setAnnualReport(String annualReport)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualReport("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublishersAssociationBuilder annualReport(String format, Object... args) { + this.annualReport = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PublishersAssociation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PublishersAssociationBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PublishersAssociationBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PublishersAssociation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PublishersAssociationBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PublishersAssociationBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PublishersAssociation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PublishersAssociationBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PublishersAssociationBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for industryStandards. + *

    + * Generated from setter {@link PublishersAssociation#setIndustryStandards(List) setIndustryStandards(List + * industryStandards)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industryStandards("example value", "example value");
    +   * }
    + * + * @param industryStandards industryStandards + * @return current instance of builder + */ + public PublishersAssociationBuilder industryStandards(String... industryStandards) { + this.industryStandards = changedValue(List.of(industryStandards)); + return this; + } + + /** + * Sets the value for industryStandards. + *

    + * Generated from setter {@link PublishersAssociation#setIndustryStandards(List) setIndustryStandards(List + * industryStandards)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industryStandards(List.of("example value"));
    +   * }
    + * + * @param industryStandards industryStandards + * @return current instance of builder + */ + public PublishersAssociationBuilder industryStandards(List industryStandards) { + this.industryStandards = changedValue(industryStandards); + return this; + } + + /** + * Sets the value for industryStandards using a builder consumer that produces the value. + *

    + * Generated from setter {@link PublishersAssociation#setIndustryStandards(List) setIndustryStandards(List + * industryStandards)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industryStandards(t -> t.add("example value"));
    +   * }
    + * + * @param industryStandardsBuilderConsumer consumer providing an instance of a builder for industryStandards + * @return current instance of builder + */ + public PublishersAssociationBuilder industryStandards( + Consumer> industryStandardsBuilderConsumer) { + ArrayListBuilder builder = this.industryStandards.isSet() + ? new ArrayListBuilder(this.industryStandards.value()) + : new ArrayListBuilder(); + industryStandardsBuilderConsumer.accept(builder); + this.industryStandards = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for industryStandards by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setIndustryStandards(List) setIndustryStandards(List + * industryStandards)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industryStandards(() -> List.of("example value"));
    +   * }
    + * + * @param industryStandardsSupplier supplier for industryStandards + * @return current instance of builder + */ + public PublishersAssociationBuilder industryStandards(Supplier> industryStandardsSupplier) { + this.industryStandards = changedValue(industryStandardsSupplier.get()); + return this; + } + + /** + * Sets the value for memberPublishers. + *

    + * Generated from setter {@link PublishersAssociation#setMemberPublishers(int) setMemberPublishers(int + * memberPublishers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberPublishers(42);
    +   * }
    + * + * @param memberPublishers memberPublishers + * @return current instance of builder + */ + public PublishersAssociationBuilder memberPublishers(int memberPublishers) { + this.memberPublishers = changedValue(memberPublishers); + return this; + } + + /** + * Sets the value for memberPublishers by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setMemberPublishers(int) setMemberPublishers(int + * memberPublishers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberPublishers(() -> 42);
    +   * }
    + * + * @param memberPublishersSupplier supplier for memberPublishers + * @return current instance of builder + */ + public PublishersAssociationBuilder memberPublishers(Supplier memberPublishersSupplier) { + this.memberPublishers = changedValue(memberPublishersSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PublishersAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PublishersAssociationBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PublishersAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PublishersAssociationBuilder 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. + *

    + * Generated from setter {@link PublishersAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PublishersAssociationBuilder 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. + *

    + * Generated from setter {@link PublishersAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublishersAssociationBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PublishersAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PublishersAssociationBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PublishersAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PublishersAssociationBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PublishersAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PublishersAssociationBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PublishersAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublishersAssociationBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PublishersAssociationBuilder 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 PublishersAssociationBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PublishersAssociation result = builder.build();
    +   * }
    + */ + @Override + public PublishersAssociation build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberPublishers.isSet() && this.memberPublishers.value() == null) { + throw new IllegalStateException("Field 'memberPublishers' is marked as non-null but null value was provided"); + } + PublishersAssociation result = new PublishersAssociation(); + this.annualReport.ifSet(result::setAnnualReport); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.industryStandards.ifSet(result::setIndustryStandards); + this.memberPublishers.ifSet(result::setMemberPublishers); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualReport", this.annualReport) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("industryStandards", this.industryStandards) + .append("memberPublishers", this.memberPublishers) + .append("name", this.name) + .append("status", this.status) + .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 PublishersAssociation with(Consumer b) { + PublishersAssociationBuilder builder; + try { + builder = new PublishersAssociationBuilder(PublishersAssociation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublishersAssociationBuilder.With' should only be implemented by classes, which could be casted to 'PublishersAssociation'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PublishersAssociationBuilder with() { + try { + return new PublishersAssociationBuilder(PublishersAssociation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublishersAssociationBuilder.With' should only be implemented by classes, which could be casted to 'PublishersAssociation'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishingServiceProviderBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishingServiceProviderBuilder.java new file mode 100644 index 00000000..80b8fd13 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PublishingServiceProviderBuilder.java @@ -0,0 +1,712 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.PublishingServiceProvider}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PublishingServiceProvider 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. + * + *

    Example:

    + * + *
    {@code
    + * PublishingServiceProvider result = PublishingServiceProviderBuilder.create()
    + *     .clientPublishers(42)
    + *     .clientPublishers(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .serviceName("example value")
    + *     .serviceName("Hello %s", "World")
    + *     .serviceName(() -> "example value")
    + *     .serviceName(sb -> sb.append("text"))
    + *     .servicesOffered(List.of("example value"))
    + *     .servicesOffered(() -> List.of("example value"))
    + *     .servicesOffered(t -> t.add("example value"))
    + *     .servicesOffered("example value", "example value")
    + *     .add2ServicesOffered("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PublishingServiceProvider.class) +public class PublishingServiceProviderBuilder implements IBuilderBase { + + /** + * Tracked value for clientPublishers: clientPublishers. + */ + private TrackedValue clientPublishers = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for serviceName: serviceName. + */ + private TrackedValue serviceName = unsetValue(); + /** + * Tracked value for servicesOffered: servicesOffered. + */ + private TrackedValue> servicesOffered = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishingServiceProvider}. + */ + public PublishingServiceProviderBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishingServiceProvider} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public PublishingServiceProviderBuilder(PublishingServiceProvider instance) { + this.clientPublishers = initialValue(instance.getClientPublishers()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.serviceName = initialValue(instance.getServiceName()); + this.servicesOffered = initialValue(instance.getServicesOffered()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishingServiceProvider}. + * + *

    Example:

    + * + *
    {@code
    +   * PublishingServiceProviderBuilder builder = PublishingServiceProviderBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PublishingServiceProvider} + */ + public static PublishingServiceProviderBuilder create() { + return new PublishingServiceProviderBuilder(); + } + + /** + * Adds a single element to servicesOffered. + *

    + * Generated from setter {@link PublishingServiceProvider#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ServicesOffered("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PublishingServiceProviderBuilder add2ServicesOffered(String element) { + List newCollection; + if (this.servicesOffered.isSet()) { + newCollection = new ArrayList<>(this.servicesOffered.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.servicesOffered = changedValue(newCollection); + return this; + } + + /** + * Sets the value for clientPublishers. + *

    + * Generated from setter {@link PublishingServiceProvider#setClientPublishers(int) setClientPublishers(int + * clientPublishers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientPublishers(42);
    +   * }
    + * + * @param clientPublishers clientPublishers + * @return current instance of builder + */ + public PublishingServiceProviderBuilder clientPublishers(int clientPublishers) { + this.clientPublishers = changedValue(clientPublishers); + return this; + } + + /** + * Sets the value for clientPublishers by invoking the provided supplier. + *

    + * Generated from setter {@link PublishingServiceProvider#setClientPublishers(int) setClientPublishers(int + * clientPublishers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientPublishers(() -> 42);
    +   * }
    + * + * @param clientPublishersSupplier supplier for clientPublishers + * @return current instance of builder + */ + public PublishingServiceProviderBuilder clientPublishers(Supplier clientPublishersSupplier) { + this.clientPublishers = changedValue(clientPublishersSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PublishingServiceProvider#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PublishingServiceProviderBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PublishingServiceProvider#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PublishingServiceProviderBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PublishingServiceProvider#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PublishingServiceProviderBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PublishingServiceProvider#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PublishingServiceProviderBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PublishingServiceProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PublishingServiceProviderBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PublishingServiceProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PublishingServiceProviderBuilder 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. + *

    + * Generated from setter {@link PublishingServiceProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PublishingServiceProviderBuilder 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. + *

    + * Generated from setter {@link PublishingServiceProvider#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublishingServiceProviderBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for serviceName. + *

    + * Generated from setter {@link PublishingServiceProvider#setServiceName(String) setServiceName(String serviceName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.serviceName("example value");
    +   * }
    + * + * @param serviceName serviceName + * @return current instance of builder + */ + public PublishingServiceProviderBuilder serviceName(String serviceName) { + this.serviceName = changedValue(serviceName); + return this; + } + + /** + * Sets the value for serviceName by executing the provided consumer. + *

    + * Generated from setter {@link PublishingServiceProvider#setServiceName(String) setServiceName(String serviceName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.serviceName(sb -> sb.append("text"));
    +   * }
    + * + * @param serviceNameStringBuilderConsumer consumer providing an instance of serviceName + * @return current instance of builder + */ + public PublishingServiceProviderBuilder serviceName(Consumer serviceNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + serviceNameStringBuilderConsumer.accept(builder); + this.serviceName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for serviceName by invoking the provided supplier. + *

    + * Generated from setter {@link PublishingServiceProvider#setServiceName(String) setServiceName(String serviceName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.serviceName(() -> "example value");
    +   * }
    + * + * @param serviceNameSupplier supplier for serviceName + * @return current instance of builder + */ + public PublishingServiceProviderBuilder serviceName(Supplier serviceNameSupplier) { + this.serviceName = changedValue(serviceNameSupplier.get()); + return this; + } + + /** + * Sets the String value for serviceName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PublishingServiceProvider#setServiceName(String) setServiceName(String serviceName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.serviceName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublishingServiceProviderBuilder serviceName(String format, Object... args) { + this.serviceName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for servicesOffered. + *

    + * Generated from setter {@link PublishingServiceProvider#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered("example value", "example value");
    +   * }
    + * + * @param servicesOffered servicesOffered + * @return current instance of builder + */ + public PublishingServiceProviderBuilder servicesOffered(String... servicesOffered) { + this.servicesOffered = changedValue(List.of(servicesOffered)); + return this; + } + + /** + * Sets the value for servicesOffered. + *

    + * Generated from setter {@link PublishingServiceProvider#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered(List.of("example value"));
    +   * }
    + * + * @param servicesOffered servicesOffered + * @return current instance of builder + */ + public PublishingServiceProviderBuilder servicesOffered(List servicesOffered) { + this.servicesOffered = changedValue(servicesOffered); + return this; + } + + /** + * Sets the value for servicesOffered using a builder consumer that produces the value. + *

    + * Generated from setter {@link PublishingServiceProvider#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered(t -> t.add("example value"));
    +   * }
    + * + * @param servicesOfferedBuilderConsumer consumer providing an instance of a builder for servicesOffered + * @return current instance of builder + */ + public PublishingServiceProviderBuilder servicesOffered( + Consumer> servicesOfferedBuilderConsumer) { + ArrayListBuilder builder = this.servicesOffered.isSet() + ? new ArrayListBuilder(this.servicesOffered.value()) + : new ArrayListBuilder(); + servicesOfferedBuilderConsumer.accept(builder); + this.servicesOffered = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for servicesOffered by invoking the provided supplier. + *

    + * Generated from setter {@link PublishingServiceProvider#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered(() -> List.of("example value"));
    +   * }
    + * + * @param servicesOfferedSupplier supplier for servicesOffered + * @return current instance of builder + */ + public PublishingServiceProviderBuilder servicesOffered(Supplier> servicesOfferedSupplier) { + this.servicesOffered = changedValue(servicesOfferedSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PublishingServiceProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PublishingServiceProviderBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PublishingServiceProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PublishingServiceProviderBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PublishingServiceProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PublishingServiceProviderBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PublishingServiceProvider#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PublishingServiceProviderBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PublishingServiceProviderBuilder 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 PublishingServiceProviderBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PublishingServiceProvider result = builder.build();
    +   * }
    + */ + @Override + public PublishingServiceProvider build() { + if (this.clientPublishers.isSet() && this.clientPublishers.value() == null) { + throw new IllegalStateException("Field 'clientPublishers' is marked as non-null but null value was provided"); + } + PublishingServiceProvider result = new PublishingServiceProvider(); + this.clientPublishers.ifSet(result::setClientPublishers); + this.createdAt.ifSet(result::setCreatedAt); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.serviceName.ifSet(result::setServiceName); + this.servicesOffered.ifSet(result::setServicesOffered); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("clientPublishers", this.clientPublishers) + .append("createdAt", this.createdAt) + .append("id", this.id) + .append("name", this.name) + .append("serviceName", this.serviceName) + .append("servicesOffered", this.servicesOffered) + .append("status", this.status) + .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 PublishingServiceProvider with(Consumer b) { + PublishingServiceProviderBuilder builder; + try { + builder = new PublishingServiceProviderBuilder(PublishingServiceProvider.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublishingServiceProviderBuilder.With' should only be implemented by classes, which could be casted to 'PublishingServiceProvider'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PublishingServiceProviderBuilder with() { + try { + return new PublishingServiceProviderBuilder(PublishingServiceProvider.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PublishingServiceProviderBuilder.With' should only be implemented by classes, which could be casted to 'PublishingServiceProvider'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PurchasingConsortiumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PurchasingConsortiumBuilder.java new file mode 100644 index 00000000..28f4da76 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/PurchasingConsortiumBuilder.java @@ -0,0 +1,644 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.PurchasingConsortium}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.PurchasingConsortium 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. + * + *

    Example:

    + * + *
    {@code
    + * PurchasingConsortium result = PurchasingConsortiumBuilder.create()
    + *     .annualPurchasingVolume(BigDecimal.valueOf(3.14))
    + *     .annualPurchasingVolume(() -> BigDecimal.valueOf(3.14))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .vendorAgreements(42)
    + *     .vendorAgreements(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PurchasingConsortium.class) +public class PurchasingConsortiumBuilder implements IBuilderBase { + + /** + * Tracked value for annualPurchasingVolume: annualPurchasingVolume. + */ + private TrackedValue annualPurchasingVolume = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for vendorAgreements: vendorAgreements. + */ + private TrackedValue vendorAgreements = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PurchasingConsortium}. + */ + public PurchasingConsortiumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PurchasingConsortium} by a instance. + * + * @param instance object instance for initialisiation + */ + public PurchasingConsortiumBuilder(PurchasingConsortium instance) { + this.annualPurchasingVolume = initialValue(instance.getAnnualPurchasingVolume()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberCount = initialValue(instance.getMemberCount()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.vendorAgreements = initialValue(instance.getVendorAgreements()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PurchasingConsortium}. + * + *

    Example:

    + * + *
    {@code
    +   * PurchasingConsortiumBuilder builder = PurchasingConsortiumBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.PurchasingConsortium} + */ + public static PurchasingConsortiumBuilder create() { + return new PurchasingConsortiumBuilder(); + } + + /** + * Sets the value for annualPurchasingVolume. + *

    + * Generated from setter {@link PurchasingConsortium#setAnnualPurchasingVolume(BigDecimal) + * setAnnualPurchasingVolume(BigDecimal annualPurchasingVolume)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualPurchasingVolume(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualPurchasingVolume annualPurchasingVolume + * @return current instance of builder + */ + public PurchasingConsortiumBuilder annualPurchasingVolume(BigDecimal annualPurchasingVolume) { + this.annualPurchasingVolume = changedValue(annualPurchasingVolume); + return this; + } + + /** + * Sets the value for annualPurchasingVolume by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setAnnualPurchasingVolume(BigDecimal) + * setAnnualPurchasingVolume(BigDecimal annualPurchasingVolume)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualPurchasingVolume(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualPurchasingVolumeSupplier supplier for annualPurchasingVolume + * @return current instance of builder + */ + public PurchasingConsortiumBuilder annualPurchasingVolume(Supplier annualPurchasingVolumeSupplier) { + this.annualPurchasingVolume = changedValue(annualPurchasingVolumeSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link PurchasingConsortium#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PurchasingConsortiumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PurchasingConsortiumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link PurchasingConsortium#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public PurchasingConsortiumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public PurchasingConsortiumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link PurchasingConsortium#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PurchasingConsortiumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PurchasingConsortiumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from setter {@link PurchasingConsortium#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public PurchasingConsortiumBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public PurchasingConsortiumBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link PurchasingConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PurchasingConsortiumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link PurchasingConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PurchasingConsortiumBuilder 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. + *

    + * Generated from setter {@link PurchasingConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PurchasingConsortiumBuilder 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. + *

    + * Generated from setter {@link PurchasingConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PurchasingConsortiumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link PurchasingConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PurchasingConsortiumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link PurchasingConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PurchasingConsortiumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PurchasingConsortiumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link PurchasingConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PurchasingConsortiumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for vendorAgreements. + *

    + * Generated from setter {@link PurchasingConsortium#setVendorAgreements(int) setVendorAgreements(int + * vendorAgreements)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.vendorAgreements(42);
    +   * }
    + * + * @param vendorAgreements vendorAgreements + * @return current instance of builder + */ + public PurchasingConsortiumBuilder vendorAgreements(int vendorAgreements) { + this.vendorAgreements = changedValue(vendorAgreements); + return this; + } + + /** + * Sets the value for vendorAgreements by invoking the provided supplier. + *

    + * Generated from setter {@link PurchasingConsortium#setVendorAgreements(int) setVendorAgreements(int + * vendorAgreements)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.vendorAgreements(() -> 42);
    +   * }
    + * + * @param vendorAgreementsSupplier supplier for vendorAgreements + * @return current instance of builder + */ + public PurchasingConsortiumBuilder vendorAgreements(Supplier vendorAgreementsSupplier) { + this.vendorAgreements = changedValue(vendorAgreementsSupplier.get()); + 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 PurchasingConsortiumBuilder 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 PurchasingConsortiumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PurchasingConsortium result = builder.build();
    +   * }
    + */ + @Override + public PurchasingConsortium build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberCount.isSet() && this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + if (this.vendorAgreements.isSet() && this.vendorAgreements.value() == null) { + throw new IllegalStateException("Field 'vendorAgreements' is marked as non-null but null value was provided"); + } + PurchasingConsortium result = new PurchasingConsortium(); + this.annualPurchasingVolume.ifSet(result::setAnnualPurchasingVolume); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberCount.ifSet(result::setMemberCount); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.vendorAgreements.ifSet(result::setVendorAgreements); + 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("annualPurchasingVolume", this.annualPurchasingVolume) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberCount", this.memberCount) + .append("name", this.name) + .append("status", this.status) + .append("vendorAgreements", this.vendorAgreements) + .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 PurchasingConsortium with(Consumer b) { + PurchasingConsortiumBuilder builder; + try { + builder = new PurchasingConsortiumBuilder(PurchasingConsortium.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PurchasingConsortiumBuilder.With' should only be implemented by classes, which could be casted to 'PurchasingConsortium'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PurchasingConsortiumBuilder with() { + try { + return new PurchasingConsortiumBuilder(PurchasingConsortium.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PurchasingConsortiumBuilder.With' should only be implemented by classes, which could be casted to 'PurchasingConsortium'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RailwayMuseumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RailwayMuseumBuilder.java new file mode 100644 index 00000000..76d0d060 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RailwayMuseumBuilder.java @@ -0,0 +1,639 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.RailwayMuseum}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.RailwayMuseum 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. + * + *

    Example:

    + * + *
    {@code
    + * RailwayMuseum result = RailwayMuseumBuilder.create()
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .exhibitCount(42)
    + *     .exhibitCount(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .locomotiveCount(42)
    + *     .locomotiveCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RailwayMuseum.class) +public class RailwayMuseumBuilder implements IBuilderBase { + + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for exhibitCount: exhibitCount. + */ + private TrackedValue exhibitCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for locomotiveCount: locomotiveCount. + */ + private TrackedValue locomotiveCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RailwayMuseum}. + */ + public RailwayMuseumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RailwayMuseum} by a instance. + * + * @param instance object instance for initialisiation + */ + public RailwayMuseumBuilder(RailwayMuseum instance) { + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.exhibitCount = initialValue(instance.getExhibitCount()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.locomotiveCount = initialValue(instance.getLocomotiveCount()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RailwayMuseum}. + * + *

    Example:

    + * + *
    {@code
    +   * RailwayMuseumBuilder builder = RailwayMuseumBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.RailwayMuseum} + */ + public static RailwayMuseumBuilder create() { + return new RailwayMuseumBuilder(); + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link RailwayMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public RailwayMuseumBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public RailwayMuseumBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link RailwayMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public RailwayMuseumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public RailwayMuseumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for exhibitCount. + *

    + * Generated from setter {@link RailwayMuseum#setExhibitCount(int) setExhibitCount(int exhibitCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitCount(42);
    +   * }
    + * + * @param exhibitCount exhibitCount + * @return current instance of builder + */ + public RailwayMuseumBuilder exhibitCount(int exhibitCount) { + this.exhibitCount = changedValue(exhibitCount); + return this; + } + + /** + * Sets the value for exhibitCount by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setExhibitCount(int) setExhibitCount(int exhibitCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitCount(() -> 42);
    +   * }
    + * + * @param exhibitCountSupplier supplier for exhibitCount + * @return current instance of builder + */ + public RailwayMuseumBuilder exhibitCount(Supplier exhibitCountSupplier) { + this.exhibitCount = changedValue(exhibitCountSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link RailwayMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public RailwayMuseumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public RailwayMuseumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link RailwayMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public RailwayMuseumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public RailwayMuseumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for locomotiveCount. + *

    + * Generated from setter {@link RailwayMuseum#setLocomotiveCount(int) setLocomotiveCount(int locomotiveCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.locomotiveCount(42);
    +   * }
    + * + * @param locomotiveCount locomotiveCount + * @return current instance of builder + */ + public RailwayMuseumBuilder locomotiveCount(int locomotiveCount) { + this.locomotiveCount = changedValue(locomotiveCount); + return this; + } + + /** + * Sets the value for locomotiveCount by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setLocomotiveCount(int) setLocomotiveCount(int locomotiveCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.locomotiveCount(() -> 42);
    +   * }
    + * + * @param locomotiveCountSupplier supplier for locomotiveCount + * @return current instance of builder + */ + public RailwayMuseumBuilder locomotiveCount(Supplier locomotiveCountSupplier) { + this.locomotiveCount = changedValue(locomotiveCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link RailwayMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public RailwayMuseumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link RailwayMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public RailwayMuseumBuilder 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. + *

    + * Generated from setter {@link RailwayMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public RailwayMuseumBuilder 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. + *

    + * Generated from setter {@link RailwayMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RailwayMuseumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link RailwayMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public RailwayMuseumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link RailwayMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public RailwayMuseumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link RailwayMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public RailwayMuseumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RailwayMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RailwayMuseumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 RailwayMuseumBuilder 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 RailwayMuseumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RailwayMuseum result = builder.build();
    +   * }
    + */ + @Override + public RailwayMuseum build() { + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.exhibitCount.isSet() && this.exhibitCount.value() == null) { + throw new IllegalStateException("Field 'exhibitCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.locomotiveCount.isSet() && this.locomotiveCount.value() == null) { + throw new IllegalStateException("Field 'locomotiveCount' is marked as non-null but null value was provided"); + } + RailwayMuseum result = new RailwayMuseum(); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.createdAt.ifSet(result::setCreatedAt); + this.exhibitCount.ifSet(result::setExhibitCount); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.locomotiveCount.ifSet(result::setLocomotiveCount); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualVisitors", this.annualVisitors) + .append("createdAt", this.createdAt) + .append("exhibitCount", this.exhibitCount) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("locomotiveCount", this.locomotiveCount) + .append("name", this.name) + .append("status", this.status) + .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 RailwayMuseum with(Consumer b) { + RailwayMuseumBuilder builder; + try { + builder = new RailwayMuseumBuilder(RailwayMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RailwayMuseumBuilder.With' should only be implemented by classes, which could be casted to 'RailwayMuseum'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RailwayMuseumBuilder with() { + try { + return new RailwayMuseumBuilder(RailwayMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RailwayMuseumBuilder.With' should only be implemented by classes, which could be casted to 'RailwayMuseum'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalDistributorBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalDistributorBuilder.java new file mode 100644 index 00000000..e50d6c60 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalDistributorBuilder.java @@ -0,0 +1,682 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.RegionalDistributor}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.RegionalDistributor 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. + * + *

    Example:

    + * + *
    {@code
    + * RegionalDistributor result = RegionalDistributorBuilder.create()
    + *     .clientCount(42)
    + *     .clientCount(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .region("example value")
    + *     .region("Hello %s", "World")
    + *     .region(() -> "example value")
    + *     .region(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .warehouseCount(42)
    + *     .warehouseCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RegionalDistributor.class) +public class RegionalDistributorBuilder implements IBuilderBase { + + /** + * Tracked value for clientCount: clientCount. + */ + private TrackedValue clientCount = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for region: region. + */ + private TrackedValue region = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for warehouseCount: warehouseCount. + */ + private TrackedValue warehouseCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalDistributor}. + */ + public RegionalDistributorBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalDistributor} by a instance. + * + * @param instance object instance for initialisiation + */ + public RegionalDistributorBuilder(RegionalDistributor instance) { + this.clientCount = initialValue(instance.getClientCount()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.region = initialValue(instance.getRegion()); + this.status = initialValue(instance.getStatus()); + this.warehouseCount = initialValue(instance.getWarehouseCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalDistributor}. + * + *

    Example:

    + * + *
    {@code
    +   * RegionalDistributorBuilder builder = RegionalDistributorBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalDistributor} + */ + public static RegionalDistributorBuilder create() { + return new RegionalDistributorBuilder(); + } + + /** + * Sets the value for clientCount. + *

    + * Generated from setter {@link RegionalDistributor#setClientCount(int) setClientCount(int clientCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientCount(42);
    +   * }
    + * + * @param clientCount clientCount + * @return current instance of builder + */ + public RegionalDistributorBuilder clientCount(int clientCount) { + this.clientCount = changedValue(clientCount); + return this; + } + + /** + * Sets the value for clientCount by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setClientCount(int) setClientCount(int clientCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientCount(() -> 42);
    +   * }
    + * + * @param clientCountSupplier supplier for clientCount + * @return current instance of builder + */ + public RegionalDistributorBuilder clientCount(Supplier clientCountSupplier) { + this.clientCount = changedValue(clientCountSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link RegionalDistributor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public RegionalDistributorBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public RegionalDistributorBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link RegionalDistributor#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public RegionalDistributorBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public RegionalDistributorBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link RegionalDistributor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public RegionalDistributorBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public RegionalDistributorBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link RegionalDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public RegionalDistributorBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link RegionalDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public RegionalDistributorBuilder 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. + *

    + * Generated from setter {@link RegionalDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public RegionalDistributorBuilder 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. + *

    + * Generated from setter {@link RegionalDistributor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalDistributorBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for region. + *

    + * Generated from setter {@link RegionalDistributor#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("example value");
    +   * }
    + * + * @param region region + * @return current instance of builder + */ + public RegionalDistributorBuilder region(String region) { + this.region = changedValue(region); + return this; + } + + /** + * Sets the value for region by executing the provided consumer. + *

    + * Generated from setter {@link RegionalDistributor#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(sb -> sb.append("text"));
    +   * }
    + * + * @param regionStringBuilderConsumer consumer providing an instance of region + * @return current instance of builder + */ + public RegionalDistributorBuilder region(Consumer regionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + regionStringBuilderConsumer.accept(builder); + this.region = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for region by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(() -> "example value");
    +   * }
    + * + * @param regionSupplier supplier for region + * @return current instance of builder + */ + public RegionalDistributorBuilder region(Supplier regionSupplier) { + this.region = changedValue(regionSupplier.get()); + return this; + } + + /** + * Sets the String value for region by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RegionalDistributor#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalDistributorBuilder region(String format, Object... args) { + this.region = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link RegionalDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public RegionalDistributorBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link RegionalDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public RegionalDistributorBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public RegionalDistributorBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RegionalDistributor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalDistributorBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for warehouseCount. + *

    + * Generated from setter {@link RegionalDistributor#setWarehouseCount(int) setWarehouseCount(int warehouseCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.warehouseCount(42);
    +   * }
    + * + * @param warehouseCount warehouseCount + * @return current instance of builder + */ + public RegionalDistributorBuilder warehouseCount(int warehouseCount) { + this.warehouseCount = changedValue(warehouseCount); + return this; + } + + /** + * Sets the value for warehouseCount by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalDistributor#setWarehouseCount(int) setWarehouseCount(int warehouseCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.warehouseCount(() -> 42);
    +   * }
    + * + * @param warehouseCountSupplier supplier for warehouseCount + * @return current instance of builder + */ + public RegionalDistributorBuilder warehouseCount(Supplier warehouseCountSupplier) { + this.warehouseCount = changedValue(warehouseCountSupplier.get()); + 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 RegionalDistributorBuilder 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 RegionalDistributorBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RegionalDistributor result = builder.build();
    +   * }
    + */ + @Override + public RegionalDistributor build() { + if (this.clientCount.isSet() && this.clientCount.value() == null) { + throw new IllegalStateException("Field 'clientCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.warehouseCount.isSet() && this.warehouseCount.value() == null) { + throw new IllegalStateException("Field 'warehouseCount' is marked as non-null but null value was provided"); + } + RegionalDistributor result = new RegionalDistributor(); + this.clientCount.ifSet(result::setClientCount); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.region.ifSet(result::setRegion); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.warehouseCount.ifSet(result::setWarehouseCount); + 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("clientCount", this.clientCount) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("region", this.region) + .append("status", this.status) + .append("warehouseCount", this.warehouseCount) + .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 RegionalDistributor with(Consumer b) { + RegionalDistributorBuilder builder; + try { + builder = new RegionalDistributorBuilder(RegionalDistributor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegionalDistributorBuilder.With' should only be implemented by classes, which could be casted to 'RegionalDistributor'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RegionalDistributorBuilder with() { + try { + return new RegionalDistributorBuilder(RegionalDistributor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegionalDistributorBuilder.With' should only be implemented by classes, which could be casted to 'RegionalDistributor'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalLibraryBuilder.java new file mode 100644 index 00000000..a3ed7754 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalLibraryBuilder.java @@ -0,0 +1,680 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.RegionalLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.RegionalLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * RegionalLibrary result = RegionalLibraryBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberLibraries(42)
    + *     .memberLibraries(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .region("example value")
    + *     .region("Hello %s", "World")
    + *     .region(() -> "example value")
    + *     .region(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalVolumes(42L)
    + *     .totalVolumes(() -> 42L)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RegionalLibrary.class) +public class RegionalLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberLibraries: memberLibraries. + */ + private TrackedValue memberLibraries = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for region: region. + */ + private TrackedValue region = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalVolumes: totalVolumes. + */ + private TrackedValue totalVolumes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalLibrary}. + */ + public RegionalLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public RegionalLibraryBuilder(RegionalLibrary instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberLibraries = initialValue(instance.getMemberLibraries()); + this.name = initialValue(instance.getName()); + this.region = initialValue(instance.getRegion()); + this.status = initialValue(instance.getStatus()); + this.totalVolumes = initialValue(instance.getTotalVolumes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * RegionalLibraryBuilder builder = RegionalLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalLibrary} + */ + public static RegionalLibraryBuilder create() { + return new RegionalLibraryBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link RegionalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public RegionalLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public RegionalLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link RegionalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public RegionalLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public RegionalLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link RegionalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public RegionalLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public RegionalLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberLibraries. + *

    + * Generated from setter {@link RegionalLibrary#setMemberLibraries(int) setMemberLibraries(int memberLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberLibraries(42);
    +   * }
    + * + * @param memberLibraries memberLibraries + * @return current instance of builder + */ + public RegionalLibraryBuilder memberLibraries(int memberLibraries) { + this.memberLibraries = changedValue(memberLibraries); + return this; + } + + /** + * Sets the value for memberLibraries by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setMemberLibraries(int) setMemberLibraries(int memberLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberLibraries(() -> 42);
    +   * }
    + * + * @param memberLibrariesSupplier supplier for memberLibraries + * @return current instance of builder + */ + public RegionalLibraryBuilder memberLibraries(Supplier memberLibrariesSupplier) { + this.memberLibraries = changedValue(memberLibrariesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link RegionalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public RegionalLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link RegionalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public RegionalLibraryBuilder 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. + *

    + * Generated from setter {@link RegionalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public RegionalLibraryBuilder 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. + *

    + * Generated from setter {@link RegionalLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for region. + *

    + * Generated from setter {@link RegionalLibrary#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("example value");
    +   * }
    + * + * @param region region + * @return current instance of builder + */ + public RegionalLibraryBuilder region(String region) { + this.region = changedValue(region); + return this; + } + + /** + * Sets the value for region by executing the provided consumer. + *

    + * Generated from setter {@link RegionalLibrary#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(sb -> sb.append("text"));
    +   * }
    + * + * @param regionStringBuilderConsumer consumer providing an instance of region + * @return current instance of builder + */ + public RegionalLibraryBuilder region(Consumer regionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + regionStringBuilderConsumer.accept(builder); + this.region = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for region by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(() -> "example value");
    +   * }
    + * + * @param regionSupplier supplier for region + * @return current instance of builder + */ + public RegionalLibraryBuilder region(Supplier regionSupplier) { + this.region = changedValue(regionSupplier.get()); + return this; + } + + /** + * Sets the String value for region by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RegionalLibrary#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalLibraryBuilder region(String format, Object... args) { + this.region = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link RegionalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public RegionalLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link RegionalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public RegionalLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public RegionalLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RegionalLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalVolumes. + *

    + * Generated from setter {@link RegionalLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(42L);
    +   * }
    + * + * @param totalVolumes totalVolumes + * @return current instance of builder + */ + public RegionalLibraryBuilder totalVolumes(long totalVolumes) { + this.totalVolumes = changedValue(totalVolumes); + return this; + } + + /** + * Sets the value for totalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(() -> 42L);
    +   * }
    + * + * @param totalVolumesSupplier supplier for totalVolumes + * @return current instance of builder + */ + public RegionalLibraryBuilder totalVolumes(Supplier totalVolumesSupplier) { + this.totalVolumes = changedValue(totalVolumesSupplier.get()); + 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 RegionalLibraryBuilder 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 RegionalLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RegionalLibrary result = builder.build();
    +   * }
    + */ + @Override + public RegionalLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberLibraries.isSet() && this.memberLibraries.value() == null) { + throw new IllegalStateException("Field 'memberLibraries' is marked as non-null but null value was provided"); + } + if (this.totalVolumes.isSet() && this.totalVolumes.value() == null) { + throw new IllegalStateException("Field 'totalVolumes' is marked as non-null but null value was provided"); + } + RegionalLibrary result = new RegionalLibrary(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberLibraries.ifSet(result::setMemberLibraries); + this.name.ifSet(result::setName); + this.region.ifSet(result::setRegion); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalVolumes.ifSet(result::setTotalVolumes); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberLibraries", this.memberLibraries) + .append("name", this.name) + .append("region", this.region) + .append("status", this.status) + .append("totalVolumes", this.totalVolumes) + .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 RegionalLibrary with(Consumer b) { + RegionalLibraryBuilder builder; + try { + builder = new RegionalLibraryBuilder(RegionalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegionalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'RegionalLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RegionalLibraryBuilder with() { + try { + return new RegionalLibraryBuilder(RegionalLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegionalLibraryBuilder.With' should only be implemented by classes, which could be casted to 'RegionalLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalPublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalPublisherBuilder.java new file mode 100644 index 00000000..8d3d2df7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegionalPublisherBuilder.java @@ -0,0 +1,682 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.RegionalPublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.RegionalPublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * RegionalPublisher result = RegionalPublisherBuilder.create()
    + *     .annualTitles(42)
    + *     .annualTitles(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .localAuthors(42)
    + *     .localAuthors(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .region("example value")
    + *     .region("Hello %s", "World")
    + *     .region(() -> "example value")
    + *     .region(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RegionalPublisher.class) +public class RegionalPublisherBuilder implements IBuilderBase { + + /** + * Tracked value for annualTitles: annualTitles. + */ + private TrackedValue annualTitles = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for localAuthors: localAuthors. + */ + private TrackedValue localAuthors = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for region: region. + */ + private TrackedValue region = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalPublisher}. + */ + public RegionalPublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalPublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public RegionalPublisherBuilder(RegionalPublisher instance) { + this.annualTitles = initialValue(instance.getAnnualTitles()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.localAuthors = initialValue(instance.getLocalAuthors()); + this.name = initialValue(instance.getName()); + this.region = initialValue(instance.getRegion()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalPublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * RegionalPublisherBuilder builder = RegionalPublisherBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegionalPublisher} + */ + public static RegionalPublisherBuilder create() { + return new RegionalPublisherBuilder(); + } + + /** + * Sets the value for annualTitles. + *

    + * Generated from setter {@link RegionalPublisher#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(42);
    +   * }
    + * + * @param annualTitles annualTitles + * @return current instance of builder + */ + public RegionalPublisherBuilder annualTitles(int annualTitles) { + this.annualTitles = changedValue(annualTitles); + return this; + } + + /** + * Sets the value for annualTitles by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(() -> 42);
    +   * }
    + * + * @param annualTitlesSupplier supplier for annualTitles + * @return current instance of builder + */ + public RegionalPublisherBuilder annualTitles(Supplier annualTitlesSupplier) { + this.annualTitles = changedValue(annualTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link RegionalPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public RegionalPublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public RegionalPublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link RegionalPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public RegionalPublisherBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public RegionalPublisherBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link RegionalPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public RegionalPublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public RegionalPublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for localAuthors. + *

    + * Generated from setter {@link RegionalPublisher#setLocalAuthors(int) setLocalAuthors(int localAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.localAuthors(42);
    +   * }
    + * + * @param localAuthors localAuthors + * @return current instance of builder + */ + public RegionalPublisherBuilder localAuthors(int localAuthors) { + this.localAuthors = changedValue(localAuthors); + return this; + } + + /** + * Sets the value for localAuthors by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setLocalAuthors(int) setLocalAuthors(int localAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.localAuthors(() -> 42);
    +   * }
    + * + * @param localAuthorsSupplier supplier for localAuthors + * @return current instance of builder + */ + public RegionalPublisherBuilder localAuthors(Supplier localAuthorsSupplier) { + this.localAuthors = changedValue(localAuthorsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link RegionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public RegionalPublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link RegionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public RegionalPublisherBuilder 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. + *

    + * Generated from setter {@link RegionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public RegionalPublisherBuilder 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. + *

    + * Generated from setter {@link RegionalPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalPublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for region. + *

    + * Generated from setter {@link RegionalPublisher#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("example value");
    +   * }
    + * + * @param region region + * @return current instance of builder + */ + public RegionalPublisherBuilder region(String region) { + this.region = changedValue(region); + return this; + } + + /** + * Sets the value for region by executing the provided consumer. + *

    + * Generated from setter {@link RegionalPublisher#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(sb -> sb.append("text"));
    +   * }
    + * + * @param regionStringBuilderConsumer consumer providing an instance of region + * @return current instance of builder + */ + public RegionalPublisherBuilder region(Consumer regionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + regionStringBuilderConsumer.accept(builder); + this.region = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for region by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(() -> "example value");
    +   * }
    + * + * @param regionSupplier supplier for region + * @return current instance of builder + */ + public RegionalPublisherBuilder region(Supplier regionSupplier) { + this.region = changedValue(regionSupplier.get()); + return this; + } + + /** + * Sets the String value for region by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RegionalPublisher#setRegion(String) setRegion(String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalPublisherBuilder region(String format, Object... args) { + this.region = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link RegionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public RegionalPublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link RegionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public RegionalPublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link RegionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public RegionalPublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link RegionalPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegionalPublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 RegionalPublisherBuilder 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 RegionalPublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RegionalPublisher result = builder.build();
    +   * }
    + */ + @Override + public RegionalPublisher build() { + if (this.annualTitles.isSet() && this.annualTitles.value() == null) { + throw new IllegalStateException("Field 'annualTitles' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.localAuthors.isSet() && this.localAuthors.value() == null) { + throw new IllegalStateException("Field 'localAuthors' is marked as non-null but null value was provided"); + } + RegionalPublisher result = new RegionalPublisher(); + this.annualTitles.ifSet(result::setAnnualTitles); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.localAuthors.ifSet(result::setLocalAuthors); + this.name.ifSet(result::setName); + this.region.ifSet(result::setRegion); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualTitles", this.annualTitles) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("localAuthors", this.localAuthors) + .append("name", this.name) + .append("region", this.region) + .append("status", this.status) + .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 RegionalPublisher with(Consumer b) { + RegionalPublisherBuilder builder; + try { + builder = new RegionalPublisherBuilder(RegionalPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegionalPublisherBuilder.With' should only be implemented by classes, which could be casted to 'RegionalPublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RegionalPublisherBuilder with() { + try { + return new RegionalPublisherBuilder(RegionalPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegionalPublisherBuilder.With' should only be implemented by classes, which could be casted to 'RegionalPublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegistryRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegistryRecordBuilder.java new file mode 100644 index 00000000..e8e6efd6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/RegistryRecordBuilder.java @@ -0,0 +1,566 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.RegistryRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.RegistryRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RegistryRecord result = RegistryRecordBuilder.create()
    + *     .registryName("example value")
    + *     .registryName("Hello %s", "World")
    + *     .registryName(() -> "example value")
    + *     .registryName(sb -> sb.append("text"))
    + *     .entriesCount(42L)
    + *     .entriesCount(() -> 42L)
    + *     .maintainedBy("example value")
    + *     .maintainedBy("Hello %s", "World")
    + *     .maintainedBy(() -> "example value")
    + *     .maintainedBy(sb -> sb.append("text"))
    + *     .lastUpdated(LocalDate.now())
    + *     .lastUpdated(() -> LocalDate.now())
    + *     .accessLevel("example value")
    + *     .accessLevel("Hello %s", "World")
    + *     .accessLevel(() -> "example value")
    + *     .accessLevel(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RegistryRecord.class) +public class RegistryRecordBuilder implements IBuilderBase { + + /** + * Tracked value for registryName: registryName. + */ + private TrackedValue registryName = unsetValue(); + /** + * Tracked value for entriesCount: entriesCount. + */ + private TrackedValue entriesCount = unsetValue(); + /** + * Tracked value for maintainedBy: maintainedBy. + */ + private TrackedValue maintainedBy = unsetValue(); + /** + * Tracked value for lastUpdated: lastUpdated. + */ + private TrackedValue lastUpdated = unsetValue(); + /** + * Tracked value for accessLevel: accessLevel. + */ + private TrackedValue accessLevel = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegistryRecord}. + */ + public RegistryRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegistryRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public RegistryRecordBuilder(RegistryRecord instance) { + this.registryName = initialValue(instance.registryName()); + this.entriesCount = initialValue(instance.entriesCount()); + this.maintainedBy = initialValue(instance.maintainedBy()); + this.lastUpdated = initialValue(instance.lastUpdated()); + this.accessLevel = initialValue(instance.accessLevel()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegistryRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RegistryRecordBuilder builder = RegistryRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.RegistryRecord} + */ + public static RegistryRecordBuilder create() { + return new RegistryRecordBuilder(); + } + + /** + * Sets the value for accessLevel. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel("example value");
    +   * }
    + * + * @param accessLevel accessLevel + * @return current instance of builder + */ + public RegistryRecordBuilder accessLevel(String accessLevel) { + this.accessLevel = changedValue(accessLevel); + return this; + } + + /** + * Sets the value for accessLevel by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param accessLevelStringBuilderConsumer consumer providing an instance of accessLevel + * @return current instance of builder + */ + public RegistryRecordBuilder accessLevel(Consumer accessLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + accessLevelStringBuilderConsumer.accept(builder); + this.accessLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for accessLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel(() -> "example value");
    +   * }
    + * + * @param accessLevelSupplier supplier for accessLevel + * @return current instance of builder + */ + public RegistryRecordBuilder accessLevel(Supplier accessLevelSupplier) { + this.accessLevel = changedValue(accessLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for accessLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegistryRecordBuilder accessLevel(String format, Object... args) { + this.accessLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for entriesCount. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.entriesCount(42L);
    +   * }
    + * + * @param entriesCount entriesCount + * @return current instance of builder + */ + public RegistryRecordBuilder entriesCount(long entriesCount) { + this.entriesCount = changedValue(entriesCount); + return this; + } + + /** + * Sets the value for entriesCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.entriesCount(() -> 42L);
    +   * }
    + * + * @param entriesCountSupplier supplier for entriesCount + * @return current instance of builder + */ + public RegistryRecordBuilder entriesCount(Supplier entriesCountSupplier) { + this.entriesCount = changedValue(entriesCountSupplier.get()); + return this; + } + + /** + * Sets the value for lastUpdated. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lastUpdated(LocalDate.now());
    +   * }
    + * + * @param lastUpdated lastUpdated + * @return current instance of builder + */ + public RegistryRecordBuilder lastUpdated(LocalDate lastUpdated) { + this.lastUpdated = changedValue(lastUpdated); + return this; + } + + /** + * Sets the value for lastUpdated by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.lastUpdated(() -> LocalDate.now());
    +   * }
    + * + * @param lastUpdatedSupplier supplier for lastUpdated + * @return current instance of builder + */ + public RegistryRecordBuilder lastUpdated(Supplier lastUpdatedSupplier) { + this.lastUpdated = changedValue(lastUpdatedSupplier.get()); + return this; + } + + /** + * Sets the value for maintainedBy. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.maintainedBy("example value");
    +   * }
    + * + * @param maintainedBy maintainedBy + * @return current instance of builder + */ + public RegistryRecordBuilder maintainedBy(String maintainedBy) { + this.maintainedBy = changedValue(maintainedBy); + return this; + } + + /** + * Sets the value for maintainedBy by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.maintainedBy(sb -> sb.append("text"));
    +   * }
    + * + * @param maintainedByStringBuilderConsumer consumer providing an instance of maintainedBy + * @return current instance of builder + */ + public RegistryRecordBuilder maintainedBy(Consumer maintainedByStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + maintainedByStringBuilderConsumer.accept(builder); + this.maintainedBy = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for maintainedBy by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.maintainedBy(() -> "example value");
    +   * }
    + * + * @param maintainedBySupplier supplier for maintainedBy + * @return current instance of builder + */ + public RegistryRecordBuilder maintainedBy(Supplier maintainedBySupplier) { + this.maintainedBy = changedValue(maintainedBySupplier.get()); + return this; + } + + /** + * Sets the String value for maintainedBy by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.maintainedBy("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegistryRecordBuilder maintainedBy(String format, Object... args) { + this.maintainedBy = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for registryName. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registryName("example value");
    +   * }
    + * + * @param registryName registryName + * @return current instance of builder + */ + public RegistryRecordBuilder registryName(String registryName) { + this.registryName = changedValue(registryName); + return this; + } + + /** + * Sets the value for registryName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registryName(sb -> sb.append("text"));
    +   * }
    + * + * @param registryNameStringBuilderConsumer consumer providing an instance of registryName + * @return current instance of builder + */ + public RegistryRecordBuilder registryName(Consumer registryNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + registryNameStringBuilderConsumer.accept(builder); + this.registryName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for registryName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registryName(() -> "example value");
    +   * }
    + * + * @param registryNameSupplier supplier for registryName + * @return current instance of builder + */ + public RegistryRecordBuilder registryName(Supplier registryNameSupplier) { + this.registryName = changedValue(registryNameSupplier.get()); + return this; + } + + /** + * Sets the String value for registryName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link RegistryRecord#RegistryRecord(String, long, String, LocalDate, String) RegistryRecord(String registryName, + * long entriesCount, String maintainedBy, LocalDate lastUpdated, String accessLevel)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registryName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RegistryRecordBuilder registryName(String format, Object... args) { + this.registryName = changedValue(String.format(format, args)); + 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 RegistryRecordBuilder 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 RegistryRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RegistryRecord result = builder.build();
    +   * }
    + */ + @Override + public RegistryRecord build() { + if (!this.entriesCount.isSet()) { + throw new IllegalStateException("Required field 'entriesCount' must be set before calling build()"); + } + if (this.entriesCount.value() == null) { + throw new IllegalStateException("Field 'entriesCount' is marked as non-null but null value was provided"); + } + RegistryRecord result = new RegistryRecord(this.registryName.value(), + this.entriesCount.value(), + this.maintainedBy.value(), + this.lastUpdated.value(), + this.accessLevel.value()); + 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("registryName", this.registryName) + .append("entriesCount", this.entriesCount) + .append("maintainedBy", this.maintainedBy) + .append("lastUpdated", this.lastUpdated) + .append("accessLevel", this.accessLevel) + .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 RegistryRecord with(Consumer b) { + RegistryRecordBuilder builder; + try { + builder = new RegistryRecordBuilder(RegistryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegistryRecordBuilder.With' should only be implemented by classes, which could be casted to 'RegistryRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RegistryRecordBuilder with() { + try { + return new RegistryRecordBuilder(RegistryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RegistryRecordBuilder.With' should only be implemented by classes, which could be casted to 'RegistryRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchAssociationBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchAssociationBuilder.java new file mode 100644 index 00000000..a527c5bc --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchAssociationBuilder.java @@ -0,0 +1,717 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.ResearchAssociation}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchAssociation 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchAssociation result = ResearchAssociationBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .grantsAwarded(42)
    + *     .grantsAwarded(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .researchAreas(List.of("example value"))
    + *     .researchAreas(() -> List.of("example value"))
    + *     .researchAreas(t -> t.add("example value"))
    + *     .researchAreas("example value", "example value")
    + *     .add2ResearchAreas("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchAssociation.class) +public class ResearchAssociationBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for grantsAwarded: grantsAwarded. + */ + private TrackedValue grantsAwarded = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for researchAreas: researchAreas. + */ + private TrackedValue> researchAreas = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchAssociation}. + */ + public ResearchAssociationBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchAssociation} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearchAssociationBuilder(ResearchAssociation instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.grantsAwarded = initialValue(instance.getGrantsAwarded()); + this.id = initialValue(instance.getId()); + this.memberCount = initialValue(instance.getMemberCount()); + this.name = initialValue(instance.getName()); + this.researchAreas = initialValue(instance.getResearchAreas()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchAssociation}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchAssociationBuilder builder = ResearchAssociationBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchAssociation} + */ + public static ResearchAssociationBuilder create() { + return new ResearchAssociationBuilder(); + } + + /** + * Adds a single element to researchAreas. + *

    + * Generated from setter {@link ResearchAssociation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ResearchAreas("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ResearchAssociationBuilder add2ResearchAreas(String element) { + List newCollection; + if (this.researchAreas.isSet()) { + newCollection = new ArrayList<>(this.researchAreas.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.researchAreas = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResearchAssociation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResearchAssociationBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResearchAssociationBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResearchAssociation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchAssociationBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchAssociationBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for grantsAwarded. + *

    + * Generated from setter {@link ResearchAssociation#setGrantsAwarded(int) setGrantsAwarded(int grantsAwarded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.grantsAwarded(42);
    +   * }
    + * + * @param grantsAwarded grantsAwarded + * @return current instance of builder + */ + public ResearchAssociationBuilder grantsAwarded(int grantsAwarded) { + this.grantsAwarded = changedValue(grantsAwarded); + return this; + } + + /** + * Sets the value for grantsAwarded by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setGrantsAwarded(int) setGrantsAwarded(int grantsAwarded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.grantsAwarded(() -> 42);
    +   * }
    + * + * @param grantsAwardedSupplier supplier for grantsAwarded + * @return current instance of builder + */ + public ResearchAssociationBuilder grantsAwarded(Supplier grantsAwardedSupplier) { + this.grantsAwarded = changedValue(grantsAwardedSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResearchAssociation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResearchAssociationBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResearchAssociationBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from setter {@link ResearchAssociation#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public ResearchAssociationBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public ResearchAssociationBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResearchAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResearchAssociationBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResearchAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResearchAssociationBuilder 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. + *

    + * Generated from setter {@link ResearchAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResearchAssociationBuilder 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. + *

    + * Generated from setter {@link ResearchAssociation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchAssociationBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researchAreas. + *

    + * Generated from setter {@link ResearchAssociation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas("example value", "example value");
    +   * }
    + * + * @param researchAreas researchAreas + * @return current instance of builder + */ + public ResearchAssociationBuilder researchAreas(String... researchAreas) { + this.researchAreas = changedValue(List.of(researchAreas)); + return this; + } + + /** + * Sets the value for researchAreas. + *

    + * Generated from setter {@link ResearchAssociation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(List.of("example value"));
    +   * }
    + * + * @param researchAreas researchAreas + * @return current instance of builder + */ + public ResearchAssociationBuilder researchAreas(List researchAreas) { + this.researchAreas = changedValue(researchAreas); + return this; + } + + /** + * Sets the value for researchAreas using a builder consumer that produces the value. + *

    + * Generated from setter {@link ResearchAssociation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(t -> t.add("example value"));
    +   * }
    + * + * @param researchAreasBuilderConsumer consumer providing an instance of a builder for researchAreas + * @return current instance of builder + */ + public ResearchAssociationBuilder researchAreas(Consumer> researchAreasBuilderConsumer) { + ArrayListBuilder builder = this.researchAreas.isSet() + ? new ArrayListBuilder(this.researchAreas.value()) + : new ArrayListBuilder(); + researchAreasBuilderConsumer.accept(builder); + this.researchAreas = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for researchAreas by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(() -> List.of("example value"));
    +   * }
    + * + * @param researchAreasSupplier supplier for researchAreas + * @return current instance of builder + */ + public ResearchAssociationBuilder researchAreas(Supplier> researchAreasSupplier) { + this.researchAreas = changedValue(researchAreasSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResearchAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResearchAssociationBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResearchAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResearchAssociationBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResearchAssociationBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchAssociation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchAssociationBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ResearchAssociationBuilder 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 ResearchAssociationBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchAssociation result = builder.build();
    +   * }
    + */ + @Override + public ResearchAssociation build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.grantsAwarded.isSet() && this.grantsAwarded.value() == null) { + throw new IllegalStateException("Field 'grantsAwarded' is marked as non-null but null value was provided"); + } + if (this.memberCount.isSet() && this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + ResearchAssociation result = new ResearchAssociation(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.grantsAwarded.ifSet(result::setGrantsAwarded); + this.id.ifSet(result::setId); + this.memberCount.ifSet(result::setMemberCount); + this.name.ifSet(result::setName); + this.researchAreas.ifSet(result::setResearchAreas); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("grantsAwarded", this.grantsAwarded) + .append("id", this.id) + .append("memberCount", this.memberCount) + .append("name", this.name) + .append("researchAreas", this.researchAreas) + .append("status", this.status) + .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 ResearchAssociation with(Consumer b) { + ResearchAssociationBuilder builder; + try { + builder = new ResearchAssociationBuilder(ResearchAssociation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchAssociationBuilder.With' should only be implemented by classes, which could be casted to 'ResearchAssociation'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchAssociationBuilder with() { + try { + return new ResearchAssociationBuilder(ResearchAssociation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchAssociationBuilder.With' should only be implemented by classes, which could be casted to 'ResearchAssociation'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchConsortiumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchConsortiumBuilder.java new file mode 100644 index 00000000..db42bc54 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchConsortiumBuilder.java @@ -0,0 +1,719 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.ResearchConsortium}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchConsortium 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchConsortium result = ResearchConsortiumBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .jointProjects(42)
    + *     .jointProjects(() -> 42)
    + *     .memberInstitutions(42)
    + *     .memberInstitutions(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .sharedResources(List.of("example value"))
    + *     .sharedResources(() -> List.of("example value"))
    + *     .sharedResources(t -> t.add("example value"))
    + *     .sharedResources("example value", "example value")
    + *     .add2SharedResources("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchConsortium.class) +public class ResearchConsortiumBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for jointProjects: jointProjects. + */ + private TrackedValue jointProjects = unsetValue(); + /** + * Tracked value for memberInstitutions: memberInstitutions. + */ + private TrackedValue memberInstitutions = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for sharedResources: sharedResources. + */ + private TrackedValue> sharedResources = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchConsortium}. + */ + public ResearchConsortiumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchConsortium} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearchConsortiumBuilder(ResearchConsortium instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.jointProjects = initialValue(instance.getJointProjects()); + this.memberInstitutions = initialValue(instance.getMemberInstitutions()); + this.name = initialValue(instance.getName()); + this.sharedResources = initialValue(instance.getSharedResources()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchConsortium}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchConsortiumBuilder builder = ResearchConsortiumBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchConsortium} + */ + public static ResearchConsortiumBuilder create() { + return new ResearchConsortiumBuilder(); + } + + /** + * Adds a single element to sharedResources. + *

    + * Generated from setter {@link ResearchConsortium#setSharedResources(List) setSharedResources(List + * sharedResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2SharedResources("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ResearchConsortiumBuilder add2SharedResources(String element) { + List newCollection; + if (this.sharedResources.isSet()) { + newCollection = new ArrayList<>(this.sharedResources.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.sharedResources = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResearchConsortium#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResearchConsortiumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResearchConsortiumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResearchConsortium#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchConsortiumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchConsortiumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResearchConsortium#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResearchConsortiumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResearchConsortiumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for jointProjects. + *

    + * Generated from setter {@link ResearchConsortium#setJointProjects(int) setJointProjects(int jointProjects)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jointProjects(42);
    +   * }
    + * + * @param jointProjects jointProjects + * @return current instance of builder + */ + public ResearchConsortiumBuilder jointProjects(int jointProjects) { + this.jointProjects = changedValue(jointProjects); + return this; + } + + /** + * Sets the value for jointProjects by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setJointProjects(int) setJointProjects(int jointProjects)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.jointProjects(() -> 42);
    +   * }
    + * + * @param jointProjectsSupplier supplier for jointProjects + * @return current instance of builder + */ + public ResearchConsortiumBuilder jointProjects(Supplier jointProjectsSupplier) { + this.jointProjects = changedValue(jointProjectsSupplier.get()); + return this; + } + + /** + * Sets the value for memberInstitutions. + *

    + * Generated from setter {@link ResearchConsortium#setMemberInstitutions(int) setMemberInstitutions(int + * memberInstitutions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberInstitutions(42);
    +   * }
    + * + * @param memberInstitutions memberInstitutions + * @return current instance of builder + */ + public ResearchConsortiumBuilder memberInstitutions(int memberInstitutions) { + this.memberInstitutions = changedValue(memberInstitutions); + return this; + } + + /** + * Sets the value for memberInstitutions by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setMemberInstitutions(int) setMemberInstitutions(int + * memberInstitutions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberInstitutions(() -> 42);
    +   * }
    + * + * @param memberInstitutionsSupplier supplier for memberInstitutions + * @return current instance of builder + */ + public ResearchConsortiumBuilder memberInstitutions(Supplier memberInstitutionsSupplier) { + this.memberInstitutions = changedValue(memberInstitutionsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResearchConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResearchConsortiumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResearchConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResearchConsortiumBuilder 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. + *

    + * Generated from setter {@link ResearchConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResearchConsortiumBuilder 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. + *

    + * Generated from setter {@link ResearchConsortium#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchConsortiumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sharedResources. + *

    + * Generated from setter {@link ResearchConsortium#setSharedResources(List) setSharedResources(List + * sharedResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sharedResources("example value", "example value");
    +   * }
    + * + * @param sharedResources sharedResources + * @return current instance of builder + */ + public ResearchConsortiumBuilder sharedResources(String... sharedResources) { + this.sharedResources = changedValue(List.of(sharedResources)); + return this; + } + + /** + * Sets the value for sharedResources. + *

    + * Generated from setter {@link ResearchConsortium#setSharedResources(List) setSharedResources(List + * sharedResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sharedResources(List.of("example value"));
    +   * }
    + * + * @param sharedResources sharedResources + * @return current instance of builder + */ + public ResearchConsortiumBuilder sharedResources(List sharedResources) { + this.sharedResources = changedValue(sharedResources); + return this; + } + + /** + * Sets the value for sharedResources using a builder consumer that produces the value. + *

    + * Generated from setter {@link ResearchConsortium#setSharedResources(List) setSharedResources(List + * sharedResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sharedResources(t -> t.add("example value"));
    +   * }
    + * + * @param sharedResourcesBuilderConsumer consumer providing an instance of a builder for sharedResources + * @return current instance of builder + */ + public ResearchConsortiumBuilder sharedResources(Consumer> sharedResourcesBuilderConsumer) { + ArrayListBuilder builder = this.sharedResources.isSet() + ? new ArrayListBuilder(this.sharedResources.value()) + : new ArrayListBuilder(); + sharedResourcesBuilderConsumer.accept(builder); + this.sharedResources = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for sharedResources by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setSharedResources(List) setSharedResources(List + * sharedResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sharedResources(() -> List.of("example value"));
    +   * }
    + * + * @param sharedResourcesSupplier supplier for sharedResources + * @return current instance of builder + */ + public ResearchConsortiumBuilder sharedResources(Supplier> sharedResourcesSupplier) { + this.sharedResources = changedValue(sharedResourcesSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResearchConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResearchConsortiumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResearchConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResearchConsortiumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResearchConsortiumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchConsortium#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchConsortiumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ResearchConsortiumBuilder 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 ResearchConsortiumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchConsortium result = builder.build();
    +   * }
    + */ + @Override + public ResearchConsortium build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.jointProjects.isSet() && this.jointProjects.value() == null) { + throw new IllegalStateException("Field 'jointProjects' is marked as non-null but null value was provided"); + } + if (this.memberInstitutions.isSet() && this.memberInstitutions.value() == null) { + throw new IllegalStateException("Field 'memberInstitutions' is marked as non-null but null value was provided"); + } + ResearchConsortium result = new ResearchConsortium(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.jointProjects.ifSet(result::setJointProjects); + this.memberInstitutions.ifSet(result::setMemberInstitutions); + this.name.ifSet(result::setName); + this.sharedResources.ifSet(result::setSharedResources); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("jointProjects", this.jointProjects) + .append("memberInstitutions", this.memberInstitutions) + .append("name", this.name) + .append("sharedResources", this.sharedResources) + .append("status", this.status) + .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 ResearchConsortium with(Consumer b) { + ResearchConsortiumBuilder builder; + try { + builder = new ResearchConsortiumBuilder(ResearchConsortium.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchConsortiumBuilder.With' should only be implemented by classes, which could be casted to 'ResearchConsortium'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchConsortiumBuilder with() { + try { + return new ResearchConsortiumBuilder(ResearchConsortium.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchConsortiumBuilder.With' should only be implemented by classes, which could be casted to 'ResearchConsortium'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchFoundationBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchFoundationBuilder.java new file mode 100644 index 00000000..423b640d --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchFoundationBuilder.java @@ -0,0 +1,715 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.ResearchFoundation}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchFoundation 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchFoundation result = ResearchFoundationBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .researchAreas(List.of("example value"))
    + *     .researchAreas(() -> List.of("example value"))
    + *     .researchAreas(t -> t.add("example value"))
    + *     .researchAreas("example value", "example value")
    + *     .add2ResearchAreas("example value")
    + *     .researchGrants(42)
    + *     .researchGrants(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalAssets(BigDecimal.valueOf(3.14))
    + *     .totalAssets(() -> BigDecimal.valueOf(3.14))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchFoundation.class) +public class ResearchFoundationBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for researchAreas: researchAreas. + */ + private TrackedValue> researchAreas = unsetValue(); + /** + * Tracked value for researchGrants: researchGrants. + */ + private TrackedValue researchGrants = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalAssets: totalAssets. + */ + private TrackedValue totalAssets = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchFoundation}. + */ + public ResearchFoundationBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchFoundation} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearchFoundationBuilder(ResearchFoundation instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.researchAreas = initialValue(instance.getResearchAreas()); + this.researchGrants = initialValue(instance.getResearchGrants()); + this.status = initialValue(instance.getStatus()); + this.totalAssets = initialValue(instance.getTotalAssets()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchFoundation}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchFoundationBuilder builder = ResearchFoundationBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchFoundation} + */ + public static ResearchFoundationBuilder create() { + return new ResearchFoundationBuilder(); + } + + /** + * Adds a single element to researchAreas. + *

    + * Generated from setter {@link ResearchFoundation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ResearchAreas("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ResearchFoundationBuilder add2ResearchAreas(String element) { + List newCollection; + if (this.researchAreas.isSet()) { + newCollection = new ArrayList<>(this.researchAreas.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.researchAreas = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResearchFoundation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResearchFoundationBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResearchFoundationBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResearchFoundation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchFoundationBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchFoundationBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResearchFoundation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResearchFoundationBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResearchFoundationBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResearchFoundation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResearchFoundationBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResearchFoundation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResearchFoundationBuilder 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. + *

    + * Generated from setter {@link ResearchFoundation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResearchFoundationBuilder 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. + *

    + * Generated from setter {@link ResearchFoundation#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchFoundationBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researchAreas. + *

    + * Generated from setter {@link ResearchFoundation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas("example value", "example value");
    +   * }
    + * + * @param researchAreas researchAreas + * @return current instance of builder + */ + public ResearchFoundationBuilder researchAreas(String... researchAreas) { + this.researchAreas = changedValue(List.of(researchAreas)); + return this; + } + + /** + * Sets the value for researchAreas. + *

    + * Generated from setter {@link ResearchFoundation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(List.of("example value"));
    +   * }
    + * + * @param researchAreas researchAreas + * @return current instance of builder + */ + public ResearchFoundationBuilder researchAreas(List researchAreas) { + this.researchAreas = changedValue(researchAreas); + return this; + } + + /** + * Sets the value for researchAreas using a builder consumer that produces the value. + *

    + * Generated from setter {@link ResearchFoundation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(t -> t.add("example value"));
    +   * }
    + * + * @param researchAreasBuilderConsumer consumer providing an instance of a builder for researchAreas + * @return current instance of builder + */ + public ResearchFoundationBuilder researchAreas(Consumer> researchAreasBuilderConsumer) { + ArrayListBuilder builder = this.researchAreas.isSet() + ? new ArrayListBuilder(this.researchAreas.value()) + : new ArrayListBuilder(); + researchAreasBuilderConsumer.accept(builder); + this.researchAreas = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for researchAreas by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setResearchAreas(List) setResearchAreas(List + * researchAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchAreas(() -> List.of("example value"));
    +   * }
    + * + * @param researchAreasSupplier supplier for researchAreas + * @return current instance of builder + */ + public ResearchFoundationBuilder researchAreas(Supplier> researchAreasSupplier) { + this.researchAreas = changedValue(researchAreasSupplier.get()); + return this; + } + + /** + * Sets the value for researchGrants. + *

    + * Generated from setter {@link ResearchFoundation#setResearchGrants(int) setResearchGrants(int researchGrants)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchGrants(42);
    +   * }
    + * + * @param researchGrants researchGrants + * @return current instance of builder + */ + public ResearchFoundationBuilder researchGrants(int researchGrants) { + this.researchGrants = changedValue(researchGrants); + return this; + } + + /** + * Sets the value for researchGrants by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setResearchGrants(int) setResearchGrants(int researchGrants)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchGrants(() -> 42);
    +   * }
    + * + * @param researchGrantsSupplier supplier for researchGrants + * @return current instance of builder + */ + public ResearchFoundationBuilder researchGrants(Supplier researchGrantsSupplier) { + this.researchGrants = changedValue(researchGrantsSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResearchFoundation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResearchFoundationBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResearchFoundation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResearchFoundationBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResearchFoundationBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchFoundation#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchFoundationBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalAssets. + *

    + * Generated from setter {@link ResearchFoundation#setTotalAssets(BigDecimal) setTotalAssets(BigDecimal totalAssets)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalAssets(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalAssets totalAssets + * @return current instance of builder + */ + public ResearchFoundationBuilder totalAssets(BigDecimal totalAssets) { + this.totalAssets = changedValue(totalAssets); + return this; + } + + /** + * Sets the value for totalAssets by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchFoundation#setTotalAssets(BigDecimal) setTotalAssets(BigDecimal totalAssets)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalAssets(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalAssetsSupplier supplier for totalAssets + * @return current instance of builder + */ + public ResearchFoundationBuilder totalAssets(Supplier totalAssetsSupplier) { + this.totalAssets = changedValue(totalAssetsSupplier.get()); + 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 ResearchFoundationBuilder 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 ResearchFoundationBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchFoundation result = builder.build();
    +   * }
    + */ + @Override + public ResearchFoundation build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.researchGrants.isSet() && this.researchGrants.value() == null) { + throw new IllegalStateException("Field 'researchGrants' is marked as non-null but null value was provided"); + } + ResearchFoundation result = new ResearchFoundation(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.researchAreas.ifSet(result::setResearchAreas); + this.researchGrants.ifSet(result::setResearchGrants); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalAssets.ifSet(result::setTotalAssets); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("researchAreas", this.researchAreas) + .append("researchGrants", this.researchGrants) + .append("status", this.status) + .append("totalAssets", this.totalAssets) + .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 ResearchFoundation with(Consumer b) { + ResearchFoundationBuilder builder; + try { + builder = new ResearchFoundationBuilder(ResearchFoundation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchFoundationBuilder.With' should only be implemented by classes, which could be casted to 'ResearchFoundation'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchFoundationBuilder with() { + try { + return new ResearchFoundationBuilder(ResearchFoundation.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchFoundationBuilder.With' should only be implemented by classes, which could be casted to 'ResearchFoundation'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteBuilder.java new file mode 100644 index 00000000..d666f178 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteBuilder.java @@ -0,0 +1,717 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.ResearchInstitute}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstitute 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchInstitute result = ResearchInstituteBuilder.create()
    + *     .annualBudget(BigDecimal.valueOf(3.14))
    + *     .annualBudget(() -> BigDecimal.valueOf(3.14))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .researchFields(List.of("example value"))
    + *     .researchFields(() -> List.of("example value"))
    + *     .researchFields(t -> t.add("example value"))
    + *     .researchFields("example value", "example value")
    + *     .add2ResearchFields("example value")
    + *     .researcherCount(42)
    + *     .researcherCount(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchInstitute.class) +public class ResearchInstituteBuilder implements IBuilderBase { + + /** + * Tracked value for annualBudget: annualBudget. + */ + private TrackedValue annualBudget = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for researchFields: researchFields. + */ + private TrackedValue> researchFields = unsetValue(); + /** + * Tracked value for researcherCount: researcherCount. + */ + private TrackedValue researcherCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstitute}. + */ + public ResearchInstituteBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstitute} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearchInstituteBuilder(ResearchInstitute instance) { + this.annualBudget = initialValue(instance.getAnnualBudget()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.researchFields = initialValue(instance.getResearchFields()); + this.researcherCount = initialValue(instance.getResearcherCount()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstitute}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchInstituteBuilder builder = ResearchInstituteBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstitute} + */ + public static ResearchInstituteBuilder create() { + return new ResearchInstituteBuilder(); + } + + /** + * Adds a single element to researchFields. + *

    + * Generated from setter {@link ResearchInstitute#setResearchFields(List) setResearchFields(List + * researchFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ResearchFields("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ResearchInstituteBuilder add2ResearchFields(String element) { + List newCollection; + if (this.researchFields.isSet()) { + newCollection = new ArrayList<>(this.researchFields.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.researchFields = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualBudget. + *

    + * Generated from setter {@link ResearchInstitute#setAnnualBudget(BigDecimal) setAnnualBudget(BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualBudget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualBudget annualBudget + * @return current instance of builder + */ + public ResearchInstituteBuilder annualBudget(BigDecimal annualBudget) { + this.annualBudget = changedValue(annualBudget); + return this; + } + + /** + * Sets the value for annualBudget by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setAnnualBudget(BigDecimal) setAnnualBudget(BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualBudget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualBudgetSupplier supplier for annualBudget + * @return current instance of builder + */ + public ResearchInstituteBuilder annualBudget(Supplier annualBudgetSupplier) { + this.annualBudget = changedValue(annualBudgetSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResearchInstitute#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResearchInstituteBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResearchInstituteBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResearchInstitute#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchInstituteBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchInstituteBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResearchInstitute#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResearchInstituteBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResearchInstituteBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResearchInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResearchInstituteBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResearchInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResearchInstituteBuilder 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. + *

    + * Generated from setter {@link ResearchInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResearchInstituteBuilder 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. + *

    + * Generated from setter {@link ResearchInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchInstituteBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researchFields. + *

    + * Generated from setter {@link ResearchInstitute#setResearchFields(List) setResearchFields(List + * researchFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchFields("example value", "example value");
    +   * }
    + * + * @param researchFields researchFields + * @return current instance of builder + */ + public ResearchInstituteBuilder researchFields(String... researchFields) { + this.researchFields = changedValue(List.of(researchFields)); + return this; + } + + /** + * Sets the value for researchFields. + *

    + * Generated from setter {@link ResearchInstitute#setResearchFields(List) setResearchFields(List + * researchFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchFields(List.of("example value"));
    +   * }
    + * + * @param researchFields researchFields + * @return current instance of builder + */ + public ResearchInstituteBuilder researchFields(List researchFields) { + this.researchFields = changedValue(researchFields); + return this; + } + + /** + * Sets the value for researchFields using a builder consumer that produces the value. + *

    + * Generated from setter {@link ResearchInstitute#setResearchFields(List) setResearchFields(List + * researchFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchFields(t -> t.add("example value"));
    +   * }
    + * + * @param researchFieldsBuilderConsumer consumer providing an instance of a builder for researchFields + * @return current instance of builder + */ + public ResearchInstituteBuilder researchFields(Consumer> researchFieldsBuilderConsumer) { + ArrayListBuilder builder = this.researchFields.isSet() + ? new ArrayListBuilder(this.researchFields.value()) + : new ArrayListBuilder(); + researchFieldsBuilderConsumer.accept(builder); + this.researchFields = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for researchFields by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setResearchFields(List) setResearchFields(List + * researchFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchFields(() -> List.of("example value"));
    +   * }
    + * + * @param researchFieldsSupplier supplier for researchFields + * @return current instance of builder + */ + public ResearchInstituteBuilder researchFields(Supplier> researchFieldsSupplier) { + this.researchFields = changedValue(researchFieldsSupplier.get()); + return this; + } + + /** + * Sets the value for researcherCount. + *

    + * Generated from setter {@link ResearchInstitute#setResearcherCount(int) setResearcherCount(int researcherCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherCount(42);
    +   * }
    + * + * @param researcherCount researcherCount + * @return current instance of builder + */ + public ResearchInstituteBuilder researcherCount(int researcherCount) { + this.researcherCount = changedValue(researcherCount); + return this; + } + + /** + * Sets the value for researcherCount by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setResearcherCount(int) setResearcherCount(int researcherCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherCount(() -> 42);
    +   * }
    + * + * @param researcherCountSupplier supplier for researcherCount + * @return current instance of builder + */ + public ResearchInstituteBuilder researcherCount(Supplier researcherCountSupplier) { + this.researcherCount = changedValue(researcherCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResearchInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResearchInstituteBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResearchInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResearchInstituteBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResearchInstituteBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchInstituteBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ResearchInstituteBuilder 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 ResearchInstituteBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchInstitute result = builder.build();
    +   * }
    + */ + @Override + public ResearchInstitute build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.researcherCount.isSet() && this.researcherCount.value() == null) { + throw new IllegalStateException("Field 'researcherCount' is marked as non-null but null value was provided"); + } + ResearchInstitute result = new ResearchInstitute(); + this.annualBudget.ifSet(result::setAnnualBudget); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.researchFields.ifSet(result::setResearchFields); + this.researcherCount.ifSet(result::setResearcherCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualBudget", this.annualBudget) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("researchFields", this.researchFields) + .append("researcherCount", this.researcherCount) + .append("status", this.status) + .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 ResearchInstitute with(Consumer b) { + ResearchInstituteBuilder builder; + try { + builder = new ResearchInstituteBuilder(ResearchInstitute.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchInstituteBuilder.With' should only be implemented by classes, which could be casted to 'ResearchInstitute'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchInstituteBuilder with() { + try { + return new ResearchInstituteBuilder(ResearchInstitute.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchInstituteBuilder.With' should only be implemented by classes, which could be casted to 'ResearchInstitute'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteRecordBuilder.java new file mode 100644 index 00000000..db84c86c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchInstituteRecordBuilder.java @@ -0,0 +1,541 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +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.performance_test.library.organizations.ResearchInstituteRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstituteRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchInstituteRecord result = ResearchInstituteRecordBuilder.create()
    + *     .instituteName("example value")
    + *     .instituteName("Hello %s", "World")
    + *     .instituteName(() -> "example value")
    + *     .instituteName(sb -> sb.append("text"))
    + *     .researchArea("example value")
    + *     .researchArea("Hello %s", "World")
    + *     .researchArea(() -> "example value")
    + *     .researchArea(sb -> sb.append("text"))
    + *     .staffCount(42)
    + *     .staffCount(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .annualBudget(BigDecimal.valueOf(3.14))
    + *     .annualBudget(() -> BigDecimal.valueOf(3.14))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchInstituteRecord.class) +public class ResearchInstituteRecordBuilder implements IBuilderBase { + + /** + * Tracked value for instituteName: instituteName. + */ + private TrackedValue instituteName = unsetValue(); + /** + * Tracked value for researchArea: researchArea. + */ + private TrackedValue researchArea = unsetValue(); + /** + * Tracked value for staffCount: staffCount. + */ + private TrackedValue staffCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for annualBudget: annualBudget. + */ + private TrackedValue annualBudget = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstituteRecord}. + */ + public ResearchInstituteRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstituteRecord} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public ResearchInstituteRecordBuilder(ResearchInstituteRecord instance) { + this.instituteName = initialValue(instance.instituteName()); + this.researchArea = initialValue(instance.researchArea()); + this.staffCount = initialValue(instance.staffCount()); + this.foundedYear = initialValue(instance.foundedYear()); + this.annualBudget = initialValue(instance.annualBudget()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstituteRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchInstituteRecordBuilder builder = ResearchInstituteRecordBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchInstituteRecord} + */ + public static ResearchInstituteRecordBuilder create() { + return new ResearchInstituteRecordBuilder(); + } + + /** + * Sets the value for annualBudget. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualBudget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualBudget annualBudget + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder annualBudget(BigDecimal annualBudget) { + this.annualBudget = changedValue(annualBudget); + return this; + } + + /** + * Sets the value for annualBudget by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualBudget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualBudgetSupplier supplier for annualBudget + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder annualBudget(Supplier annualBudgetSupplier) { + this.annualBudget = changedValue(annualBudgetSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for instituteName. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instituteName("example value");
    +   * }
    + * + * @param instituteName instituteName + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder instituteName(String instituteName) { + this.instituteName = changedValue(instituteName); + return this; + } + + /** + * Sets the value for instituteName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instituteName(sb -> sb.append("text"));
    +   * }
    + * + * @param instituteNameStringBuilderConsumer consumer providing an instance of instituteName + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder instituteName(Consumer instituteNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + instituteNameStringBuilderConsumer.accept(builder); + this.instituteName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for instituteName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instituteName(() -> "example value");
    +   * }
    + * + * @param instituteNameSupplier supplier for instituteName + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder instituteName(Supplier instituteNameSupplier) { + this.instituteName = changedValue(instituteNameSupplier.get()); + return this; + } + + /** + * Sets the String value for instituteName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.instituteName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder instituteName(String format, Object... args) { + this.instituteName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researchArea. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchArea("example value");
    +   * }
    + * + * @param researchArea researchArea + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder researchArea(String researchArea) { + this.researchArea = changedValue(researchArea); + return this; + } + + /** + * Sets the value for researchArea by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchArea(sb -> sb.append("text"));
    +   * }
    + * + * @param researchAreaStringBuilderConsumer consumer providing an instance of researchArea + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder researchArea(Consumer researchAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + researchAreaStringBuilderConsumer.accept(builder); + this.researchArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for researchArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchArea(() -> "example value");
    +   * }
    + * + * @param researchAreaSupplier supplier for researchArea + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder researchArea(Supplier researchAreaSupplier) { + this.researchArea = changedValue(researchAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for researchArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder researchArea(String format, Object... args) { + this.researchArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for staffCount. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(42);
    +   * }
    + * + * @param staffCount staffCount + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder staffCount(int staffCount) { + this.staffCount = changedValue(staffCount); + return this; + } + + /** + * Sets the value for staffCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ResearchInstituteRecord#ResearchInstituteRecord(String, String, int, int, BigDecimal) + * ResearchInstituteRecord(String instituteName, String researchArea, int staffCount, int foundedYear, BigDecimal + * annualBudget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(() -> 42);
    +   * }
    + * + * @param staffCountSupplier supplier for staffCount + * @return current instance of builder + */ + public ResearchInstituteRecordBuilder staffCount(Supplier staffCountSupplier) { + this.staffCount = changedValue(staffCountSupplier.get()); + 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 ResearchInstituteRecordBuilder 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 ResearchInstituteRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchInstituteRecord result = builder.build();
    +   * }
    + */ + @Override + public ResearchInstituteRecord build() { + if (!this.staffCount.isSet()) { + throw new IllegalStateException("Required field 'staffCount' must be set before calling build()"); + } + if (this.staffCount.value() == null) { + throw new IllegalStateException("Field 'staffCount' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + ResearchInstituteRecord result = new ResearchInstituteRecord(this.instituteName.value(), + this.researchArea.value(), + this.staffCount.value(), + this.foundedYear.value(), + this.annualBudget.value()); + 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("instituteName", this.instituteName) + .append("researchArea", this.researchArea) + .append("staffCount", this.staffCount) + .append("foundedYear", this.foundedYear) + .append("annualBudget", this.annualBudget) + .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 ResearchInstituteRecord with(Consumer b) { + ResearchInstituteRecordBuilder builder; + try { + builder = new ResearchInstituteRecordBuilder(ResearchInstituteRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchInstituteRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResearchInstituteRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchInstituteRecordBuilder with() { + try { + return new ResearchInstituteRecordBuilder(ResearchInstituteRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchInstituteRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResearchInstituteRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchLaboratoryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchLaboratoryBuilder.java new file mode 100644 index 00000000..2afe539d --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchLaboratoryBuilder.java @@ -0,0 +1,682 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.ResearchLaboratory}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchLaboratory 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchLaboratory result = ResearchLaboratoryBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .equipmentCount(42)
    + *     .equipmentCount(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .labType("example value")
    + *     .labType("Hello %s", "World")
    + *     .labType(() -> "example value")
    + *     .labType(sb -> sb.append("text"))
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .researcherCount(42)
    + *     .researcherCount(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchLaboratory.class) +public class ResearchLaboratoryBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for equipmentCount: equipmentCount. + */ + private TrackedValue equipmentCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for labType: labType. + */ + private TrackedValue labType = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for researcherCount: researcherCount. + */ + private TrackedValue researcherCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchLaboratory}. + */ + public ResearchLaboratoryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchLaboratory} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearchLaboratoryBuilder(ResearchLaboratory instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.equipmentCount = initialValue(instance.getEquipmentCount()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.labType = initialValue(instance.getLabType()); + this.name = initialValue(instance.getName()); + this.researcherCount = initialValue(instance.getResearcherCount()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchLaboratory}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchLaboratoryBuilder builder = ResearchLaboratoryBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchLaboratory} + */ + public static ResearchLaboratoryBuilder create() { + return new ResearchLaboratoryBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResearchLaboratory#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResearchLaboratoryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResearchLaboratoryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for equipmentCount. + *

    + * Generated from setter {@link ResearchLaboratory#setEquipmentCount(int) setEquipmentCount(int equipmentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.equipmentCount(42);
    +   * }
    + * + * @param equipmentCount equipmentCount + * @return current instance of builder + */ + public ResearchLaboratoryBuilder equipmentCount(int equipmentCount) { + this.equipmentCount = changedValue(equipmentCount); + return this; + } + + /** + * Sets the value for equipmentCount by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setEquipmentCount(int) setEquipmentCount(int equipmentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.equipmentCount(() -> 42);
    +   * }
    + * + * @param equipmentCountSupplier supplier for equipmentCount + * @return current instance of builder + */ + public ResearchLaboratoryBuilder equipmentCount(Supplier equipmentCountSupplier) { + this.equipmentCount = changedValue(equipmentCountSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResearchLaboratory#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchLaboratoryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchLaboratoryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResearchLaboratory#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResearchLaboratoryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResearchLaboratoryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for labType. + *

    + * Generated from setter {@link ResearchLaboratory#setLabType(String) setLabType(String labType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labType("example value");
    +   * }
    + * + * @param labType labType + * @return current instance of builder + */ + public ResearchLaboratoryBuilder labType(String labType) { + this.labType = changedValue(labType); + return this; + } + + /** + * Sets the value for labType by executing the provided consumer. + *

    + * Generated from setter {@link ResearchLaboratory#setLabType(String) setLabType(String labType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labType(sb -> sb.append("text"));
    +   * }
    + * + * @param labTypeStringBuilderConsumer consumer providing an instance of labType + * @return current instance of builder + */ + public ResearchLaboratoryBuilder labType(Consumer labTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + labTypeStringBuilderConsumer.accept(builder); + this.labType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for labType by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setLabType(String) setLabType(String labType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labType(() -> "example value");
    +   * }
    + * + * @param labTypeSupplier supplier for labType + * @return current instance of builder + */ + public ResearchLaboratoryBuilder labType(Supplier labTypeSupplier) { + this.labType = changedValue(labTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for labType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchLaboratory#setLabType(String) setLabType(String labType)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchLaboratoryBuilder labType(String format, Object... args) { + this.labType = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResearchLaboratory#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResearchLaboratoryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResearchLaboratory#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResearchLaboratoryBuilder 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. + *

    + * Generated from setter {@link ResearchLaboratory#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResearchLaboratoryBuilder 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. + *

    + * Generated from setter {@link ResearchLaboratory#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchLaboratoryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researcherCount. + *

    + * Generated from setter {@link ResearchLaboratory#setResearcherCount(int) setResearcherCount(int researcherCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherCount(42);
    +   * }
    + * + * @param researcherCount researcherCount + * @return current instance of builder + */ + public ResearchLaboratoryBuilder researcherCount(int researcherCount) { + this.researcherCount = changedValue(researcherCount); + return this; + } + + /** + * Sets the value for researcherCount by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setResearcherCount(int) setResearcherCount(int researcherCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherCount(() -> 42);
    +   * }
    + * + * @param researcherCountSupplier supplier for researcherCount + * @return current instance of builder + */ + public ResearchLaboratoryBuilder researcherCount(Supplier researcherCountSupplier) { + this.researcherCount = changedValue(researcherCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResearchLaboratory#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResearchLaboratoryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResearchLaboratory#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResearchLaboratoryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchLaboratory#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResearchLaboratoryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchLaboratory#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchLaboratoryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ResearchLaboratoryBuilder 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 ResearchLaboratoryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchLaboratory result = builder.build();
    +   * }
    + */ + @Override + public ResearchLaboratory build() { + if (this.equipmentCount.isSet() && this.equipmentCount.value() == null) { + throw new IllegalStateException("Field 'equipmentCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.researcherCount.isSet() && this.researcherCount.value() == null) { + throw new IllegalStateException("Field 'researcherCount' is marked as non-null but null value was provided"); + } + ResearchLaboratory result = new ResearchLaboratory(); + this.createdAt.ifSet(result::setCreatedAt); + this.equipmentCount.ifSet(result::setEquipmentCount); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.labType.ifSet(result::setLabType); + this.name.ifSet(result::setName); + this.researcherCount.ifSet(result::setResearcherCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("equipmentCount", this.equipmentCount) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("labType", this.labType) + .append("name", this.name) + .append("researcherCount", this.researcherCount) + .append("status", this.status) + .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 ResearchLaboratory with(Consumer b) { + ResearchLaboratoryBuilder builder; + try { + builder = new ResearchLaboratoryBuilder(ResearchLaboratory.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchLaboratoryBuilder.With' should only be implemented by classes, which could be casted to 'ResearchLaboratory'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchLaboratoryBuilder with() { + try { + return new ResearchLaboratoryBuilder(ResearchLaboratory.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchLaboratoryBuilder.With' should only be implemented by classes, which could be casted to 'ResearchLaboratory'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchUniversityBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchUniversityBuilder.java new file mode 100644 index 00000000..d9002f34 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResearchUniversityBuilder.java @@ -0,0 +1,641 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.ResearchUniversity}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResearchUniversity 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearchUniversity result = ResearchUniversityBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .doctoralPrograms(42)
    + *     .doctoralPrograms(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .researchExpenditure(BigDecimal.valueOf(3.14))
    + *     .researchExpenditure(() -> BigDecimal.valueOf(3.14))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .studentCount(42)
    + *     .studentCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearchUniversity.class) +public class ResearchUniversityBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for doctoralPrograms: doctoralPrograms. + */ + private TrackedValue doctoralPrograms = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for researchExpenditure: researchExpenditure. + */ + private TrackedValue researchExpenditure = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for studentCount: studentCount. + */ + private TrackedValue studentCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchUniversity}. + */ + public ResearchUniversityBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchUniversity} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearchUniversityBuilder(ResearchUniversity instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.doctoralPrograms = initialValue(instance.getDoctoralPrograms()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.researchExpenditure = initialValue(instance.getResearchExpenditure()); + this.status = initialValue(instance.getStatus()); + this.studentCount = initialValue(instance.getStudentCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchUniversity}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchUniversityBuilder builder = ResearchUniversityBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResearchUniversity} + */ + public static ResearchUniversityBuilder create() { + return new ResearchUniversityBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResearchUniversity#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResearchUniversityBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResearchUniversityBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for doctoralPrograms. + *

    + * Generated from setter {@link ResearchUniversity#setDoctoralPrograms(int) setDoctoralPrograms(int doctoralPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.doctoralPrograms(42);
    +   * }
    + * + * @param doctoralPrograms doctoralPrograms + * @return current instance of builder + */ + public ResearchUniversityBuilder doctoralPrograms(int doctoralPrograms) { + this.doctoralPrograms = changedValue(doctoralPrograms); + return this; + } + + /** + * Sets the value for doctoralPrograms by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setDoctoralPrograms(int) setDoctoralPrograms(int doctoralPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.doctoralPrograms(() -> 42);
    +   * }
    + * + * @param doctoralProgramsSupplier supplier for doctoralPrograms + * @return current instance of builder + */ + public ResearchUniversityBuilder doctoralPrograms(Supplier doctoralProgramsSupplier) { + this.doctoralPrograms = changedValue(doctoralProgramsSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResearchUniversity#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResearchUniversityBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResearchUniversityBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResearchUniversity#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResearchUniversityBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResearchUniversityBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResearchUniversity#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResearchUniversityBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResearchUniversity#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResearchUniversityBuilder 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. + *

    + * Generated from setter {@link ResearchUniversity#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResearchUniversityBuilder 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. + *

    + * Generated from setter {@link ResearchUniversity#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchUniversityBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for researchExpenditure. + *

    + * Generated from setter {@link ResearchUniversity#setResearchExpenditure(BigDecimal) + * setResearchExpenditure(BigDecimal researchExpenditure)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchExpenditure(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param researchExpenditure researchExpenditure + * @return current instance of builder + */ + public ResearchUniversityBuilder researchExpenditure(BigDecimal researchExpenditure) { + this.researchExpenditure = changedValue(researchExpenditure); + return this; + } + + /** + * Sets the value for researchExpenditure by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setResearchExpenditure(BigDecimal) + * setResearchExpenditure(BigDecimal researchExpenditure)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researchExpenditure(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param researchExpenditureSupplier supplier for researchExpenditure + * @return current instance of builder + */ + public ResearchUniversityBuilder researchExpenditure(Supplier researchExpenditureSupplier) { + this.researchExpenditure = changedValue(researchExpenditureSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResearchUniversity#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResearchUniversityBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResearchUniversity#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResearchUniversityBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResearchUniversityBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResearchUniversity#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearchUniversityBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for studentCount. + *

    + * Generated from setter {@link ResearchUniversity#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(42);
    +   * }
    + * + * @param studentCount studentCount + * @return current instance of builder + */ + public ResearchUniversityBuilder studentCount(int studentCount) { + this.studentCount = changedValue(studentCount); + return this; + } + + /** + * Sets the value for studentCount by invoking the provided supplier. + *

    + * Generated from setter {@link ResearchUniversity#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(() -> 42);
    +   * }
    + * + * @param studentCountSupplier supplier for studentCount + * @return current instance of builder + */ + public ResearchUniversityBuilder studentCount(Supplier studentCountSupplier) { + this.studentCount = changedValue(studentCountSupplier.get()); + 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 ResearchUniversityBuilder 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 ResearchUniversityBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearchUniversity result = builder.build();
    +   * }
    + */ + @Override + public ResearchUniversity build() { + if (this.doctoralPrograms.isSet() && this.doctoralPrograms.value() == null) { + throw new IllegalStateException("Field 'doctoralPrograms' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.studentCount.isSet() && this.studentCount.value() == null) { + throw new IllegalStateException("Field 'studentCount' is marked as non-null but null value was provided"); + } + ResearchUniversity result = new ResearchUniversity(); + this.createdAt.ifSet(result::setCreatedAt); + this.doctoralPrograms.ifSet(result::setDoctoralPrograms); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.researchExpenditure.ifSet(result::setResearchExpenditure); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.studentCount.ifSet(result::setStudentCount); + 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("createdAt", this.createdAt) + .append("doctoralPrograms", this.doctoralPrograms) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("researchExpenditure", this.researchExpenditure) + .append("status", this.status) + .append("studentCount", this.studentCount) + .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 ResearchUniversity with(Consumer b) { + ResearchUniversityBuilder builder; + try { + builder = new ResearchUniversityBuilder(ResearchUniversity.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchUniversityBuilder.With' should only be implemented by classes, which could be casted to 'ResearchUniversity'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearchUniversityBuilder with() { + try { + return new ResearchUniversityBuilder(ResearchUniversity.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearchUniversityBuilder.With' should only be implemented by classes, which could be casted to 'ResearchUniversity'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResourceSharingNetworkBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResourceSharingNetworkBuilder.java new file mode 100644 index 00000000..33f8d3f4 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ResourceSharingNetworkBuilder.java @@ -0,0 +1,649 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.ResourceSharingNetwork}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ResourceSharingNetwork 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. + * + *

    Example:

    + * + *
    {@code
    + * ResourceSharingNetwork result = ResourceSharingNetworkBuilder.create()
    + *     .annualTransactions(42L)
    + *     .annualTransactions(() -> 42L)
    + *     .averageDeliveryDays(3.14)
    + *     .averageDeliveryDays(() -> 3.14)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberLibraries(42)
    + *     .memberLibraries(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResourceSharingNetwork.class) +public class ResourceSharingNetworkBuilder implements IBuilderBase { + + /** + * Tracked value for annualTransactions: annualTransactions. + */ + private TrackedValue annualTransactions = unsetValue(); + /** + * Tracked value for averageDeliveryDays: averageDeliveryDays. + */ + private TrackedValue averageDeliveryDays = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberLibraries: memberLibraries. + */ + private TrackedValue memberLibraries = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResourceSharingNetwork}. + */ + public ResourceSharingNetworkBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResourceSharingNetwork} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public ResourceSharingNetworkBuilder(ResourceSharingNetwork instance) { + this.annualTransactions = initialValue(instance.getAnnualTransactions()); + this.averageDeliveryDays = initialValue(instance.getAverageDeliveryDays()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberLibraries = initialValue(instance.getMemberLibraries()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResourceSharingNetwork}. + * + *

    Example:

    + * + *
    {@code
    +   * ResourceSharingNetworkBuilder builder = ResourceSharingNetworkBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ResourceSharingNetwork} + */ + public static ResourceSharingNetworkBuilder create() { + return new ResourceSharingNetworkBuilder(); + } + + /** + * Sets the value for annualTransactions. + *

    + * Generated from setter {@link ResourceSharingNetwork#setAnnualTransactions(long) setAnnualTransactions(long + * annualTransactions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTransactions(42L);
    +   * }
    + * + * @param annualTransactions annualTransactions + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder annualTransactions(long annualTransactions) { + this.annualTransactions = changedValue(annualTransactions); + return this; + } + + /** + * Sets the value for annualTransactions by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setAnnualTransactions(long) setAnnualTransactions(long + * annualTransactions)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTransactions(() -> 42L);
    +   * }
    + * + * @param annualTransactionsSupplier supplier for annualTransactions + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder annualTransactions(Supplier annualTransactionsSupplier) { + this.annualTransactions = changedValue(annualTransactionsSupplier.get()); + return this; + } + + /** + * Sets the value for averageDeliveryDays. + *

    + * Generated from setter {@link ResourceSharingNetwork#setAverageDeliveryDays(double) setAverageDeliveryDays(double + * averageDeliveryDays)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.averageDeliveryDays(3.14);
    +   * }
    + * + * @param averageDeliveryDays averageDeliveryDays + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder averageDeliveryDays(double averageDeliveryDays) { + this.averageDeliveryDays = changedValue(averageDeliveryDays); + return this; + } + + /** + * Sets the value for averageDeliveryDays by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setAverageDeliveryDays(double) setAverageDeliveryDays(double + * averageDeliveryDays)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.averageDeliveryDays(() -> 3.14);
    +   * }
    + * + * @param averageDeliveryDaysSupplier supplier for averageDeliveryDays + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder averageDeliveryDays(Supplier averageDeliveryDaysSupplier) { + this.averageDeliveryDays = changedValue(averageDeliveryDaysSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ResourceSharingNetwork#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ResourceSharingNetwork#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ResourceSharingNetwork#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberLibraries. + *

    + * Generated from setter {@link ResourceSharingNetwork#setMemberLibraries(int) setMemberLibraries(int + * memberLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberLibraries(42);
    +   * }
    + * + * @param memberLibraries memberLibraries + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder memberLibraries(int memberLibraries) { + this.memberLibraries = changedValue(memberLibraries); + return this; + } + + /** + * Sets the value for memberLibraries by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setMemberLibraries(int) setMemberLibraries(int + * memberLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberLibraries(() -> 42);
    +   * }
    + * + * @param memberLibrariesSupplier supplier for memberLibraries + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder memberLibraries(Supplier memberLibrariesSupplier) { + this.memberLibraries = changedValue(memberLibrariesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ResourceSharingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ResourceSharingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder 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. + *

    + * Generated from setter {@link ResourceSharingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder 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. + *

    + * Generated from setter {@link ResourceSharingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ResourceSharingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ResourceSharingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ResourceSharingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ResourceSharingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResourceSharingNetworkBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ResourceSharingNetworkBuilder 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 ResourceSharingNetworkBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResourceSharingNetwork result = builder.build();
    +   * }
    + */ + @Override + public ResourceSharingNetwork build() { + if (this.annualTransactions.isSet() && this.annualTransactions.value() == null) { + throw new IllegalStateException("Field 'annualTransactions' is marked as non-null but null value was provided"); + } + if (this.averageDeliveryDays.isSet() && this.averageDeliveryDays.value() == null) { + throw new IllegalStateException("Field 'averageDeliveryDays' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberLibraries.isSet() && this.memberLibraries.value() == null) { + throw new IllegalStateException("Field 'memberLibraries' is marked as non-null but null value was provided"); + } + ResourceSharingNetwork result = new ResourceSharingNetwork(); + this.annualTransactions.ifSet(result::setAnnualTransactions); + this.averageDeliveryDays.ifSet(result::setAverageDeliveryDays); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberLibraries.ifSet(result::setMemberLibraries); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualTransactions", this.annualTransactions) + .append("averageDeliveryDays", this.averageDeliveryDays) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberLibraries", this.memberLibraries) + .append("name", this.name) + .append("status", this.status) + .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 ResourceSharingNetwork with(Consumer b) { + ResourceSharingNetworkBuilder builder; + try { + builder = new ResourceSharingNetworkBuilder(ResourceSharingNetwork.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResourceSharingNetworkBuilder.With' should only be implemented by classes, which could be casted to 'ResourceSharingNetwork'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResourceSharingNetworkBuilder with() { + try { + return new ResourceSharingNetworkBuilder(ResourceSharingNetwork.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResourceSharingNetworkBuilder.With' should only be implemented by classes, which could be casted to 'ResourceSharingNetwork'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarlyPublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarlyPublisherBuilder.java new file mode 100644 index 00000000..668bda92 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarlyPublisherBuilder.java @@ -0,0 +1,757 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.ScholarlyPublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ScholarlyPublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * ScholarlyPublisher result = ScholarlyPublisherBuilder.create()
    + *     .bookSeries(List.of("example value"))
    + *     .bookSeries(() -> List.of("example value"))
    + *     .bookSeries(t -> t.add("example value"))
    + *     .bookSeries("example value", "example value")
    + *     .add2BookSeries("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .journalCount(42)
    + *     .journalCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .peerReviewProcess("example value")
    + *     .peerReviewProcess("Hello %s", "World")
    + *     .peerReviewProcess(() -> "example value")
    + *     .peerReviewProcess(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScholarlyPublisher.class) +public class ScholarlyPublisherBuilder implements IBuilderBase { + + /** + * Tracked value for bookSeries: bookSeries. + */ + private TrackedValue> bookSeries = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for journalCount: journalCount. + */ + private TrackedValue journalCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for peerReviewProcess: peerReviewProcess. + */ + private TrackedValue peerReviewProcess = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarlyPublisher}. + */ + public ScholarlyPublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarlyPublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScholarlyPublisherBuilder(ScholarlyPublisher instance) { + this.bookSeries = initialValue(instance.getBookSeries()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.journalCount = initialValue(instance.getJournalCount()); + this.name = initialValue(instance.getName()); + this.peerReviewProcess = initialValue(instance.getPeerReviewProcess()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarlyPublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarlyPublisherBuilder builder = ScholarlyPublisherBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarlyPublisher} + */ + public static ScholarlyPublisherBuilder create() { + return new ScholarlyPublisherBuilder(); + } + + /** + * Adds a single element to bookSeries. + *

    + * Generated from setter {@link ScholarlyPublisher#setBookSeries(List) setBookSeries(List bookSeries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2BookSeries("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ScholarlyPublisherBuilder add2BookSeries(String element) { + List newCollection; + if (this.bookSeries.isSet()) { + newCollection = new ArrayList<>(this.bookSeries.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.bookSeries = changedValue(newCollection); + return this; + } + + /** + * Sets the value for bookSeries. + *

    + * Generated from setter {@link ScholarlyPublisher#setBookSeries(List) setBookSeries(List bookSeries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bookSeries("example value", "example value");
    +   * }
    + * + * @param bookSeries bookSeries + * @return current instance of builder + */ + public ScholarlyPublisherBuilder bookSeries(String... bookSeries) { + this.bookSeries = changedValue(List.of(bookSeries)); + return this; + } + + /** + * Sets the value for bookSeries. + *

    + * Generated from setter {@link ScholarlyPublisher#setBookSeries(List) setBookSeries(List bookSeries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bookSeries(List.of("example value"));
    +   * }
    + * + * @param bookSeries bookSeries + * @return current instance of builder + */ + public ScholarlyPublisherBuilder bookSeries(List bookSeries) { + this.bookSeries = changedValue(bookSeries); + return this; + } + + /** + * Sets the value for bookSeries using a builder consumer that produces the value. + *

    + * Generated from setter {@link ScholarlyPublisher#setBookSeries(List) setBookSeries(List bookSeries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bookSeries(t -> t.add("example value"));
    +   * }
    + * + * @param bookSeriesBuilderConsumer consumer providing an instance of a builder for bookSeries + * @return current instance of builder + */ + public ScholarlyPublisherBuilder bookSeries(Consumer> bookSeriesBuilderConsumer) { + ArrayListBuilder builder = this.bookSeries.isSet() + ? new ArrayListBuilder(this.bookSeries.value()) + : new ArrayListBuilder(); + bookSeriesBuilderConsumer.accept(builder); + this.bookSeries = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for bookSeries by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setBookSeries(List) setBookSeries(List bookSeries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bookSeries(() -> List.of("example value"));
    +   * }
    + * + * @param bookSeriesSupplier supplier for bookSeries + * @return current instance of builder + */ + public ScholarlyPublisherBuilder bookSeries(Supplier> bookSeriesSupplier) { + this.bookSeries = changedValue(bookSeriesSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ScholarlyPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ScholarlyPublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ScholarlyPublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ScholarlyPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ScholarlyPublisherBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ScholarlyPublisherBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ScholarlyPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ScholarlyPublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ScholarlyPublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for journalCount. + *

    + * Generated from setter {@link ScholarlyPublisher#setJournalCount(int) setJournalCount(int journalCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalCount(42);
    +   * }
    + * + * @param journalCount journalCount + * @return current instance of builder + */ + public ScholarlyPublisherBuilder journalCount(int journalCount) { + this.journalCount = changedValue(journalCount); + return this; + } + + /** + * Sets the value for journalCount by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setJournalCount(int) setJournalCount(int journalCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalCount(() -> 42);
    +   * }
    + * + * @param journalCountSupplier supplier for journalCount + * @return current instance of builder + */ + public ScholarlyPublisherBuilder journalCount(Supplier journalCountSupplier) { + this.journalCount = changedValue(journalCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ScholarlyPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ScholarlyPublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ScholarlyPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ScholarlyPublisherBuilder 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. + *

    + * Generated from setter {@link ScholarlyPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ScholarlyPublisherBuilder 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. + *

    + * Generated from setter {@link ScholarlyPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarlyPublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for peerReviewProcess. + *

    + * Generated from setter {@link ScholarlyPublisher#setPeerReviewProcess(String) setPeerReviewProcess(String + * peerReviewProcess)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.peerReviewProcess("example value");
    +   * }
    + * + * @param peerReviewProcess peerReviewProcess + * @return current instance of builder + */ + public ScholarlyPublisherBuilder peerReviewProcess(String peerReviewProcess) { + this.peerReviewProcess = changedValue(peerReviewProcess); + return this; + } + + /** + * Sets the value for peerReviewProcess by executing the provided consumer. + *

    + * Generated from setter {@link ScholarlyPublisher#setPeerReviewProcess(String) setPeerReviewProcess(String + * peerReviewProcess)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.peerReviewProcess(sb -> sb.append("text"));
    +   * }
    + * + * @param peerReviewProcessStringBuilderConsumer consumer providing an instance of peerReviewProcess + * @return current instance of builder + */ + public ScholarlyPublisherBuilder peerReviewProcess(Consumer peerReviewProcessStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + peerReviewProcessStringBuilderConsumer.accept(builder); + this.peerReviewProcess = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for peerReviewProcess by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setPeerReviewProcess(String) setPeerReviewProcess(String + * peerReviewProcess)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.peerReviewProcess(() -> "example value");
    +   * }
    + * + * @param peerReviewProcessSupplier supplier for peerReviewProcess + * @return current instance of builder + */ + public ScholarlyPublisherBuilder peerReviewProcess(Supplier peerReviewProcessSupplier) { + this.peerReviewProcess = changedValue(peerReviewProcessSupplier.get()); + return this; + } + + /** + * Sets the String value for peerReviewProcess by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ScholarlyPublisher#setPeerReviewProcess(String) setPeerReviewProcess(String + * peerReviewProcess)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.peerReviewProcess("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarlyPublisherBuilder peerReviewProcess(String format, Object... args) { + this.peerReviewProcess = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ScholarlyPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ScholarlyPublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ScholarlyPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ScholarlyPublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarlyPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ScholarlyPublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ScholarlyPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarlyPublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ScholarlyPublisherBuilder 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 ScholarlyPublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarlyPublisher result = builder.build();
    +   * }
    + */ + @Override + public ScholarlyPublisher build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.journalCount.isSet() && this.journalCount.value() == null) { + throw new IllegalStateException("Field 'journalCount' is marked as non-null but null value was provided"); + } + ScholarlyPublisher result = new ScholarlyPublisher(); + this.bookSeries.ifSet(result::setBookSeries); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.journalCount.ifSet(result::setJournalCount); + this.name.ifSet(result::setName); + this.peerReviewProcess.ifSet(result::setPeerReviewProcess); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("bookSeries", this.bookSeries) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("journalCount", this.journalCount) + .append("name", this.name) + .append("peerReviewProcess", this.peerReviewProcess) + .append("status", this.status) + .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 ScholarlyPublisher with(Consumer b) { + ScholarlyPublisherBuilder builder; + try { + builder = new ScholarlyPublisherBuilder(ScholarlyPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarlyPublisherBuilder.With' should only be implemented by classes, which could be casted to 'ScholarlyPublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScholarlyPublisherBuilder with() { + try { + return new ScholarlyPublisherBuilder(ScholarlyPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarlyPublisherBuilder.With' should only be implemented by classes, which could be casted to 'ScholarlyPublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipFundBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipFundBuilder.java new file mode 100644 index 00000000..871a8702 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipFundBuilder.java @@ -0,0 +1,684 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.ScholarshipFund}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipFund 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. + * + *

    Example:

    + * + *
    {@code
    + * ScholarshipFund result = ScholarshipFundBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .eligibilityCriteria("example value")
    + *     .eligibilityCriteria("Hello %s", "World")
    + *     .eligibilityCriteria(() -> "example value")
    + *     .eligibilityCriteria(sb -> sb.append("text"))
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .fundValue(BigDecimal.valueOf(3.14))
    + *     .fundValue(() -> BigDecimal.valueOf(3.14))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .scholarshipsAwarded(42)
    + *     .scholarshipsAwarded(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScholarshipFund.class) +public class ScholarshipFundBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for eligibilityCriteria: eligibilityCriteria. + */ + private TrackedValue eligibilityCriteria = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for fundValue: fundValue. + */ + private TrackedValue fundValue = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for scholarshipsAwarded: scholarshipsAwarded. + */ + private TrackedValue scholarshipsAwarded = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipFund}. + */ + public ScholarshipFundBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipFund} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScholarshipFundBuilder(ScholarshipFund instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.eligibilityCriteria = initialValue(instance.getEligibilityCriteria()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.fundValue = initialValue(instance.getFundValue()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.scholarshipsAwarded = initialValue(instance.getScholarshipsAwarded()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipFund}. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarshipFundBuilder builder = ScholarshipFundBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipFund} + */ + public static ScholarshipFundBuilder create() { + return new ScholarshipFundBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ScholarshipFund#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ScholarshipFundBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ScholarshipFundBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for eligibilityCriteria. + *

    + * Generated from setter {@link ScholarshipFund#setEligibilityCriteria(String) setEligibilityCriteria(String + * eligibilityCriteria)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibilityCriteria("example value");
    +   * }
    + * + * @param eligibilityCriteria eligibilityCriteria + * @return current instance of builder + */ + public ScholarshipFundBuilder eligibilityCriteria(String eligibilityCriteria) { + this.eligibilityCriteria = changedValue(eligibilityCriteria); + return this; + } + + /** + * Sets the value for eligibilityCriteria by executing the provided consumer. + *

    + * Generated from setter {@link ScholarshipFund#setEligibilityCriteria(String) setEligibilityCriteria(String + * eligibilityCriteria)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibilityCriteria(sb -> sb.append("text"));
    +   * }
    + * + * @param eligibilityCriteriaStringBuilderConsumer consumer providing an instance of eligibilityCriteria + * @return current instance of builder + */ + public ScholarshipFundBuilder eligibilityCriteria(Consumer eligibilityCriteriaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + eligibilityCriteriaStringBuilderConsumer.accept(builder); + this.eligibilityCriteria = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for eligibilityCriteria by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setEligibilityCriteria(String) setEligibilityCriteria(String + * eligibilityCriteria)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibilityCriteria(() -> "example value");
    +   * }
    + * + * @param eligibilityCriteriaSupplier supplier for eligibilityCriteria + * @return current instance of builder + */ + public ScholarshipFundBuilder eligibilityCriteria(Supplier eligibilityCriteriaSupplier) { + this.eligibilityCriteria = changedValue(eligibilityCriteriaSupplier.get()); + return this; + } + + /** + * Sets the String value for eligibilityCriteria by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ScholarshipFund#setEligibilityCriteria(String) setEligibilityCriteria(String + * eligibilityCriteria)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibilityCriteria("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarshipFundBuilder eligibilityCriteria(String format, Object... args) { + this.eligibilityCriteria = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ScholarshipFund#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ScholarshipFundBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ScholarshipFundBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for fundValue. + *

    + * Generated from setter {@link ScholarshipFund#setFundValue(BigDecimal) setFundValue(BigDecimal fundValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fundValue(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param fundValue fundValue + * @return current instance of builder + */ + public ScholarshipFundBuilder fundValue(BigDecimal fundValue) { + this.fundValue = changedValue(fundValue); + return this; + } + + /** + * Sets the value for fundValue by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setFundValue(BigDecimal) setFundValue(BigDecimal fundValue)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fundValue(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param fundValueSupplier supplier for fundValue + * @return current instance of builder + */ + public ScholarshipFundBuilder fundValue(Supplier fundValueSupplier) { + this.fundValue = changedValue(fundValueSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ScholarshipFund#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ScholarshipFundBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ScholarshipFundBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ScholarshipFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ScholarshipFundBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ScholarshipFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ScholarshipFundBuilder 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. + *

    + * Generated from setter {@link ScholarshipFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ScholarshipFundBuilder 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. + *

    + * Generated from setter {@link ScholarshipFund#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarshipFundBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for scholarshipsAwarded. + *

    + * Generated from setter {@link ScholarshipFund#setScholarshipsAwarded(int) setScholarshipsAwarded(int + * scholarshipsAwarded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarshipsAwarded(42);
    +   * }
    + * + * @param scholarshipsAwarded scholarshipsAwarded + * @return current instance of builder + */ + public ScholarshipFundBuilder scholarshipsAwarded(int scholarshipsAwarded) { + this.scholarshipsAwarded = changedValue(scholarshipsAwarded); + return this; + } + + /** + * Sets the value for scholarshipsAwarded by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setScholarshipsAwarded(int) setScholarshipsAwarded(int + * scholarshipsAwarded)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarshipsAwarded(() -> 42);
    +   * }
    + * + * @param scholarshipsAwardedSupplier supplier for scholarshipsAwarded + * @return current instance of builder + */ + public ScholarshipFundBuilder scholarshipsAwarded(Supplier scholarshipsAwardedSupplier) { + this.scholarshipsAwarded = changedValue(scholarshipsAwardedSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ScholarshipFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ScholarshipFundBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ScholarshipFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ScholarshipFundBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ScholarshipFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ScholarshipFundBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ScholarshipFund#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarshipFundBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ScholarshipFundBuilder 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 ScholarshipFundBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarshipFund result = builder.build();
    +   * }
    + */ + @Override + public ScholarshipFund build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.scholarshipsAwarded.isSet() && this.scholarshipsAwarded.value() == null) { + throw new IllegalStateException("Field 'scholarshipsAwarded' is marked as non-null but null value was provided"); + } + ScholarshipFund result = new ScholarshipFund(); + this.createdAt.ifSet(result::setCreatedAt); + this.eligibilityCriteria.ifSet(result::setEligibilityCriteria); + this.foundedYear.ifSet(result::setFoundedYear); + this.fundValue.ifSet(result::setFundValue); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.scholarshipsAwarded.ifSet(result::setScholarshipsAwarded); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("eligibilityCriteria", this.eligibilityCriteria) + .append("foundedYear", this.foundedYear) + .append("fundValue", this.fundValue) + .append("id", this.id) + .append("name", this.name) + .append("scholarshipsAwarded", this.scholarshipsAwarded) + .append("status", this.status) + .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 ScholarshipFund with(Consumer b) { + ScholarshipFundBuilder builder; + try { + builder = new ScholarshipFundBuilder(ScholarshipFund.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarshipFundBuilder.With' should only be implemented by classes, which could be casted to 'ScholarshipFund'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScholarshipFundBuilder with() { + try { + return new ScholarshipFundBuilder(ScholarshipFund.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarshipFundBuilder.With' should only be implemented by classes, which could be casted to 'ScholarshipFund'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipRecordBuilder.java new file mode 100644 index 00000000..48a65eeb --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScholarshipRecordBuilder.java @@ -0,0 +1,523 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +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.performance_test.library.organizations.ScholarshipRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ScholarshipRecord result = ScholarshipRecordBuilder.create()
    + *     .scholarshipName("example value")
    + *     .scholarshipName("Hello %s", "World")
    + *     .scholarshipName(() -> "example value")
    + *     .scholarshipName(sb -> sb.append("text"))
    + *     .amount(BigDecimal.valueOf(3.14))
    + *     .amount(() -> BigDecimal.valueOf(3.14))
    + *     .eligibility("example value")
    + *     .eligibility("Hello %s", "World")
    + *     .eligibility(() -> "example value")
    + *     .eligibility(sb -> sb.append("text"))
    + *     .awardsPerYear(42)
    + *     .awardsPerYear(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScholarshipRecord.class) +public class ScholarshipRecordBuilder implements IBuilderBase { + + /** + * Tracked value for scholarshipName: scholarshipName. + */ + private TrackedValue scholarshipName = unsetValue(); + /** + * Tracked value for amount: amount. + */ + private TrackedValue amount = unsetValue(); + /** + * Tracked value for eligibility: eligibility. + */ + private TrackedValue eligibility = unsetValue(); + /** + * Tracked value for awardsPerYear: awardsPerYear. + */ + private TrackedValue awardsPerYear = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipRecord}. + */ + public ScholarshipRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScholarshipRecordBuilder(ScholarshipRecord instance) { + this.scholarshipName = initialValue(instance.scholarshipName()); + this.amount = initialValue(instance.amount()); + this.eligibility = initialValue(instance.eligibility()); + this.awardsPerYear = initialValue(instance.awardsPerYear()); + this.foundedYear = initialValue(instance.foundedYear()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarshipRecordBuilder builder = ScholarshipRecordBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScholarshipRecord} + */ + public static ScholarshipRecordBuilder create() { + return new ScholarshipRecordBuilder(); + } + + /** + * Sets the value for amount. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.amount(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param amount amount + * @return current instance of builder + */ + public ScholarshipRecordBuilder amount(BigDecimal amount) { + this.amount = changedValue(amount); + return this; + } + + /** + * Sets the value for amount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.amount(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param amountSupplier supplier for amount + * @return current instance of builder + */ + public ScholarshipRecordBuilder amount(Supplier amountSupplier) { + this.amount = changedValue(amountSupplier.get()); + return this; + } + + /** + * Sets the value for awardsPerYear. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.awardsPerYear(42);
    +   * }
    + * + * @param awardsPerYear awardsPerYear + * @return current instance of builder + */ + public ScholarshipRecordBuilder awardsPerYear(int awardsPerYear) { + this.awardsPerYear = changedValue(awardsPerYear); + return this; + } + + /** + * Sets the value for awardsPerYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.awardsPerYear(() -> 42);
    +   * }
    + * + * @param awardsPerYearSupplier supplier for awardsPerYear + * @return current instance of builder + */ + public ScholarshipRecordBuilder awardsPerYear(Supplier awardsPerYearSupplier) { + this.awardsPerYear = changedValue(awardsPerYearSupplier.get()); + return this; + } + + /** + * Sets the value for eligibility. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibility("example value");
    +   * }
    + * + * @param eligibility eligibility + * @return current instance of builder + */ + public ScholarshipRecordBuilder eligibility(String eligibility) { + this.eligibility = changedValue(eligibility); + return this; + } + + /** + * Sets the value for eligibility by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibility(sb -> sb.append("text"));
    +   * }
    + * + * @param eligibilityStringBuilderConsumer consumer providing an instance of eligibility + * @return current instance of builder + */ + public ScholarshipRecordBuilder eligibility(Consumer eligibilityStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + eligibilityStringBuilderConsumer.accept(builder); + this.eligibility = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for eligibility by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibility(() -> "example value");
    +   * }
    + * + * @param eligibilitySupplier supplier for eligibility + * @return current instance of builder + */ + public ScholarshipRecordBuilder eligibility(Supplier eligibilitySupplier) { + this.eligibility = changedValue(eligibilitySupplier.get()); + return this; + } + + /** + * Sets the String value for eligibility by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.eligibility("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarshipRecordBuilder eligibility(String format, Object... args) { + this.eligibility = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ScholarshipRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ScholarshipRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for scholarshipName. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarshipName("example value");
    +   * }
    + * + * @param scholarshipName scholarshipName + * @return current instance of builder + */ + public ScholarshipRecordBuilder scholarshipName(String scholarshipName) { + this.scholarshipName = changedValue(scholarshipName); + return this; + } + + /** + * Sets the value for scholarshipName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarshipName(sb -> sb.append("text"));
    +   * }
    + * + * @param scholarshipNameStringBuilderConsumer consumer providing an instance of scholarshipName + * @return current instance of builder + */ + public ScholarshipRecordBuilder scholarshipName(Consumer scholarshipNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + scholarshipNameStringBuilderConsumer.accept(builder); + this.scholarshipName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for scholarshipName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarshipName(() -> "example value");
    +   * }
    + * + * @param scholarshipNameSupplier supplier for scholarshipName + * @return current instance of builder + */ + public ScholarshipRecordBuilder scholarshipName(Supplier scholarshipNameSupplier) { + this.scholarshipName = changedValue(scholarshipNameSupplier.get()); + return this; + } + + /** + * Sets the String value for scholarshipName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link ScholarshipRecord#ScholarshipRecord(String, BigDecimal, String, int, int) ScholarshipRecord(String + * scholarshipName, BigDecimal amount, String eligibility, int awardsPerYear, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarshipName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarshipRecordBuilder scholarshipName(String format, Object... args) { + this.scholarshipName = changedValue(String.format(format, args)); + 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 ScholarshipRecordBuilder 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 ScholarshipRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarshipRecord result = builder.build();
    +   * }
    + */ + @Override + public ScholarshipRecord build() { + if (!this.awardsPerYear.isSet()) { + throw new IllegalStateException("Required field 'awardsPerYear' must be set before calling build()"); + } + if (this.awardsPerYear.value() == null) { + throw new IllegalStateException("Field 'awardsPerYear' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + ScholarshipRecord result = new ScholarshipRecord(this.scholarshipName + .value(), this.amount.value(), this.eligibility.value(), this.awardsPerYear.value(), this.foundedYear.value()); + 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("scholarshipName", this.scholarshipName) + .append("amount", this.amount) + .append("eligibility", this.eligibility) + .append("awardsPerYear", this.awardsPerYear) + .append("foundedYear", this.foundedYear) + .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 ScholarshipRecord with(Consumer b) { + ScholarshipRecordBuilder builder; + try { + builder = new ScholarshipRecordBuilder(ScholarshipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarshipRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScholarshipRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScholarshipRecordBuilder with() { + try { + return new ScholarshipRecordBuilder(ScholarshipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarshipRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScholarshipRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolLibraryBuilder.java new file mode 100644 index 00000000..e9372b2e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolLibraryBuilder.java @@ -0,0 +1,751 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.SchoolLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SchoolLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * SchoolLibrary result = SchoolLibraryBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .gradeLevels(List.of("example value"))
    + *     .gradeLevels(() -> List.of("example value"))
    + *     .gradeLevels(t -> t.add("example value"))
    + *     .gradeLevels("example value", "example value")
    + *     .add2GradeLevels("example value")
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .schoolName("example value")
    + *     .schoolName("Hello %s", "World")
    + *     .schoolName(() -> "example value")
    + *     .schoolName(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalVolumes(42)
    + *     .totalVolumes(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SchoolLibrary.class) +public class SchoolLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for gradeLevels: gradeLevels. + */ + private TrackedValue> gradeLevels = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for schoolName: schoolName. + */ + private TrackedValue schoolName = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalVolumes: totalVolumes. + */ + private TrackedValue totalVolumes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolLibrary}. + */ + public SchoolLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public SchoolLibraryBuilder(SchoolLibrary instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.gradeLevels = initialValue(instance.getGradeLevels()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.schoolName = initialValue(instance.getSchoolName()); + this.status = initialValue(instance.getStatus()); + this.totalVolumes = initialValue(instance.getTotalVolumes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * SchoolLibraryBuilder builder = SchoolLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolLibrary} + */ + public static SchoolLibraryBuilder create() { + return new SchoolLibraryBuilder(); + } + + /** + * Adds a single element to gradeLevels. + *

    + * Generated from setter {@link SchoolLibrary#setGradeLevels(List) setGradeLevels(List gradeLevels)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2GradeLevels("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public SchoolLibraryBuilder add2GradeLevels(String element) { + List newCollection; + if (this.gradeLevels.isSet()) { + newCollection = new ArrayList<>(this.gradeLevels.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.gradeLevels = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SchoolLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SchoolLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SchoolLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link SchoolLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SchoolLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SchoolLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for gradeLevels. + *

    + * Generated from setter {@link SchoolLibrary#setGradeLevels(List) setGradeLevels(List gradeLevels)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevels("example value", "example value");
    +   * }
    + * + * @param gradeLevels gradeLevels + * @return current instance of builder + */ + public SchoolLibraryBuilder gradeLevels(String... gradeLevels) { + this.gradeLevels = changedValue(List.of(gradeLevels)); + return this; + } + + /** + * Sets the value for gradeLevels. + *

    + * Generated from setter {@link SchoolLibrary#setGradeLevels(List) setGradeLevels(List gradeLevels)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevels(List.of("example value"));
    +   * }
    + * + * @param gradeLevels gradeLevels + * @return current instance of builder + */ + public SchoolLibraryBuilder gradeLevels(List gradeLevels) { + this.gradeLevels = changedValue(gradeLevels); + return this; + } + + /** + * Sets the value for gradeLevels using a builder consumer that produces the value. + *

    + * Generated from setter {@link SchoolLibrary#setGradeLevels(List) setGradeLevels(List gradeLevels)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevels(t -> t.add("example value"));
    +   * }
    + * + * @param gradeLevelsBuilderConsumer consumer providing an instance of a builder for gradeLevels + * @return current instance of builder + */ + public SchoolLibraryBuilder gradeLevels(Consumer> gradeLevelsBuilderConsumer) { + ArrayListBuilder builder = this.gradeLevels.isSet() + ? new ArrayListBuilder(this.gradeLevels.value()) + : new ArrayListBuilder(); + gradeLevelsBuilderConsumer.accept(builder); + this.gradeLevels = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for gradeLevels by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setGradeLevels(List) setGradeLevels(List gradeLevels)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.gradeLevels(() -> List.of("example value"));
    +   * }
    + * + * @param gradeLevelsSupplier supplier for gradeLevels + * @return current instance of builder + */ + public SchoolLibraryBuilder gradeLevels(Supplier> gradeLevelsSupplier) { + this.gradeLevels = changedValue(gradeLevelsSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SchoolLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SchoolLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SchoolLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SchoolLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SchoolLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SchoolLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SchoolLibraryBuilder 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. + *

    + * Generated from setter {@link SchoolLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SchoolLibraryBuilder 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. + *

    + * Generated from setter {@link SchoolLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SchoolLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for schoolName. + *

    + * Generated from setter {@link SchoolLibrary#setSchoolName(String) setSchoolName(String schoolName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName("example value");
    +   * }
    + * + * @param schoolName schoolName + * @return current instance of builder + */ + public SchoolLibraryBuilder schoolName(String schoolName) { + this.schoolName = changedValue(schoolName); + return this; + } + + /** + * Sets the value for schoolName by executing the provided consumer. + *

    + * Generated from setter {@link SchoolLibrary#setSchoolName(String) setSchoolName(String schoolName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName(sb -> sb.append("text"));
    +   * }
    + * + * @param schoolNameStringBuilderConsumer consumer providing an instance of schoolName + * @return current instance of builder + */ + public SchoolLibraryBuilder schoolName(Consumer schoolNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + schoolNameStringBuilderConsumer.accept(builder); + this.schoolName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for schoolName by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setSchoolName(String) setSchoolName(String schoolName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName(() -> "example value");
    +   * }
    + * + * @param schoolNameSupplier supplier for schoolName + * @return current instance of builder + */ + public SchoolLibraryBuilder schoolName(Supplier schoolNameSupplier) { + this.schoolName = changedValue(schoolNameSupplier.get()); + return this; + } + + /** + * Sets the String value for schoolName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SchoolLibrary#setSchoolName(String) setSchoolName(String schoolName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SchoolLibraryBuilder schoolName(String format, Object... args) { + this.schoolName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SchoolLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SchoolLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SchoolLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SchoolLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SchoolLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SchoolLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SchoolLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalVolumes. + *

    + * Generated from setter {@link SchoolLibrary#setTotalVolumes(int) setTotalVolumes(int totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(42);
    +   * }
    + * + * @param totalVolumes totalVolumes + * @return current instance of builder + */ + public SchoolLibraryBuilder totalVolumes(int totalVolumes) { + this.totalVolumes = changedValue(totalVolumes); + return this; + } + + /** + * Sets the value for totalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link SchoolLibrary#setTotalVolumes(int) setTotalVolumes(int totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(() -> 42);
    +   * }
    + * + * @param totalVolumesSupplier supplier for totalVolumes + * @return current instance of builder + */ + public SchoolLibraryBuilder totalVolumes(Supplier totalVolumesSupplier) { + this.totalVolumes = changedValue(totalVolumesSupplier.get()); + 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 SchoolLibraryBuilder 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 SchoolLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SchoolLibrary result = builder.build();
    +   * }
    + */ + @Override + public SchoolLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.totalVolumes.isSet() && this.totalVolumes.value() == null) { + throw new IllegalStateException("Field 'totalVolumes' is marked as non-null but null value was provided"); + } + SchoolLibrary result = new SchoolLibrary(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.gradeLevels.ifSet(result::setGradeLevels); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.schoolName.ifSet(result::setSchoolName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalVolumes.ifSet(result::setTotalVolumes); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("gradeLevels", this.gradeLevels) + .append("id", this.id) + .append("name", this.name) + .append("schoolName", this.schoolName) + .append("status", this.status) + .append("totalVolumes", this.totalVolumes) + .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 SchoolLibrary with(Consumer b) { + SchoolLibraryBuilder builder; + try { + builder = new SchoolLibraryBuilder(SchoolLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SchoolLibraryBuilder.With' should only be implemented by classes, which could be casted to 'SchoolLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SchoolLibraryBuilder with() { + try { + return new SchoolLibraryBuilder(SchoolLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SchoolLibraryBuilder.With' should only be implemented by classes, which could be casted to 'SchoolLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolRecordBuilder.java new file mode 100644 index 00000000..841b05b6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SchoolRecordBuilder.java @@ -0,0 +1,515 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.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.performance_test.library.organizations.SchoolRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SchoolRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SchoolRecord result = SchoolRecordBuilder.create()
    + *     .schoolName("example value")
    + *     .schoolName("Hello %s", "World")
    + *     .schoolName(() -> "example value")
    + *     .schoolName(sb -> sb.append("text"))
    + *     .district("example value")
    + *     .district("Hello %s", "World")
    + *     .district(() -> "example value")
    + *     .district(sb -> sb.append("text"))
    + *     .studentCount(42)
    + *     .studentCount(() -> 42)
    + *     .teacherCount(42)
    + *     .teacherCount(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SchoolRecord.class) +public class SchoolRecordBuilder implements IBuilderBase { + + /** + * Tracked value for schoolName: schoolName. + */ + private TrackedValue schoolName = unsetValue(); + /** + * Tracked value for district: district. + */ + private TrackedValue district = unsetValue(); + /** + * Tracked value for studentCount: studentCount. + */ + private TrackedValue studentCount = unsetValue(); + /** + * Tracked value for teacherCount: teacherCount. + */ + private TrackedValue teacherCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolRecord}. + */ + public SchoolRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SchoolRecordBuilder(SchoolRecord instance) { + this.schoolName = initialValue(instance.schoolName()); + this.district = initialValue(instance.district()); + this.studentCount = initialValue(instance.studentCount()); + this.teacherCount = initialValue(instance.teacherCount()); + this.foundedYear = initialValue(instance.foundedYear()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SchoolRecordBuilder builder = SchoolRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SchoolRecord} + */ + public static SchoolRecordBuilder create() { + return new SchoolRecordBuilder(); + } + + /** + * Sets the value for district. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.district("example value");
    +   * }
    + * + * @param district district + * @return current instance of builder + */ + public SchoolRecordBuilder district(String district) { + this.district = changedValue(district); + return this; + } + + /** + * Sets the value for district by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.district(sb -> sb.append("text"));
    +   * }
    + * + * @param districtStringBuilderConsumer consumer providing an instance of district + * @return current instance of builder + */ + public SchoolRecordBuilder district(Consumer districtStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + districtStringBuilderConsumer.accept(builder); + this.district = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for district by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.district(() -> "example value");
    +   * }
    + * + * @param districtSupplier supplier for district + * @return current instance of builder + */ + public SchoolRecordBuilder district(Supplier districtSupplier) { + this.district = changedValue(districtSupplier.get()); + return this; + } + + /** + * Sets the String value for district by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.district("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SchoolRecordBuilder district(String format, Object... args) { + this.district = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SchoolRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SchoolRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for schoolName. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName("example value");
    +   * }
    + * + * @param schoolName schoolName + * @return current instance of builder + */ + public SchoolRecordBuilder schoolName(String schoolName) { + this.schoolName = changedValue(schoolName); + return this; + } + + /** + * Sets the value for schoolName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName(sb -> sb.append("text"));
    +   * }
    + * + * @param schoolNameStringBuilderConsumer consumer providing an instance of schoolName + * @return current instance of builder + */ + public SchoolRecordBuilder schoolName(Consumer schoolNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + schoolNameStringBuilderConsumer.accept(builder); + this.schoolName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for schoolName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName(() -> "example value");
    +   * }
    + * + * @param schoolNameSupplier supplier for schoolName + * @return current instance of builder + */ + public SchoolRecordBuilder schoolName(Supplier schoolNameSupplier) { + this.schoolName = changedValue(schoolNameSupplier.get()); + return this; + } + + /** + * Sets the String value for schoolName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.schoolName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SchoolRecordBuilder schoolName(String format, Object... args) { + this.schoolName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for studentCount. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(42);
    +   * }
    + * + * @param studentCount studentCount + * @return current instance of builder + */ + public SchoolRecordBuilder studentCount(int studentCount) { + this.studentCount = changedValue(studentCount); + return this; + } + + /** + * Sets the value for studentCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(() -> 42);
    +   * }
    + * + * @param studentCountSupplier supplier for studentCount + * @return current instance of builder + */ + public SchoolRecordBuilder studentCount(Supplier studentCountSupplier) { + this.studentCount = changedValue(studentCountSupplier.get()); + return this; + } + + /** + * Sets the value for teacherCount. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.teacherCount(42);
    +   * }
    + * + * @param teacherCount teacherCount + * @return current instance of builder + */ + public SchoolRecordBuilder teacherCount(int teacherCount) { + this.teacherCount = changedValue(teacherCount); + return this; + } + + /** + * Sets the value for teacherCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SchoolRecord#SchoolRecord(String, String, int, int, int) + * SchoolRecord(String schoolName, String district, int studentCount, int teacherCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.teacherCount(() -> 42);
    +   * }
    + * + * @param teacherCountSupplier supplier for teacherCount + * @return current instance of builder + */ + public SchoolRecordBuilder teacherCount(Supplier teacherCountSupplier) { + this.teacherCount = changedValue(teacherCountSupplier.get()); + 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 SchoolRecordBuilder 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 SchoolRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SchoolRecord result = builder.build();
    +   * }
    + */ + @Override + public SchoolRecord build() { + if (!this.studentCount.isSet()) { + throw new IllegalStateException("Required field 'studentCount' must be set before calling build()"); + } + if (this.studentCount.value() == null) { + throw new IllegalStateException("Field 'studentCount' is marked as non-null but null value was provided"); + } + if (!this.teacherCount.isSet()) { + throw new IllegalStateException("Required field 'teacherCount' must be set before calling build()"); + } + if (this.teacherCount.value() == null) { + throw new IllegalStateException("Field 'teacherCount' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + SchoolRecord result = new SchoolRecord(this.schoolName.value(), + this.district.value(), + this.studentCount.value(), + this.teacherCount.value(), + this.foundedYear.value()); + 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("schoolName", this.schoolName) + .append("district", this.district) + .append("studentCount", this.studentCount) + .append("teacherCount", this.teacherCount) + .append("foundedYear", this.foundedYear) + .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 SchoolRecord with(Consumer b) { + SchoolRecordBuilder builder; + try { + builder = new SchoolRecordBuilder(SchoolRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SchoolRecordBuilder.With' should only be implemented by classes, which could be casted to 'SchoolRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SchoolRecordBuilder with() { + try { + return new SchoolRecordBuilder(SchoolRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SchoolRecordBuilder.With' should only be implemented by classes, which could be casted to 'SchoolRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScienceMuseumBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScienceMuseumBuilder.java new file mode 100644 index 00000000..3797e183 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ScienceMuseumBuilder.java @@ -0,0 +1,641 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.ScienceMuseum}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ScienceMuseum 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. + * + *

    Example:

    + * + *
    {@code
    + * ScienceMuseum result = ScienceMuseumBuilder.create()
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .exhibitCount(42)
    + *     .exhibitCount(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .interactiveDisplays(42)
    + *     .interactiveDisplays(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScienceMuseum.class) +public class ScienceMuseumBuilder implements IBuilderBase { + + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for exhibitCount: exhibitCount. + */ + private TrackedValue exhibitCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for interactiveDisplays: interactiveDisplays. + */ + private TrackedValue interactiveDisplays = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScienceMuseum}. + */ + public ScienceMuseumBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScienceMuseum} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScienceMuseumBuilder(ScienceMuseum instance) { + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.exhibitCount = initialValue(instance.getExhibitCount()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.interactiveDisplays = initialValue(instance.getInteractiveDisplays()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScienceMuseum}. + * + *

    Example:

    + * + *
    {@code
    +   * ScienceMuseumBuilder builder = ScienceMuseumBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.ScienceMuseum} + */ + public static ScienceMuseumBuilder create() { + return new ScienceMuseumBuilder(); + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link ScienceMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public ScienceMuseumBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public ScienceMuseumBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ScienceMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ScienceMuseumBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ScienceMuseumBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for exhibitCount. + *

    + * Generated from setter {@link ScienceMuseum#setExhibitCount(int) setExhibitCount(int exhibitCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitCount(42);
    +   * }
    + * + * @param exhibitCount exhibitCount + * @return current instance of builder + */ + public ScienceMuseumBuilder exhibitCount(int exhibitCount) { + this.exhibitCount = changedValue(exhibitCount); + return this; + } + + /** + * Sets the value for exhibitCount by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setExhibitCount(int) setExhibitCount(int exhibitCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.exhibitCount(() -> 42);
    +   * }
    + * + * @param exhibitCountSupplier supplier for exhibitCount + * @return current instance of builder + */ + public ScienceMuseumBuilder exhibitCount(Supplier exhibitCountSupplier) { + this.exhibitCount = changedValue(exhibitCountSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ScienceMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ScienceMuseumBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ScienceMuseumBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ScienceMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ScienceMuseumBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ScienceMuseumBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for interactiveDisplays. + *

    + * Generated from setter {@link ScienceMuseum#setInteractiveDisplays(int) setInteractiveDisplays(int + * interactiveDisplays)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.interactiveDisplays(42);
    +   * }
    + * + * @param interactiveDisplays interactiveDisplays + * @return current instance of builder + */ + public ScienceMuseumBuilder interactiveDisplays(int interactiveDisplays) { + this.interactiveDisplays = changedValue(interactiveDisplays); + return this; + } + + /** + * Sets the value for interactiveDisplays by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setInteractiveDisplays(int) setInteractiveDisplays(int + * interactiveDisplays)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.interactiveDisplays(() -> 42);
    +   * }
    + * + * @param interactiveDisplaysSupplier supplier for interactiveDisplays + * @return current instance of builder + */ + public ScienceMuseumBuilder interactiveDisplays(Supplier interactiveDisplaysSupplier) { + this.interactiveDisplays = changedValue(interactiveDisplaysSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ScienceMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ScienceMuseumBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ScienceMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ScienceMuseumBuilder 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. + *

    + * Generated from setter {@link ScienceMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ScienceMuseumBuilder 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. + *

    + * Generated from setter {@link ScienceMuseum#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScienceMuseumBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ScienceMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ScienceMuseumBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ScienceMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ScienceMuseumBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ScienceMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ScienceMuseumBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ScienceMuseum#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScienceMuseumBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ScienceMuseumBuilder 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 ScienceMuseumBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScienceMuseum result = builder.build();
    +   * }
    + */ + @Override + public ScienceMuseum build() { + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.exhibitCount.isSet() && this.exhibitCount.value() == null) { + throw new IllegalStateException("Field 'exhibitCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.interactiveDisplays.isSet() && this.interactiveDisplays.value() == null) { + throw new IllegalStateException("Field 'interactiveDisplays' is marked as non-null but null value was provided"); + } + ScienceMuseum result = new ScienceMuseum(); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.createdAt.ifSet(result::setCreatedAt); + this.exhibitCount.ifSet(result::setExhibitCount); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.interactiveDisplays.ifSet(result::setInteractiveDisplays); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualVisitors", this.annualVisitors) + .append("createdAt", this.createdAt) + .append("exhibitCount", this.exhibitCount) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("interactiveDisplays", this.interactiveDisplays) + .append("name", this.name) + .append("status", this.status) + .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 ScienceMuseum with(Consumer b) { + ScienceMuseumBuilder builder; + try { + builder = new ScienceMuseumBuilder(ScienceMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScienceMuseumBuilder.With' should only be implemented by classes, which could be casted to 'ScienceMuseum'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScienceMuseumBuilder with() { + try { + return new ScienceMuseumBuilder(ScienceMuseum.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScienceMuseumBuilder.With' should only be implemented by classes, which could be casted to 'ScienceMuseum'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SectionRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SectionRecordBuilder.java new file mode 100644 index 00000000..1e5992a5 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SectionRecordBuilder.java @@ -0,0 +1,555 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.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.performance_test.library.organizations.SectionRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SectionRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SectionRecord result = SectionRecordBuilder.create()
    + *     .sectionName("example value")
    + *     .sectionName("Hello %s", "World")
    + *     .sectionName(() -> "example value")
    + *     .sectionName(sb -> sb.append("text"))
    + *     .parentOrganization("example value")
    + *     .parentOrganization("Hello %s", "World")
    + *     .parentOrganization(() -> "example value")
    + *     .parentOrganization(sb -> sb.append("text"))
    + *     .focusArea("example value")
    + *     .focusArea("Hello %s", "World")
    + *     .focusArea(() -> "example value")
    + *     .focusArea(sb -> sb.append("text"))
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SectionRecord.class) +public class SectionRecordBuilder implements IBuilderBase { + + /** + * Tracked value for sectionName: sectionName. + */ + private TrackedValue sectionName = unsetValue(); + /** + * Tracked value for parentOrganization: parentOrganization. + */ + private TrackedValue parentOrganization = unsetValue(); + /** + * Tracked value for focusArea: focusArea. + */ + private TrackedValue focusArea = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SectionRecord}. + */ + public SectionRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SectionRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SectionRecordBuilder(SectionRecord instance) { + this.sectionName = initialValue(instance.sectionName()); + this.parentOrganization = initialValue(instance.parentOrganization()); + this.focusArea = initialValue(instance.focusArea()); + this.memberCount = initialValue(instance.memberCount()); + this.foundedYear = initialValue(instance.foundedYear()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SectionRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SectionRecordBuilder builder = SectionRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SectionRecord} + */ + public static SectionRecordBuilder create() { + return new SectionRecordBuilder(); + } + + /** + * Sets the value for focusArea. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea("example value");
    +   * }
    + * + * @param focusArea focusArea + * @return current instance of builder + */ + public SectionRecordBuilder focusArea(String focusArea) { + this.focusArea = changedValue(focusArea); + return this; + } + + /** + * Sets the value for focusArea by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea(sb -> sb.append("text"));
    +   * }
    + * + * @param focusAreaStringBuilderConsumer consumer providing an instance of focusArea + * @return current instance of builder + */ + public SectionRecordBuilder focusArea(Consumer focusAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + focusAreaStringBuilderConsumer.accept(builder); + this.focusArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for focusArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea(() -> "example value");
    +   * }
    + * + * @param focusAreaSupplier supplier for focusArea + * @return current instance of builder + */ + public SectionRecordBuilder focusArea(Supplier focusAreaSupplier) { + this.focusArea = changedValue(focusAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for focusArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SectionRecordBuilder focusArea(String format, Object... args) { + this.focusArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SectionRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SectionRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public SectionRecordBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public SectionRecordBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for parentOrganization. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization("example value");
    +   * }
    + * + * @param parentOrganization parentOrganization + * @return current instance of builder + */ + public SectionRecordBuilder parentOrganization(String parentOrganization) { + this.parentOrganization = changedValue(parentOrganization); + return this; + } + + /** + * Sets the value for parentOrganization by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization(sb -> sb.append("text"));
    +   * }
    + * + * @param parentOrganizationStringBuilderConsumer consumer providing an instance of parentOrganization + * @return current instance of builder + */ + public SectionRecordBuilder parentOrganization(Consumer parentOrganizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + parentOrganizationStringBuilderConsumer.accept(builder); + this.parentOrganization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for parentOrganization by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization(() -> "example value");
    +   * }
    + * + * @param parentOrganizationSupplier supplier for parentOrganization + * @return current instance of builder + */ + public SectionRecordBuilder parentOrganization(Supplier parentOrganizationSupplier) { + this.parentOrganization = changedValue(parentOrganizationSupplier.get()); + return this; + } + + /** + * Sets the String value for parentOrganization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SectionRecordBuilder parentOrganization(String format, Object... args) { + this.parentOrganization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sectionName. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sectionName("example value");
    +   * }
    + * + * @param sectionName sectionName + * @return current instance of builder + */ + public SectionRecordBuilder sectionName(String sectionName) { + this.sectionName = changedValue(sectionName); + return this; + } + + /** + * Sets the value for sectionName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sectionName(sb -> sb.append("text"));
    +   * }
    + * + * @param sectionNameStringBuilderConsumer consumer providing an instance of sectionName + * @return current instance of builder + */ + public SectionRecordBuilder sectionName(Consumer sectionNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sectionNameStringBuilderConsumer.accept(builder); + this.sectionName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sectionName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sectionName(() -> "example value");
    +   * }
    + * + * @param sectionNameSupplier supplier for sectionName + * @return current instance of builder + */ + public SectionRecordBuilder sectionName(Supplier sectionNameSupplier) { + this.sectionName = changedValue(sectionNameSupplier.get()); + return this; + } + + /** + * Sets the String value for sectionName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SectionRecord#SectionRecord(String, String, String, int, int) + * SectionRecord(String sectionName, String parentOrganization, String focusArea, int memberCount, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sectionName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SectionRecordBuilder sectionName(String format, Object... args) { + this.sectionName = changedValue(String.format(format, args)); + 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 SectionRecordBuilder 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 SectionRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SectionRecord result = builder.build();
    +   * }
    + */ + @Override + public SectionRecord build() { + if (!this.memberCount.isSet()) { + throw new IllegalStateException("Required field 'memberCount' must be set before calling build()"); + } + if (this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + SectionRecord result = new SectionRecord(this.sectionName.value(), + this.parentOrganization.value(), + this.focusArea.value(), + this.memberCount.value(), + this.foundedYear.value()); + 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("sectionName", this.sectionName) + .append("parentOrganization", this.parentOrganization) + .append("focusArea", this.focusArea) + .append("memberCount", this.memberCount) + .append("foundedYear", this.foundedYear) + .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 SectionRecord with(Consumer b) { + SectionRecordBuilder builder; + try { + builder = new SectionRecordBuilder(SectionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SectionRecordBuilder.With' should only be implemented by classes, which could be casted to 'SectionRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SectionRecordBuilder with() { + try { + return new SectionRecordBuilder(SectionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SectionRecordBuilder.With' should only be implemented by classes, which could be casted to 'SectionRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SelfPublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SelfPublisherBuilder.java new file mode 100644 index 00000000..c72ab754 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SelfPublisherBuilder.java @@ -0,0 +1,759 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.SelfPublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SelfPublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * SelfPublisher result = SelfPublisherBuilder.create()
    + *     .annualPublications(42)
    + *     .annualPublications(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .platformName("example value")
    + *     .platformName("Hello %s", "World")
    + *     .platformName(() -> "example value")
    + *     .platformName(sb -> sb.append("text"))
    + *     .registeredAuthors(42)
    + *     .registeredAuthors(() -> 42)
    + *     .servicesOffered(List.of("example value"))
    + *     .servicesOffered(() -> List.of("example value"))
    + *     .servicesOffered(t -> t.add("example value"))
    + *     .servicesOffered("example value", "example value")
    + *     .add2ServicesOffered("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SelfPublisher.class) +public class SelfPublisherBuilder implements IBuilderBase { + + /** + * Tracked value for annualPublications: annualPublications. + */ + private TrackedValue annualPublications = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for platformName: platformName. + */ + private TrackedValue platformName = unsetValue(); + /** + * Tracked value for registeredAuthors: registeredAuthors. + */ + private TrackedValue registeredAuthors = unsetValue(); + /** + * Tracked value for servicesOffered: servicesOffered. + */ + private TrackedValue> servicesOffered = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SelfPublisher}. + */ + public SelfPublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SelfPublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public SelfPublisherBuilder(SelfPublisher instance) { + this.annualPublications = initialValue(instance.getAnnualPublications()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.platformName = initialValue(instance.getPlatformName()); + this.registeredAuthors = initialValue(instance.getRegisteredAuthors()); + this.servicesOffered = initialValue(instance.getServicesOffered()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SelfPublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * SelfPublisherBuilder builder = SelfPublisherBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SelfPublisher} + */ + public static SelfPublisherBuilder create() { + return new SelfPublisherBuilder(); + } + + /** + * Adds a single element to servicesOffered. + *

    + * Generated from setter {@link SelfPublisher#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ServicesOffered("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public SelfPublisherBuilder add2ServicesOffered(String element) { + List newCollection; + if (this.servicesOffered.isSet()) { + newCollection = new ArrayList<>(this.servicesOffered.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.servicesOffered = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualPublications. + *

    + * Generated from setter {@link SelfPublisher#setAnnualPublications(int) setAnnualPublications(int + * annualPublications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualPublications(42);
    +   * }
    + * + * @param annualPublications annualPublications + * @return current instance of builder + */ + public SelfPublisherBuilder annualPublications(int annualPublications) { + this.annualPublications = changedValue(annualPublications); + return this; + } + + /** + * Sets the value for annualPublications by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setAnnualPublications(int) setAnnualPublications(int + * annualPublications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualPublications(() -> 42);
    +   * }
    + * + * @param annualPublicationsSupplier supplier for annualPublications + * @return current instance of builder + */ + public SelfPublisherBuilder annualPublications(Supplier annualPublicationsSupplier) { + this.annualPublications = changedValue(annualPublicationsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SelfPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SelfPublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SelfPublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SelfPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SelfPublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SelfPublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SelfPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SelfPublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SelfPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SelfPublisherBuilder 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. + *

    + * Generated from setter {@link SelfPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SelfPublisherBuilder 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. + *

    + * Generated from setter {@link SelfPublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SelfPublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for platformName. + *

    + * Generated from setter {@link SelfPublisher#setPlatformName(String) setPlatformName(String platformName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName("example value");
    +   * }
    + * + * @param platformName platformName + * @return current instance of builder + */ + public SelfPublisherBuilder platformName(String platformName) { + this.platformName = changedValue(platformName); + return this; + } + + /** + * Sets the value for platformName by executing the provided consumer. + *

    + * Generated from setter {@link SelfPublisher#setPlatformName(String) setPlatformName(String platformName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName(sb -> sb.append("text"));
    +   * }
    + * + * @param platformNameStringBuilderConsumer consumer providing an instance of platformName + * @return current instance of builder + */ + public SelfPublisherBuilder platformName(Consumer platformNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + platformNameStringBuilderConsumer.accept(builder); + this.platformName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for platformName by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setPlatformName(String) setPlatformName(String platformName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName(() -> "example value");
    +   * }
    + * + * @param platformNameSupplier supplier for platformName + * @return current instance of builder + */ + public SelfPublisherBuilder platformName(Supplier platformNameSupplier) { + this.platformName = changedValue(platformNameSupplier.get()); + return this; + } + + /** + * Sets the String value for platformName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SelfPublisher#setPlatformName(String) setPlatformName(String platformName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platformName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SelfPublisherBuilder platformName(String format, Object... args) { + this.platformName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for registeredAuthors. + *

    + * Generated from setter {@link SelfPublisher#setRegisteredAuthors(int) setRegisteredAuthors(int registeredAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registeredAuthors(42);
    +   * }
    + * + * @param registeredAuthors registeredAuthors + * @return current instance of builder + */ + public SelfPublisherBuilder registeredAuthors(int registeredAuthors) { + this.registeredAuthors = changedValue(registeredAuthors); + return this; + } + + /** + * Sets the value for registeredAuthors by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setRegisteredAuthors(int) setRegisteredAuthors(int registeredAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registeredAuthors(() -> 42);
    +   * }
    + * + * @param registeredAuthorsSupplier supplier for registeredAuthors + * @return current instance of builder + */ + public SelfPublisherBuilder registeredAuthors(Supplier registeredAuthorsSupplier) { + this.registeredAuthors = changedValue(registeredAuthorsSupplier.get()); + return this; + } + + /** + * Sets the value for servicesOffered. + *

    + * Generated from setter {@link SelfPublisher#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered("example value", "example value");
    +   * }
    + * + * @param servicesOffered servicesOffered + * @return current instance of builder + */ + public SelfPublisherBuilder servicesOffered(String... servicesOffered) { + this.servicesOffered = changedValue(List.of(servicesOffered)); + return this; + } + + /** + * Sets the value for servicesOffered. + *

    + * Generated from setter {@link SelfPublisher#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered(List.of("example value"));
    +   * }
    + * + * @param servicesOffered servicesOffered + * @return current instance of builder + */ + public SelfPublisherBuilder servicesOffered(List servicesOffered) { + this.servicesOffered = changedValue(servicesOffered); + return this; + } + + /** + * Sets the value for servicesOffered using a builder consumer that produces the value. + *

    + * Generated from setter {@link SelfPublisher#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered(t -> t.add("example value"));
    +   * }
    + * + * @param servicesOfferedBuilderConsumer consumer providing an instance of a builder for servicesOffered + * @return current instance of builder + */ + public SelfPublisherBuilder servicesOffered(Consumer> servicesOfferedBuilderConsumer) { + ArrayListBuilder builder = this.servicesOffered.isSet() + ? new ArrayListBuilder(this.servicesOffered.value()) + : new ArrayListBuilder(); + servicesOfferedBuilderConsumer.accept(builder); + this.servicesOffered = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for servicesOffered by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setServicesOffered(List) setServicesOffered(List + * servicesOffered)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.servicesOffered(() -> List.of("example value"));
    +   * }
    + * + * @param servicesOfferedSupplier supplier for servicesOffered + * @return current instance of builder + */ + public SelfPublisherBuilder servicesOffered(Supplier> servicesOfferedSupplier) { + this.servicesOffered = changedValue(servicesOfferedSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SelfPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SelfPublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SelfPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SelfPublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SelfPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SelfPublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SelfPublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SelfPublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 SelfPublisherBuilder 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 SelfPublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SelfPublisher result = builder.build();
    +   * }
    + */ + @Override + public SelfPublisher build() { + if (this.annualPublications.isSet() && this.annualPublications.value() == null) { + throw new IllegalStateException("Field 'annualPublications' is marked as non-null but null value was provided"); + } + if (this.registeredAuthors.isSet() && this.registeredAuthors.value() == null) { + throw new IllegalStateException("Field 'registeredAuthors' is marked as non-null but null value was provided"); + } + SelfPublisher result = new SelfPublisher(); + this.annualPublications.ifSet(result::setAnnualPublications); + this.createdAt.ifSet(result::setCreatedAt); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.platformName.ifSet(result::setPlatformName); + this.registeredAuthors.ifSet(result::setRegisteredAuthors); + this.servicesOffered.ifSet(result::setServicesOffered); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualPublications", this.annualPublications) + .append("createdAt", this.createdAt) + .append("id", this.id) + .append("name", this.name) + .append("platformName", this.platformName) + .append("registeredAuthors", this.registeredAuthors) + .append("servicesOffered", this.servicesOffered) + .append("status", this.status) + .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 SelfPublisher with(Consumer b) { + SelfPublisherBuilder builder; + try { + builder = new SelfPublisherBuilder(SelfPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SelfPublisherBuilder.With' should only be implemented by classes, which could be casted to 'SelfPublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SelfPublisherBuilder with() { + try { + return new SelfPublisherBuilder(SelfPublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SelfPublisherBuilder.With' should only be implemented by classes, which could be casted to 'SelfPublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SmallPressBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SmallPressBuilder.java new file mode 100644 index 00000000..da7eafc3 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SmallPressBuilder.java @@ -0,0 +1,680 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.SmallPress}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SmallPress 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. + * + *

    Example:

    + * + *
    {@code
    + * SmallPress result = SmallPressBuilder.create()
    + *     .annualTitles(42)
    + *     .annualTitles(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .focusArea("example value")
    + *     .focusArea("Hello %s", "World")
    + *     .focusArea(() -> "example value")
    + *     .focusArea(sb -> sb.append("text"))
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .staffCount(42)
    + *     .staffCount(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SmallPress.class) +public class SmallPressBuilder implements IBuilderBase { + + /** + * Tracked value for annualTitles: annualTitles. + */ + private TrackedValue annualTitles = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for focusArea: focusArea. + */ + private TrackedValue focusArea = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for staffCount: staffCount. + */ + private TrackedValue staffCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SmallPress}. + */ + public SmallPressBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SmallPress} by a instance. + * + * @param instance object instance for initialisiation + */ + public SmallPressBuilder(SmallPress instance) { + this.annualTitles = initialValue(instance.getAnnualTitles()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.focusArea = initialValue(instance.getFocusArea()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.staffCount = initialValue(instance.getStaffCount()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SmallPress}. + * + *

    Example:

    + * + *
    {@code
    +   * SmallPressBuilder builder = SmallPressBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SmallPress} + */ + public static SmallPressBuilder create() { + return new SmallPressBuilder(); + } + + /** + * Sets the value for annualTitles. + *

    + * Generated from setter {@link SmallPress#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(42);
    +   * }
    + * + * @param annualTitles annualTitles + * @return current instance of builder + */ + public SmallPressBuilder annualTitles(int annualTitles) { + this.annualTitles = changedValue(annualTitles); + return this; + } + + /** + * Sets the value for annualTitles by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(() -> 42);
    +   * }
    + * + * @param annualTitlesSupplier supplier for annualTitles + * @return current instance of builder + */ + public SmallPressBuilder annualTitles(Supplier annualTitlesSupplier) { + this.annualTitles = changedValue(annualTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SmallPress#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SmallPressBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SmallPressBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for focusArea. + *

    + * Generated from setter {@link SmallPress#setFocusArea(String) setFocusArea(String focusArea)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea("example value");
    +   * }
    + * + * @param focusArea focusArea + * @return current instance of builder + */ + public SmallPressBuilder focusArea(String focusArea) { + this.focusArea = changedValue(focusArea); + return this; + } + + /** + * Sets the value for focusArea by executing the provided consumer. + *

    + * Generated from setter {@link SmallPress#setFocusArea(String) setFocusArea(String focusArea)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea(sb -> sb.append("text"));
    +   * }
    + * + * @param focusAreaStringBuilderConsumer consumer providing an instance of focusArea + * @return current instance of builder + */ + public SmallPressBuilder focusArea(Consumer focusAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + focusAreaStringBuilderConsumer.accept(builder); + this.focusArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for focusArea by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setFocusArea(String) setFocusArea(String focusArea)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea(() -> "example value");
    +   * }
    + * + * @param focusAreaSupplier supplier for focusArea + * @return current instance of builder + */ + public SmallPressBuilder focusArea(Supplier focusAreaSupplier) { + this.focusArea = changedValue(focusAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for focusArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SmallPress#setFocusArea(String) setFocusArea(String focusArea)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SmallPressBuilder focusArea(String format, Object... args) { + this.focusArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link SmallPress#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SmallPressBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SmallPressBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SmallPress#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SmallPressBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SmallPressBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SmallPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SmallPressBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SmallPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SmallPressBuilder 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. + *

    + * Generated from setter {@link SmallPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SmallPressBuilder 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. + *

    + * Generated from setter {@link SmallPress#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SmallPressBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for staffCount. + *

    + * Generated from setter {@link SmallPress#setStaffCount(int) setStaffCount(int staffCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(42);
    +   * }
    + * + * @param staffCount staffCount + * @return current instance of builder + */ + public SmallPressBuilder staffCount(int staffCount) { + this.staffCount = changedValue(staffCount); + return this; + } + + /** + * Sets the value for staffCount by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setStaffCount(int) setStaffCount(int staffCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(() -> 42);
    +   * }
    + * + * @param staffCountSupplier supplier for staffCount + * @return current instance of builder + */ + public SmallPressBuilder staffCount(Supplier staffCountSupplier) { + this.staffCount = changedValue(staffCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SmallPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SmallPressBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SmallPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SmallPressBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SmallPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SmallPressBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SmallPress#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SmallPressBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 SmallPressBuilder 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 SmallPressBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SmallPress result = builder.build();
    +   * }
    + */ + @Override + public SmallPress build() { + if (this.annualTitles.isSet() && this.annualTitles.value() == null) { + throw new IllegalStateException("Field 'annualTitles' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.staffCount.isSet() && this.staffCount.value() == null) { + throw new IllegalStateException("Field 'staffCount' is marked as non-null but null value was provided"); + } + SmallPress result = new SmallPress(); + this.annualTitles.ifSet(result::setAnnualTitles); + this.createdAt.ifSet(result::setCreatedAt); + this.focusArea.ifSet(result::setFocusArea); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.staffCount.ifSet(result::setStaffCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualTitles", this.annualTitles) + .append("createdAt", this.createdAt) + .append("focusArea", this.focusArea) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("staffCount", this.staffCount) + .append("status", this.status) + .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 SmallPress with(Consumer b) { + SmallPressBuilder builder; + try { + builder = new SmallPressBuilder(SmallPress.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SmallPressBuilder.With' should only be implemented by classes, which could be casted to 'SmallPress'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SmallPressBuilder with() { + try { + return new SmallPressBuilder(SmallPress.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SmallPressBuilder.With' should only be implemented by classes, which could be casted to 'SmallPress'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SocietyRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SocietyRecordBuilder.java new file mode 100644 index 00000000..355e9832 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SocietyRecordBuilder.java @@ -0,0 +1,507 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +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.performance_test.library.organizations.SocietyRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SocietyRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SocietyRecord result = SocietyRecordBuilder.create()
    + *     .societyName("example value")
    + *     .societyName("Hello %s", "World")
    + *     .societyName(() -> "example value")
    + *     .societyName(sb -> sb.append("text"))
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .field("example value")
    + *     .field("Hello %s", "World")
    + *     .field(() -> "example value")
    + *     .field(sb -> sb.append("text"))
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .annualFee(BigDecimal.valueOf(3.14))
    + *     .annualFee(() -> BigDecimal.valueOf(3.14))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SocietyRecord.class) +public class SocietyRecordBuilder implements IBuilderBase { + + /** + * Tracked value for societyName: societyName. + */ + private TrackedValue societyName = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for field: field. + */ + private TrackedValue field = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for annualFee: annualFee. + */ + private TrackedValue annualFee = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SocietyRecord}. + */ + public SocietyRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SocietyRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SocietyRecordBuilder(SocietyRecord instance) { + this.societyName = initialValue(instance.societyName()); + this.memberCount = initialValue(instance.memberCount()); + this.field = initialValue(instance.field()); + this.foundedYear = initialValue(instance.foundedYear()); + this.annualFee = initialValue(instance.annualFee()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SocietyRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SocietyRecordBuilder builder = SocietyRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SocietyRecord} + */ + public static SocietyRecordBuilder create() { + return new SocietyRecordBuilder(); + } + + /** + * Sets the value for annualFee. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualFee(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualFee annualFee + * @return current instance of builder + */ + public SocietyRecordBuilder annualFee(BigDecimal annualFee) { + this.annualFee = changedValue(annualFee); + return this; + } + + /** + * Sets the value for annualFee by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualFee(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param annualFeeSupplier supplier for annualFee + * @return current instance of builder + */ + public SocietyRecordBuilder annualFee(Supplier annualFeeSupplier) { + this.annualFee = changedValue(annualFeeSupplier.get()); + return this; + } + + /** + * Sets the value for field. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("example value");
    +   * }
    + * + * @param field field + * @return current instance of builder + */ + public SocietyRecordBuilder field(String field) { + this.field = changedValue(field); + return this; + } + + /** + * Sets the value for field by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(sb -> sb.append("text"));
    +   * }
    + * + * @param fieldStringBuilderConsumer consumer providing an instance of field + * @return current instance of builder + */ + public SocietyRecordBuilder field(Consumer fieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fieldStringBuilderConsumer.accept(builder); + this.field = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for field by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(() -> "example value");
    +   * }
    + * + * @param fieldSupplier supplier for field + * @return current instance of builder + */ + public SocietyRecordBuilder field(Supplier fieldSupplier) { + this.field = changedValue(fieldSupplier.get()); + return this; + } + + /** + * Sets the String value for field by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SocietyRecordBuilder field(String format, Object... args) { + this.field = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SocietyRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SocietyRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public SocietyRecordBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public SocietyRecordBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for societyName. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.societyName("example value");
    +   * }
    + * + * @param societyName societyName + * @return current instance of builder + */ + public SocietyRecordBuilder societyName(String societyName) { + this.societyName = changedValue(societyName); + return this; + } + + /** + * Sets the value for societyName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.societyName(sb -> sb.append("text"));
    +   * }
    + * + * @param societyNameStringBuilderConsumer consumer providing an instance of societyName + * @return current instance of builder + */ + public SocietyRecordBuilder societyName(Consumer societyNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + societyNameStringBuilderConsumer.accept(builder); + this.societyName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for societyName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.societyName(() -> "example value");
    +   * }
    + * + * @param societyNameSupplier supplier for societyName + * @return current instance of builder + */ + public SocietyRecordBuilder societyName(Supplier societyNameSupplier) { + this.societyName = changedValue(societyNameSupplier.get()); + return this; + } + + /** + * Sets the String value for societyName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SocietyRecord#SocietyRecord(String, int, String, int, BigDecimal) + * SocietyRecord(String societyName, int memberCount, String field, int foundedYear, BigDecimal annualFee)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.societyName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SocietyRecordBuilder societyName(String format, Object... args) { + this.societyName = changedValue(String.format(format, args)); + 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 SocietyRecordBuilder 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 SocietyRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SocietyRecord result = builder.build();
    +   * }
    + */ + @Override + public SocietyRecord build() { + if (!this.memberCount.isSet()) { + throw new IllegalStateException("Required field 'memberCount' must be set before calling build()"); + } + if (this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + SocietyRecord result = new SocietyRecord(this.societyName + .value(), this.memberCount.value(), this.field.value(), this.foundedYear.value(), this.annualFee.value()); + 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("societyName", this.societyName) + .append("memberCount", this.memberCount) + .append("field", this.field) + .append("foundedYear", this.foundedYear) + .append("annualFee", this.annualFee) + .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 SocietyRecord with(Consumer b) { + SocietyRecordBuilder builder; + try { + builder = new SocietyRecordBuilder(SocietyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SocietyRecordBuilder.With' should only be implemented by classes, which could be casted to 'SocietyRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SocietyRecordBuilder with() { + try { + return new SocietyRecordBuilder(SocietyRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SocietyRecordBuilder.With' should only be implemented by classes, which could be casted to 'SocietyRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialLibraryBuilder.java new file mode 100644 index 00000000..98803835 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialLibraryBuilder.java @@ -0,0 +1,721 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.SpecialLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SpecialLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * SpecialLibrary result = SpecialLibraryBuilder.create()
    + *     .accessPolicy("example value")
    + *     .accessPolicy("Hello %s", "World")
    + *     .accessPolicy(() -> "example value")
    + *     .accessPolicy(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .specialization("example value")
    + *     .specialization("Hello %s", "World")
    + *     .specialization(() -> "example value")
    + *     .specialization(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalVolumes(42L)
    + *     .totalVolumes(() -> 42L)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SpecialLibrary.class) +public class SpecialLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for accessPolicy: accessPolicy. + */ + private TrackedValue accessPolicy = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for specialization: specialization. + */ + private TrackedValue specialization = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalVolumes: totalVolumes. + */ + private TrackedValue totalVolumes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialLibrary}. + */ + public SpecialLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public SpecialLibraryBuilder(SpecialLibrary instance) { + this.accessPolicy = initialValue(instance.getAccessPolicy()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.specialization = initialValue(instance.getSpecialization()); + this.status = initialValue(instance.getStatus()); + this.totalVolumes = initialValue(instance.getTotalVolumes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * SpecialLibraryBuilder builder = SpecialLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialLibrary} + */ + public static SpecialLibraryBuilder create() { + return new SpecialLibraryBuilder(); + } + + /** + * Sets the value for accessPolicy. + *

    + * Generated from setter {@link SpecialLibrary#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy("example value");
    +   * }
    + * + * @param accessPolicy accessPolicy + * @return current instance of builder + */ + public SpecialLibraryBuilder accessPolicy(String accessPolicy) { + this.accessPolicy = changedValue(accessPolicy); + return this; + } + + /** + * Sets the value for accessPolicy by executing the provided consumer. + *

    + * Generated from setter {@link SpecialLibrary#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy(sb -> sb.append("text"));
    +   * }
    + * + * @param accessPolicyStringBuilderConsumer consumer providing an instance of accessPolicy + * @return current instance of builder + */ + public SpecialLibraryBuilder accessPolicy(Consumer accessPolicyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + accessPolicyStringBuilderConsumer.accept(builder); + this.accessPolicy = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for accessPolicy by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy(() -> "example value");
    +   * }
    + * + * @param accessPolicySupplier supplier for accessPolicy + * @return current instance of builder + */ + public SpecialLibraryBuilder accessPolicy(Supplier accessPolicySupplier) { + this.accessPolicy = changedValue(accessPolicySupplier.get()); + return this; + } + + /** + * Sets the String value for accessPolicy by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SpecialLibrary#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialLibraryBuilder accessPolicy(String format, Object... args) { + this.accessPolicy = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SpecialLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SpecialLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SpecialLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link SpecialLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SpecialLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SpecialLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SpecialLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SpecialLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SpecialLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SpecialLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SpecialLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SpecialLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SpecialLibraryBuilder 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. + *

    + * Generated from setter {@link SpecialLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SpecialLibraryBuilder 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. + *

    + * Generated from setter {@link SpecialLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for specialization. + *

    + * Generated from setter {@link SpecialLibrary#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("example value");
    +   * }
    + * + * @param specialization specialization + * @return current instance of builder + */ + public SpecialLibraryBuilder specialization(String specialization) { + this.specialization = changedValue(specialization); + return this; + } + + /** + * Sets the value for specialization by executing the provided consumer. + *

    + * Generated from setter {@link SpecialLibrary#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(sb -> sb.append("text"));
    +   * }
    + * + * @param specializationStringBuilderConsumer consumer providing an instance of specialization + * @return current instance of builder + */ + public SpecialLibraryBuilder specialization(Consumer specializationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specializationStringBuilderConsumer.accept(builder); + this.specialization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialization by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(() -> "example value");
    +   * }
    + * + * @param specializationSupplier supplier for specialization + * @return current instance of builder + */ + public SpecialLibraryBuilder specialization(Supplier specializationSupplier) { + this.specialization = changedValue(specializationSupplier.get()); + return this; + } + + /** + * Sets the String value for specialization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SpecialLibrary#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialLibraryBuilder specialization(String format, Object... args) { + this.specialization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SpecialLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SpecialLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SpecialLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SpecialLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SpecialLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SpecialLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalVolumes. + *

    + * Generated from setter {@link SpecialLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(42L);
    +   * }
    + * + * @param totalVolumes totalVolumes + * @return current instance of builder + */ + public SpecialLibraryBuilder totalVolumes(long totalVolumes) { + this.totalVolumes = changedValue(totalVolumes); + return this; + } + + /** + * Sets the value for totalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(() -> 42L);
    +   * }
    + * + * @param totalVolumesSupplier supplier for totalVolumes + * @return current instance of builder + */ + public SpecialLibraryBuilder totalVolumes(Supplier totalVolumesSupplier) { + this.totalVolumes = changedValue(totalVolumesSupplier.get()); + 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 SpecialLibraryBuilder 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 SpecialLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SpecialLibrary result = builder.build();
    +   * }
    + */ + @Override + public SpecialLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.totalVolumes.isSet() && this.totalVolumes.value() == null) { + throw new IllegalStateException("Field 'totalVolumes' is marked as non-null but null value was provided"); + } + SpecialLibrary result = new SpecialLibrary(); + this.accessPolicy.ifSet(result::setAccessPolicy); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.specialization.ifSet(result::setSpecialization); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalVolumes.ifSet(result::setTotalVolumes); + 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("accessPolicy", this.accessPolicy) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("specialization", this.specialization) + .append("status", this.status) + .append("totalVolumes", this.totalVolumes) + .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 SpecialLibrary with(Consumer b) { + SpecialLibraryBuilder builder; + try { + builder = new SpecialLibraryBuilder(SpecialLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SpecialLibraryBuilder.With' should only be implemented by classes, which could be casted to 'SpecialLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SpecialLibraryBuilder with() { + try { + return new SpecialLibraryBuilder(SpecialLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SpecialLibraryBuilder.With' should only be implemented by classes, which could be casted to 'SpecialLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialtyBookstoreBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialtyBookstoreBuilder.java new file mode 100644 index 00000000..73f8377e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SpecialtyBookstoreBuilder.java @@ -0,0 +1,723 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.SpecialtyBookstore}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SpecialtyBookstore 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. + * + *

    Example:

    + * + *
    {@code
    + * SpecialtyBookstore result = SpecialtyBookstoreBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .inventorySize(42)
    + *     .inventorySize(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .specialty("example value")
    + *     .specialty("Hello %s", "World")
    + *     .specialty(() -> "example value")
    + *     .specialty(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .storeName("example value")
    + *     .storeName("Hello %s", "World")
    + *     .storeName(() -> "example value")
    + *     .storeName(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SpecialtyBookstore.class) +public class SpecialtyBookstoreBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for inventorySize: inventorySize. + */ + private TrackedValue inventorySize = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for specialty: specialty. + */ + private TrackedValue specialty = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for storeName: storeName. + */ + private TrackedValue storeName = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialtyBookstore}. + */ + public SpecialtyBookstoreBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialtyBookstore} by a instance. + * + * @param instance object instance for initialisiation + */ + public SpecialtyBookstoreBuilder(SpecialtyBookstore instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.inventorySize = initialValue(instance.getInventorySize()); + this.name = initialValue(instance.getName()); + this.specialty = initialValue(instance.getSpecialty()); + this.status = initialValue(instance.getStatus()); + this.storeName = initialValue(instance.getStoreName()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialtyBookstore}. + * + *

    Example:

    + * + *
    {@code
    +   * SpecialtyBookstoreBuilder builder = SpecialtyBookstoreBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SpecialtyBookstore} + */ + public static SpecialtyBookstoreBuilder create() { + return new SpecialtyBookstoreBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SpecialtyBookstore#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link SpecialtyBookstore#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SpecialtyBookstore#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for inventorySize. + *

    + * Generated from setter {@link SpecialtyBookstore#setInventorySize(int) setInventorySize(int inventorySize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.inventorySize(42);
    +   * }
    + * + * @param inventorySize inventorySize + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder inventorySize(int inventorySize) { + this.inventorySize = changedValue(inventorySize); + return this; + } + + /** + * Sets the value for inventorySize by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setInventorySize(int) setInventorySize(int inventorySize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.inventorySize(() -> 42);
    +   * }
    + * + * @param inventorySizeSupplier supplier for inventorySize + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder inventorySize(Supplier inventorySizeSupplier) { + this.inventorySize = changedValue(inventorySizeSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SpecialtyBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SpecialtyBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder 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. + *

    + * Generated from setter {@link SpecialtyBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder 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. + *

    + * Generated from setter {@link SpecialtyBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for specialty. + *

    + * Generated from setter {@link SpecialtyBookstore#setSpecialty(String) setSpecialty(String specialty)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty("example value");
    +   * }
    + * + * @param specialty specialty + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder specialty(String specialty) { + this.specialty = changedValue(specialty); + return this; + } + + /** + * Sets the value for specialty by executing the provided consumer. + *

    + * Generated from setter {@link SpecialtyBookstore#setSpecialty(String) setSpecialty(String specialty)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty(sb -> sb.append("text"));
    +   * }
    + * + * @param specialtyStringBuilderConsumer consumer providing an instance of specialty + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder specialty(Consumer specialtyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specialtyStringBuilderConsumer.accept(builder); + this.specialty = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialty by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setSpecialty(String) setSpecialty(String specialty)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty(() -> "example value");
    +   * }
    + * + * @param specialtySupplier supplier for specialty + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder specialty(Supplier specialtySupplier) { + this.specialty = changedValue(specialtySupplier.get()); + return this; + } + + /** + * Sets the String value for specialty by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SpecialtyBookstore#setSpecialty(String) setSpecialty(String specialty)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder specialty(String format, Object... args) { + this.specialty = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SpecialtyBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SpecialtyBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SpecialtyBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for storeName. + *

    + * Generated from setter {@link SpecialtyBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName("example value");
    +   * }
    + * + * @param storeName storeName + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder storeName(String storeName) { + this.storeName = changedValue(storeName); + return this; + } + + /** + * Sets the value for storeName by executing the provided consumer. + *

    + * Generated from setter {@link SpecialtyBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName(sb -> sb.append("text"));
    +   * }
    + * + * @param storeNameStringBuilderConsumer consumer providing an instance of storeName + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder storeName(Consumer storeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + storeNameStringBuilderConsumer.accept(builder); + this.storeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for storeName by invoking the provided supplier. + *

    + * Generated from setter {@link SpecialtyBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName(() -> "example value");
    +   * }
    + * + * @param storeNameSupplier supplier for storeName + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder storeName(Supplier storeNameSupplier) { + this.storeName = changedValue(storeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for storeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SpecialtyBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialtyBookstoreBuilder storeName(String format, Object... args) { + this.storeName = changedValue(String.format(format, args)); + 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 SpecialtyBookstoreBuilder 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 SpecialtyBookstoreBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SpecialtyBookstore result = builder.build();
    +   * }
    + */ + @Override + public SpecialtyBookstore build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.inventorySize.isSet() && this.inventorySize.value() == null) { + throw new IllegalStateException("Field 'inventorySize' is marked as non-null but null value was provided"); + } + SpecialtyBookstore result = new SpecialtyBookstore(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.inventorySize.ifSet(result::setInventorySize); + this.name.ifSet(result::setName); + this.specialty.ifSet(result::setSpecialty); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.storeName.ifSet(result::setStoreName); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("inventorySize", this.inventorySize) + .append("name", this.name) + .append("specialty", this.specialty) + .append("status", this.status) + .append("storeName", this.storeName) + .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 SpecialtyBookstore with(Consumer b) { + SpecialtyBookstoreBuilder builder; + try { + builder = new SpecialtyBookstoreBuilder(SpecialtyBookstore.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SpecialtyBookstoreBuilder.With' should only be implemented by classes, which could be casted to 'SpecialtyBookstore'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SpecialtyBookstoreBuilder with() { + try { + return new SpecialtyBookstoreBuilder(SpecialtyBookstore.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SpecialtyBookstoreBuilder.With' should only be implemented by classes, which could be casted to 'SpecialtyBookstore'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SponsorshipRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SponsorshipRecordBuilder.java new file mode 100644 index 00000000..cd3b8a57 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SponsorshipRecordBuilder.java @@ -0,0 +1,526 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +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.performance_test.library.organizations.SponsorshipRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SponsorshipRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SponsorshipRecord result = SponsorshipRecordBuilder.create()
    + *     .sponsorName("example value")
    + *     .sponsorName("Hello %s", "World")
    + *     .sponsorName(() -> "example value")
    + *     .sponsorName(sb -> sb.append("text"))
    + *     .beneficiary("example value")
    + *     .beneficiary("Hello %s", "World")
    + *     .beneficiary(() -> "example value")
    + *     .beneficiary(sb -> sb.append("text"))
    + *     .amount(BigDecimal.valueOf(3.14))
    + *     .amount(() -> BigDecimal.valueOf(3.14))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .endDate(LocalDate.now())
    + *     .endDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SponsorshipRecord.class) +public class SponsorshipRecordBuilder implements IBuilderBase { + + /** + * Tracked value for sponsorName: sponsorName. + */ + private TrackedValue sponsorName = unsetValue(); + /** + * Tracked value for beneficiary: beneficiary. + */ + private TrackedValue beneficiary = unsetValue(); + /** + * Tracked value for amount: amount. + */ + private TrackedValue amount = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + /** + * Tracked value for endDate: endDate. + */ + private TrackedValue endDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SponsorshipRecord}. + */ + public SponsorshipRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SponsorshipRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SponsorshipRecordBuilder(SponsorshipRecord instance) { + this.sponsorName = initialValue(instance.sponsorName()); + this.beneficiary = initialValue(instance.beneficiary()); + this.amount = initialValue(instance.amount()); + this.startDate = initialValue(instance.startDate()); + this.endDate = initialValue(instance.endDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SponsorshipRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SponsorshipRecordBuilder builder = SponsorshipRecordBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SponsorshipRecord} + */ + public static SponsorshipRecordBuilder create() { + return new SponsorshipRecordBuilder(); + } + + /** + * Sets the value for amount. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.amount(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param amount amount + * @return current instance of builder + */ + public SponsorshipRecordBuilder amount(BigDecimal amount) { + this.amount = changedValue(amount); + return this; + } + + /** + * Sets the value for amount by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.amount(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param amountSupplier supplier for amount + * @return current instance of builder + */ + public SponsorshipRecordBuilder amount(Supplier amountSupplier) { + this.amount = changedValue(amountSupplier.get()); + return this; + } + + /** + * Sets the value for beneficiary. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.beneficiary("example value");
    +   * }
    + * + * @param beneficiary beneficiary + * @return current instance of builder + */ + public SponsorshipRecordBuilder beneficiary(String beneficiary) { + this.beneficiary = changedValue(beneficiary); + return this; + } + + /** + * Sets the value for beneficiary by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.beneficiary(sb -> sb.append("text"));
    +   * }
    + * + * @param beneficiaryStringBuilderConsumer consumer providing an instance of beneficiary + * @return current instance of builder + */ + public SponsorshipRecordBuilder beneficiary(Consumer beneficiaryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + beneficiaryStringBuilderConsumer.accept(builder); + this.beneficiary = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for beneficiary by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.beneficiary(() -> "example value");
    +   * }
    + * + * @param beneficiarySupplier supplier for beneficiary + * @return current instance of builder + */ + public SponsorshipRecordBuilder beneficiary(Supplier beneficiarySupplier) { + this.beneficiary = changedValue(beneficiarySupplier.get()); + return this; + } + + /** + * Sets the String value for beneficiary by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.beneficiary("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SponsorshipRecordBuilder beneficiary(String format, Object... args) { + this.beneficiary = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for endDate. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endDate(LocalDate.now());
    +   * }
    + * + * @param endDate endDate + * @return current instance of builder + */ + public SponsorshipRecordBuilder endDate(LocalDate endDate) { + this.endDate = changedValue(endDate); + return this; + } + + /** + * Sets the value for endDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.endDate(() -> LocalDate.now());
    +   * }
    + * + * @param endDateSupplier supplier for endDate + * @return current instance of builder + */ + public SponsorshipRecordBuilder endDate(Supplier endDateSupplier) { + this.endDate = changedValue(endDateSupplier.get()); + return this; + } + + /** + * Sets the value for sponsorName. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName("example value");
    +   * }
    + * + * @param sponsorName sponsorName + * @return current instance of builder + */ + public SponsorshipRecordBuilder sponsorName(String sponsorName) { + this.sponsorName = changedValue(sponsorName); + return this; + } + + /** + * Sets the value for sponsorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName(sb -> sb.append("text"));
    +   * }
    + * + * @param sponsorNameStringBuilderConsumer consumer providing an instance of sponsorName + * @return current instance of builder + */ + public SponsorshipRecordBuilder sponsorName(Consumer sponsorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sponsorNameStringBuilderConsumer.accept(builder); + this.sponsorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sponsorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName(() -> "example value");
    +   * }
    + * + * @param sponsorNameSupplier supplier for sponsorName + * @return current instance of builder + */ + public SponsorshipRecordBuilder sponsorName(Supplier sponsorNameSupplier) { + this.sponsorName = changedValue(sponsorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for sponsorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SponsorshipRecordBuilder sponsorName(String format, Object... args) { + this.sponsorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public SponsorshipRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorshipRecord#SponsorshipRecord(String, String, BigDecimal, LocalDate, LocalDate) + * SponsorshipRecord(String sponsorName, String beneficiary, BigDecimal amount, LocalDate startDate, LocalDate + * endDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public SponsorshipRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + 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 SponsorshipRecordBuilder 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 SponsorshipRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SponsorshipRecord result = builder.build();
    +   * }
    + */ + @Override + public SponsorshipRecord build() { + SponsorshipRecord result = new SponsorshipRecord(this.sponsorName + .value(), this.beneficiary.value(), this.amount.value(), this.startDate.value(), this.endDate.value()); + 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("sponsorName", this.sponsorName) + .append("beneficiary", this.beneficiary) + .append("amount", this.amount) + .append("startDate", this.startDate) + .append("endDate", this.endDate) + .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 SponsorshipRecord with(Consumer b) { + SponsorshipRecordBuilder builder; + try { + builder = new SponsorshipRecordBuilder(SponsorshipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SponsorshipRecordBuilder.With' should only be implemented by classes, which could be casted to 'SponsorshipRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SponsorshipRecordBuilder with() { + try { + return new SponsorshipRecordBuilder(SponsorshipRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SponsorshipRecordBuilder.With' should only be implemented by classes, which could be casted to 'SponsorshipRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StandardsOrganizationBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StandardsOrganizationBuilder.java new file mode 100644 index 00000000..0ad3fa6e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StandardsOrganizationBuilder.java @@ -0,0 +1,716 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.StandardsOrganization}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.StandardsOrganization 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. + * + *

    Example:

    + * + *
    {@code
    + * StandardsOrganization result = StandardsOrganizationBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .focusAreas(List.of("example value"))
    + *     .focusAreas(() -> List.of("example value"))
    + *     .focusAreas(t -> t.add("example value"))
    + *     .focusAreas("example value", "example value")
    + *     .add2FocusAreas("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberOrganizations(42)
    + *     .memberOrganizations(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .standardsPublished(42)
    + *     .standardsPublished(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StandardsOrganization.class) +public class StandardsOrganizationBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for focusAreas: focusAreas. + */ + private TrackedValue> focusAreas = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberOrganizations: memberOrganizations. + */ + private TrackedValue memberOrganizations = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for standardsPublished: standardsPublished. + */ + private TrackedValue standardsPublished = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StandardsOrganization}. + */ + public StandardsOrganizationBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StandardsOrganization} by a instance. + * + * @param instance object instance for initialisiation + */ + public StandardsOrganizationBuilder(StandardsOrganization instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.focusAreas = initialValue(instance.getFocusAreas()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberOrganizations = initialValue(instance.getMemberOrganizations()); + this.name = initialValue(instance.getName()); + this.standardsPublished = initialValue(instance.getStandardsPublished()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StandardsOrganization}. + * + *

    Example:

    + * + *
    {@code
    +   * StandardsOrganizationBuilder builder = StandardsOrganizationBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StandardsOrganization} + */ + public static StandardsOrganizationBuilder create() { + return new StandardsOrganizationBuilder(); + } + + /** + * Adds a single element to focusAreas. + *

    + * Generated from setter {@link StandardsOrganization#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2FocusAreas("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public StandardsOrganizationBuilder add2FocusAreas(String element) { + List newCollection; + if (this.focusAreas.isSet()) { + newCollection = new ArrayList<>(this.focusAreas.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.focusAreas = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link StandardsOrganization#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public StandardsOrganizationBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public StandardsOrganizationBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for focusAreas. + *

    + * Generated from setter {@link StandardsOrganization#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas("example value", "example value");
    +   * }
    + * + * @param focusAreas focusAreas + * @return current instance of builder + */ + public StandardsOrganizationBuilder focusAreas(String... focusAreas) { + this.focusAreas = changedValue(List.of(focusAreas)); + return this; + } + + /** + * Sets the value for focusAreas. + *

    + * Generated from setter {@link StandardsOrganization#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas(List.of("example value"));
    +   * }
    + * + * @param focusAreas focusAreas + * @return current instance of builder + */ + public StandardsOrganizationBuilder focusAreas(List focusAreas) { + this.focusAreas = changedValue(focusAreas); + return this; + } + + /** + * Sets the value for focusAreas using a builder consumer that produces the value. + *

    + * Generated from setter {@link StandardsOrganization#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas(t -> t.add("example value"));
    +   * }
    + * + * @param focusAreasBuilderConsumer consumer providing an instance of a builder for focusAreas + * @return current instance of builder + */ + public StandardsOrganizationBuilder focusAreas(Consumer> focusAreasBuilderConsumer) { + ArrayListBuilder builder = this.focusAreas.isSet() + ? new ArrayListBuilder(this.focusAreas.value()) + : new ArrayListBuilder(); + focusAreasBuilderConsumer.accept(builder); + this.focusAreas = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for focusAreas by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas(() -> List.of("example value"));
    +   * }
    + * + * @param focusAreasSupplier supplier for focusAreas + * @return current instance of builder + */ + public StandardsOrganizationBuilder focusAreas(Supplier> focusAreasSupplier) { + this.focusAreas = changedValue(focusAreasSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link StandardsOrganization#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public StandardsOrganizationBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public StandardsOrganizationBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link StandardsOrganization#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public StandardsOrganizationBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public StandardsOrganizationBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberOrganizations. + *

    + * Generated from setter {@link StandardsOrganization#setMemberOrganizations(int) setMemberOrganizations(int + * memberOrganizations)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberOrganizations(42);
    +   * }
    + * + * @param memberOrganizations memberOrganizations + * @return current instance of builder + */ + public StandardsOrganizationBuilder memberOrganizations(int memberOrganizations) { + this.memberOrganizations = changedValue(memberOrganizations); + return this; + } + + /** + * Sets the value for memberOrganizations by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setMemberOrganizations(int) setMemberOrganizations(int + * memberOrganizations)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberOrganizations(() -> 42);
    +   * }
    + * + * @param memberOrganizationsSupplier supplier for memberOrganizations + * @return current instance of builder + */ + public StandardsOrganizationBuilder memberOrganizations(Supplier memberOrganizationsSupplier) { + this.memberOrganizations = changedValue(memberOrganizationsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link StandardsOrganization#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public StandardsOrganizationBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link StandardsOrganization#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public StandardsOrganizationBuilder 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. + *

    + * Generated from setter {@link StandardsOrganization#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public StandardsOrganizationBuilder 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. + *

    + * Generated from setter {@link StandardsOrganization#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StandardsOrganizationBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for standardsPublished. + *

    + * Generated from setter {@link StandardsOrganization#setStandardsPublished(int) setStandardsPublished(int + * standardsPublished)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standardsPublished(42);
    +   * }
    + * + * @param standardsPublished standardsPublished + * @return current instance of builder + */ + public StandardsOrganizationBuilder standardsPublished(int standardsPublished) { + this.standardsPublished = changedValue(standardsPublished); + return this; + } + + /** + * Sets the value for standardsPublished by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setStandardsPublished(int) setStandardsPublished(int + * standardsPublished)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.standardsPublished(() -> 42);
    +   * }
    + * + * @param standardsPublishedSupplier supplier for standardsPublished + * @return current instance of builder + */ + public StandardsOrganizationBuilder standardsPublished(Supplier standardsPublishedSupplier) { + this.standardsPublished = changedValue(standardsPublishedSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link StandardsOrganization#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public StandardsOrganizationBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link StandardsOrganization#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public StandardsOrganizationBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link StandardsOrganization#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public StandardsOrganizationBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StandardsOrganization#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StandardsOrganizationBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 StandardsOrganizationBuilder 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 StandardsOrganizationBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StandardsOrganization result = builder.build();
    +   * }
    + */ + @Override + public StandardsOrganization build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberOrganizations.isSet() && this.memberOrganizations.value() == null) { + throw new IllegalStateException("Field 'memberOrganizations' is marked as non-null but null value was provided"); + } + if (this.standardsPublished.isSet() && this.standardsPublished.value() == null) { + throw new IllegalStateException("Field 'standardsPublished' is marked as non-null but null value was provided"); + } + StandardsOrganization result = new StandardsOrganization(); + this.createdAt.ifSet(result::setCreatedAt); + this.focusAreas.ifSet(result::setFocusAreas); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberOrganizations.ifSet(result::setMemberOrganizations); + this.name.ifSet(result::setName); + this.standardsPublished.ifSet(result::setStandardsPublished); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("focusAreas", this.focusAreas) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberOrganizations", this.memberOrganizations) + .append("name", this.name) + .append("standardsPublished", this.standardsPublished) + .append("status", this.status) + .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 StandardsOrganization with(Consumer b) { + StandardsOrganizationBuilder builder; + try { + builder = new StandardsOrganizationBuilder(StandardsOrganization.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StandardsOrganizationBuilder.With' should only be implemented by classes, which could be casted to 'StandardsOrganization'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StandardsOrganizationBuilder with() { + try { + return new StandardsOrganizationBuilder(StandardsOrganization.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StandardsOrganizationBuilder.With' should only be implemented by classes, which could be casted to 'StandardsOrganization'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateArchiveBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateArchiveBuilder.java new file mode 100644 index 00000000..94b5ca2b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateArchiveBuilder.java @@ -0,0 +1,721 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.StateArchive}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.StateArchive 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. + * + *

    Example:

    + * + *
    {@code
    + * StateArchive result = StateArchiveBuilder.create()
    + *     .accessPolicy("example value")
    + *     .accessPolicy("Hello %s", "World")
    + *     .accessPolicy(() -> "example value")
    + *     .accessPolicy(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .documentCount(42L)
    + *     .documentCount(() -> 42L)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .state("example value")
    + *     .state("Hello %s", "World")
    + *     .state(() -> "example value")
    + *     .state(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StateArchive.class) +public class StateArchiveBuilder implements IBuilderBase { + + /** + * Tracked value for accessPolicy: accessPolicy. + */ + private TrackedValue accessPolicy = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for documentCount: documentCount. + */ + private TrackedValue documentCount = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for state: state. + */ + private TrackedValue state = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateArchive}. + */ + public StateArchiveBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateArchive} by a instance. + * + * @param instance object instance for initialisiation + */ + public StateArchiveBuilder(StateArchive instance) { + this.accessPolicy = initialValue(instance.getAccessPolicy()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.documentCount = initialValue(instance.getDocumentCount()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.state = initialValue(instance.getState()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateArchive}. + * + *

    Example:

    + * + *
    {@code
    +   * StateArchiveBuilder builder = StateArchiveBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateArchive} + */ + public static StateArchiveBuilder create() { + return new StateArchiveBuilder(); + } + + /** + * Sets the value for accessPolicy. + *

    + * Generated from setter {@link StateArchive#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy("example value");
    +   * }
    + * + * @param accessPolicy accessPolicy + * @return current instance of builder + */ + public StateArchiveBuilder accessPolicy(String accessPolicy) { + this.accessPolicy = changedValue(accessPolicy); + return this; + } + + /** + * Sets the value for accessPolicy by executing the provided consumer. + *

    + * Generated from setter {@link StateArchive#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy(sb -> sb.append("text"));
    +   * }
    + * + * @param accessPolicyStringBuilderConsumer consumer providing an instance of accessPolicy + * @return current instance of builder + */ + public StateArchiveBuilder accessPolicy(Consumer accessPolicyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + accessPolicyStringBuilderConsumer.accept(builder); + this.accessPolicy = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for accessPolicy by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy(() -> "example value");
    +   * }
    + * + * @param accessPolicySupplier supplier for accessPolicy + * @return current instance of builder + */ + public StateArchiveBuilder accessPolicy(Supplier accessPolicySupplier) { + this.accessPolicy = changedValue(accessPolicySupplier.get()); + return this; + } + + /** + * Sets the String value for accessPolicy by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateArchive#setAccessPolicy(String) setAccessPolicy(String accessPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accessPolicy("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateArchiveBuilder accessPolicy(String format, Object... args) { + this.accessPolicy = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link StateArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public StateArchiveBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public StateArchiveBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for documentCount. + *

    + * Generated from setter {@link StateArchive#setDocumentCount(long) setDocumentCount(long documentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.documentCount(42L);
    +   * }
    + * + * @param documentCount documentCount + * @return current instance of builder + */ + public StateArchiveBuilder documentCount(long documentCount) { + this.documentCount = changedValue(documentCount); + return this; + } + + /** + * Sets the value for documentCount by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setDocumentCount(long) setDocumentCount(long documentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.documentCount(() -> 42L);
    +   * }
    + * + * @param documentCountSupplier supplier for documentCount + * @return current instance of builder + */ + public StateArchiveBuilder documentCount(Supplier documentCountSupplier) { + this.documentCount = changedValue(documentCountSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link StateArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public StateArchiveBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public StateArchiveBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link StateArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public StateArchiveBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public StateArchiveBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link StateArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public StateArchiveBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link StateArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public StateArchiveBuilder 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. + *

    + * Generated from setter {@link StateArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public StateArchiveBuilder 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. + *

    + * Generated from setter {@link StateArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateArchiveBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for state. + *

    + * Generated from setter {@link StateArchive#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state("example value");
    +   * }
    + * + * @param state state + * @return current instance of builder + */ + public StateArchiveBuilder state(String state) { + this.state = changedValue(state); + return this; + } + + /** + * Sets the value for state by executing the provided consumer. + *

    + * Generated from setter {@link StateArchive#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state(sb -> sb.append("text"));
    +   * }
    + * + * @param stateStringBuilderConsumer consumer providing an instance of state + * @return current instance of builder + */ + public StateArchiveBuilder state(Consumer stateStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + stateStringBuilderConsumer.accept(builder); + this.state = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for state by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state(() -> "example value");
    +   * }
    + * + * @param stateSupplier supplier for state + * @return current instance of builder + */ + public StateArchiveBuilder state(Supplier stateSupplier) { + this.state = changedValue(stateSupplier.get()); + return this; + } + + /** + * Sets the String value for state by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateArchive#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateArchiveBuilder state(String format, Object... args) { + this.state = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link StateArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public StateArchiveBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link StateArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public StateArchiveBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link StateArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public StateArchiveBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateArchiveBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 StateArchiveBuilder 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 StateArchiveBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StateArchive result = builder.build();
    +   * }
    + */ + @Override + public StateArchive build() { + if (this.documentCount.isSet() && this.documentCount.value() == null) { + throw new IllegalStateException("Field 'documentCount' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + StateArchive result = new StateArchive(); + this.accessPolicy.ifSet(result::setAccessPolicy); + this.createdAt.ifSet(result::setCreatedAt); + this.documentCount.ifSet(result::setDocumentCount); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.state.ifSet(result::setState); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("accessPolicy", this.accessPolicy) + .append("createdAt", this.createdAt) + .append("documentCount", this.documentCount) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("state", this.state) + .append("status", this.status) + .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 StateArchive with(Consumer b) { + StateArchiveBuilder builder; + try { + builder = new StateArchiveBuilder(StateArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StateArchiveBuilder.With' should only be implemented by classes, which could be casted to 'StateArchive'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StateArchiveBuilder with() { + try { + return new StateArchiveBuilder(StateArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StateArchiveBuilder.With' should only be implemented by classes, which could be casted to 'StateArchive'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryAgencyBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryAgencyBuilder.java new file mode 100644 index 00000000..24470bad --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryAgencyBuilder.java @@ -0,0 +1,682 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.StateLibraryAgency}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.StateLibraryAgency 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. + * + *

    Example:

    + * + *
    {@code
    + * StateLibraryAgency result = StateLibraryAgencyBuilder.create()
    + *     .budget(BigDecimal.valueOf(3.14))
    + *     .budget(() -> BigDecimal.valueOf(3.14))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .state("example value")
    + *     .state("Hello %s", "World")
    + *     .state(() -> "example value")
    + *     .state(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .supportedLibraries(42)
    + *     .supportedLibraries(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StateLibraryAgency.class) +public class StateLibraryAgencyBuilder implements IBuilderBase { + + /** + * Tracked value for budget: budget. + */ + private TrackedValue budget = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for state: state. + */ + private TrackedValue state = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for supportedLibraries: supportedLibraries. + */ + private TrackedValue supportedLibraries = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibraryAgency}. + */ + public StateLibraryAgencyBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibraryAgency} by a instance. + * + * @param instance object instance for initialisiation + */ + public StateLibraryAgencyBuilder(StateLibraryAgency instance) { + this.budget = initialValue(instance.getBudget()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.state = initialValue(instance.getState()); + this.status = initialValue(instance.getStatus()); + this.supportedLibraries = initialValue(instance.getSupportedLibraries()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibraryAgency}. + * + *

    Example:

    + * + *
    {@code
    +   * StateLibraryAgencyBuilder builder = StateLibraryAgencyBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibraryAgency} + */ + public static StateLibraryAgencyBuilder create() { + return new StateLibraryAgencyBuilder(); + } + + /** + * Sets the value for budget. + *

    + * Generated from setter {@link StateLibraryAgency#setBudget(BigDecimal) setBudget(BigDecimal budget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budget budget + * @return current instance of builder + */ + public StateLibraryAgencyBuilder budget(BigDecimal budget) { + this.budget = changedValue(budget); + return this; + } + + /** + * Sets the value for budget by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setBudget(BigDecimal) setBudget(BigDecimal budget)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.budget(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param budgetSupplier supplier for budget + * @return current instance of builder + */ + public StateLibraryAgencyBuilder budget(Supplier budgetSupplier) { + this.budget = changedValue(budgetSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link StateLibraryAgency#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public StateLibraryAgencyBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public StateLibraryAgencyBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link StateLibraryAgency#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public StateLibraryAgencyBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public StateLibraryAgencyBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link StateLibraryAgency#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public StateLibraryAgencyBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public StateLibraryAgencyBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link StateLibraryAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public StateLibraryAgencyBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link StateLibraryAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public StateLibraryAgencyBuilder 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. + *

    + * Generated from setter {@link StateLibraryAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public StateLibraryAgencyBuilder 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. + *

    + * Generated from setter {@link StateLibraryAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateLibraryAgencyBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for state. + *

    + * Generated from setter {@link StateLibraryAgency#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state("example value");
    +   * }
    + * + * @param state state + * @return current instance of builder + */ + public StateLibraryAgencyBuilder state(String state) { + this.state = changedValue(state); + return this; + } + + /** + * Sets the value for state by executing the provided consumer. + *

    + * Generated from setter {@link StateLibraryAgency#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state(sb -> sb.append("text"));
    +   * }
    + * + * @param stateStringBuilderConsumer consumer providing an instance of state + * @return current instance of builder + */ + public StateLibraryAgencyBuilder state(Consumer stateStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + stateStringBuilderConsumer.accept(builder); + this.state = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for state by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state(() -> "example value");
    +   * }
    + * + * @param stateSupplier supplier for state + * @return current instance of builder + */ + public StateLibraryAgencyBuilder state(Supplier stateSupplier) { + this.state = changedValue(stateSupplier.get()); + return this; + } + + /** + * Sets the String value for state by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateLibraryAgency#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateLibraryAgencyBuilder state(String format, Object... args) { + this.state = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link StateLibraryAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public StateLibraryAgencyBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link StateLibraryAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public StateLibraryAgencyBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public StateLibraryAgencyBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateLibraryAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateLibraryAgencyBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for supportedLibraries. + *

    + * Generated from setter {@link StateLibraryAgency#setSupportedLibraries(int) setSupportedLibraries(int + * supportedLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supportedLibraries(42);
    +   * }
    + * + * @param supportedLibraries supportedLibraries + * @return current instance of builder + */ + public StateLibraryAgencyBuilder supportedLibraries(int supportedLibraries) { + this.supportedLibraries = changedValue(supportedLibraries); + return this; + } + + /** + * Sets the value for supportedLibraries by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibraryAgency#setSupportedLibraries(int) setSupportedLibraries(int + * supportedLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supportedLibraries(() -> 42);
    +   * }
    + * + * @param supportedLibrariesSupplier supplier for supportedLibraries + * @return current instance of builder + */ + public StateLibraryAgencyBuilder supportedLibraries(Supplier supportedLibrariesSupplier) { + this.supportedLibraries = changedValue(supportedLibrariesSupplier.get()); + 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 StateLibraryAgencyBuilder 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 StateLibraryAgencyBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StateLibraryAgency result = builder.build();
    +   * }
    + */ + @Override + public StateLibraryAgency build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.supportedLibraries.isSet() && this.supportedLibraries.value() == null) { + throw new IllegalStateException("Field 'supportedLibraries' is marked as non-null but null value was provided"); + } + StateLibraryAgency result = new StateLibraryAgency(); + this.budget.ifSet(result::setBudget); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.state.ifSet(result::setState); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.supportedLibraries.ifSet(result::setSupportedLibraries); + 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("budget", this.budget) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("state", this.state) + .append("status", this.status) + .append("supportedLibraries", this.supportedLibraries) + .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 StateLibraryAgency with(Consumer b) { + StateLibraryAgencyBuilder builder; + try { + builder = new StateLibraryAgencyBuilder(StateLibraryAgency.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StateLibraryAgencyBuilder.With' should only be implemented by classes, which could be casted to 'StateLibraryAgency'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StateLibraryAgencyBuilder with() { + try { + return new StateLibraryAgencyBuilder(StateLibraryAgency.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StateLibraryAgencyBuilder.With' should only be implemented by classes, which could be casted to 'StateLibraryAgency'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryBuilder.java new file mode 100644 index 00000000..728d0be5 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StateLibraryBuilder.java @@ -0,0 +1,757 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.StateLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.StateLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * StateLibrary result = StateLibraryBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .regionalCollections(List.of("example value"))
    + *     .regionalCollections(() -> List.of("example value"))
    + *     .regionalCollections(t -> t.add("example value"))
    + *     .regionalCollections("example value", "example value")
    + *     .add2RegionalCollections("example value")
    + *     .state("example value")
    + *     .state("Hello %s", "World")
    + *     .state(() -> "example value")
    + *     .state(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalVolumes(42L)
    + *     .totalVolumes(() -> 42L)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StateLibrary.class) +public class StateLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for regionalCollections: regionalCollections. + */ + private TrackedValue> regionalCollections = unsetValue(); + /** + * Tracked value for state: state. + */ + private TrackedValue state = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalVolumes: totalVolumes. + */ + private TrackedValue totalVolumes = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibrary}. + */ + public StateLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public StateLibraryBuilder(StateLibrary instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.regionalCollections = initialValue(instance.getRegionalCollections()); + this.state = initialValue(instance.getState()); + this.status = initialValue(instance.getStatus()); + this.totalVolumes = initialValue(instance.getTotalVolumes()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * StateLibraryBuilder builder = StateLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.StateLibrary} + */ + public static StateLibraryBuilder create() { + return new StateLibraryBuilder(); + } + + /** + * Adds a single element to regionalCollections. + *

    + * Generated from setter {@link StateLibrary#setRegionalCollections(List) setRegionalCollections(List + * regionalCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2RegionalCollections("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public StateLibraryBuilder add2RegionalCollections(String element) { + List newCollection; + if (this.regionalCollections.isSet()) { + newCollection = new ArrayList<>(this.regionalCollections.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.regionalCollections = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link StateLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public StateLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public StateLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link StateLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public StateLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public StateLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link StateLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public StateLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public StateLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link StateLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public StateLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link StateLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public StateLibraryBuilder 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. + *

    + * Generated from setter {@link StateLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public StateLibraryBuilder 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. + *

    + * Generated from setter {@link StateLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for regionalCollections. + *

    + * Generated from setter {@link StateLibrary#setRegionalCollections(List) setRegionalCollections(List + * regionalCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.regionalCollections("example value", "example value");
    +   * }
    + * + * @param regionalCollections regionalCollections + * @return current instance of builder + */ + public StateLibraryBuilder regionalCollections(String... regionalCollections) { + this.regionalCollections = changedValue(List.of(regionalCollections)); + return this; + } + + /** + * Sets the value for regionalCollections. + *

    + * Generated from setter {@link StateLibrary#setRegionalCollections(List) setRegionalCollections(List + * regionalCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.regionalCollections(List.of("example value"));
    +   * }
    + * + * @param regionalCollections regionalCollections + * @return current instance of builder + */ + public StateLibraryBuilder regionalCollections(List regionalCollections) { + this.regionalCollections = changedValue(regionalCollections); + return this; + } + + /** + * Sets the value for regionalCollections using a builder consumer that produces the value. + *

    + * Generated from setter {@link StateLibrary#setRegionalCollections(List) setRegionalCollections(List + * regionalCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.regionalCollections(t -> t.add("example value"));
    +   * }
    + * + * @param regionalCollectionsBuilderConsumer consumer providing an instance of a builder for regionalCollections + * @return current instance of builder + */ + public StateLibraryBuilder regionalCollections( + Consumer> regionalCollectionsBuilderConsumer) { + ArrayListBuilder builder = this.regionalCollections.isSet() + ? new ArrayListBuilder(this.regionalCollections.value()) + : new ArrayListBuilder(); + regionalCollectionsBuilderConsumer.accept(builder); + this.regionalCollections = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for regionalCollections by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setRegionalCollections(List) setRegionalCollections(List + * regionalCollections)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.regionalCollections(() -> List.of("example value"));
    +   * }
    + * + * @param regionalCollectionsSupplier supplier for regionalCollections + * @return current instance of builder + */ + public StateLibraryBuilder regionalCollections(Supplier> regionalCollectionsSupplier) { + this.regionalCollections = changedValue(regionalCollectionsSupplier.get()); + return this; + } + + /** + * Sets the value for state. + *

    + * Generated from setter {@link StateLibrary#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state("example value");
    +   * }
    + * + * @param state state + * @return current instance of builder + */ + public StateLibraryBuilder state(String state) { + this.state = changedValue(state); + return this; + } + + /** + * Sets the value for state by executing the provided consumer. + *

    + * Generated from setter {@link StateLibrary#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state(sb -> sb.append("text"));
    +   * }
    + * + * @param stateStringBuilderConsumer consumer providing an instance of state + * @return current instance of builder + */ + public StateLibraryBuilder state(Consumer stateStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + stateStringBuilderConsumer.accept(builder); + this.state = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for state by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state(() -> "example value");
    +   * }
    + * + * @param stateSupplier supplier for state + * @return current instance of builder + */ + public StateLibraryBuilder state(Supplier stateSupplier) { + this.state = changedValue(stateSupplier.get()); + return this; + } + + /** + * Sets the String value for state by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateLibrary#setState(String) setState(String state)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.state("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateLibraryBuilder state(String format, Object... args) { + this.state = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link StateLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public StateLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link StateLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public StateLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public StateLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StateLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StateLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalVolumes. + *

    + * Generated from setter {@link StateLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(42L);
    +   * }
    + * + * @param totalVolumes totalVolumes + * @return current instance of builder + */ + public StateLibraryBuilder totalVolumes(long totalVolumes) { + this.totalVolumes = changedValue(totalVolumes); + return this; + } + + /** + * Sets the value for totalVolumes by invoking the provided supplier. + *

    + * Generated from setter {@link StateLibrary#setTotalVolumes(long) setTotalVolumes(long totalVolumes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalVolumes(() -> 42L);
    +   * }
    + * + * @param totalVolumesSupplier supplier for totalVolumes + * @return current instance of builder + */ + public StateLibraryBuilder totalVolumes(Supplier totalVolumesSupplier) { + this.totalVolumes = changedValue(totalVolumesSupplier.get()); + 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 StateLibraryBuilder 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 StateLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StateLibrary result = builder.build();
    +   * }
    + */ + @Override + public StateLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.totalVolumes.isSet() && this.totalVolumes.value() == null) { + throw new IllegalStateException("Field 'totalVolumes' is marked as non-null but null value was provided"); + } + StateLibrary result = new StateLibrary(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.regionalCollections.ifSet(result::setRegionalCollections); + this.state.ifSet(result::setState); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalVolumes.ifSet(result::setTotalVolumes); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("regionalCollections", this.regionalCollections) + .append("state", this.state) + .append("status", this.status) + .append("totalVolumes", this.totalVolumes) + .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 StateLibrary with(Consumer b) { + StateLibraryBuilder builder; + try { + builder = new StateLibraryBuilder(StateLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StateLibraryBuilder.With' should only be implemented by classes, which could be casted to 'StateLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StateLibraryBuilder with() { + try { + return new StateLibraryBuilder(StateLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StateLibraryBuilder.With' should only be implemented by classes, which could be casted to 'StateLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StreamingServiceBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StreamingServiceBuilder.java new file mode 100644 index 00000000..84a76e5a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/StreamingServiceBuilder.java @@ -0,0 +1,711 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.StreamingService}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.StreamingService 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. + * + *

    Example:

    + * + *
    {@code
    + * StreamingService result = StreamingServiceBuilder.create()
    + *     .activeUsers(42)
    + *     .activeUsers(() -> 42)
    + *     .availableTitles(42L)
    + *     .availableTitles(() -> 42L)
    + *     .contentTypes(List.of("example value"))
    + *     .contentTypes(() -> List.of("example value"))
    + *     .contentTypes(t -> t.add("example value"))
    + *     .contentTypes("example value", "example value")
    + *     .add2ContentTypes("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StreamingService.class) +public class StreamingServiceBuilder implements IBuilderBase { + + /** + * Tracked value for activeUsers: activeUsers. + */ + private TrackedValue activeUsers = unsetValue(); + /** + * Tracked value for availableTitles: availableTitles. + */ + private TrackedValue availableTitles = unsetValue(); + /** + * Tracked value for contentTypes: contentTypes. + */ + private TrackedValue> contentTypes = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StreamingService}. + */ + public StreamingServiceBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StreamingService} by a instance. + * + * @param instance object instance for initialisiation + */ + public StreamingServiceBuilder(StreamingService instance) { + this.activeUsers = initialValue(instance.getActiveUsers()); + this.availableTitles = initialValue(instance.getAvailableTitles()); + this.contentTypes = initialValue(instance.getContentTypes()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.StreamingService}. + * + *

    Example:

    + * + *
    {@code
    +   * StreamingServiceBuilder builder = StreamingServiceBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.StreamingService} + */ + public static StreamingServiceBuilder create() { + return new StreamingServiceBuilder(); + } + + /** + * Sets the value for activeUsers. + *

    + * Generated from setter {@link StreamingService#setActiveUsers(int) setActiveUsers(int activeUsers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.activeUsers(42);
    +   * }
    + * + * @param activeUsers activeUsers + * @return current instance of builder + */ + public StreamingServiceBuilder activeUsers(int activeUsers) { + this.activeUsers = changedValue(activeUsers); + return this; + } + + /** + * Sets the value for activeUsers by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setActiveUsers(int) setActiveUsers(int activeUsers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.activeUsers(() -> 42);
    +   * }
    + * + * @param activeUsersSupplier supplier for activeUsers + * @return current instance of builder + */ + public StreamingServiceBuilder activeUsers(Supplier activeUsersSupplier) { + this.activeUsers = changedValue(activeUsersSupplier.get()); + return this; + } + + /** + * Adds a single element to contentTypes. + *

    + * Generated from setter {@link StreamingService#setContentTypes(List) setContentTypes(List contentTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ContentTypes("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public StreamingServiceBuilder add2ContentTypes(String element) { + List newCollection; + if (this.contentTypes.isSet()) { + newCollection = new ArrayList<>(this.contentTypes.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.contentTypes = changedValue(newCollection); + return this; + } + + /** + * Sets the value for availableTitles. + *

    + * Generated from setter {@link StreamingService#setAvailableTitles(long) setAvailableTitles(long availableTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.availableTitles(42L);
    +   * }
    + * + * @param availableTitles availableTitles + * @return current instance of builder + */ + public StreamingServiceBuilder availableTitles(long availableTitles) { + this.availableTitles = changedValue(availableTitles); + return this; + } + + /** + * Sets the value for availableTitles by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setAvailableTitles(long) setAvailableTitles(long availableTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.availableTitles(() -> 42L);
    +   * }
    + * + * @param availableTitlesSupplier supplier for availableTitles + * @return current instance of builder + */ + public StreamingServiceBuilder availableTitles(Supplier availableTitlesSupplier) { + this.availableTitles = changedValue(availableTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for contentTypes. + *

    + * Generated from setter {@link StreamingService#setContentTypes(List) setContentTypes(List contentTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentTypes("example value", "example value");
    +   * }
    + * + * @param contentTypes contentTypes + * @return current instance of builder + */ + public StreamingServiceBuilder contentTypes(String... contentTypes) { + this.contentTypes = changedValue(List.of(contentTypes)); + return this; + } + + /** + * Sets the value for contentTypes. + *

    + * Generated from setter {@link StreamingService#setContentTypes(List) setContentTypes(List contentTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentTypes(List.of("example value"));
    +   * }
    + * + * @param contentTypes contentTypes + * @return current instance of builder + */ + public StreamingServiceBuilder contentTypes(List contentTypes) { + this.contentTypes = changedValue(contentTypes); + return this; + } + + /** + * Sets the value for contentTypes using a builder consumer that produces the value. + *

    + * Generated from setter {@link StreamingService#setContentTypes(List) setContentTypes(List contentTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentTypes(t -> t.add("example value"));
    +   * }
    + * + * @param contentTypesBuilderConsumer consumer providing an instance of a builder for contentTypes + * @return current instance of builder + */ + public StreamingServiceBuilder contentTypes(Consumer> contentTypesBuilderConsumer) { + ArrayListBuilder builder = this.contentTypes.isSet() + ? new ArrayListBuilder(this.contentTypes.value()) + : new ArrayListBuilder(); + contentTypesBuilderConsumer.accept(builder); + this.contentTypes = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for contentTypes by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setContentTypes(List) setContentTypes(List contentTypes)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contentTypes(() -> List.of("example value"));
    +   * }
    + * + * @param contentTypesSupplier supplier for contentTypes + * @return current instance of builder + */ + public StreamingServiceBuilder contentTypes(Supplier> contentTypesSupplier) { + this.contentTypes = changedValue(contentTypesSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link StreamingService#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public StreamingServiceBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public StreamingServiceBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link StreamingService#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public StreamingServiceBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public StreamingServiceBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link StreamingService#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public StreamingServiceBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public StreamingServiceBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link StreamingService#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public StreamingServiceBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link StreamingService#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public StreamingServiceBuilder 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. + *

    + * Generated from setter {@link StreamingService#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public StreamingServiceBuilder 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. + *

    + * Generated from setter {@link StreamingService#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StreamingServiceBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link StreamingService#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public StreamingServiceBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link StreamingService#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public StreamingServiceBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link StreamingService#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public StreamingServiceBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link StreamingService#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StreamingServiceBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 StreamingServiceBuilder 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 StreamingServiceBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StreamingService result = builder.build();
    +   * }
    + */ + @Override + public StreamingService build() { + if (this.activeUsers.isSet() && this.activeUsers.value() == null) { + throw new IllegalStateException("Field 'activeUsers' is marked as non-null but null value was provided"); + } + if (this.availableTitles.isSet() && this.availableTitles.value() == null) { + throw new IllegalStateException("Field 'availableTitles' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + StreamingService result = new StreamingService(); + this.activeUsers.ifSet(result::setActiveUsers); + this.availableTitles.ifSet(result::setAvailableTitles); + this.contentTypes.ifSet(result::setContentTypes); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("activeUsers", this.activeUsers) + .append("availableTitles", this.availableTitles) + .append("contentTypes", this.contentTypes) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .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 StreamingService with(Consumer b) { + StreamingServiceBuilder builder; + try { + builder = new StreamingServiceBuilder(StreamingService.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StreamingServiceBuilder.With' should only be implemented by classes, which could be casted to 'StreamingService'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StreamingServiceBuilder with() { + try { + return new StreamingServiceBuilder(StreamingService.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StreamingServiceBuilder.With' should only be implemented by classes, which could be casted to 'StreamingService'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubjectHeadingAuthorityBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubjectHeadingAuthorityBuilder.java new file mode 100644 index 00000000..235c71d0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubjectHeadingAuthorityBuilder.java @@ -0,0 +1,719 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.SubjectHeadingAuthority}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SubjectHeadingAuthority 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. + * + *

    Example:

    + * + *
    {@code
    + * SubjectHeadingAuthority result = SubjectHeadingAuthorityBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .headingCount(42L)
    + *     .headingCount(() -> 42L)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .languagesSupported(List.of("example value"))
    + *     .languagesSupported(() -> List.of("example value"))
    + *     .languagesSupported(t -> t.add("example value"))
    + *     .languagesSupported("example value", "example value")
    + *     .add2LanguagesSupported("example value")
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .updatesPerYear(42)
    + *     .updatesPerYear(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SubjectHeadingAuthority.class) +public class SubjectHeadingAuthorityBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for headingCount: headingCount. + */ + private TrackedValue headingCount = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for languagesSupported: languagesSupported. + */ + private TrackedValue> languagesSupported = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for updatesPerYear: updatesPerYear. + */ + private TrackedValue updatesPerYear = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubjectHeadingAuthority}. + */ + public SubjectHeadingAuthorityBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubjectHeadingAuthority} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public SubjectHeadingAuthorityBuilder(SubjectHeadingAuthority instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.headingCount = initialValue(instance.getHeadingCount()); + this.id = initialValue(instance.getId()); + this.languagesSupported = initialValue(instance.getLanguagesSupported()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.updatesPerYear = initialValue(instance.getUpdatesPerYear()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubjectHeadingAuthority}. + * + *

    Example:

    + * + *
    {@code
    +   * SubjectHeadingAuthorityBuilder builder = SubjectHeadingAuthorityBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubjectHeadingAuthority} + */ + public static SubjectHeadingAuthorityBuilder create() { + return new SubjectHeadingAuthorityBuilder(); + } + + /** + * Adds a single element to languagesSupported. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setLanguagesSupported(List) setLanguagesSupported(List + * languagesSupported)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2LanguagesSupported("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder add2LanguagesSupported(String element) { + List newCollection; + if (this.languagesSupported.isSet()) { + newCollection = new ArrayList<>(this.languagesSupported.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.languagesSupported = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for headingCount. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setHeadingCount(long) setHeadingCount(long headingCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headingCount(42L);
    +   * }
    + * + * @param headingCount headingCount + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder headingCount(long headingCount) { + this.headingCount = changedValue(headingCount); + return this; + } + + /** + * Sets the value for headingCount by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setHeadingCount(long) setHeadingCount(long headingCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.headingCount(() -> 42L);
    +   * }
    + * + * @param headingCountSupplier supplier for headingCount + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder headingCount(Supplier headingCountSupplier) { + this.headingCount = changedValue(headingCountSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for languagesSupported. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setLanguagesSupported(List) setLanguagesSupported(List + * languagesSupported)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languagesSupported("example value", "example value");
    +   * }
    + * + * @param languagesSupported languagesSupported + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder languagesSupported(String... languagesSupported) { + this.languagesSupported = changedValue(List.of(languagesSupported)); + return this; + } + + /** + * Sets the value for languagesSupported. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setLanguagesSupported(List) setLanguagesSupported(List + * languagesSupported)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languagesSupported(List.of("example value"));
    +   * }
    + * + * @param languagesSupported languagesSupported + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder languagesSupported(List languagesSupported) { + this.languagesSupported = changedValue(languagesSupported); + return this; + } + + /** + * Sets the value for languagesSupported using a builder consumer that produces the value. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setLanguagesSupported(List) setLanguagesSupported(List + * languagesSupported)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languagesSupported(t -> t.add("example value"));
    +   * }
    + * + * @param languagesSupportedBuilderConsumer consumer providing an instance of a builder for languagesSupported + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder languagesSupported( + Consumer> languagesSupportedBuilderConsumer) { + ArrayListBuilder builder = this.languagesSupported.isSet() + ? new ArrayListBuilder(this.languagesSupported.value()) + : new ArrayListBuilder(); + languagesSupportedBuilderConsumer.accept(builder); + this.languagesSupported = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for languagesSupported by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setLanguagesSupported(List) setLanguagesSupported(List + * languagesSupported)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languagesSupported(() -> List.of("example value"));
    +   * }
    + * + * @param languagesSupportedSupplier supplier for languagesSupported + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder languagesSupported(Supplier> languagesSupportedSupplier) { + this.languagesSupported = changedValue(languagesSupportedSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder 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. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder 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. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for updatesPerYear. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setUpdatesPerYear(int) setUpdatesPerYear(int updatesPerYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.updatesPerYear(42);
    +   * }
    + * + * @param updatesPerYear updatesPerYear + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder updatesPerYear(int updatesPerYear) { + this.updatesPerYear = changedValue(updatesPerYear); + return this; + } + + /** + * Sets the value for updatesPerYear by invoking the provided supplier. + *

    + * Generated from setter {@link SubjectHeadingAuthority#setUpdatesPerYear(int) setUpdatesPerYear(int updatesPerYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.updatesPerYear(() -> 42);
    +   * }
    + * + * @param updatesPerYearSupplier supplier for updatesPerYear + * @return current instance of builder + */ + public SubjectHeadingAuthorityBuilder updatesPerYear(Supplier updatesPerYearSupplier) { + this.updatesPerYear = changedValue(updatesPerYearSupplier.get()); + 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 SubjectHeadingAuthorityBuilder 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 SubjectHeadingAuthorityBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SubjectHeadingAuthority result = builder.build();
    +   * }
    + */ + @Override + public SubjectHeadingAuthority build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.headingCount.isSet() && this.headingCount.value() == null) { + throw new IllegalStateException("Field 'headingCount' is marked as non-null but null value was provided"); + } + if (this.updatesPerYear.isSet() && this.updatesPerYear.value() == null) { + throw new IllegalStateException("Field 'updatesPerYear' is marked as non-null but null value was provided"); + } + SubjectHeadingAuthority result = new SubjectHeadingAuthority(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.headingCount.ifSet(result::setHeadingCount); + this.id.ifSet(result::setId); + this.languagesSupported.ifSet(result::setLanguagesSupported); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.updatesPerYear.ifSet(result::setUpdatesPerYear); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("headingCount", this.headingCount) + .append("id", this.id) + .append("languagesSupported", this.languagesSupported) + .append("name", this.name) + .append("status", this.status) + .append("updatesPerYear", this.updatesPerYear) + .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 SubjectHeadingAuthority with(Consumer b) { + SubjectHeadingAuthorityBuilder builder; + try { + builder = new SubjectHeadingAuthorityBuilder(SubjectHeadingAuthority.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubjectHeadingAuthorityBuilder.With' should only be implemented by classes, which could be casted to 'SubjectHeadingAuthority'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SubjectHeadingAuthorityBuilder with() { + try { + return new SubjectHeadingAuthorityBuilder(SubjectHeadingAuthority.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubjectHeadingAuthorityBuilder.With' should only be implemented by classes, which could be casted to 'SubjectHeadingAuthority'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubscriptionAgencyBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubscriptionAgencyBuilder.java new file mode 100644 index 00000000..da8281c6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubscriptionAgencyBuilder.java @@ -0,0 +1,641 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.SubscriptionAgency}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SubscriptionAgency 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. + * + *

    Example:

    + * + *
    {@code
    + * SubscriptionAgency result = SubscriptionAgencyBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .journalTitles(42)
    + *     .journalTitles(() -> 42)
    + *     .libraryClients(42)
    + *     .libraryClients(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .renewalRate(3.14)
    + *     .renewalRate(() -> 3.14)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SubscriptionAgency.class) +public class SubscriptionAgencyBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for journalTitles: journalTitles. + */ + private TrackedValue journalTitles = unsetValue(); + /** + * Tracked value for libraryClients: libraryClients. + */ + private TrackedValue libraryClients = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for renewalRate: renewalRate. + */ + private TrackedValue renewalRate = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubscriptionAgency}. + */ + public SubscriptionAgencyBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubscriptionAgency} by a instance. + * + * @param instance object instance for initialisiation + */ + public SubscriptionAgencyBuilder(SubscriptionAgency instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.journalTitles = initialValue(instance.getJournalTitles()); + this.libraryClients = initialValue(instance.getLibraryClients()); + this.name = initialValue(instance.getName()); + this.renewalRate = initialValue(instance.getRenewalRate()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubscriptionAgency}. + * + *

    Example:

    + * + *
    {@code
    +   * SubscriptionAgencyBuilder builder = SubscriptionAgencyBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubscriptionAgency} + */ + public static SubscriptionAgencyBuilder create() { + return new SubscriptionAgencyBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SubscriptionAgency#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SubscriptionAgencyBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SubscriptionAgencyBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link SubscriptionAgency#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public SubscriptionAgencyBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public SubscriptionAgencyBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SubscriptionAgency#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SubscriptionAgencyBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SubscriptionAgencyBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for journalTitles. + *

    + * Generated from setter {@link SubscriptionAgency#setJournalTitles(int) setJournalTitles(int journalTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalTitles(42);
    +   * }
    + * + * @param journalTitles journalTitles + * @return current instance of builder + */ + public SubscriptionAgencyBuilder journalTitles(int journalTitles) { + this.journalTitles = changedValue(journalTitles); + return this; + } + + /** + * Sets the value for journalTitles by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setJournalTitles(int) setJournalTitles(int journalTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalTitles(() -> 42);
    +   * }
    + * + * @param journalTitlesSupplier supplier for journalTitles + * @return current instance of builder + */ + public SubscriptionAgencyBuilder journalTitles(Supplier journalTitlesSupplier) { + this.journalTitles = changedValue(journalTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for libraryClients. + *

    + * Generated from setter {@link SubscriptionAgency#setLibraryClients(int) setLibraryClients(int libraryClients)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.libraryClients(42);
    +   * }
    + * + * @param libraryClients libraryClients + * @return current instance of builder + */ + public SubscriptionAgencyBuilder libraryClients(int libraryClients) { + this.libraryClients = changedValue(libraryClients); + return this; + } + + /** + * Sets the value for libraryClients by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setLibraryClients(int) setLibraryClients(int libraryClients)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.libraryClients(() -> 42);
    +   * }
    + * + * @param libraryClientsSupplier supplier for libraryClients + * @return current instance of builder + */ + public SubscriptionAgencyBuilder libraryClients(Supplier libraryClientsSupplier) { + this.libraryClients = changedValue(libraryClientsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SubscriptionAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SubscriptionAgencyBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SubscriptionAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SubscriptionAgencyBuilder 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. + *

    + * Generated from setter {@link SubscriptionAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SubscriptionAgencyBuilder 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. + *

    + * Generated from setter {@link SubscriptionAgency#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubscriptionAgencyBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for renewalRate. + *

    + * Generated from setter {@link SubscriptionAgency#setRenewalRate(double) setRenewalRate(double renewalRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.renewalRate(3.14);
    +   * }
    + * + * @param renewalRate renewalRate + * @return current instance of builder + */ + public SubscriptionAgencyBuilder renewalRate(double renewalRate) { + this.renewalRate = changedValue(renewalRate); + return this; + } + + /** + * Sets the value for renewalRate by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setRenewalRate(double) setRenewalRate(double renewalRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.renewalRate(() -> 3.14);
    +   * }
    + * + * @param renewalRateSupplier supplier for renewalRate + * @return current instance of builder + */ + public SubscriptionAgencyBuilder renewalRate(Supplier renewalRateSupplier) { + this.renewalRate = changedValue(renewalRateSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SubscriptionAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SubscriptionAgencyBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SubscriptionAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SubscriptionAgencyBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SubscriptionAgencyBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SubscriptionAgency#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubscriptionAgencyBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 SubscriptionAgencyBuilder 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 SubscriptionAgencyBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SubscriptionAgency result = builder.build();
    +   * }
    + */ + @Override + public SubscriptionAgency build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.journalTitles.isSet() && this.journalTitles.value() == null) { + throw new IllegalStateException("Field 'journalTitles' is marked as non-null but null value was provided"); + } + if (this.libraryClients.isSet() && this.libraryClients.value() == null) { + throw new IllegalStateException("Field 'libraryClients' is marked as non-null but null value was provided"); + } + if (this.renewalRate.isSet() && this.renewalRate.value() == null) { + throw new IllegalStateException("Field 'renewalRate' is marked as non-null but null value was provided"); + } + SubscriptionAgency result = new SubscriptionAgency(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.journalTitles.ifSet(result::setJournalTitles); + this.libraryClients.ifSet(result::setLibraryClients); + this.name.ifSet(result::setName); + this.renewalRate.ifSet(result::setRenewalRate); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("journalTitles", this.journalTitles) + .append("libraryClients", this.libraryClients) + .append("name", this.name) + .append("renewalRate", this.renewalRate) + .append("status", this.status) + .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 SubscriptionAgency with(Consumer b) { + SubscriptionAgencyBuilder builder; + try { + builder = new SubscriptionAgencyBuilder(SubscriptionAgency.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubscriptionAgencyBuilder.With' should only be implemented by classes, which could be casted to 'SubscriptionAgency'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SubscriptionAgencyBuilder with() { + try { + return new SubscriptionAgencyBuilder(SubscriptionAgency.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubscriptionAgencyBuilder.With' should only be implemented by classes, which could be casted to 'SubscriptionAgency'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubsidiaryRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubsidiaryRecordBuilder.java new file mode 100644 index 00000000..6c6741bc --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/SubsidiaryRecordBuilder.java @@ -0,0 +1,567 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.SubsidiaryRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.SubsidiaryRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SubsidiaryRecord result = SubsidiaryRecordBuilder.create()
    + *     .subsidiaryName("example value")
    + *     .subsidiaryName("Hello %s", "World")
    + *     .subsidiaryName(() -> "example value")
    + *     .subsidiaryName(sb -> sb.append("text"))
    + *     .parentCompany("example value")
    + *     .parentCompany("Hello %s", "World")
    + *     .parentCompany(() -> "example value")
    + *     .parentCompany(sb -> sb.append("text"))
    + *     .ownershipPercent(3.14)
    + *     .ownershipPercent(() -> 3.14)
    + *     .country("example value")
    + *     .country("Hello %s", "World")
    + *     .country(() -> "example value")
    + *     .country(sb -> sb.append("text"))
    + *     .establishedDate(LocalDate.now())
    + *     .establishedDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SubsidiaryRecord.class) +public class SubsidiaryRecordBuilder implements IBuilderBase { + + /** + * Tracked value for subsidiaryName: subsidiaryName. + */ + private TrackedValue subsidiaryName = unsetValue(); + /** + * Tracked value for parentCompany: parentCompany. + */ + private TrackedValue parentCompany = unsetValue(); + /** + * Tracked value for ownershipPercent: ownershipPercent. + */ + private TrackedValue ownershipPercent = unsetValue(); + /** + * Tracked value for country: country. + */ + private TrackedValue country = unsetValue(); + /** + * Tracked value for establishedDate: establishedDate. + */ + private TrackedValue establishedDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubsidiaryRecord}. + */ + public SubsidiaryRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubsidiaryRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SubsidiaryRecordBuilder(SubsidiaryRecord instance) { + this.subsidiaryName = initialValue(instance.subsidiaryName()); + this.parentCompany = initialValue(instance.parentCompany()); + this.ownershipPercent = initialValue(instance.ownershipPercent()); + this.country = initialValue(instance.country()); + this.establishedDate = initialValue(instance.establishedDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubsidiaryRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SubsidiaryRecordBuilder builder = SubsidiaryRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.SubsidiaryRecord} + */ + public static SubsidiaryRecordBuilder create() { + return new SubsidiaryRecordBuilder(); + } + + /** + * Sets the value for country. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("example value");
    +   * }
    + * + * @param country country + * @return current instance of builder + */ + public SubsidiaryRecordBuilder country(String country) { + this.country = changedValue(country); + return this; + } + + /** + * Sets the value for country by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(sb -> sb.append("text"));
    +   * }
    + * + * @param countryStringBuilderConsumer consumer providing an instance of country + * @return current instance of builder + */ + public SubsidiaryRecordBuilder country(Consumer countryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + countryStringBuilderConsumer.accept(builder); + this.country = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for country by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country(() -> "example value");
    +   * }
    + * + * @param countrySupplier supplier for country + * @return current instance of builder + */ + public SubsidiaryRecordBuilder country(Supplier countrySupplier) { + this.country = changedValue(countrySupplier.get()); + return this; + } + + /** + * Sets the String value for country by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.country("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubsidiaryRecordBuilder country(String format, Object... args) { + this.country = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for establishedDate. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.establishedDate(LocalDate.now());
    +   * }
    + * + * @param establishedDate establishedDate + * @return current instance of builder + */ + public SubsidiaryRecordBuilder establishedDate(LocalDate establishedDate) { + this.establishedDate = changedValue(establishedDate); + return this; + } + + /** + * Sets the value for establishedDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.establishedDate(() -> LocalDate.now());
    +   * }
    + * + * @param establishedDateSupplier supplier for establishedDate + * @return current instance of builder + */ + public SubsidiaryRecordBuilder establishedDate(Supplier establishedDateSupplier) { + this.establishedDate = changedValue(establishedDateSupplier.get()); + return this; + } + + /** + * Sets the value for ownershipPercent. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ownershipPercent(3.14);
    +   * }
    + * + * @param ownershipPercent ownershipPercent + * @return current instance of builder + */ + public SubsidiaryRecordBuilder ownershipPercent(double ownershipPercent) { + this.ownershipPercent = changedValue(ownershipPercent); + return this; + } + + /** + * Sets the value for ownershipPercent by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.ownershipPercent(() -> 3.14);
    +   * }
    + * + * @param ownershipPercentSupplier supplier for ownershipPercent + * @return current instance of builder + */ + public SubsidiaryRecordBuilder ownershipPercent(Supplier ownershipPercentSupplier) { + this.ownershipPercent = changedValue(ownershipPercentSupplier.get()); + return this; + } + + /** + * Sets the value for parentCompany. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentCompany("example value");
    +   * }
    + * + * @param parentCompany parentCompany + * @return current instance of builder + */ + public SubsidiaryRecordBuilder parentCompany(String parentCompany) { + this.parentCompany = changedValue(parentCompany); + return this; + } + + /** + * Sets the value for parentCompany by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentCompany(sb -> sb.append("text"));
    +   * }
    + * + * @param parentCompanyStringBuilderConsumer consumer providing an instance of parentCompany + * @return current instance of builder + */ + public SubsidiaryRecordBuilder parentCompany(Consumer parentCompanyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + parentCompanyStringBuilderConsumer.accept(builder); + this.parentCompany = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for parentCompany by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentCompany(() -> "example value");
    +   * }
    + * + * @param parentCompanySupplier supplier for parentCompany + * @return current instance of builder + */ + public SubsidiaryRecordBuilder parentCompany(Supplier parentCompanySupplier) { + this.parentCompany = changedValue(parentCompanySupplier.get()); + return this; + } + + /** + * Sets the String value for parentCompany by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentCompany("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubsidiaryRecordBuilder parentCompany(String format, Object... args) { + this.parentCompany = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for subsidiaryName. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subsidiaryName("example value");
    +   * }
    + * + * @param subsidiaryName subsidiaryName + * @return current instance of builder + */ + public SubsidiaryRecordBuilder subsidiaryName(String subsidiaryName) { + this.subsidiaryName = changedValue(subsidiaryName); + return this; + } + + /** + * Sets the value for subsidiaryName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subsidiaryName(sb -> sb.append("text"));
    +   * }
    + * + * @param subsidiaryNameStringBuilderConsumer consumer providing an instance of subsidiaryName + * @return current instance of builder + */ + public SubsidiaryRecordBuilder subsidiaryName(Consumer subsidiaryNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + subsidiaryNameStringBuilderConsumer.accept(builder); + this.subsidiaryName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for subsidiaryName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subsidiaryName(() -> "example value");
    +   * }
    + * + * @param subsidiaryNameSupplier supplier for subsidiaryName + * @return current instance of builder + */ + public SubsidiaryRecordBuilder subsidiaryName(Supplier subsidiaryNameSupplier) { + this.subsidiaryName = changedValue(subsidiaryNameSupplier.get()); + return this; + } + + /** + * Sets the String value for subsidiaryName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SubsidiaryRecord#SubsidiaryRecord(String, String, double, String, LocalDate) SubsidiaryRecord(String + * subsidiaryName, String parentCompany, double ownershipPercent, String country, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.subsidiaryName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubsidiaryRecordBuilder subsidiaryName(String format, Object... args) { + this.subsidiaryName = changedValue(String.format(format, args)); + 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 SubsidiaryRecordBuilder 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 SubsidiaryRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SubsidiaryRecord result = builder.build();
    +   * }
    + */ + @Override + public SubsidiaryRecord build() { + if (!this.ownershipPercent.isSet()) { + throw new IllegalStateException("Required field 'ownershipPercent' must be set before calling build()"); + } + if (this.ownershipPercent.value() == null) { + throw new IllegalStateException("Field 'ownershipPercent' is marked as non-null but null value was provided"); + } + SubsidiaryRecord result = new SubsidiaryRecord(this.subsidiaryName.value(), + this.parentCompany.value(), + this.ownershipPercent.value(), + this.country.value(), + this.establishedDate.value()); + 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("subsidiaryName", this.subsidiaryName) + .append("parentCompany", this.parentCompany) + .append("ownershipPercent", this.ownershipPercent) + .append("country", this.country) + .append("establishedDate", this.establishedDate) + .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 SubsidiaryRecord with(Consumer b) { + SubsidiaryRecordBuilder builder; + try { + builder = new SubsidiaryRecordBuilder(SubsidiaryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubsidiaryRecordBuilder.With' should only be implemented by classes, which could be casted to 'SubsidiaryRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SubsidiaryRecordBuilder with() { + try { + return new SubsidiaryRecordBuilder(SubsidiaryRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubsidiaryRecordBuilder.With' should only be implemented by classes, which could be casted to 'SubsidiaryRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TechnicalInstituteBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TechnicalInstituteBuilder.java new file mode 100644 index 00000000..1037a81f --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TechnicalInstituteBuilder.java @@ -0,0 +1,717 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.TechnicalInstitute}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.TechnicalInstitute 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. + * + *

    Example:

    + * + *
    {@code
    + * TechnicalInstitute result = TechnicalInstituteBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .labCount(42)
    + *     .labCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .studentCount(42)
    + *     .studentCount(() -> 42)
    + *     .technicalFields(List.of("example value"))
    + *     .technicalFields(() -> List.of("example value"))
    + *     .technicalFields(t -> t.add("example value"))
    + *     .technicalFields("example value", "example value")
    + *     .add2TechnicalFields("example value")
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TechnicalInstitute.class) +public class TechnicalInstituteBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for labCount: labCount. + */ + private TrackedValue labCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for studentCount: studentCount. + */ + private TrackedValue studentCount = unsetValue(); + /** + * Tracked value for technicalFields: technicalFields. + */ + private TrackedValue> technicalFields = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TechnicalInstitute}. + */ + public TechnicalInstituteBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TechnicalInstitute} by a instance. + * + * @param instance object instance for initialisiation + */ + public TechnicalInstituteBuilder(TechnicalInstitute instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.labCount = initialValue(instance.getLabCount()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.studentCount = initialValue(instance.getStudentCount()); + this.technicalFields = initialValue(instance.getTechnicalFields()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TechnicalInstitute}. + * + *

    Example:

    + * + *
    {@code
    +   * TechnicalInstituteBuilder builder = TechnicalInstituteBuilder.create();
    +   * }
    + * + * @return builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TechnicalInstitute} + */ + public static TechnicalInstituteBuilder create() { + return new TechnicalInstituteBuilder(); + } + + /** + * Adds a single element to technicalFields. + *

    + * Generated from setter {@link TechnicalInstitute#setTechnicalFields(List) setTechnicalFields(List + * technicalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2TechnicalFields("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TechnicalInstituteBuilder add2TechnicalFields(String element) { + List newCollection; + if (this.technicalFields.isSet()) { + newCollection = new ArrayList<>(this.technicalFields.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.technicalFields = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link TechnicalInstitute#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TechnicalInstituteBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TechnicalInstituteBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link TechnicalInstitute#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public TechnicalInstituteBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public TechnicalInstituteBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link TechnicalInstitute#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TechnicalInstituteBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TechnicalInstituteBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for labCount. + *

    + * Generated from setter {@link TechnicalInstitute#setLabCount(int) setLabCount(int labCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labCount(42);
    +   * }
    + * + * @param labCount labCount + * @return current instance of builder + */ + public TechnicalInstituteBuilder labCount(int labCount) { + this.labCount = changedValue(labCount); + return this; + } + + /** + * Sets the value for labCount by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setLabCount(int) setLabCount(int labCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.labCount(() -> 42);
    +   * }
    + * + * @param labCountSupplier supplier for labCount + * @return current instance of builder + */ + public TechnicalInstituteBuilder labCount(Supplier labCountSupplier) { + this.labCount = changedValue(labCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link TechnicalInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TechnicalInstituteBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link TechnicalInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TechnicalInstituteBuilder 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. + *

    + * Generated from setter {@link TechnicalInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TechnicalInstituteBuilder 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. + *

    + * Generated from setter {@link TechnicalInstitute#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TechnicalInstituteBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link TechnicalInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public TechnicalInstituteBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link TechnicalInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public TechnicalInstituteBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public TechnicalInstituteBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TechnicalInstitute#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TechnicalInstituteBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for studentCount. + *

    + * Generated from setter {@link TechnicalInstitute#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(42);
    +   * }
    + * + * @param studentCount studentCount + * @return current instance of builder + */ + public TechnicalInstituteBuilder studentCount(int studentCount) { + this.studentCount = changedValue(studentCount); + return this; + } + + /** + * Sets the value for studentCount by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(() -> 42);
    +   * }
    + * + * @param studentCountSupplier supplier for studentCount + * @return current instance of builder + */ + public TechnicalInstituteBuilder studentCount(Supplier studentCountSupplier) { + this.studentCount = changedValue(studentCountSupplier.get()); + return this; + } + + /** + * Sets the value for technicalFields. + *

    + * Generated from setter {@link TechnicalInstitute#setTechnicalFields(List) setTechnicalFields(List + * technicalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalFields("example value", "example value");
    +   * }
    + * + * @param technicalFields technicalFields + * @return current instance of builder + */ + public TechnicalInstituteBuilder technicalFields(String... technicalFields) { + this.technicalFields = changedValue(List.of(technicalFields)); + return this; + } + + /** + * Sets the value for technicalFields. + *

    + * Generated from setter {@link TechnicalInstitute#setTechnicalFields(List) setTechnicalFields(List + * technicalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalFields(List.of("example value"));
    +   * }
    + * + * @param technicalFields technicalFields + * @return current instance of builder + */ + public TechnicalInstituteBuilder technicalFields(List technicalFields) { + this.technicalFields = changedValue(technicalFields); + return this; + } + + /** + * Sets the value for technicalFields using a builder consumer that produces the value. + *

    + * Generated from setter {@link TechnicalInstitute#setTechnicalFields(List) setTechnicalFields(List + * technicalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalFields(t -> t.add("example value"));
    +   * }
    + * + * @param technicalFieldsBuilderConsumer consumer providing an instance of a builder for technicalFields + * @return current instance of builder + */ + public TechnicalInstituteBuilder technicalFields(Consumer> technicalFieldsBuilderConsumer) { + ArrayListBuilder builder = this.technicalFields.isSet() + ? new ArrayListBuilder(this.technicalFields.value()) + : new ArrayListBuilder(); + technicalFieldsBuilderConsumer.accept(builder); + this.technicalFields = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for technicalFields by invoking the provided supplier. + *

    + * Generated from setter {@link TechnicalInstitute#setTechnicalFields(List) setTechnicalFields(List + * technicalFields)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalFields(() -> List.of("example value"));
    +   * }
    + * + * @param technicalFieldsSupplier supplier for technicalFields + * @return current instance of builder + */ + public TechnicalInstituteBuilder technicalFields(Supplier> technicalFieldsSupplier) { + this.technicalFields = changedValue(technicalFieldsSupplier.get()); + 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 TechnicalInstituteBuilder 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 TechnicalInstituteBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TechnicalInstitute result = builder.build();
    +   * }
    + */ + @Override + public TechnicalInstitute build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.labCount.isSet() && this.labCount.value() == null) { + throw new IllegalStateException("Field 'labCount' is marked as non-null but null value was provided"); + } + if (this.studentCount.isSet() && this.studentCount.value() == null) { + throw new IllegalStateException("Field 'studentCount' is marked as non-null but null value was provided"); + } + TechnicalInstitute result = new TechnicalInstitute(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.labCount.ifSet(result::setLabCount); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.studentCount.ifSet(result::setStudentCount); + this.technicalFields.ifSet(result::setTechnicalFields); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("labCount", this.labCount) + .append("name", this.name) + .append("status", this.status) + .append("studentCount", this.studentCount) + .append("technicalFields", this.technicalFields) + .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 TechnicalInstitute with(Consumer b) { + TechnicalInstituteBuilder builder; + try { + builder = new TechnicalInstituteBuilder(TechnicalInstitute.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TechnicalInstituteBuilder.With' should only be implemented by classes, which could be casted to 'TechnicalInstitute'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TechnicalInstituteBuilder with() { + try { + return new TechnicalInstituteBuilder(TechnicalInstitute.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TechnicalInstituteBuilder.With' should only be implemented by classes, which could be casted to 'TechnicalInstitute'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TheaterArchiveBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TheaterArchiveBuilder.java new file mode 100644 index 00000000..af9c9bcb --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TheaterArchiveBuilder.java @@ -0,0 +1,751 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.TheaterArchive}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.TheaterArchive 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. + * + *

    Example:

    + * + *
    {@code
    + * TheaterArchive result = TheaterArchiveBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .mediaFormats(List.of("example value"))
    + *     .mediaFormats(() -> List.of("example value"))
    + *     .mediaFormats(t -> t.add("example value"))
    + *     .mediaFormats("example value", "example value")
    + *     .add2MediaFormats("example value")
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .performanceCount(42)
    + *     .performanceCount(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .theaterName("example value")
    + *     .theaterName("Hello %s", "World")
    + *     .theaterName(() -> "example value")
    + *     .theaterName(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TheaterArchive.class) +public class TheaterArchiveBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for mediaFormats: mediaFormats. + */ + private TrackedValue> mediaFormats = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for performanceCount: performanceCount. + */ + private TrackedValue performanceCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for theaterName: theaterName. + */ + private TrackedValue theaterName = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TheaterArchive}. + */ + public TheaterArchiveBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TheaterArchive} by a instance. + * + * @param instance object instance for initialisiation + */ + public TheaterArchiveBuilder(TheaterArchive instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.mediaFormats = initialValue(instance.getMediaFormats()); + this.name = initialValue(instance.getName()); + this.performanceCount = initialValue(instance.getPerformanceCount()); + this.status = initialValue(instance.getStatus()); + this.theaterName = initialValue(instance.getTheaterName()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TheaterArchive}. + * + *

    Example:

    + * + *
    {@code
    +   * TheaterArchiveBuilder builder = TheaterArchiveBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.TheaterArchive} + */ + public static TheaterArchiveBuilder create() { + return new TheaterArchiveBuilder(); + } + + /** + * Adds a single element to mediaFormats. + *

    + * Generated from setter {@link TheaterArchive#setMediaFormats(List) setMediaFormats(List mediaFormats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2MediaFormats("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TheaterArchiveBuilder add2MediaFormats(String element) { + List newCollection; + if (this.mediaFormats.isSet()) { + newCollection = new ArrayList<>(this.mediaFormats.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.mediaFormats = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link TheaterArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TheaterArchiveBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TheaterArchiveBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link TheaterArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public TheaterArchiveBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public TheaterArchiveBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link TheaterArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TheaterArchiveBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TheaterArchiveBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for mediaFormats. + *

    + * Generated from setter {@link TheaterArchive#setMediaFormats(List) setMediaFormats(List mediaFormats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaFormats("example value", "example value");
    +   * }
    + * + * @param mediaFormats mediaFormats + * @return current instance of builder + */ + public TheaterArchiveBuilder mediaFormats(String... mediaFormats) { + this.mediaFormats = changedValue(List.of(mediaFormats)); + return this; + } + + /** + * Sets the value for mediaFormats. + *

    + * Generated from setter {@link TheaterArchive#setMediaFormats(List) setMediaFormats(List mediaFormats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaFormats(List.of("example value"));
    +   * }
    + * + * @param mediaFormats mediaFormats + * @return current instance of builder + */ + public TheaterArchiveBuilder mediaFormats(List mediaFormats) { + this.mediaFormats = changedValue(mediaFormats); + return this; + } + + /** + * Sets the value for mediaFormats using a builder consumer that produces the value. + *

    + * Generated from setter {@link TheaterArchive#setMediaFormats(List) setMediaFormats(List mediaFormats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaFormats(t -> t.add("example value"));
    +   * }
    + * + * @param mediaFormatsBuilderConsumer consumer providing an instance of a builder for mediaFormats + * @return current instance of builder + */ + public TheaterArchiveBuilder mediaFormats(Consumer> mediaFormatsBuilderConsumer) { + ArrayListBuilder builder = this.mediaFormats.isSet() + ? new ArrayListBuilder(this.mediaFormats.value()) + : new ArrayListBuilder(); + mediaFormatsBuilderConsumer.accept(builder); + this.mediaFormats = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for mediaFormats by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setMediaFormats(List) setMediaFormats(List mediaFormats)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mediaFormats(() -> List.of("example value"));
    +   * }
    + * + * @param mediaFormatsSupplier supplier for mediaFormats + * @return current instance of builder + */ + public TheaterArchiveBuilder mediaFormats(Supplier> mediaFormatsSupplier) { + this.mediaFormats = changedValue(mediaFormatsSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link TheaterArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TheaterArchiveBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link TheaterArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TheaterArchiveBuilder 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. + *

    + * Generated from setter {@link TheaterArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TheaterArchiveBuilder 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. + *

    + * Generated from setter {@link TheaterArchive#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TheaterArchiveBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for performanceCount. + *

    + * Generated from setter {@link TheaterArchive#setPerformanceCount(int) setPerformanceCount(int performanceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceCount(42);
    +   * }
    + * + * @param performanceCount performanceCount + * @return current instance of builder + */ + public TheaterArchiveBuilder performanceCount(int performanceCount) { + this.performanceCount = changedValue(performanceCount); + return this; + } + + /** + * Sets the value for performanceCount by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setPerformanceCount(int) setPerformanceCount(int performanceCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.performanceCount(() -> 42);
    +   * }
    + * + * @param performanceCountSupplier supplier for performanceCount + * @return current instance of builder + */ + public TheaterArchiveBuilder performanceCount(Supplier performanceCountSupplier) { + this.performanceCount = changedValue(performanceCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link TheaterArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public TheaterArchiveBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link TheaterArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public TheaterArchiveBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public TheaterArchiveBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TheaterArchive#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TheaterArchiveBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for theaterName. + *

    + * Generated from setter {@link TheaterArchive#setTheaterName(String) setTheaterName(String theaterName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theaterName("example value");
    +   * }
    + * + * @param theaterName theaterName + * @return current instance of builder + */ + public TheaterArchiveBuilder theaterName(String theaterName) { + this.theaterName = changedValue(theaterName); + return this; + } + + /** + * Sets the value for theaterName by executing the provided consumer. + *

    + * Generated from setter {@link TheaterArchive#setTheaterName(String) setTheaterName(String theaterName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theaterName(sb -> sb.append("text"));
    +   * }
    + * + * @param theaterNameStringBuilderConsumer consumer providing an instance of theaterName + * @return current instance of builder + */ + public TheaterArchiveBuilder theaterName(Consumer theaterNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + theaterNameStringBuilderConsumer.accept(builder); + this.theaterName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for theaterName by invoking the provided supplier. + *

    + * Generated from setter {@link TheaterArchive#setTheaterName(String) setTheaterName(String theaterName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theaterName(() -> "example value");
    +   * }
    + * + * @param theaterNameSupplier supplier for theaterName + * @return current instance of builder + */ + public TheaterArchiveBuilder theaterName(Supplier theaterNameSupplier) { + this.theaterName = changedValue(theaterNameSupplier.get()); + return this; + } + + /** + * Sets the String value for theaterName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TheaterArchive#setTheaterName(String) setTheaterName(String theaterName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.theaterName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TheaterArchiveBuilder theaterName(String format, Object... args) { + this.theaterName = changedValue(String.format(format, args)); + 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 TheaterArchiveBuilder 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 TheaterArchiveBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TheaterArchive result = builder.build();
    +   * }
    + */ + @Override + public TheaterArchive build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.performanceCount.isSet() && this.performanceCount.value() == null) { + throw new IllegalStateException("Field 'performanceCount' is marked as non-null but null value was provided"); + } + TheaterArchive result = new TheaterArchive(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.mediaFormats.ifSet(result::setMediaFormats); + this.name.ifSet(result::setName); + this.performanceCount.ifSet(result::setPerformanceCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.theaterName.ifSet(result::setTheaterName); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("mediaFormats", this.mediaFormats) + .append("name", this.name) + .append("performanceCount", this.performanceCount) + .append("status", this.status) + .append("theaterName", this.theaterName) + .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 TheaterArchive with(Consumer b) { + TheaterArchiveBuilder builder; + try { + builder = new TheaterArchiveBuilder(TheaterArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TheaterArchiveBuilder.With' should only be implemented by classes, which could be casted to 'TheaterArchive'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TheaterArchiveBuilder with() { + try { + return new TheaterArchiveBuilder(TheaterArchive.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TheaterArchiveBuilder.With' should only be implemented by classes, which could be casted to 'TheaterArchive'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ThinkTankBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ThinkTankBuilder.java new file mode 100644 index 00000000..b7e7e723 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ThinkTankBuilder.java @@ -0,0 +1,710 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.ThinkTank}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.ThinkTank 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. + * + *

    Example:

    + * + *
    {@code
    + * ThinkTank result = ThinkTankBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .focusAreas(List.of("example value"))
    + *     .focusAreas(() -> List.of("example value"))
    + *     .focusAreas(t -> t.add("example value"))
    + *     .focusAreas("example value", "example value")
    + *     .add2FocusAreas("example value")
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .publicationsPerYear(42)
    + *     .publicationsPerYear(() -> 42)
    + *     .staffCount(42)
    + *     .staffCount(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ThinkTank.class) +public class ThinkTankBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for focusAreas: focusAreas. + */ + private TrackedValue> focusAreas = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for publicationsPerYear: publicationsPerYear. + */ + private TrackedValue publicationsPerYear = unsetValue(); + /** + * Tracked value for staffCount: staffCount. + */ + private TrackedValue staffCount = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ThinkTank}. + */ + public ThinkTankBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ThinkTank} by a instance. + * + * @param instance object instance for initialisiation + */ + public ThinkTankBuilder(ThinkTank instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.focusAreas = initialValue(instance.getFocusAreas()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.publicationsPerYear = initialValue(instance.getPublicationsPerYear()); + this.staffCount = initialValue(instance.getStaffCount()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.ThinkTank}. + * + *

    Example:

    + * + *
    {@code
    +   * ThinkTankBuilder builder = ThinkTankBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.ThinkTank} + */ + public static ThinkTankBuilder create() { + return new ThinkTankBuilder(); + } + + /** + * Adds a single element to focusAreas. + *

    + * Generated from setter {@link ThinkTank#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2FocusAreas("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ThinkTankBuilder add2FocusAreas(String element) { + List newCollection; + if (this.focusAreas.isSet()) { + newCollection = new ArrayList<>(this.focusAreas.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.focusAreas = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ThinkTank#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ThinkTankBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ThinkTankBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for focusAreas. + *

    + * Generated from setter {@link ThinkTank#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas("example value", "example value");
    +   * }
    + * + * @param focusAreas focusAreas + * @return current instance of builder + */ + public ThinkTankBuilder focusAreas(String... focusAreas) { + this.focusAreas = changedValue(List.of(focusAreas)); + return this; + } + + /** + * Sets the value for focusAreas. + *

    + * Generated from setter {@link ThinkTank#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas(List.of("example value"));
    +   * }
    + * + * @param focusAreas focusAreas + * @return current instance of builder + */ + public ThinkTankBuilder focusAreas(List focusAreas) { + this.focusAreas = changedValue(focusAreas); + return this; + } + + /** + * Sets the value for focusAreas using a builder consumer that produces the value. + *

    + * Generated from setter {@link ThinkTank#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas(t -> t.add("example value"));
    +   * }
    + * + * @param focusAreasBuilderConsumer consumer providing an instance of a builder for focusAreas + * @return current instance of builder + */ + public ThinkTankBuilder focusAreas(Consumer> focusAreasBuilderConsumer) { + ArrayListBuilder builder = this.focusAreas.isSet() + ? new ArrayListBuilder(this.focusAreas.value()) + : new ArrayListBuilder(); + focusAreasBuilderConsumer.accept(builder); + this.focusAreas = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for focusAreas by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setFocusAreas(List) setFocusAreas(List focusAreas)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.focusAreas(() -> List.of("example value"));
    +   * }
    + * + * @param focusAreasSupplier supplier for focusAreas + * @return current instance of builder + */ + public ThinkTankBuilder focusAreas(Supplier> focusAreasSupplier) { + this.focusAreas = changedValue(focusAreasSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link ThinkTank#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ThinkTankBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ThinkTankBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ThinkTank#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ThinkTankBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ThinkTankBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ThinkTank#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ThinkTankBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ThinkTank#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ThinkTankBuilder 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. + *

    + * Generated from setter {@link ThinkTank#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ThinkTankBuilder 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. + *

    + * Generated from setter {@link ThinkTank#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ThinkTankBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publicationsPerYear. + *

    + * Generated from setter {@link ThinkTank#setPublicationsPerYear(int) setPublicationsPerYear(int publicationsPerYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationsPerYear(42);
    +   * }
    + * + * @param publicationsPerYear publicationsPerYear + * @return current instance of builder + */ + public ThinkTankBuilder publicationsPerYear(int publicationsPerYear) { + this.publicationsPerYear = changedValue(publicationsPerYear); + return this; + } + + /** + * Sets the value for publicationsPerYear by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setPublicationsPerYear(int) setPublicationsPerYear(int publicationsPerYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publicationsPerYear(() -> 42);
    +   * }
    + * + * @param publicationsPerYearSupplier supplier for publicationsPerYear + * @return current instance of builder + */ + public ThinkTankBuilder publicationsPerYear(Supplier publicationsPerYearSupplier) { + this.publicationsPerYear = changedValue(publicationsPerYearSupplier.get()); + return this; + } + + /** + * Sets the value for staffCount. + *

    + * Generated from setter {@link ThinkTank#setStaffCount(int) setStaffCount(int staffCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(42);
    +   * }
    + * + * @param staffCount staffCount + * @return current instance of builder + */ + public ThinkTankBuilder staffCount(int staffCount) { + this.staffCount = changedValue(staffCount); + return this; + } + + /** + * Sets the value for staffCount by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setStaffCount(int) setStaffCount(int staffCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(() -> 42);
    +   * }
    + * + * @param staffCountSupplier supplier for staffCount + * @return current instance of builder + */ + public ThinkTankBuilder staffCount(Supplier staffCountSupplier) { + this.staffCount = changedValue(staffCountSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ThinkTank#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ThinkTankBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ThinkTank#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ThinkTankBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ThinkTank#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ThinkTankBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ThinkTank#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ThinkTankBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ThinkTankBuilder 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 ThinkTankBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ThinkTank result = builder.build();
    +   * }
    + */ + @Override + public ThinkTank build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.publicationsPerYear.isSet() && this.publicationsPerYear.value() == null) { + throw new IllegalStateException("Field 'publicationsPerYear' is marked as non-null but null value was provided"); + } + if (this.staffCount.isSet() && this.staffCount.value() == null) { + throw new IllegalStateException("Field 'staffCount' is marked as non-null but null value was provided"); + } + ThinkTank result = new ThinkTank(); + this.createdAt.ifSet(result::setCreatedAt); + this.focusAreas.ifSet(result::setFocusAreas); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.publicationsPerYear.ifSet(result::setPublicationsPerYear); + this.staffCount.ifSet(result::setStaffCount); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("focusAreas", this.focusAreas) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("publicationsPerYear", this.publicationsPerYear) + .append("staffCount", this.staffCount) + .append("status", this.status) + .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 ThinkTank with(Consumer b) { + ThinkTankBuilder builder; + try { + builder = new ThinkTankBuilder(ThinkTank.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ThinkTankBuilder.With' should only be implemented by classes, which could be casted to 'ThinkTank'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ThinkTankBuilder with() { + try { + return new ThinkTankBuilder(ThinkTank.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ThinkTankBuilder.With' should only be implemented by classes, which could be casted to 'ThinkTank'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TradePublisherBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TradePublisherBuilder.java new file mode 100644 index 00000000..89f35968 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TradePublisherBuilder.java @@ -0,0 +1,786 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; +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.builders.ArrayListBuilder; +import org.javahelpers.simple.builders.core.builders.HashSetBuilder; +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.performance_test.library.organizations.TradePublisher}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.TradePublisher 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. + * + *

    Example:

    + * + *
    {@code
    + * TradePublisher result = TradePublisherBuilder.create()
    + *     .annualTitles(42)
    + *     .annualTitles(() -> 42)
    + *     .bestsellingAuthors(Set.of("example value"))
    + *     .bestsellingAuthors(() -> Set.of("example value"))
    + *     .bestsellingAuthors(t -> t.add("example value"))
    + *     .bestsellingAuthors("example value", "example value")
    + *     .add2BestsellingAuthors("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .genres(List.of("example value"))
    + *     .genres(() -> List.of("example value"))
    + *     .genres(t -> t.add("example value"))
    + *     .genres("example value", "example value")
    + *     .add2Genres("example value")
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TradePublisher.class) +public class TradePublisherBuilder implements IBuilderBase { + + /** + * Tracked value for annualTitles: annualTitles. + */ + private TrackedValue annualTitles = unsetValue(); + /** + * Tracked value for bestsellingAuthors: bestsellingAuthors. + */ + private TrackedValue> bestsellingAuthors = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for genres: genres. + */ + private TrackedValue> genres = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TradePublisher}. + */ + public TradePublisherBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TradePublisher} by a instance. + * + * @param instance object instance for initialisiation + */ + public TradePublisherBuilder(TradePublisher instance) { + this.annualTitles = initialValue(instance.getAnnualTitles()); + this.bestsellingAuthors = initialValue(instance.getBestsellingAuthors()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.genres = initialValue(instance.getGenres()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TradePublisher}. + * + *

    Example:

    + * + *
    {@code
    +   * TradePublisherBuilder builder = TradePublisherBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.TradePublisher} + */ + public static TradePublisherBuilder create() { + return new TradePublisherBuilder(); + } + + /** + * Adds a single element to bestsellingAuthors. + *

    + * Generated from setter {@link TradePublisher#setBestsellingAuthors(Set) setBestsellingAuthors(Set + * bestsellingAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2BestsellingAuthors("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TradePublisherBuilder add2BestsellingAuthors(String element) { + Set newCollection; + if (this.bestsellingAuthors.isSet()) { + newCollection = new HashSet<>(this.bestsellingAuthors.value()); + } else { + newCollection = new HashSet<>(); + } + newCollection.add(element); + this.bestsellingAuthors = changedValue(newCollection); + return this; + } + + /** + * Adds a single element to genres. + *

    + * Generated from setter {@link TradePublisher#setGenres(List) setGenres(List genres)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Genres("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TradePublisherBuilder add2Genres(String element) { + List newCollection; + if (this.genres.isSet()) { + newCollection = new ArrayList<>(this.genres.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.genres = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualTitles. + *

    + * Generated from setter {@link TradePublisher#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(42);
    +   * }
    + * + * @param annualTitles annualTitles + * @return current instance of builder + */ + public TradePublisherBuilder annualTitles(int annualTitles) { + this.annualTitles = changedValue(annualTitles); + return this; + } + + /** + * Sets the value for annualTitles by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setAnnualTitles(int) setAnnualTitles(int annualTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualTitles(() -> 42);
    +   * }
    + * + * @param annualTitlesSupplier supplier for annualTitles + * @return current instance of builder + */ + public TradePublisherBuilder annualTitles(Supplier annualTitlesSupplier) { + this.annualTitles = changedValue(annualTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for bestsellingAuthors. + *

    + * Generated from setter {@link TradePublisher#setBestsellingAuthors(Set) setBestsellingAuthors(Set + * bestsellingAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bestsellingAuthors("example value", "example value");
    +   * }
    + * + * @param bestsellingAuthors bestsellingAuthors + * @return current instance of builder + */ + public TradePublisherBuilder bestsellingAuthors(String... bestsellingAuthors) { + this.bestsellingAuthors = changedValue(Set.of(bestsellingAuthors)); + return this; + } + + /** + * Sets the value for bestsellingAuthors. + *

    + * Generated from setter {@link TradePublisher#setBestsellingAuthors(Set) setBestsellingAuthors(Set + * bestsellingAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bestsellingAuthors(Set.of("example value"));
    +   * }
    + * + * @param bestsellingAuthors bestsellingAuthors + * @return current instance of builder + */ + public TradePublisherBuilder bestsellingAuthors(Set bestsellingAuthors) { + this.bestsellingAuthors = changedValue(bestsellingAuthors); + return this; + } + + /** + * Sets the value for bestsellingAuthors using a builder consumer that produces the value. + *

    + * Generated from setter {@link TradePublisher#setBestsellingAuthors(Set) setBestsellingAuthors(Set + * bestsellingAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bestsellingAuthors(t -> t.add("example value"));
    +   * }
    + * + * @param bestsellingAuthorsBuilderConsumer consumer providing an instance of a builder for bestsellingAuthors + * @return current instance of builder + */ + public TradePublisherBuilder bestsellingAuthors(Consumer> bestsellingAuthorsBuilderConsumer) { + HashSetBuilder builder = this.bestsellingAuthors.isSet() + ? new HashSetBuilder(this.bestsellingAuthors.value()) + : new HashSetBuilder(); + bestsellingAuthorsBuilderConsumer.accept(builder); + this.bestsellingAuthors = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for bestsellingAuthors by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setBestsellingAuthors(Set) setBestsellingAuthors(Set + * bestsellingAuthors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.bestsellingAuthors(() -> Set.of("example value"));
    +   * }
    + * + * @param bestsellingAuthorsSupplier supplier for bestsellingAuthors + * @return current instance of builder + */ + public TradePublisherBuilder bestsellingAuthors(Supplier> bestsellingAuthorsSupplier) { + this.bestsellingAuthors = changedValue(bestsellingAuthorsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link TradePublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TradePublisherBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TradePublisherBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link TradePublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public TradePublisherBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public TradePublisherBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for genres. + *

    + * Generated from setter {@link TradePublisher#setGenres(List) setGenres(List genres)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genres("example value", "example value");
    +   * }
    + * + * @param genres genres + * @return current instance of builder + */ + public TradePublisherBuilder genres(String... genres) { + this.genres = changedValue(List.of(genres)); + return this; + } + + /** + * Sets the value for genres. + *

    + * Generated from setter {@link TradePublisher#setGenres(List) setGenres(List genres)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genres(List.of("example value"));
    +   * }
    + * + * @param genres genres + * @return current instance of builder + */ + public TradePublisherBuilder genres(List genres) { + this.genres = changedValue(genres); + return this; + } + + /** + * Sets the value for genres using a builder consumer that produces the value. + *

    + * Generated from setter {@link TradePublisher#setGenres(List) setGenres(List genres)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genres(t -> t.add("example value"));
    +   * }
    + * + * @param genresBuilderConsumer consumer providing an instance of a builder for genres + * @return current instance of builder + */ + public TradePublisherBuilder genres(Consumer> genresBuilderConsumer) { + ArrayListBuilder builder = this.genres.isSet() + ? new ArrayListBuilder(this.genres.value()) + : new ArrayListBuilder(); + genresBuilderConsumer.accept(builder); + this.genres = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for genres by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setGenres(List) setGenres(List genres)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.genres(() -> List.of("example value"));
    +   * }
    + * + * @param genresSupplier supplier for genres + * @return current instance of builder + */ + public TradePublisherBuilder genres(Supplier> genresSupplier) { + this.genres = changedValue(genresSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link TradePublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TradePublisherBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TradePublisherBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link TradePublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TradePublisherBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link TradePublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TradePublisherBuilder 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. + *

    + * Generated from setter {@link TradePublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TradePublisherBuilder 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. + *

    + * Generated from setter {@link TradePublisher#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TradePublisherBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link TradePublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public TradePublisherBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link TradePublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public TradePublisherBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link TradePublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public TradePublisherBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TradePublisher#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TradePublisherBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 TradePublisherBuilder 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 TradePublisherBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TradePublisher result = builder.build();
    +   * }
    + */ + @Override + public TradePublisher build() { + if (this.annualTitles.isSet() && this.annualTitles.value() == null) { + throw new IllegalStateException("Field 'annualTitles' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + TradePublisher result = new TradePublisher(); + this.annualTitles.ifSet(result::setAnnualTitles); + this.bestsellingAuthors.ifSet(result::setBestsellingAuthors); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.genres.ifSet(result::setGenres); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualTitles", this.annualTitles) + .append("bestsellingAuthors", this.bestsellingAuthors) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("genres", this.genres) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .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 TradePublisher with(Consumer b) { + TradePublisherBuilder builder; + try { + builder = new TradePublisherBuilder(TradePublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TradePublisherBuilder.With' should only be implemented by classes, which could be casted to 'TradePublisher'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TradePublisherBuilder with() { + try { + return new TradePublisherBuilder(TradePublisher.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TradePublisherBuilder.With' should only be implemented by classes, which could be casted to 'TradePublisher'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrainingNetworkBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrainingNetworkBuilder.java new file mode 100644 index 00000000..e4ab3f13 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrainingNetworkBuilder.java @@ -0,0 +1,716 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.TrainingNetwork}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.TrainingNetwork 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. + * + *

    Example:

    + * + *
    {@code
    + * TrainingNetwork result = TrainingNetworkBuilder.create()
    + *     .annualWorkshops(42)
    + *     .annualWorkshops(() -> 42)
    + *     .certificationPrograms(List.of("example value"))
    + *     .certificationPrograms(() -> List.of("example value"))
    + *     .certificationPrograms(t -> t.add("example value"))
    + *     .certificationPrograms("example value", "example value")
    + *     .add2CertificationPrograms("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TrainingNetwork.class) +public class TrainingNetworkBuilder implements IBuilderBase { + + /** + * Tracked value for annualWorkshops: annualWorkshops. + */ + private TrackedValue annualWorkshops = unsetValue(); + /** + * Tracked value for certificationPrograms: certificationPrograms. + */ + private TrackedValue> certificationPrograms = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrainingNetwork}. + */ + public TrainingNetworkBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrainingNetwork} by a instance. + * + * @param instance object instance for initialisiation + */ + public TrainingNetworkBuilder(TrainingNetwork instance) { + this.annualWorkshops = initialValue(instance.getAnnualWorkshops()); + this.certificationPrograms = initialValue(instance.getCertificationPrograms()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.memberCount = initialValue(instance.getMemberCount()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrainingNetwork}. + * + *

    Example:

    + * + *
    {@code
    +   * TrainingNetworkBuilder builder = TrainingNetworkBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrainingNetwork} + */ + public static TrainingNetworkBuilder create() { + return new TrainingNetworkBuilder(); + } + + /** + * Adds a single element to certificationPrograms. + *

    + * Generated from setter {@link TrainingNetwork#setCertificationPrograms(List) setCertificationPrograms(List + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2CertificationPrograms("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TrainingNetworkBuilder add2CertificationPrograms(String element) { + List newCollection; + if (this.certificationPrograms.isSet()) { + newCollection = new ArrayList<>(this.certificationPrograms.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.certificationPrograms = changedValue(newCollection); + return this; + } + + /** + * Sets the value for annualWorkshops. + *

    + * Generated from setter {@link TrainingNetwork#setAnnualWorkshops(int) setAnnualWorkshops(int annualWorkshops)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualWorkshops(42);
    +   * }
    + * + * @param annualWorkshops annualWorkshops + * @return current instance of builder + */ + public TrainingNetworkBuilder annualWorkshops(int annualWorkshops) { + this.annualWorkshops = changedValue(annualWorkshops); + return this; + } + + /** + * Sets the value for annualWorkshops by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setAnnualWorkshops(int) setAnnualWorkshops(int annualWorkshops)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualWorkshops(() -> 42);
    +   * }
    + * + * @param annualWorkshopsSupplier supplier for annualWorkshops + * @return current instance of builder + */ + public TrainingNetworkBuilder annualWorkshops(Supplier annualWorkshopsSupplier) { + this.annualWorkshops = changedValue(annualWorkshopsSupplier.get()); + return this; + } + + /** + * Sets the value for certificationPrograms. + *

    + * Generated from setter {@link TrainingNetwork#setCertificationPrograms(List) setCertificationPrograms(List + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms("example value", "example value");
    +   * }
    + * + * @param certificationPrograms certificationPrograms + * @return current instance of builder + */ + public TrainingNetworkBuilder certificationPrograms(String... certificationPrograms) { + this.certificationPrograms = changedValue(List.of(certificationPrograms)); + return this; + } + + /** + * Sets the value for certificationPrograms. + *

    + * Generated from setter {@link TrainingNetwork#setCertificationPrograms(List) setCertificationPrograms(List + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(List.of("example value"));
    +   * }
    + * + * @param certificationPrograms certificationPrograms + * @return current instance of builder + */ + public TrainingNetworkBuilder certificationPrograms(List certificationPrograms) { + this.certificationPrograms = changedValue(certificationPrograms); + return this; + } + + /** + * Sets the value for certificationPrograms using a builder consumer that produces the value. + *

    + * Generated from setter {@link TrainingNetwork#setCertificationPrograms(List) setCertificationPrograms(List + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(t -> t.add("example value"));
    +   * }
    + * + * @param certificationProgramsBuilderConsumer consumer providing an instance of a builder for certificationPrograms + * @return current instance of builder + */ + public TrainingNetworkBuilder certificationPrograms( + Consumer> certificationProgramsBuilderConsumer) { + ArrayListBuilder builder = this.certificationPrograms.isSet() + ? new ArrayListBuilder(this.certificationPrograms.value()) + : new ArrayListBuilder(); + certificationProgramsBuilderConsumer.accept(builder); + this.certificationPrograms = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for certificationPrograms by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setCertificationPrograms(List) setCertificationPrograms(List + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(() -> List.of("example value"));
    +   * }
    + * + * @param certificationProgramsSupplier supplier for certificationPrograms + * @return current instance of builder + */ + public TrainingNetworkBuilder certificationPrograms(Supplier> certificationProgramsSupplier) { + this.certificationPrograms = changedValue(certificationProgramsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link TrainingNetwork#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TrainingNetworkBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TrainingNetworkBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link TrainingNetwork#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public TrainingNetworkBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public TrainingNetworkBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link TrainingNetwork#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TrainingNetworkBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TrainingNetworkBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from setter {@link TrainingNetwork#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public TrainingNetworkBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setMemberCount(int) setMemberCount(int memberCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public TrainingNetworkBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link TrainingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TrainingNetworkBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link TrainingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TrainingNetworkBuilder 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. + *

    + * Generated from setter {@link TrainingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TrainingNetworkBuilder 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. + *

    + * Generated from setter {@link TrainingNetwork#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TrainingNetworkBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link TrainingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public TrainingNetworkBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link TrainingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public TrainingNetworkBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link TrainingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public TrainingNetworkBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link TrainingNetwork#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TrainingNetworkBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 TrainingNetworkBuilder 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 TrainingNetworkBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TrainingNetwork result = builder.build();
    +   * }
    + */ + @Override + public TrainingNetwork build() { + if (this.annualWorkshops.isSet() && this.annualWorkshops.value() == null) { + throw new IllegalStateException("Field 'annualWorkshops' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.memberCount.isSet() && this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + TrainingNetwork result = new TrainingNetwork(); + this.annualWorkshops.ifSet(result::setAnnualWorkshops); + this.certificationPrograms.ifSet(result::setCertificationPrograms); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.memberCount.ifSet(result::setMemberCount); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("annualWorkshops", this.annualWorkshops) + .append("certificationPrograms", this.certificationPrograms) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("memberCount", this.memberCount) + .append("name", this.name) + .append("status", this.status) + .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 TrainingNetwork with(Consumer b) { + TrainingNetworkBuilder builder; + try { + builder = new TrainingNetworkBuilder(TrainingNetwork.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TrainingNetworkBuilder.With' should only be implemented by classes, which could be casted to 'TrainingNetwork'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TrainingNetworkBuilder with() { + try { + return new TrainingNetworkBuilder(TrainingNetwork.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TrainingNetworkBuilder.With' should only be implemented by classes, which could be casted to 'TrainingNetwork'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrustRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrustRecordBuilder.java new file mode 100644 index 00000000..36bbbeb8 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/TrustRecordBuilder.java @@ -0,0 +1,510 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.math.BigDecimal; +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.performance_test.library.organizations.TrustRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.TrustRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TrustRecord result = TrustRecordBuilder.create()
    + *     .trustName("example value")
    + *     .trustName("Hello %s", "World")
    + *     .trustName(() -> "example value")
    + *     .trustName(sb -> sb.append("text"))
    + *     .trustType("example value")
    + *     .trustType("Hello %s", "World")
    + *     .trustType(() -> "example value")
    + *     .trustType(sb -> sb.append("text"))
    + *     .totalAssets(BigDecimal.valueOf(3.14))
    + *     .totalAssets(() -> BigDecimal.valueOf(3.14))
    + *     .beneficiaries(42)
    + *     .beneficiaries(() -> 42)
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TrustRecord.class) +public class TrustRecordBuilder implements IBuilderBase { + + /** + * Tracked value for trustName: trustName. + */ + private TrackedValue trustName = unsetValue(); + /** + * Tracked value for trustType: trustType. + */ + private TrackedValue trustType = unsetValue(); + /** + * Tracked value for totalAssets: totalAssets. + */ + private TrackedValue totalAssets = unsetValue(); + /** + * Tracked value for beneficiaries: beneficiaries. + */ + private TrackedValue beneficiaries = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrustRecord}. + */ + public TrustRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrustRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TrustRecordBuilder(TrustRecord instance) { + this.trustName = initialValue(instance.trustName()); + this.trustType = initialValue(instance.trustType()); + this.totalAssets = initialValue(instance.totalAssets()); + this.beneficiaries = initialValue(instance.beneficiaries()); + this.foundedYear = initialValue(instance.foundedYear()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrustRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TrustRecordBuilder builder = TrustRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.TrustRecord} + */ + public static TrustRecordBuilder create() { + return new TrustRecordBuilder(); + } + + /** + * Sets the value for beneficiaries. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.beneficiaries(42);
    +   * }
    + * + * @param beneficiaries beneficiaries + * @return current instance of builder + */ + public TrustRecordBuilder beneficiaries(int beneficiaries) { + this.beneficiaries = changedValue(beneficiaries); + return this; + } + + /** + * Sets the value for beneficiaries by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.beneficiaries(() -> 42);
    +   * }
    + * + * @param beneficiariesSupplier supplier for beneficiaries + * @return current instance of builder + */ + public TrustRecordBuilder beneficiaries(Supplier beneficiariesSupplier) { + this.beneficiaries = changedValue(beneficiariesSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public TrustRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public TrustRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for totalAssets. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalAssets(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalAssets totalAssets + * @return current instance of builder + */ + public TrustRecordBuilder totalAssets(BigDecimal totalAssets) { + this.totalAssets = changedValue(totalAssets); + return this; + } + + /** + * Sets the value for totalAssets by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalAssets(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalAssetsSupplier supplier for totalAssets + * @return current instance of builder + */ + public TrustRecordBuilder totalAssets(Supplier totalAssetsSupplier) { + this.totalAssets = changedValue(totalAssetsSupplier.get()); + return this; + } + + /** + * Sets the value for trustName. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustName("example value");
    +   * }
    + * + * @param trustName trustName + * @return current instance of builder + */ + public TrustRecordBuilder trustName(String trustName) { + this.trustName = changedValue(trustName); + return this; + } + + /** + * Sets the value for trustName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustName(sb -> sb.append("text"));
    +   * }
    + * + * @param trustNameStringBuilderConsumer consumer providing an instance of trustName + * @return current instance of builder + */ + public TrustRecordBuilder trustName(Consumer trustNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + trustNameStringBuilderConsumer.accept(builder); + this.trustName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for trustName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustName(() -> "example value");
    +   * }
    + * + * @param trustNameSupplier supplier for trustName + * @return current instance of builder + */ + public TrustRecordBuilder trustName(Supplier trustNameSupplier) { + this.trustName = changedValue(trustNameSupplier.get()); + return this; + } + + /** + * Sets the String value for trustName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TrustRecordBuilder trustName(String format, Object... args) { + this.trustName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for trustType. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustType("example value");
    +   * }
    + * + * @param trustType trustType + * @return current instance of builder + */ + public TrustRecordBuilder trustType(String trustType) { + this.trustType = changedValue(trustType); + return this; + } + + /** + * Sets the value for trustType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustType(sb -> sb.append("text"));
    +   * }
    + * + * @param trustTypeStringBuilderConsumer consumer providing an instance of trustType + * @return current instance of builder + */ + public TrustRecordBuilder trustType(Consumer trustTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + trustTypeStringBuilderConsumer.accept(builder); + this.trustType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for trustType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustType(() -> "example value");
    +   * }
    + * + * @param trustTypeSupplier supplier for trustType + * @return current instance of builder + */ + public TrustRecordBuilder trustType(Supplier trustTypeSupplier) { + this.trustType = changedValue(trustTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for trustType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TrustRecord#TrustRecord(String, String, BigDecimal, int, int) + * TrustRecord(String trustName, String trustType, BigDecimal totalAssets, int beneficiaries, int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trustType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TrustRecordBuilder trustType(String format, Object... args) { + this.trustType = changedValue(String.format(format, args)); + 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 TrustRecordBuilder 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 TrustRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TrustRecord result = builder.build();
    +   * }
    + */ + @Override + public TrustRecord build() { + if (!this.beneficiaries.isSet()) { + throw new IllegalStateException("Required field 'beneficiaries' must be set before calling build()"); + } + if (this.beneficiaries.value() == null) { + throw new IllegalStateException("Field 'beneficiaries' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + TrustRecord result = new TrustRecord(this.trustName.value(), + this.trustType.value(), + this.totalAssets.value(), + this.beneficiaries.value(), + this.foundedYear.value()); + 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("trustName", this.trustName) + .append("trustType", this.trustType) + .append("totalAssets", this.totalAssets) + .append("beneficiaries", this.beneficiaries) + .append("foundedYear", this.foundedYear) + .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 TrustRecord with(Consumer b) { + TrustRecordBuilder builder; + try { + builder = new TrustRecordBuilder(TrustRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TrustRecordBuilder.With' should only be implemented by classes, which could be casted to 'TrustRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TrustRecordBuilder with() { + try { + return new TrustRecordBuilder(TrustRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TrustRecordBuilder.With' should only be implemented by classes, which could be casted to 'TrustRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnionRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnionRecordBuilder.java new file mode 100644 index 00000000..37ca360e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnionRecordBuilder.java @@ -0,0 +1,506 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.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.performance_test.library.organizations.UnionRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.UnionRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * UnionRecord result = UnionRecordBuilder.create()
    + *     .unionName("example value")
    + *     .unionName("Hello %s", "World")
    + *     .unionName(() -> "example value")
    + *     .unionName(sb -> sb.append("text"))
    + *     .memberCount(42)
    + *     .memberCount(() -> 42)
    + *     .industry("example value")
    + *     .industry("Hello %s", "World")
    + *     .industry(() -> "example value")
    + *     .industry(sb -> sb.append("text"))
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .active(true)
    + *     .active(() -> true)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = UnionRecord.class) +public class UnionRecordBuilder implements IBuilderBase { + + /** + * Tracked value for unionName: unionName. + */ + private TrackedValue unionName = unsetValue(); + /** + * Tracked value for memberCount: memberCount. + */ + private TrackedValue memberCount = unsetValue(); + /** + * Tracked value for industry: industry. + */ + private TrackedValue industry = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for active: active. + */ + private TrackedValue active = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnionRecord}. + */ + public UnionRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnionRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public UnionRecordBuilder(UnionRecord instance) { + this.unionName = initialValue(instance.unionName()); + this.memberCount = initialValue(instance.memberCount()); + this.industry = initialValue(instance.industry()); + this.foundedYear = initialValue(instance.foundedYear()); + this.active = initialValue(instance.active()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnionRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * UnionRecordBuilder builder = UnionRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnionRecord} + */ + public static UnionRecordBuilder create() { + return new UnionRecordBuilder(); + } + + /** + * Sets the value for active. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(true);
    +   * }
    + * + * @param active active + * @return current instance of builder + */ + public UnionRecordBuilder active(boolean active) { + this.active = changedValue(active); + return this; + } + + /** + * Sets the value for active by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.active(() -> true);
    +   * }
    + * + * @param activeSupplier supplier for active + * @return current instance of builder + */ + public UnionRecordBuilder active(Supplier activeSupplier) { + this.active = changedValue(activeSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public UnionRecordBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public UnionRecordBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for industry. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industry("example value");
    +   * }
    + * + * @param industry industry + * @return current instance of builder + */ + public UnionRecordBuilder industry(String industry) { + this.industry = changedValue(industry); + return this; + } + + /** + * Sets the value for industry by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industry(sb -> sb.append("text"));
    +   * }
    + * + * @param industryStringBuilderConsumer consumer providing an instance of industry + * @return current instance of builder + */ + public UnionRecordBuilder industry(Consumer industryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + industryStringBuilderConsumer.accept(builder); + this.industry = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for industry by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industry(() -> "example value");
    +   * }
    + * + * @param industrySupplier supplier for industry + * @return current instance of builder + */ + public UnionRecordBuilder industry(Supplier industrySupplier) { + this.industry = changedValue(industrySupplier.get()); + return this; + } + + /** + * Sets the String value for industry by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.industry("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UnionRecordBuilder industry(String format, Object... args) { + this.industry = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for memberCount. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(42);
    +   * }
    + * + * @param memberCount memberCount + * @return current instance of builder + */ + public UnionRecordBuilder memberCount(int memberCount) { + this.memberCount = changedValue(memberCount); + return this; + } + + /** + * Sets the value for memberCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.memberCount(() -> 42);
    +   * }
    + * + * @param memberCountSupplier supplier for memberCount + * @return current instance of builder + */ + public UnionRecordBuilder memberCount(Supplier memberCountSupplier) { + this.memberCount = changedValue(memberCountSupplier.get()); + return this; + } + + /** + * Sets the value for unionName. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unionName("example value");
    +   * }
    + * + * @param unionName unionName + * @return current instance of builder + */ + public UnionRecordBuilder unionName(String unionName) { + this.unionName = changedValue(unionName); + return this; + } + + /** + * Sets the value for unionName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unionName(sb -> sb.append("text"));
    +   * }
    + * + * @param unionNameStringBuilderConsumer consumer providing an instance of unionName + * @return current instance of builder + */ + public UnionRecordBuilder unionName(Consumer unionNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + unionNameStringBuilderConsumer.accept(builder); + this.unionName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for unionName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unionName(() -> "example value");
    +   * }
    + * + * @param unionNameSupplier supplier for unionName + * @return current instance of builder + */ + public UnionRecordBuilder unionName(Supplier unionNameSupplier) { + this.unionName = changedValue(unionNameSupplier.get()); + return this; + } + + /** + * Sets the String value for unionName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link UnionRecord#UnionRecord(String, int, String, int, boolean) + * UnionRecord(String unionName, int memberCount, String industry, int foundedYear, boolean active)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unionName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UnionRecordBuilder unionName(String format, Object... args) { + this.unionName = changedValue(String.format(format, args)); + 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 UnionRecordBuilder 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 UnionRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * UnionRecord result = builder.build();
    +   * }
    + */ + @Override + public UnionRecord build() { + if (!this.memberCount.isSet()) { + throw new IllegalStateException("Required field 'memberCount' must be set before calling build()"); + } + if (this.memberCount.value() == null) { + throw new IllegalStateException("Field 'memberCount' is marked as non-null but null value was provided"); + } + if (!this.foundedYear.isSet()) { + throw new IllegalStateException("Required field 'foundedYear' must be set before calling build()"); + } + if (this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + UnionRecord result = new UnionRecord(this.unionName + .value(), this.memberCount.value(), this.industry.value(), this.foundedYear.value(), this.active.valueOr(true)); + 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("unionName", this.unionName) + .append("memberCount", this.memberCount) + .append("industry", this.industry) + .append("foundedYear", this.foundedYear) + .append("active", this.active) + .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 UnionRecord with(Consumer b) { + UnionRecordBuilder builder; + try { + builder = new UnionRecordBuilder(UnionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'UnionRecordBuilder.With' should only be implemented by classes, which could be casted to 'UnionRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default UnionRecordBuilder with() { + try { + return new UnionRecordBuilder(UnionRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'UnionRecordBuilder.With' should only be implemented by classes, which could be casted to 'UnionRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnitRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnitRecordBuilder.java new file mode 100644 index 00000000..c5307367 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UnitRecordBuilder.java @@ -0,0 +1,550 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +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.performance_test.library.organizations.UnitRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.UnitRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * UnitRecord result = UnitRecordBuilder.create()
    + *     .unitName("example value")
    + *     .unitName("Hello %s", "World")
    + *     .unitName(() -> "example value")
    + *     .unitName(sb -> sb.append("text"))
    + *     .parentOrganization("example value")
    + *     .parentOrganization("Hello %s", "World")
    + *     .parentOrganization(() -> "example value")
    + *     .parentOrganization(sb -> sb.append("text"))
    + *     .function("example value")
    + *     .function("Hello %s", "World")
    + *     .function(() -> "example value")
    + *     .function(sb -> sb.append("text"))
    + *     .staffCount(42)
    + *     .staffCount(() -> 42)
    + *     .establishedDate(LocalDate.now())
    + *     .establishedDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = UnitRecord.class) +public class UnitRecordBuilder implements IBuilderBase { + + /** + * Tracked value for unitName: unitName. + */ + private TrackedValue unitName = unsetValue(); + /** + * Tracked value for parentOrganization: parentOrganization. + */ + private TrackedValue parentOrganization = unsetValue(); + /** + * Tracked value for function: function. + */ + private TrackedValue function = unsetValue(); + /** + * Tracked value for staffCount: staffCount. + */ + private TrackedValue staffCount = unsetValue(); + /** + * Tracked value for establishedDate: establishedDate. + */ + private TrackedValue establishedDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnitRecord}. + */ + public UnitRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnitRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public UnitRecordBuilder(UnitRecord instance) { + this.unitName = initialValue(instance.unitName()); + this.parentOrganization = initialValue(instance.parentOrganization()); + this.function = initialValue(instance.function()); + this.staffCount = initialValue(instance.staffCount()); + this.establishedDate = initialValue(instance.establishedDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnitRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * UnitRecordBuilder builder = UnitRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.UnitRecord} + */ + public static UnitRecordBuilder create() { + return new UnitRecordBuilder(); + } + + /** + * Sets the value for establishedDate. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.establishedDate(LocalDate.now());
    +   * }
    + * + * @param establishedDate establishedDate + * @return current instance of builder + */ + public UnitRecordBuilder establishedDate(LocalDate establishedDate) { + this.establishedDate = changedValue(establishedDate); + return this; + } + + /** + * Sets the value for establishedDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.establishedDate(() -> LocalDate.now());
    +   * }
    + * + * @param establishedDateSupplier supplier for establishedDate + * @return current instance of builder + */ + public UnitRecordBuilder establishedDate(Supplier establishedDateSupplier) { + this.establishedDate = changedValue(establishedDateSupplier.get()); + return this; + } + + /** + * Sets the value for function. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.function("example value");
    +   * }
    + * + * @param function function + * @return current instance of builder + */ + public UnitRecordBuilder function(String function) { + this.function = changedValue(function); + return this; + } + + /** + * Sets the value for function by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.function(sb -> sb.append("text"));
    +   * }
    + * + * @param functionStringBuilderConsumer consumer providing an instance of function + * @return current instance of builder + */ + public UnitRecordBuilder function(Consumer functionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + functionStringBuilderConsumer.accept(builder); + this.function = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for function by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.function(() -> "example value");
    +   * }
    + * + * @param functionSupplier supplier for function + * @return current instance of builder + */ + public UnitRecordBuilder function(Supplier functionSupplier) { + this.function = changedValue(functionSupplier.get()); + return this; + } + + /** + * Sets the String value for function by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.function("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UnitRecordBuilder function(String format, Object... args) { + this.function = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for parentOrganization. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization("example value");
    +   * }
    + * + * @param parentOrganization parentOrganization + * @return current instance of builder + */ + public UnitRecordBuilder parentOrganization(String parentOrganization) { + this.parentOrganization = changedValue(parentOrganization); + return this; + } + + /** + * Sets the value for parentOrganization by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization(sb -> sb.append("text"));
    +   * }
    + * + * @param parentOrganizationStringBuilderConsumer consumer providing an instance of parentOrganization + * @return current instance of builder + */ + public UnitRecordBuilder parentOrganization(Consumer parentOrganizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + parentOrganizationStringBuilderConsumer.accept(builder); + this.parentOrganization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for parentOrganization by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization(() -> "example value");
    +   * }
    + * + * @param parentOrganizationSupplier supplier for parentOrganization + * @return current instance of builder + */ + public UnitRecordBuilder parentOrganization(Supplier parentOrganizationSupplier) { + this.parentOrganization = changedValue(parentOrganizationSupplier.get()); + return this; + } + + /** + * Sets the String value for parentOrganization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.parentOrganization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UnitRecordBuilder parentOrganization(String format, Object... args) { + this.parentOrganization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for staffCount. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(42);
    +   * }
    + * + * @param staffCount staffCount + * @return current instance of builder + */ + public UnitRecordBuilder staffCount(int staffCount) { + this.staffCount = changedValue(staffCount); + return this; + } + + /** + * Sets the value for staffCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.staffCount(() -> 42);
    +   * }
    + * + * @param staffCountSupplier supplier for staffCount + * @return current instance of builder + */ + public UnitRecordBuilder staffCount(Supplier staffCountSupplier) { + this.staffCount = changedValue(staffCountSupplier.get()); + return this; + } + + /** + * Sets the value for unitName. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unitName("example value");
    +   * }
    + * + * @param unitName unitName + * @return current instance of builder + */ + public UnitRecordBuilder unitName(String unitName) { + this.unitName = changedValue(unitName); + return this; + } + + /** + * Sets the value for unitName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unitName(sb -> sb.append("text"));
    +   * }
    + * + * @param unitNameStringBuilderConsumer consumer providing an instance of unitName + * @return current instance of builder + */ + public UnitRecordBuilder unitName(Consumer unitNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + unitNameStringBuilderConsumer.accept(builder); + this.unitName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for unitName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unitName(() -> "example value");
    +   * }
    + * + * @param unitNameSupplier supplier for unitName + * @return current instance of builder + */ + public UnitRecordBuilder unitName(Supplier unitNameSupplier) { + this.unitName = changedValue(unitNameSupplier.get()); + return this; + } + + /** + * Sets the String value for unitName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link UnitRecord#UnitRecord(String, String, String, int, LocalDate) + * UnitRecord(String unitName, String parentOrganization, String function, int staffCount, LocalDate establishedDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.unitName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UnitRecordBuilder unitName(String format, Object... args) { + this.unitName = changedValue(String.format(format, args)); + 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 UnitRecordBuilder 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 UnitRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * UnitRecord result = builder.build();
    +   * }
    + */ + @Override + public UnitRecord build() { + if (!this.staffCount.isSet()) { + throw new IllegalStateException("Required field 'staffCount' must be set before calling build()"); + } + if (this.staffCount.value() == null) { + throw new IllegalStateException("Field 'staffCount' is marked as non-null but null value was provided"); + } + UnitRecord result = new UnitRecord(this.unitName.value(), + this.parentOrganization.value(), + this.function.value(), + this.staffCount.value(), + this.establishedDate.value()); + 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("unitName", this.unitName) + .append("parentOrganization", this.parentOrganization) + .append("function", this.function) + .append("staffCount", this.staffCount) + .append("establishedDate", this.establishedDate) + .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 UnitRecord with(Consumer b) { + UnitRecordBuilder builder; + try { + builder = new UnitRecordBuilder(UnitRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'UnitRecordBuilder.With' should only be implemented by classes, which could be casted to 'UnitRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default UnitRecordBuilder with() { + try { + return new UnitRecordBuilder(UnitRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'UnitRecordBuilder.With' should only be implemented by classes, which could be casted to 'UnitRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UsedBookstoreBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UsedBookstoreBuilder.java new file mode 100644 index 00000000..14c9a295 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/UsedBookstoreBuilder.java @@ -0,0 +1,725 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.UsedBookstore}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.UsedBookstore 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. + * + *

    Example:

    + * + *
    {@code
    + * UsedBookstore result = UsedBookstoreBuilder.create()
    + *     .acquisitionPolicy("example value")
    + *     .acquisitionPolicy("Hello %s", "World")
    + *     .acquisitionPolicy(() -> "example value")
    + *     .acquisitionPolicy(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .inventorySize(42)
    + *     .inventorySize(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .storeName("example value")
    + *     .storeName("Hello %s", "World")
    + *     .storeName(() -> "example value")
    + *     .storeName(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = UsedBookstore.class) +public class UsedBookstoreBuilder implements IBuilderBase { + + /** + * Tracked value for acquisitionPolicy: acquisitionPolicy. + */ + private TrackedValue acquisitionPolicy = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for inventorySize: inventorySize. + */ + private TrackedValue inventorySize = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for storeName: storeName. + */ + private TrackedValue storeName = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UsedBookstore}. + */ + public UsedBookstoreBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UsedBookstore} by a instance. + * + * @param instance object instance for initialisiation + */ + public UsedBookstoreBuilder(UsedBookstore instance) { + this.acquisitionPolicy = initialValue(instance.getAcquisitionPolicy()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.inventorySize = initialValue(instance.getInventorySize()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.storeName = initialValue(instance.getStoreName()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.UsedBookstore}. + * + *

    Example:

    + * + *
    {@code
    +   * UsedBookstoreBuilder builder = UsedBookstoreBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.UsedBookstore} + */ + public static UsedBookstoreBuilder create() { + return new UsedBookstoreBuilder(); + } + + /** + * Sets the value for acquisitionPolicy. + *

    + * Generated from setter {@link UsedBookstore#setAcquisitionPolicy(String) setAcquisitionPolicy(String + * acquisitionPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.acquisitionPolicy("example value");
    +   * }
    + * + * @param acquisitionPolicy acquisitionPolicy + * @return current instance of builder + */ + public UsedBookstoreBuilder acquisitionPolicy(String acquisitionPolicy) { + this.acquisitionPolicy = changedValue(acquisitionPolicy); + return this; + } + + /** + * Sets the value for acquisitionPolicy by executing the provided consumer. + *

    + * Generated from setter {@link UsedBookstore#setAcquisitionPolicy(String) setAcquisitionPolicy(String + * acquisitionPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.acquisitionPolicy(sb -> sb.append("text"));
    +   * }
    + * + * @param acquisitionPolicyStringBuilderConsumer consumer providing an instance of acquisitionPolicy + * @return current instance of builder + */ + public UsedBookstoreBuilder acquisitionPolicy(Consumer acquisitionPolicyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + acquisitionPolicyStringBuilderConsumer.accept(builder); + this.acquisitionPolicy = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for acquisitionPolicy by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setAcquisitionPolicy(String) setAcquisitionPolicy(String + * acquisitionPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.acquisitionPolicy(() -> "example value");
    +   * }
    + * + * @param acquisitionPolicySupplier supplier for acquisitionPolicy + * @return current instance of builder + */ + public UsedBookstoreBuilder acquisitionPolicy(Supplier acquisitionPolicySupplier) { + this.acquisitionPolicy = changedValue(acquisitionPolicySupplier.get()); + return this; + } + + /** + * Sets the String value for acquisitionPolicy by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link UsedBookstore#setAcquisitionPolicy(String) setAcquisitionPolicy(String + * acquisitionPolicy)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.acquisitionPolicy("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UsedBookstoreBuilder acquisitionPolicy(String format, Object... args) { + this.acquisitionPolicy = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link UsedBookstore#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public UsedBookstoreBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public UsedBookstoreBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link UsedBookstore#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public UsedBookstoreBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public UsedBookstoreBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link UsedBookstore#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public UsedBookstoreBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public UsedBookstoreBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for inventorySize. + *

    + * Generated from setter {@link UsedBookstore#setInventorySize(int) setInventorySize(int inventorySize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.inventorySize(42);
    +   * }
    + * + * @param inventorySize inventorySize + * @return current instance of builder + */ + public UsedBookstoreBuilder inventorySize(int inventorySize) { + this.inventorySize = changedValue(inventorySize); + return this; + } + + /** + * Sets the value for inventorySize by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setInventorySize(int) setInventorySize(int inventorySize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.inventorySize(() -> 42);
    +   * }
    + * + * @param inventorySizeSupplier supplier for inventorySize + * @return current instance of builder + */ + public UsedBookstoreBuilder inventorySize(Supplier inventorySizeSupplier) { + this.inventorySize = changedValue(inventorySizeSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link UsedBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public UsedBookstoreBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link UsedBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public UsedBookstoreBuilder 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. + *

    + * Generated from setter {@link UsedBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public UsedBookstoreBuilder 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. + *

    + * Generated from setter {@link UsedBookstore#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UsedBookstoreBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link UsedBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public UsedBookstoreBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link UsedBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public UsedBookstoreBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public UsedBookstoreBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link UsedBookstore#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UsedBookstoreBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for storeName. + *

    + * Generated from setter {@link UsedBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName("example value");
    +   * }
    + * + * @param storeName storeName + * @return current instance of builder + */ + public UsedBookstoreBuilder storeName(String storeName) { + this.storeName = changedValue(storeName); + return this; + } + + /** + * Sets the value for storeName by executing the provided consumer. + *

    + * Generated from setter {@link UsedBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName(sb -> sb.append("text"));
    +   * }
    + * + * @param storeNameStringBuilderConsumer consumer providing an instance of storeName + * @return current instance of builder + */ + public UsedBookstoreBuilder storeName(Consumer storeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + storeNameStringBuilderConsumer.accept(builder); + this.storeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for storeName by invoking the provided supplier. + *

    + * Generated from setter {@link UsedBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName(() -> "example value");
    +   * }
    + * + * @param storeNameSupplier supplier for storeName + * @return current instance of builder + */ + public UsedBookstoreBuilder storeName(Supplier storeNameSupplier) { + this.storeName = changedValue(storeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for storeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link UsedBookstore#setStoreName(String) setStoreName(String storeName)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.storeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public UsedBookstoreBuilder storeName(String format, Object... args) { + this.storeName = changedValue(String.format(format, args)); + 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 UsedBookstoreBuilder 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 UsedBookstoreBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * UsedBookstore result = builder.build();
    +   * }
    + */ + @Override + public UsedBookstore build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.inventorySize.isSet() && this.inventorySize.value() == null) { + throw new IllegalStateException("Field 'inventorySize' is marked as non-null but null value was provided"); + } + UsedBookstore result = new UsedBookstore(); + this.acquisitionPolicy.ifSet(result::setAcquisitionPolicy); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.inventorySize.ifSet(result::setInventorySize); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.storeName.ifSet(result::setStoreName); + 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("acquisitionPolicy", this.acquisitionPolicy) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("inventorySize", this.inventorySize) + .append("name", this.name) + .append("status", this.status) + .append("storeName", this.storeName) + .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 UsedBookstore with(Consumer b) { + UsedBookstoreBuilder builder; + try { + builder = new UsedBookstoreBuilder(UsedBookstore.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'UsedBookstoreBuilder.With' should only be implemented by classes, which could be casted to 'UsedBookstore'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default UsedBookstoreBuilder with() { + try { + return new UsedBookstoreBuilder(UsedBookstore.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'UsedBookstoreBuilder.With' should only be implemented by classes, which could be casted to 'UsedBookstore'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VirtualLibraryBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VirtualLibraryBuilder.java new file mode 100644 index 00000000..07d5fd28 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VirtualLibraryBuilder.java @@ -0,0 +1,680 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.VirtualLibrary}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.VirtualLibrary 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. + * + *

    Example:

    + * + *
    {@code
    + * VirtualLibrary result = VirtualLibraryBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .onlineResources(42L)
    + *     .onlineResources(() -> 42L)
    + *     .platform("example value")
    + *     .platform("Hello %s", "World")
    + *     .platform(() -> "example value")
    + *     .platform(sb -> sb.append("text"))
    + *     .registeredUsers(42)
    + *     .registeredUsers(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = VirtualLibrary.class) +public class VirtualLibraryBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for onlineResources: onlineResources. + */ + private TrackedValue onlineResources = unsetValue(); + /** + * Tracked value for platform: platform. + */ + private TrackedValue platform = unsetValue(); + /** + * Tracked value for registeredUsers: registeredUsers. + */ + private TrackedValue registeredUsers = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.VirtualLibrary}. + */ + public VirtualLibraryBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.VirtualLibrary} by a instance. + * + * @param instance object instance for initialisiation + */ + public VirtualLibraryBuilder(VirtualLibrary instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.onlineResources = initialValue(instance.getOnlineResources()); + this.platform = initialValue(instance.getPlatform()); + this.registeredUsers = initialValue(instance.getRegisteredUsers()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.VirtualLibrary}. + * + *

    Example:

    + * + *
    {@code
    +   * VirtualLibraryBuilder builder = VirtualLibraryBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.VirtualLibrary} + */ + public static VirtualLibraryBuilder create() { + return new VirtualLibraryBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link VirtualLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public VirtualLibraryBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public VirtualLibraryBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link VirtualLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public VirtualLibraryBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public VirtualLibraryBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link VirtualLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public VirtualLibraryBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public VirtualLibraryBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link VirtualLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public VirtualLibraryBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link VirtualLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public VirtualLibraryBuilder 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. + *

    + * Generated from setter {@link VirtualLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public VirtualLibraryBuilder 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. + *

    + * Generated from setter {@link VirtualLibrary#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VirtualLibraryBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for onlineResources. + *

    + * Generated from setter {@link VirtualLibrary#setOnlineResources(long) setOnlineResources(long onlineResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.onlineResources(42L);
    +   * }
    + * + * @param onlineResources onlineResources + * @return current instance of builder + */ + public VirtualLibraryBuilder onlineResources(long onlineResources) { + this.onlineResources = changedValue(onlineResources); + return this; + } + + /** + * Sets the value for onlineResources by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setOnlineResources(long) setOnlineResources(long onlineResources)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.onlineResources(() -> 42L);
    +   * }
    + * + * @param onlineResourcesSupplier supplier for onlineResources + * @return current instance of builder + */ + public VirtualLibraryBuilder onlineResources(Supplier onlineResourcesSupplier) { + this.onlineResources = changedValue(onlineResourcesSupplier.get()); + return this; + } + + /** + * Sets the value for platform. + *

    + * Generated from setter {@link VirtualLibrary#setPlatform(String) setPlatform(String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform("example value");
    +   * }
    + * + * @param platform platform + * @return current instance of builder + */ + public VirtualLibraryBuilder platform(String platform) { + this.platform = changedValue(platform); + return this; + } + + /** + * Sets the value for platform by executing the provided consumer. + *

    + * Generated from setter {@link VirtualLibrary#setPlatform(String) setPlatform(String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform(sb -> sb.append("text"));
    +   * }
    + * + * @param platformStringBuilderConsumer consumer providing an instance of platform + * @return current instance of builder + */ + public VirtualLibraryBuilder platform(Consumer platformStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + platformStringBuilderConsumer.accept(builder); + this.platform = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for platform by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setPlatform(String) setPlatform(String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform(() -> "example value");
    +   * }
    + * + * @param platformSupplier supplier for platform + * @return current instance of builder + */ + public VirtualLibraryBuilder platform(Supplier platformSupplier) { + this.platform = changedValue(platformSupplier.get()); + return this; + } + + /** + * Sets the String value for platform by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link VirtualLibrary#setPlatform(String) setPlatform(String platform)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.platform("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VirtualLibraryBuilder platform(String format, Object... args) { + this.platform = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for registeredUsers. + *

    + * Generated from setter {@link VirtualLibrary#setRegisteredUsers(int) setRegisteredUsers(int registeredUsers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registeredUsers(42);
    +   * }
    + * + * @param registeredUsers registeredUsers + * @return current instance of builder + */ + public VirtualLibraryBuilder registeredUsers(int registeredUsers) { + this.registeredUsers = changedValue(registeredUsers); + return this; + } + + /** + * Sets the value for registeredUsers by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setRegisteredUsers(int) setRegisteredUsers(int registeredUsers)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.registeredUsers(() -> 42);
    +   * }
    + * + * @param registeredUsersSupplier supplier for registeredUsers + * @return current instance of builder + */ + public VirtualLibraryBuilder registeredUsers(Supplier registeredUsersSupplier) { + this.registeredUsers = changedValue(registeredUsersSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link VirtualLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public VirtualLibraryBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link VirtualLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public VirtualLibraryBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link VirtualLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public VirtualLibraryBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link VirtualLibrary#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VirtualLibraryBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 VirtualLibraryBuilder 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 VirtualLibraryBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * VirtualLibrary result = builder.build();
    +   * }
    + */ + @Override + public VirtualLibrary build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.onlineResources.isSet() && this.onlineResources.value() == null) { + throw new IllegalStateException("Field 'onlineResources' is marked as non-null but null value was provided"); + } + if (this.registeredUsers.isSet() && this.registeredUsers.value() == null) { + throw new IllegalStateException("Field 'registeredUsers' is marked as non-null but null value was provided"); + } + VirtualLibrary result = new VirtualLibrary(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.onlineResources.ifSet(result::setOnlineResources); + this.platform.ifSet(result::setPlatform); + this.registeredUsers.ifSet(result::setRegisteredUsers); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("onlineResources", this.onlineResources) + .append("platform", this.platform) + .append("registeredUsers", this.registeredUsers) + .append("status", this.status) + .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 VirtualLibrary with(Consumer b) { + VirtualLibraryBuilder builder; + try { + builder = new VirtualLibraryBuilder(VirtualLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VirtualLibraryBuilder.With' should only be implemented by classes, which could be casted to 'VirtualLibrary'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VirtualLibraryBuilder with() { + try { + return new VirtualLibraryBuilder(VirtualLibrary.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VirtualLibraryBuilder.With' should only be implemented by classes, which could be casted to 'VirtualLibrary'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VocationalSchoolBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VocationalSchoolBuilder.java new file mode 100644 index 00000000..6870b50b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/VocationalSchoolBuilder.java @@ -0,0 +1,715 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.organizations.VocationalSchool}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.VocationalSchool 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. + * + *

    Example:

    + * + *
    {@code
    + * VocationalSchool result = VocationalSchoolBuilder.create()
    + *     .certificationPrograms(42)
    + *     .certificationPrograms(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .studentCount(42)
    + *     .studentCount(() -> 42)
    + *     .trades(List.of("example value"))
    + *     .trades(() -> List.of("example value"))
    + *     .trades(t -> t.add("example value"))
    + *     .trades("example value", "example value")
    + *     .add2Trades("example value")
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = VocationalSchool.class) +public class VocationalSchoolBuilder implements IBuilderBase { + + /** + * Tracked value for certificationPrograms: certificationPrograms. + */ + private TrackedValue certificationPrograms = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for studentCount: studentCount. + */ + private TrackedValue studentCount = unsetValue(); + /** + * Tracked value for trades: trades. + */ + private TrackedValue> trades = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.VocationalSchool}. + */ + public VocationalSchoolBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.VocationalSchool} by a instance. + * + * @param instance object instance for initialisiation + */ + public VocationalSchoolBuilder(VocationalSchool instance) { + this.certificationPrograms = initialValue(instance.getCertificationPrograms()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.studentCount = initialValue(instance.getStudentCount()); + this.trades = initialValue(instance.getTrades()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.VocationalSchool}. + * + *

    Example:

    + * + *
    {@code
    +   * VocationalSchoolBuilder builder = VocationalSchoolBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.VocationalSchool} + */ + public static VocationalSchoolBuilder create() { + return new VocationalSchoolBuilder(); + } + + /** + * Adds a single element to trades. + *

    + * Generated from setter {@link VocationalSchool#setTrades(List) setTrades(List trades)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Trades("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public VocationalSchoolBuilder add2Trades(String element) { + List newCollection; + if (this.trades.isSet()) { + newCollection = new ArrayList<>(this.trades.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.trades = changedValue(newCollection); + return this; + } + + /** + * Sets the value for certificationPrograms. + *

    + * Generated from setter {@link VocationalSchool#setCertificationPrograms(int) setCertificationPrograms(int + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(42);
    +   * }
    + * + * @param certificationPrograms certificationPrograms + * @return current instance of builder + */ + public VocationalSchoolBuilder certificationPrograms(int certificationPrograms) { + this.certificationPrograms = changedValue(certificationPrograms); + return this; + } + + /** + * Sets the value for certificationPrograms by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setCertificationPrograms(int) setCertificationPrograms(int + * certificationPrograms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certificationPrograms(() -> 42);
    +   * }
    + * + * @param certificationProgramsSupplier supplier for certificationPrograms + * @return current instance of builder + */ + public VocationalSchoolBuilder certificationPrograms(Supplier certificationProgramsSupplier) { + this.certificationPrograms = changedValue(certificationProgramsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link VocationalSchool#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public VocationalSchoolBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public VocationalSchoolBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link VocationalSchool#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public VocationalSchoolBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public VocationalSchoolBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link VocationalSchool#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public VocationalSchoolBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public VocationalSchoolBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link VocationalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public VocationalSchoolBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link VocationalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public VocationalSchoolBuilder 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. + *

    + * Generated from setter {@link VocationalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public VocationalSchoolBuilder 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. + *

    + * Generated from setter {@link VocationalSchool#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VocationalSchoolBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link VocationalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public VocationalSchoolBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link VocationalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public VocationalSchoolBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public VocationalSchoolBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link VocationalSchool#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VocationalSchoolBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for studentCount. + *

    + * Generated from setter {@link VocationalSchool#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(42);
    +   * }
    + * + * @param studentCount studentCount + * @return current instance of builder + */ + public VocationalSchoolBuilder studentCount(int studentCount) { + this.studentCount = changedValue(studentCount); + return this; + } + + /** + * Sets the value for studentCount by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setStudentCount(int) setStudentCount(int studentCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.studentCount(() -> 42);
    +   * }
    + * + * @param studentCountSupplier supplier for studentCount + * @return current instance of builder + */ + public VocationalSchoolBuilder studentCount(Supplier studentCountSupplier) { + this.studentCount = changedValue(studentCountSupplier.get()); + return this; + } + + /** + * Sets the value for trades. + *

    + * Generated from setter {@link VocationalSchool#setTrades(List) setTrades(List trades)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trades("example value", "example value");
    +   * }
    + * + * @param trades trades + * @return current instance of builder + */ + public VocationalSchoolBuilder trades(String... trades) { + this.trades = changedValue(List.of(trades)); + return this; + } + + /** + * Sets the value for trades. + *

    + * Generated from setter {@link VocationalSchool#setTrades(List) setTrades(List trades)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trades(List.of("example value"));
    +   * }
    + * + * @param trades trades + * @return current instance of builder + */ + public VocationalSchoolBuilder trades(List trades) { + this.trades = changedValue(trades); + return this; + } + + /** + * Sets the value for trades using a builder consumer that produces the value. + *

    + * Generated from setter {@link VocationalSchool#setTrades(List) setTrades(List trades)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trades(t -> t.add("example value"));
    +   * }
    + * + * @param tradesBuilderConsumer consumer providing an instance of a builder for trades + * @return current instance of builder + */ + public VocationalSchoolBuilder trades(Consumer> tradesBuilderConsumer) { + ArrayListBuilder builder = this.trades.isSet() + ? new ArrayListBuilder(this.trades.value()) + : new ArrayListBuilder(); + tradesBuilderConsumer.accept(builder); + this.trades = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for trades by invoking the provided supplier. + *

    + * Generated from setter {@link VocationalSchool#setTrades(List) setTrades(List trades)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trades(() -> List.of("example value"));
    +   * }
    + * + * @param tradesSupplier supplier for trades + * @return current instance of builder + */ + public VocationalSchoolBuilder trades(Supplier> tradesSupplier) { + this.trades = changedValue(tradesSupplier.get()); + 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 VocationalSchoolBuilder 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 VocationalSchoolBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * VocationalSchool result = builder.build();
    +   * }
    + */ + @Override + public VocationalSchool build() { + if (this.certificationPrograms.isSet() && this.certificationPrograms.value() == null) { + throw new IllegalStateException( + "Field 'certificationPrograms' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.studentCount.isSet() && this.studentCount.value() == null) { + throw new IllegalStateException("Field 'studentCount' is marked as non-null but null value was provided"); + } + VocationalSchool result = new VocationalSchool(); + this.certificationPrograms.ifSet(result::setCertificationPrograms); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.studentCount.ifSet(result::setStudentCount); + this.trades.ifSet(result::setTrades); + 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("certificationPrograms", this.certificationPrograms) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .append("studentCount", this.studentCount) + .append("trades", this.trades) + .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 VocationalSchool with(Consumer b) { + VocationalSchoolBuilder builder; + try { + builder = new VocationalSchoolBuilder(VocationalSchool.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VocationalSchoolBuilder.With' should only be implemented by classes, which could be casted to 'VocationalSchool'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VocationalSchoolBuilder with() { + try { + return new VocationalSchoolBuilder(VocationalSchool.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VocationalSchoolBuilder.With' should only be implemented by classes, which could be casted to 'VocationalSchool'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/WholesalerBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/WholesalerBuilder.java new file mode 100644 index 00000000..8d366aa8 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/WholesalerBuilder.java @@ -0,0 +1,639 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.Wholesaler}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.Wholesaler 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. + * + *

    Example:

    + * + *
    {@code
    + * Wholesaler result = WholesalerBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .inventorySize(42L)
    + *     .inventorySize(() -> 42L)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .retailerClients(42)
    + *     .retailerClients(() -> 42)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .supplierCount(42)
    + *     .supplierCount(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Wholesaler.class) +public class WholesalerBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for inventorySize: inventorySize. + */ + private TrackedValue inventorySize = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for retailerClients: retailerClients. + */ + private TrackedValue retailerClients = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for supplierCount: supplierCount. + */ + private TrackedValue supplierCount = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Wholesaler}. + */ + public WholesalerBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Wholesaler} by a instance. + * + * @param instance object instance for initialisiation + */ + public WholesalerBuilder(Wholesaler instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.inventorySize = initialValue(instance.getInventorySize()); + this.name = initialValue(instance.getName()); + this.retailerClients = initialValue(instance.getRetailerClients()); + this.status = initialValue(instance.getStatus()); + this.supplierCount = initialValue(instance.getSupplierCount()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Wholesaler}. + * + *

    Example:

    + * + *
    {@code
    +   * WholesalerBuilder builder = WholesalerBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.Wholesaler} + */ + public static WholesalerBuilder create() { + return new WholesalerBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Wholesaler#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public WholesalerBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public WholesalerBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link Wholesaler#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public WholesalerBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public WholesalerBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Wholesaler#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public WholesalerBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public WholesalerBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for inventorySize. + *

    + * Generated from setter {@link Wholesaler#setInventorySize(long) setInventorySize(long inventorySize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.inventorySize(42L);
    +   * }
    + * + * @param inventorySize inventorySize + * @return current instance of builder + */ + public WholesalerBuilder inventorySize(long inventorySize) { + this.inventorySize = changedValue(inventorySize); + return this; + } + + /** + * Sets the value for inventorySize by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setInventorySize(long) setInventorySize(long inventorySize)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.inventorySize(() -> 42L);
    +   * }
    + * + * @param inventorySizeSupplier supplier for inventorySize + * @return current instance of builder + */ + public WholesalerBuilder inventorySize(Supplier inventorySizeSupplier) { + this.inventorySize = changedValue(inventorySizeSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Wholesaler#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public WholesalerBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Wholesaler#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public WholesalerBuilder 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. + *

    + * Generated from setter {@link Wholesaler#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public WholesalerBuilder 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. + *

    + * Generated from setter {@link Wholesaler#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WholesalerBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for retailerClients. + *

    + * Generated from setter {@link Wholesaler#setRetailerClients(int) setRetailerClients(int retailerClients)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.retailerClients(42);
    +   * }
    + * + * @param retailerClients retailerClients + * @return current instance of builder + */ + public WholesalerBuilder retailerClients(int retailerClients) { + this.retailerClients = changedValue(retailerClients); + return this; + } + + /** + * Sets the value for retailerClients by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setRetailerClients(int) setRetailerClients(int retailerClients)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.retailerClients(() -> 42);
    +   * }
    + * + * @param retailerClientsSupplier supplier for retailerClients + * @return current instance of builder + */ + public WholesalerBuilder retailerClients(Supplier retailerClientsSupplier) { + this.retailerClients = changedValue(retailerClientsSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Wholesaler#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public WholesalerBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Wholesaler#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public WholesalerBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public WholesalerBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Wholesaler#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WholesalerBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for supplierCount. + *

    + * Generated from setter {@link Wholesaler#setSupplierCount(int) setSupplierCount(int supplierCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierCount(42);
    +   * }
    + * + * @param supplierCount supplierCount + * @return current instance of builder + */ + public WholesalerBuilder supplierCount(int supplierCount) { + this.supplierCount = changedValue(supplierCount); + return this; + } + + /** + * Sets the value for supplierCount by invoking the provided supplier. + *

    + * Generated from setter {@link Wholesaler#setSupplierCount(int) setSupplierCount(int supplierCount)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierCount(() -> 42);
    +   * }
    + * + * @param supplierCountSupplier supplier for supplierCount + * @return current instance of builder + */ + public WholesalerBuilder supplierCount(Supplier supplierCountSupplier) { + this.supplierCount = changedValue(supplierCountSupplier.get()); + 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 WholesalerBuilder 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 WholesalerBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Wholesaler result = builder.build();
    +   * }
    + */ + @Override + public Wholesaler build() { + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.inventorySize.isSet() && this.inventorySize.value() == null) { + throw new IllegalStateException("Field 'inventorySize' is marked as non-null but null value was provided"); + } + if (this.retailerClients.isSet() && this.retailerClients.value() == null) { + throw new IllegalStateException("Field 'retailerClients' is marked as non-null but null value was provided"); + } + if (this.supplierCount.isSet() && this.supplierCount.value() == null) { + throw new IllegalStateException("Field 'supplierCount' is marked as non-null but null value was provided"); + } + Wholesaler result = new Wholesaler(); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.inventorySize.ifSet(result::setInventorySize); + this.name.ifSet(result::setName); + this.retailerClients.ifSet(result::setRetailerClients); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.supplierCount.ifSet(result::setSupplierCount); + 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("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("inventorySize", this.inventorySize) + .append("name", this.name) + .append("retailerClients", this.retailerClients) + .append("status", this.status) + .append("supplierCount", this.supplierCount) + .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 Wholesaler with(Consumer b) { + WholesalerBuilder builder; + try { + builder = new WholesalerBuilder(Wholesaler.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WholesalerBuilder.With' should only be implemented by classes, which could be casted to 'Wholesaler'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WholesalerBuilder with() { + try { + return new WholesalerBuilder(Wholesaler.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WholesalerBuilder.With' should only be implemented by classes, which could be casted to 'Wholesaler'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ZooBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ZooBuilder.java new file mode 100644 index 00000000..02084182 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/organizations/ZooBuilder.java @@ -0,0 +1,638 @@ +package org.javahelpers.simple.builders.performance_test.library.organizations; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.organizations.Zoo}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.organizations.Zoo 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. + * + *

    Example:

    + * + *
    {@code
    + * Zoo result = ZooBuilder.create()
    + *     .animalSpecies(42)
    + *     .animalSpecies(() -> 42)
    + *     .annualVisitors(42L)
    + *     .annualVisitors(() -> 42L)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .foundedYear(42)
    + *     .foundedYear(() -> 42)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .totalAnimals(42)
    + *     .totalAnimals(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Zoo.class) +public class ZooBuilder implements IBuilderBase { + + /** + * Tracked value for animalSpecies: animalSpecies. + */ + private TrackedValue animalSpecies = unsetValue(); + /** + * Tracked value for annualVisitors: annualVisitors. + */ + private TrackedValue annualVisitors = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for foundedYear: foundedYear. + */ + private TrackedValue foundedYear = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for totalAnimals: totalAnimals. + */ + private TrackedValue totalAnimals = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.organizations.Zoo}. + */ + public ZooBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.Zoo} by + * a instance. + * + * @param instance object instance for initialisiation + */ + public ZooBuilder(Zoo instance) { + this.animalSpecies = initialValue(instance.getAnimalSpecies()); + this.annualVisitors = initialValue(instance.getAnnualVisitors()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.foundedYear = initialValue(instance.getFoundedYear()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.totalAnimals = initialValue(instance.getTotalAnimals()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.Zoo}. + * + *

    Example:

    + * + *
    {@code
    +   * ZooBuilder builder = ZooBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.organizations.Zoo} + */ + public static ZooBuilder create() { + return new ZooBuilder(); + } + + /** + * Sets the value for animalSpecies. + *

    + * Generated from setter {@link Zoo#setAnimalSpecies(int) setAnimalSpecies(int animalSpecies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.animalSpecies(42);
    +   * }
    + * + * @param animalSpecies animalSpecies + * @return current instance of builder + */ + public ZooBuilder animalSpecies(int animalSpecies) { + this.animalSpecies = changedValue(animalSpecies); + return this; + } + + /** + * Sets the value for animalSpecies by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setAnimalSpecies(int) setAnimalSpecies(int animalSpecies)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.animalSpecies(() -> 42);
    +   * }
    + * + * @param animalSpeciesSupplier supplier for animalSpecies + * @return current instance of builder + */ + public ZooBuilder animalSpecies(Supplier animalSpeciesSupplier) { + this.animalSpecies = changedValue(animalSpeciesSupplier.get()); + return this; + } + + /** + * Sets the value for annualVisitors. + *

    + * Generated from setter {@link Zoo#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(42L);
    +   * }
    + * + * @param annualVisitors annualVisitors + * @return current instance of builder + */ + public ZooBuilder annualVisitors(long annualVisitors) { + this.annualVisitors = changedValue(annualVisitors); + return this; + } + + /** + * Sets the value for annualVisitors by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setAnnualVisitors(long) setAnnualVisitors(long annualVisitors)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.annualVisitors(() -> 42L);
    +   * }
    + * + * @param annualVisitorsSupplier supplier for annualVisitors + * @return current instance of builder + */ + public ZooBuilder annualVisitors(Supplier annualVisitorsSupplier) { + this.annualVisitors = changedValue(annualVisitorsSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Zoo#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ZooBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ZooBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for foundedYear. + *

    + * Generated from setter {@link Zoo#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(42);
    +   * }
    + * + * @param foundedYear foundedYear + * @return current instance of builder + */ + public ZooBuilder foundedYear(int foundedYear) { + this.foundedYear = changedValue(foundedYear); + return this; + } + + /** + * Sets the value for foundedYear by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setFoundedYear(int) setFoundedYear(int foundedYear)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.foundedYear(() -> 42);
    +   * }
    + * + * @param foundedYearSupplier supplier for foundedYear + * @return current instance of builder + */ + public ZooBuilder foundedYear(Supplier foundedYearSupplier) { + this.foundedYear = changedValue(foundedYearSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Zoo#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ZooBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ZooBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Zoo#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ZooBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Zoo#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ZooBuilder 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. + *

    + * Generated from setter {@link Zoo#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ZooBuilder 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. + *

    + * Generated from setter {@link Zoo#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ZooBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Zoo#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ZooBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Zoo#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ZooBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ZooBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Zoo#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ZooBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for totalAnimals. + *

    + * Generated from setter {@link Zoo#setTotalAnimals(int) setTotalAnimals(int totalAnimals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalAnimals(42);
    +   * }
    + * + * @param totalAnimals totalAnimals + * @return current instance of builder + */ + public ZooBuilder totalAnimals(int totalAnimals) { + this.totalAnimals = changedValue(totalAnimals); + return this; + } + + /** + * Sets the value for totalAnimals by invoking the provided supplier. + *

    + * Generated from setter {@link Zoo#setTotalAnimals(int) setTotalAnimals(int totalAnimals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalAnimals(() -> 42);
    +   * }
    + * + * @param totalAnimalsSupplier supplier for totalAnimals + * @return current instance of builder + */ + public ZooBuilder totalAnimals(Supplier totalAnimalsSupplier) { + this.totalAnimals = changedValue(totalAnimalsSupplier.get()); + 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 ZooBuilder 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 ZooBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Zoo result = builder.build();
    +   * }
    + */ + @Override + public Zoo build() { + if (this.animalSpecies.isSet() && this.animalSpecies.value() == null) { + throw new IllegalStateException("Field 'animalSpecies' is marked as non-null but null value was provided"); + } + if (this.annualVisitors.isSet() && this.annualVisitors.value() == null) { + throw new IllegalStateException("Field 'annualVisitors' is marked as non-null but null value was provided"); + } + if (this.foundedYear.isSet() && this.foundedYear.value() == null) { + throw new IllegalStateException("Field 'foundedYear' is marked as non-null but null value was provided"); + } + if (this.totalAnimals.isSet() && this.totalAnimals.value() == null) { + throw new IllegalStateException("Field 'totalAnimals' is marked as non-null but null value was provided"); + } + Zoo result = new Zoo(); + this.animalSpecies.ifSet(result::setAnimalSpecies); + this.annualVisitors.ifSet(result::setAnnualVisitors); + this.createdAt.ifSet(result::setCreatedAt); + this.foundedYear.ifSet(result::setFoundedYear); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.totalAnimals.ifSet(result::setTotalAnimals); + 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("animalSpecies", this.animalSpecies) + .append("annualVisitors", this.annualVisitors) + .append("createdAt", this.createdAt) + .append("foundedYear", this.foundedYear) + .append("id", this.id) + .append("name", this.name) + .append("status", this.status) + .append("totalAnimals", this.totalAnimals) + .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 Zoo with(Consumer b) { + ZooBuilder builder; + try { + builder = new ZooBuilder(Zoo.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ZooBuilder.With' should only be implemented by classes, which could be casted to 'Zoo'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ZooBuilder with() { + try { + return new ZooBuilder(Zoo.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ZooBuilder.With' should only be implemented by classes, which could be casted to 'Zoo'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ManagingEditorBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ManagingEditorBuilder.java new file mode 100644 index 00000000..2a39835f --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ManagingEditorBuilder.java @@ -0,0 +1,843 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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; +import org.javahelpers.simple.builders.performance_test.library.organizations.CommercialPublisher; +import org.javahelpers.simple.builders.performance_test.library.organizations.CommercialPublisherBuilder; + +/** + * Builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ManagingEditor}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.ManagingEditor 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. + * + *

    Example:

    + * + *
    {@code
    + * ManagingEditor result = ManagingEditorBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .employeeId("example value")
    + *     .employeeId("Hello %s", "World")
    + *     .employeeId(() -> "example value")
    + *     .employeeId(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .manuscriptsInReview(42)
    + *     .manuscriptsInReview(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .productionSchedule("example value")
    + *     .productionSchedule("Hello %s", "World")
    + *     .productionSchedule(() -> "example value")
    + *     .productionSchedule(sb -> sb.append("text"))
    + *     .publication("example value")
    + *     .publication("Hello %s", "World")
    + *     .publication(() -> "example value")
    + *     .publication(sb -> sb.append("text"))
    + *     .publisher(new CommercialPublisher())
    + *     .publisher(CommercialPublisher::new)
    + *     .publisher(commercialPublisherBuilder -> commercialPublisherBuilder)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ManagingEditor.class) +public class ManagingEditorBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for employeeId: employeeId. + */ + private TrackedValue employeeId = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for manuscriptsInReview: manuscriptsInReview. + */ + private TrackedValue manuscriptsInReview = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for productionSchedule: productionSchedule. + */ + private TrackedValue productionSchedule = unsetValue(); + /** + * Tracked value for publication: publication. + */ + private TrackedValue publication = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ManagingEditor}. + */ + public ManagingEditorBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ManagingEditor} by a instance. + * + * @param instance object instance for initialisiation + */ + public ManagingEditorBuilder(ManagingEditor instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.employeeId = initialValue(instance.getEmployeeId()); + this.id = initialValue(instance.getId()); + this.manuscriptsInReview = initialValue(instance.getManuscriptsInReview()); + this.name = initialValue(instance.getName()); + this.productionSchedule = initialValue(instance.getProductionSchedule()); + this.publication = initialValue(instance.getPublication()); + this.publisher = initialValue(instance.getPublisher()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ManagingEditor}. + * + *

    Example:

    + * + *
    {@code
    +   * ManagingEditorBuilder builder = ManagingEditorBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ManagingEditor} + */ + public static ManagingEditorBuilder create() { + return new ManagingEditorBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link ManagingEditor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ManagingEditorBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ManagingEditorBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for employeeId. + *

    + * Generated from setter {@link ManagingEditor#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId("example value");
    +   * }
    + * + * @param employeeId employeeId + * @return current instance of builder + */ + public ManagingEditorBuilder employeeId(String employeeId) { + this.employeeId = changedValue(employeeId); + return this; + } + + /** + * Sets the value for employeeId by executing the provided consumer. + *

    + * Generated from setter {@link ManagingEditor#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId(sb -> sb.append("text"));
    +   * }
    + * + * @param employeeIdStringBuilderConsumer consumer providing an instance of employeeId + * @return current instance of builder + */ + public ManagingEditorBuilder employeeId(Consumer employeeIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + employeeIdStringBuilderConsumer.accept(builder); + this.employeeId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for employeeId by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId(() -> "example value");
    +   * }
    + * + * @param employeeIdSupplier supplier for employeeId + * @return current instance of builder + */ + public ManagingEditorBuilder employeeId(Supplier employeeIdSupplier) { + this.employeeId = changedValue(employeeIdSupplier.get()); + return this; + } + + /** + * Sets the String value for employeeId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ManagingEditor#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManagingEditorBuilder employeeId(String format, Object... args) { + this.employeeId = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link ManagingEditor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ManagingEditorBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ManagingEditorBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for manuscriptsInReview. + *

    + * Generated from setter {@link ManagingEditor#setManuscriptsInReview(int) setManuscriptsInReview(int + * manuscriptsInReview)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.manuscriptsInReview(42);
    +   * }
    + * + * @param manuscriptsInReview manuscriptsInReview + * @return current instance of builder + */ + public ManagingEditorBuilder manuscriptsInReview(int manuscriptsInReview) { + this.manuscriptsInReview = changedValue(manuscriptsInReview); + return this; + } + + /** + * Sets the value for manuscriptsInReview by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setManuscriptsInReview(int) setManuscriptsInReview(int + * manuscriptsInReview)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.manuscriptsInReview(() -> 42);
    +   * }
    + * + * @param manuscriptsInReviewSupplier supplier for manuscriptsInReview + * @return current instance of builder + */ + public ManagingEditorBuilder manuscriptsInReview(Supplier manuscriptsInReviewSupplier) { + this.manuscriptsInReview = changedValue(manuscriptsInReviewSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link ManagingEditor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ManagingEditorBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link ManagingEditor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ManagingEditorBuilder 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. + *

    + * Generated from setter {@link ManagingEditor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ManagingEditorBuilder 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. + *

    + * Generated from setter {@link ManagingEditor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManagingEditorBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for productionSchedule. + *

    + * Generated from setter {@link ManagingEditor#setProductionSchedule(String) setProductionSchedule(String + * productionSchedule)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionSchedule("example value");
    +   * }
    + * + * @param productionSchedule productionSchedule + * @return current instance of builder + */ + public ManagingEditorBuilder productionSchedule(String productionSchedule) { + this.productionSchedule = changedValue(productionSchedule); + return this; + } + + /** + * Sets the value for productionSchedule by executing the provided consumer. + *

    + * Generated from setter {@link ManagingEditor#setProductionSchedule(String) setProductionSchedule(String + * productionSchedule)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionSchedule(sb -> sb.append("text"));
    +   * }
    + * + * @param productionScheduleStringBuilderConsumer consumer providing an instance of productionSchedule + * @return current instance of builder + */ + public ManagingEditorBuilder productionSchedule(Consumer productionScheduleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + productionScheduleStringBuilderConsumer.accept(builder); + this.productionSchedule = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for productionSchedule by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setProductionSchedule(String) setProductionSchedule(String + * productionSchedule)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionSchedule(() -> "example value");
    +   * }
    + * + * @param productionScheduleSupplier supplier for productionSchedule + * @return current instance of builder + */ + public ManagingEditorBuilder productionSchedule(Supplier productionScheduleSupplier) { + this.productionSchedule = changedValue(productionScheduleSupplier.get()); + return this; + } + + /** + * Sets the String value for productionSchedule by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ManagingEditor#setProductionSchedule(String) setProductionSchedule(String + * productionSchedule)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productionSchedule("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManagingEditorBuilder productionSchedule(String format, Object... args) { + this.productionSchedule = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publication. + *

    + * Generated from setter {@link ManagingEditor#setPublication(String) setPublication(String publication)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publication("example value");
    +   * }
    + * + * @param publication publication + * @return current instance of builder + */ + public ManagingEditorBuilder publication(String publication) { + this.publication = changedValue(publication); + return this; + } + + /** + * Sets the value for publication by executing the provided consumer. + *

    + * Generated from setter {@link ManagingEditor#setPublication(String) setPublication(String publication)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publication(sb -> sb.append("text"));
    +   * }
    + * + * @param publicationStringBuilderConsumer consumer providing an instance of publication + * @return current instance of builder + */ + public ManagingEditorBuilder publication(Consumer publicationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + publicationStringBuilderConsumer.accept(builder); + this.publication = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for publication by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setPublication(String) setPublication(String publication)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publication(() -> "example value");
    +   * }
    + * + * @param publicationSupplier supplier for publication + * @return current instance of builder + */ + public ManagingEditorBuilder publication(Supplier publicationSupplier) { + this.publication = changedValue(publicationSupplier.get()); + return this; + } + + /** + * Sets the String value for publication by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ManagingEditor#setPublication(String) setPublication(String publication)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publication("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManagingEditorBuilder publication(String format, Object... args) { + this.publication = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from setter {@link ManagingEditor#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(new CommercialPublisher());
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public ManagingEditorBuilder publisher(CommercialPublisher publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher using a builder consumer that produces the value. + *

    + * Generated from setter {@link ManagingEditor#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(commercialPublisherBuilder -> commercialPublisherBuilder);
    +   * }
    + * + * @param publisherBuilderConsumer consumer providing an instance of a builder for publisher + * @return current instance of builder + */ + public ManagingEditorBuilder publisher(Consumer publisherBuilderConsumer) { + CommercialPublisherBuilder builder = this.publisher.isSet() + ? new CommercialPublisherBuilder(this.publisher.value()) + : new CommercialPublisherBuilder(); + publisherBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(CommercialPublisher::new);
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public ManagingEditorBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link ManagingEditor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ManagingEditorBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link ManagingEditor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ManagingEditorBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link ManagingEditor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ManagingEditorBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link ManagingEditor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ManagingEditorBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ManagingEditorBuilder 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 ManagingEditorBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ManagingEditor result = builder.build();
    +   * }
    + */ + @Override + public ManagingEditor build() { + if (this.manuscriptsInReview.isSet() && this.manuscriptsInReview.value() == null) { + throw new IllegalStateException("Field 'manuscriptsInReview' is marked as non-null but null value was provided"); + } + ManagingEditor result = new ManagingEditor(); + this.createdAt.ifSet(result::setCreatedAt); + this.employeeId.ifSet(result::setEmployeeId); + this.id.ifSet(result::setId); + this.manuscriptsInReview.ifSet(result::setManuscriptsInReview); + this.name.ifSet(result::setName); + this.productionSchedule.ifSet(result::setProductionSchedule); + this.publication.ifSet(result::setPublication); + this.publisher.ifSet(result::setPublisher); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("employeeId", this.employeeId) + .append("id", this.id) + .append("manuscriptsInReview", this.manuscriptsInReview) + .append("name", this.name) + .append("productionSchedule", this.productionSchedule) + .append("publication", this.publication) + .append("publisher", this.publisher) + .append("status", this.status) + .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 ManagingEditor with(Consumer b) { + ManagingEditorBuilder builder; + try { + builder = new ManagingEditorBuilder(ManagingEditor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ManagingEditorBuilder.With' should only be implemented by classes, which could be casted to 'ManagingEditor'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ManagingEditorBuilder with() { + try { + return new ManagingEditorBuilder(ManagingEditor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ManagingEditorBuilder.With' should only be implemented by classes, which could be casted to 'ManagingEditor'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/MentorRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/MentorRecordBuilder.java new file mode 100644 index 00000000..133a1b80 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/MentorRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.MentorRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.MentorRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * MentorRecord result = MentorRecordBuilder.create()
    + *     .mentorId(UUID.randomUUID())
    + *     .mentorId(() -> UUID.randomUUID())
    + *     .mentorName("example value")
    + *     .mentorName("Hello %s", "World")
    + *     .mentorName(() -> "example value")
    + *     .mentorName(sb -> sb.append("text"))
    + *     .expertiseArea("example value")
    + *     .expertiseArea("Hello %s", "World")
    + *     .expertiseArea(() -> "example value")
    + *     .expertiseArea(sb -> sb.append("text"))
    + *     .menteesCount(42)
    + *     .menteesCount(() -> 42)
    + *     .yearsExperience(42)
    + *     .yearsExperience(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = MentorRecord.class) +public class MentorRecordBuilder implements IBuilderBase { + + /** + * Tracked value for mentorId: mentorId. + */ + private TrackedValue mentorId = unsetValue(); + /** + * Tracked value for mentorName: mentorName. + */ + private TrackedValue mentorName = unsetValue(); + /** + * Tracked value for expertiseArea: expertiseArea. + */ + private TrackedValue expertiseArea = unsetValue(); + /** + * Tracked value for menteesCount: menteesCount. + */ + private TrackedValue menteesCount = unsetValue(); + /** + * Tracked value for yearsExperience: yearsExperience. + */ + private TrackedValue yearsExperience = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.MentorRecord}. + */ + public MentorRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.MentorRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public MentorRecordBuilder(MentorRecord instance) { + this.mentorId = initialValue(instance.mentorId()); + this.mentorName = initialValue(instance.mentorName()); + this.expertiseArea = initialValue(instance.expertiseArea()); + this.menteesCount = initialValue(instance.menteesCount()); + this.yearsExperience = initialValue(instance.yearsExperience()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.MentorRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * MentorRecordBuilder builder = MentorRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.MentorRecord} + */ + public static MentorRecordBuilder create() { + return new MentorRecordBuilder(); + } + + /** + * Sets the value for expertiseArea. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea("example value");
    +   * }
    + * + * @param expertiseArea expertiseArea + * @return current instance of builder + */ + public MentorRecordBuilder expertiseArea(String expertiseArea) { + this.expertiseArea = changedValue(expertiseArea); + return this; + } + + /** + * Sets the value for expertiseArea by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea(sb -> sb.append("text"));
    +   * }
    + * + * @param expertiseAreaStringBuilderConsumer consumer providing an instance of expertiseArea + * @return current instance of builder + */ + public MentorRecordBuilder expertiseArea(Consumer expertiseAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + expertiseAreaStringBuilderConsumer.accept(builder); + this.expertiseArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for expertiseArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea(() -> "example value");
    +   * }
    + * + * @param expertiseAreaSupplier supplier for expertiseArea + * @return current instance of builder + */ + public MentorRecordBuilder expertiseArea(Supplier expertiseAreaSupplier) { + this.expertiseArea = changedValue(expertiseAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for expertiseArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MentorRecordBuilder expertiseArea(String format, Object... args) { + this.expertiseArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for menteesCount. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.menteesCount(42);
    +   * }
    + * + * @param menteesCount menteesCount + * @return current instance of builder + */ + public MentorRecordBuilder menteesCount(int menteesCount) { + this.menteesCount = changedValue(menteesCount); + return this; + } + + /** + * Sets the value for menteesCount by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.menteesCount(() -> 42);
    +   * }
    + * + * @param menteesCountSupplier supplier for menteesCount + * @return current instance of builder + */ + public MentorRecordBuilder menteesCount(Supplier menteesCountSupplier) { + this.menteesCount = changedValue(menteesCountSupplier.get()); + return this; + } + + /** + * Sets the value for mentorId. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorId(UUID.randomUUID());
    +   * }
    + * + * @param mentorId mentorId + * @return current instance of builder + */ + public MentorRecordBuilder mentorId(UUID mentorId) { + this.mentorId = changedValue(mentorId); + return this; + } + + /** + * Sets the value for mentorId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorId(() -> UUID.randomUUID());
    +   * }
    + * + * @param mentorIdSupplier supplier for mentorId + * @return current instance of builder + */ + public MentorRecordBuilder mentorId(Supplier mentorIdSupplier) { + this.mentorId = changedValue(mentorIdSupplier.get()); + return this; + } + + /** + * Sets the value for mentorName. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorName("example value");
    +   * }
    + * + * @param mentorName mentorName + * @return current instance of builder + */ + public MentorRecordBuilder mentorName(String mentorName) { + this.mentorName = changedValue(mentorName); + return this; + } + + /** + * Sets the value for mentorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorName(sb -> sb.append("text"));
    +   * }
    + * + * @param mentorNameStringBuilderConsumer consumer providing an instance of mentorName + * @return current instance of builder + */ + public MentorRecordBuilder mentorName(Consumer mentorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + mentorNameStringBuilderConsumer.accept(builder); + this.mentorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for mentorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorName(() -> "example value");
    +   * }
    + * + * @param mentorNameSupplier supplier for mentorName + * @return current instance of builder + */ + public MentorRecordBuilder mentorName(Supplier mentorNameSupplier) { + this.mentorName = changedValue(mentorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for mentorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.mentorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public MentorRecordBuilder mentorName(String format, Object... args) { + this.mentorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for yearsExperience. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(42);
    +   * }
    + * + * @param yearsExperience yearsExperience + * @return current instance of builder + */ + public MentorRecordBuilder yearsExperience(int yearsExperience) { + this.yearsExperience = changedValue(yearsExperience); + return this; + } + + /** + * Sets the value for yearsExperience by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link MentorRecord#MentorRecord(UUID, String, String, int, int) + * MentorRecord(UUID mentorId, String mentorName, String expertiseArea, int menteesCount, int yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(() -> 42);
    +   * }
    + * + * @param yearsExperienceSupplier supplier for yearsExperience + * @return current instance of builder + */ + public MentorRecordBuilder yearsExperience(Supplier yearsExperienceSupplier) { + this.yearsExperience = changedValue(yearsExperienceSupplier.get()); + 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 MentorRecordBuilder 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 MentorRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * MentorRecord result = builder.build();
    +   * }
    + */ + @Override + public MentorRecord build() { + if (!this.menteesCount.isSet()) { + throw new IllegalStateException("Required field 'menteesCount' must be set before calling build()"); + } + if (this.menteesCount.value() == null) { + throw new IllegalStateException("Field 'menteesCount' is marked as non-null but null value was provided"); + } + if (!this.yearsExperience.isSet()) { + throw new IllegalStateException("Required field 'yearsExperience' must be set before calling build()"); + } + if (this.yearsExperience.value() == null) { + throw new IllegalStateException("Field 'yearsExperience' is marked as non-null but null value was provided"); + } + MentorRecord result = new MentorRecord(this.mentorId.value(), + this.mentorName.value(), + this.expertiseArea.value(), + this.menteesCount.value(), + this.yearsExperience.value()); + 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("mentorId", this.mentorId) + .append("mentorName", this.mentorName) + .append("expertiseArea", this.expertiseArea) + .append("menteesCount", this.menteesCount) + .append("yearsExperience", this.yearsExperience) + .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 MentorRecord with(Consumer b) { + MentorRecordBuilder builder; + try { + builder = new MentorRecordBuilder(MentorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MentorRecordBuilder.With' should only be implemented by classes, which could be casted to 'MentorRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default MentorRecordBuilder with() { + try { + return new MentorRecordBuilder(MentorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'MentorRecordBuilder.With' should only be implemented by classes, which could be casted to 'MentorRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OfficerRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OfficerRecordBuilder.java new file mode 100644 index 00000000..f533707c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OfficerRecordBuilder.java @@ -0,0 +1,541 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.OfficerRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.OfficerRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * OfficerRecord result = OfficerRecordBuilder.create()
    + *     .officerId(UUID.randomUUID())
    + *     .officerId(() -> UUID.randomUUID())
    + *     .officerName("example value")
    + *     .officerName("Hello %s", "World")
    + *     .officerName(() -> "example value")
    + *     .officerName(sb -> sb.append("text"))
    + *     .role("example value")
    + *     .role("Hello %s", "World")
    + *     .role(() -> "example value")
    + *     .role(sb -> sb.append("text"))
    + *     .organization("example value")
    + *     .organization("Hello %s", "World")
    + *     .organization(() -> "example value")
    + *     .organization(sb -> sb.append("text"))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = OfficerRecord.class) +public class OfficerRecordBuilder implements IBuilderBase { + + /** + * Tracked value for officerId: officerId. + */ + private TrackedValue officerId = unsetValue(); + /** + * Tracked value for officerName: officerName. + */ + private TrackedValue officerName = unsetValue(); + /** + * Tracked value for role: role. + */ + private TrackedValue role = unsetValue(); + /** + * Tracked value for organization: organization. + */ + private TrackedValue organization = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.OfficerRecord}. + */ + public OfficerRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.OfficerRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public OfficerRecordBuilder(OfficerRecord instance) { + this.officerId = initialValue(instance.officerId()); + this.officerName = initialValue(instance.officerName()); + this.role = initialValue(instance.role()); + this.organization = initialValue(instance.organization()); + this.startDate = initialValue(instance.startDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.OfficerRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * OfficerRecordBuilder builder = OfficerRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.OfficerRecord} + */ + public static OfficerRecordBuilder create() { + return new OfficerRecordBuilder(); + } + + /** + * Sets the value for officerId. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.officerId(UUID.randomUUID());
    +   * }
    + * + * @param officerId officerId + * @return current instance of builder + */ + public OfficerRecordBuilder officerId(UUID officerId) { + this.officerId = changedValue(officerId); + return this; + } + + /** + * Sets the value for officerId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.officerId(() -> UUID.randomUUID());
    +   * }
    + * + * @param officerIdSupplier supplier for officerId + * @return current instance of builder + */ + public OfficerRecordBuilder officerId(Supplier officerIdSupplier) { + this.officerId = changedValue(officerIdSupplier.get()); + return this; + } + + /** + * Sets the value for officerName. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.officerName("example value");
    +   * }
    + * + * @param officerName officerName + * @return current instance of builder + */ + public OfficerRecordBuilder officerName(String officerName) { + this.officerName = changedValue(officerName); + return this; + } + + /** + * Sets the value for officerName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.officerName(sb -> sb.append("text"));
    +   * }
    + * + * @param officerNameStringBuilderConsumer consumer providing an instance of officerName + * @return current instance of builder + */ + public OfficerRecordBuilder officerName(Consumer officerNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + officerNameStringBuilderConsumer.accept(builder); + this.officerName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for officerName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.officerName(() -> "example value");
    +   * }
    + * + * @param officerNameSupplier supplier for officerName + * @return current instance of builder + */ + public OfficerRecordBuilder officerName(Supplier officerNameSupplier) { + this.officerName = changedValue(officerNameSupplier.get()); + return this; + } + + /** + * Sets the String value for officerName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.officerName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OfficerRecordBuilder officerName(String format, Object... args) { + this.officerName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for organization. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("example value");
    +   * }
    + * + * @param organization organization + * @return current instance of builder + */ + public OfficerRecordBuilder organization(String organization) { + this.organization = changedValue(organization); + return this; + } + + /** + * Sets the value for organization by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(sb -> sb.append("text"));
    +   * }
    + * + * @param organizationStringBuilderConsumer consumer providing an instance of organization + * @return current instance of builder + */ + public OfficerRecordBuilder organization(Consumer organizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizationStringBuilderConsumer.accept(builder); + this.organization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organization by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(() -> "example value");
    +   * }
    + * + * @param organizationSupplier supplier for organization + * @return current instance of builder + */ + public OfficerRecordBuilder organization(Supplier organizationSupplier) { + this.organization = changedValue(organizationSupplier.get()); + return this; + } + + /** + * Sets the String value for organization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OfficerRecordBuilder organization(String format, Object... args) { + this.organization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for role. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.role("example value");
    +   * }
    + * + * @param role role + * @return current instance of builder + */ + public OfficerRecordBuilder role(String role) { + this.role = changedValue(role); + return this; + } + + /** + * Sets the value for role by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.role(sb -> sb.append("text"));
    +   * }
    + * + * @param roleStringBuilderConsumer consumer providing an instance of role + * @return current instance of builder + */ + public OfficerRecordBuilder role(Consumer roleStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + roleStringBuilderConsumer.accept(builder); + this.role = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for role by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.role(() -> "example value");
    +   * }
    + * + * @param roleSupplier supplier for role + * @return current instance of builder + */ + public OfficerRecordBuilder role(Supplier roleSupplier) { + this.role = changedValue(roleSupplier.get()); + return this; + } + + /** + * Sets the String value for role by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.role("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OfficerRecordBuilder role(String format, Object... args) { + this.role = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public OfficerRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OfficerRecord#OfficerRecord(UUID, String, String, String, LocalDate) + * OfficerRecord(UUID officerId, String officerName, String role, String organization, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public OfficerRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + 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 OfficerRecordBuilder 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 OfficerRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * OfficerRecord result = builder.build();
    +   * }
    + */ + @Override + public OfficerRecord build() { + OfficerRecord result = new OfficerRecord(this.officerId + .value(), this.officerName.value(), this.role.value(), this.organization.value(), this.startDate.value()); + 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("officerId", this.officerId) + .append("officerName", this.officerName) + .append("role", this.role) + .append("organization", this.organization) + .append("startDate", this.startDate) + .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 OfficerRecord with(Consumer b) { + OfficerRecordBuilder builder; + try { + builder = new OfficerRecordBuilder(OfficerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OfficerRecordBuilder.With' should only be implemented by classes, which could be casted to 'OfficerRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default OfficerRecordBuilder with() { + try { + return new OfficerRecordBuilder(OfficerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OfficerRecordBuilder.With' should only be implemented by classes, which could be casted to 'OfficerRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OperatorRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OperatorRecordBuilder.java new file mode 100644 index 00000000..e921a1c0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/OperatorRecordBuilder.java @@ -0,0 +1,549 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.OperatorRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.OperatorRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * OperatorRecord result = OperatorRecordBuilder.create()
    + *     .operatorId(UUID.randomUUID())
    + *     .operatorId(() -> UUID.randomUUID())
    + *     .operatorName("example value")
    + *     .operatorName("Hello %s", "World")
    + *     .operatorName(() -> "example value")
    + *     .operatorName(sb -> sb.append("text"))
    + *     .machineType("example value")
    + *     .machineType("Hello %s", "World")
    + *     .machineType(() -> "example value")
    + *     .machineType(sb -> sb.append("text"))
    + *     .yearsExperience(42)
    + *     .yearsExperience(() -> 42)
    + *     .shift("example value")
    + *     .shift("Hello %s", "World")
    + *     .shift(() -> "example value")
    + *     .shift(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = OperatorRecord.class) +public class OperatorRecordBuilder implements IBuilderBase { + + /** + * Tracked value for operatorId: operatorId. + */ + private TrackedValue operatorId = unsetValue(); + /** + * Tracked value for operatorName: operatorName. + */ + private TrackedValue operatorName = unsetValue(); + /** + * Tracked value for machineType: machineType. + */ + private TrackedValue machineType = unsetValue(); + /** + * Tracked value for yearsExperience: yearsExperience. + */ + private TrackedValue yearsExperience = unsetValue(); + /** + * Tracked value for shift: shift. + */ + private TrackedValue shift = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.OperatorRecord}. + */ + public OperatorRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.OperatorRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public OperatorRecordBuilder(OperatorRecord instance) { + this.operatorId = initialValue(instance.operatorId()); + this.operatorName = initialValue(instance.operatorName()); + this.machineType = initialValue(instance.machineType()); + this.yearsExperience = initialValue(instance.yearsExperience()); + this.shift = initialValue(instance.shift()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.OperatorRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * OperatorRecordBuilder builder = OperatorRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.OperatorRecord} + */ + public static OperatorRecordBuilder create() { + return new OperatorRecordBuilder(); + } + + /** + * Sets the value for machineType. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.machineType("example value");
    +   * }
    + * + * @param machineType machineType + * @return current instance of builder + */ + public OperatorRecordBuilder machineType(String machineType) { + this.machineType = changedValue(machineType); + return this; + } + + /** + * Sets the value for machineType by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.machineType(sb -> sb.append("text"));
    +   * }
    + * + * @param machineTypeStringBuilderConsumer consumer providing an instance of machineType + * @return current instance of builder + */ + public OperatorRecordBuilder machineType(Consumer machineTypeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + machineTypeStringBuilderConsumer.accept(builder); + this.machineType = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for machineType by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.machineType(() -> "example value");
    +   * }
    + * + * @param machineTypeSupplier supplier for machineType + * @return current instance of builder + */ + public OperatorRecordBuilder machineType(Supplier machineTypeSupplier) { + this.machineType = changedValue(machineTypeSupplier.get()); + return this; + } + + /** + * Sets the String value for machineType by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.machineType("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OperatorRecordBuilder machineType(String format, Object... args) { + this.machineType = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for operatorId. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.operatorId(UUID.randomUUID());
    +   * }
    + * + * @param operatorId operatorId + * @return current instance of builder + */ + public OperatorRecordBuilder operatorId(UUID operatorId) { + this.operatorId = changedValue(operatorId); + return this; + } + + /** + * Sets the value for operatorId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.operatorId(() -> UUID.randomUUID());
    +   * }
    + * + * @param operatorIdSupplier supplier for operatorId + * @return current instance of builder + */ + public OperatorRecordBuilder operatorId(Supplier operatorIdSupplier) { + this.operatorId = changedValue(operatorIdSupplier.get()); + return this; + } + + /** + * Sets the value for operatorName. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.operatorName("example value");
    +   * }
    + * + * @param operatorName operatorName + * @return current instance of builder + */ + public OperatorRecordBuilder operatorName(String operatorName) { + this.operatorName = changedValue(operatorName); + return this; + } + + /** + * Sets the value for operatorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.operatorName(sb -> sb.append("text"));
    +   * }
    + * + * @param operatorNameStringBuilderConsumer consumer providing an instance of operatorName + * @return current instance of builder + */ + public OperatorRecordBuilder operatorName(Consumer operatorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + operatorNameStringBuilderConsumer.accept(builder); + this.operatorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for operatorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.operatorName(() -> "example value");
    +   * }
    + * + * @param operatorNameSupplier supplier for operatorName + * @return current instance of builder + */ + public OperatorRecordBuilder operatorName(Supplier operatorNameSupplier) { + this.operatorName = changedValue(operatorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for operatorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.operatorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OperatorRecordBuilder operatorName(String format, Object... args) { + this.operatorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for shift. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift("example value");
    +   * }
    + * + * @param shift shift + * @return current instance of builder + */ + public OperatorRecordBuilder shift(String shift) { + this.shift = changedValue(shift); + return this; + } + + /** + * Sets the value for shift by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift(sb -> sb.append("text"));
    +   * }
    + * + * @param shiftStringBuilderConsumer consumer providing an instance of shift + * @return current instance of builder + */ + public OperatorRecordBuilder shift(Consumer shiftStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + shiftStringBuilderConsumer.accept(builder); + this.shift = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for shift by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift(() -> "example value");
    +   * }
    + * + * @param shiftSupplier supplier for shift + * @return current instance of builder + */ + public OperatorRecordBuilder shift(Supplier shiftSupplier) { + this.shift = changedValue(shiftSupplier.get()); + return this; + } + + /** + * Sets the String value for shift by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public OperatorRecordBuilder shift(String format, Object... args) { + this.shift = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for yearsExperience. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(42);
    +   * }
    + * + * @param yearsExperience yearsExperience + * @return current instance of builder + */ + public OperatorRecordBuilder yearsExperience(int yearsExperience) { + this.yearsExperience = changedValue(yearsExperience); + return this; + } + + /** + * Sets the value for yearsExperience by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link OperatorRecord#OperatorRecord(UUID, String, String, int, String) + * OperatorRecord(UUID operatorId, String operatorName, String machineType, int yearsExperience, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(() -> 42);
    +   * }
    + * + * @param yearsExperienceSupplier supplier for yearsExperience + * @return current instance of builder + */ + public OperatorRecordBuilder yearsExperience(Supplier yearsExperienceSupplier) { + this.yearsExperience = changedValue(yearsExperienceSupplier.get()); + 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 OperatorRecordBuilder 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 OperatorRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * OperatorRecord result = builder.build();
    +   * }
    + */ + @Override + public OperatorRecord build() { + if (!this.yearsExperience.isSet()) { + throw new IllegalStateException("Required field 'yearsExperience' must be set before calling build()"); + } + if (this.yearsExperience.value() == null) { + throw new IllegalStateException("Field 'yearsExperience' is marked as non-null but null value was provided"); + } + OperatorRecord result = new OperatorRecord(this.operatorId.value(), + this.operatorName.value(), + this.machineType.value(), + this.yearsExperience.value(), + this.shift.value()); + 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("operatorId", this.operatorId) + .append("operatorName", this.operatorName) + .append("machineType", this.machineType) + .append("yearsExperience", this.yearsExperience) + .append("shift", this.shift) + .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 OperatorRecord with(Consumer b) { + OperatorRecordBuilder builder; + try { + builder = new OperatorRecordBuilder(OperatorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OperatorRecordBuilder.With' should only be implemented by classes, which could be casted to 'OperatorRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default OperatorRecordBuilder with() { + try { + return new OperatorRecordBuilder(OperatorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'OperatorRecordBuilder.With' should only be implemented by classes, which could be casted to 'OperatorRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronOfArtsRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronOfArtsRecordBuilder.java new file mode 100644 index 00000000..b4542f4b --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronOfArtsRecordBuilder.java @@ -0,0 +1,548 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.PatronOfArtsRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.PatronOfArtsRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PatronOfArtsRecord result = PatronOfArtsRecordBuilder.create()
    + *     .patronId(UUID.randomUUID())
    + *     .patronId(() -> UUID.randomUUID())
    + *     .patronName("example value")
    + *     .patronName("Hello %s", "World")
    + *     .patronName(() -> "example value")
    + *     .patronName(sb -> sb.append("text"))
    + *     .artFormsSupported(List.of("example value"))
    + *     .artFormsSupported(() -> List.of("example value"))
    + *     .artFormsSupported(t -> t.add("example value"))
    + *     .artFormsSupported("example value", "example value")
    + *     .add2ArtFormsSupported("example value")
    + *     .totalContributed(BigDecimal.valueOf(3.14))
    + *     .totalContributed(() -> BigDecimal.valueOf(3.14))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PatronOfArtsRecord.class) +public class PatronOfArtsRecordBuilder implements IBuilderBase { + + /** + * Tracked value for patronId: patronId. + */ + private TrackedValue patronId = unsetValue(); + /** + * Tracked value for patronName: patronName. + */ + private TrackedValue patronName = unsetValue(); + /** + * Tracked value for artFormsSupported: artFormsSupported. + */ + private TrackedValue> artFormsSupported = unsetValue(); + /** + * Tracked value for totalContributed: totalContributed. + */ + private TrackedValue totalContributed = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronOfArtsRecord}. + */ + public PatronOfArtsRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronOfArtsRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PatronOfArtsRecordBuilder(PatronOfArtsRecord instance) { + this.patronId = initialValue(instance.patronId()); + this.patronName = initialValue(instance.patronName()); + this.artFormsSupported = initialValue(instance.artFormsSupported()); + this.totalContributed = initialValue(instance.totalContributed()); + this.startDate = initialValue(instance.startDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronOfArtsRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PatronOfArtsRecordBuilder builder = PatronOfArtsRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronOfArtsRecord} + */ + public static PatronOfArtsRecordBuilder create() { + return new PatronOfArtsRecordBuilder(); + } + + /** + * Adds a single element to artFormsSupported. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ArtFormsSupported("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder add2ArtFormsSupported(String element) { + List newCollection; + if (this.artFormsSupported.isSet()) { + newCollection = new ArrayList<>(this.artFormsSupported.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.artFormsSupported = changedValue(newCollection); + return this; + } + + /** + * Sets the value for artFormsSupported. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.artFormsSupported("example value", "example value");
    +   * }
    + * + * @param artFormsSupported artFormsSupported + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder artFormsSupported(String... artFormsSupported) { + this.artFormsSupported = changedValue(List.of(artFormsSupported)); + return this; + } + + /** + * Sets the value for artFormsSupported. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.artFormsSupported(List.of("example value"));
    +   * }
    + * + * @param artFormsSupported artFormsSupported + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder artFormsSupported(List artFormsSupported) { + this.artFormsSupported = changedValue(artFormsSupported); + return this; + } + + /** + * Sets the value for artFormsSupported using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.artFormsSupported(t -> t.add("example value"));
    +   * }
    + * + * @param artFormsSupportedBuilderConsumer consumer providing an instance of a builder for artFormsSupported + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder artFormsSupported( + Consumer> artFormsSupportedBuilderConsumer) { + ArrayListBuilder builder = this.artFormsSupported.isSet() + ? new ArrayListBuilder(this.artFormsSupported.value()) + : new ArrayListBuilder(); + artFormsSupportedBuilderConsumer.accept(builder); + this.artFormsSupported = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for artFormsSupported by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.artFormsSupported(() -> List.of("example value"));
    +   * }
    + * + * @param artFormsSupportedSupplier supplier for artFormsSupported + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder artFormsSupported(Supplier> artFormsSupportedSupplier) { + this.artFormsSupported = changedValue(artFormsSupportedSupplier.get()); + return this; + } + + /** + * Sets the value for patronId. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patronId(UUID.randomUUID());
    +   * }
    + * + * @param patronId patronId + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder patronId(UUID patronId) { + this.patronId = changedValue(patronId); + return this; + } + + /** + * Sets the value for patronId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patronId(() -> UUID.randomUUID());
    +   * }
    + * + * @param patronIdSupplier supplier for patronId + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder patronId(Supplier patronIdSupplier) { + this.patronId = changedValue(patronIdSupplier.get()); + return this; + } + + /** + * Sets the value for patronName. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patronName("example value");
    +   * }
    + * + * @param patronName patronName + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder patronName(String patronName) { + this.patronName = changedValue(patronName); + return this; + } + + /** + * Sets the value for patronName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patronName(sb -> sb.append("text"));
    +   * }
    + * + * @param patronNameStringBuilderConsumer consumer providing an instance of patronName + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder patronName(Consumer patronNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + patronNameStringBuilderConsumer.accept(builder); + this.patronName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for patronName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patronName(() -> "example value");
    +   * }
    + * + * @param patronNameSupplier supplier for patronName + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder patronName(Supplier patronNameSupplier) { + this.patronName = changedValue(patronNameSupplier.get()); + return this; + } + + /** + * Sets the String value for patronName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.patronName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder patronName(String format, Object... args) { + this.patronName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + return this; + } + + /** + * Sets the value for totalContributed. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalContributed(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalContributed totalContributed + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder totalContributed(BigDecimal totalContributed) { + this.totalContributed = changedValue(totalContributed); + return this; + } + + /** + * Sets the value for totalContributed by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronOfArtsRecord#PatronOfArtsRecord(UUID, String, List, BigDecimal, LocalDate) PatronOfArtsRecord(UUID + * patronId, String patronName, List artFormsSupported, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalContributed(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalContributedSupplier supplier for totalContributed + * @return current instance of builder + */ + public PatronOfArtsRecordBuilder totalContributed(Supplier totalContributedSupplier) { + this.totalContributed = changedValue(totalContributedSupplier.get()); + 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 PatronOfArtsRecordBuilder 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 PatronOfArtsRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PatronOfArtsRecord result = builder.build();
    +   * }
    + */ + @Override + public PatronOfArtsRecord build() { + PatronOfArtsRecord result = new PatronOfArtsRecord(this.patronId.value(), + this.patronName.value(), + this.artFormsSupported.value(), + this.totalContributed.value(), + this.startDate.value()); + 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("patronId", this.patronId) + .append("patronName", this.patronName) + .append("artFormsSupported", this.artFormsSupported) + .append("totalContributed", this.totalContributed) + .append("startDate", this.startDate) + .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 PatronOfArtsRecord with(Consumer b) { + PatronOfArtsRecordBuilder builder; + try { + builder = new PatronOfArtsRecordBuilder(PatronOfArtsRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PatronOfArtsRecordBuilder.With' should only be implemented by classes, which could be casted to 'PatronOfArtsRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PatronOfArtsRecordBuilder with() { + try { + return new PatronOfArtsRecordBuilder(PatronOfArtsRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PatronOfArtsRecordBuilder.With' should only be implemented by classes, which could be casted to 'PatronOfArtsRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronRecordBuilder.java new file mode 100644 index 00000000..df59c5f9 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PatronRecordBuilder.java @@ -0,0 +1,617 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.math.BigDecimal; +import java.time.LocalDate; +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.performance_test.library.persons.PatronRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.PatronRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PatronRecord result = PatronRecordBuilder.create()
    + *     .membershipId("example value")
    + *     .membershipId("Hello %s", "World")
    + *     .membershipId(() -> "example value")
    + *     .membershipId(sb -> sb.append("text"))
    + *     .fullName("example value")
    + *     .fullName("Hello %s", "World")
    + *     .fullName(() -> "example value")
    + *     .fullName(sb -> sb.append("text"))
    + *     .joinDate(LocalDate.now())
    + *     .joinDate(() -> LocalDate.now())
    + *     .itemsCheckedOut(42)
    + *     .itemsCheckedOut(() -> 42)
    + *     .finesOwed(BigDecimal.valueOf(3.14))
    + *     .finesOwed(() -> BigDecimal.valueOf(3.14))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PatronRecord.class) +public class PatronRecordBuilder implements IBuilderBase { + + /** + * Tracked value for membershipId: membershipId. + */ + private TrackedValue membershipId = unsetValue(); + /** + * Tracked value for fullName: fullName. + */ + private TrackedValue fullName = unsetValue(); + /** + * Tracked value for joinDate: joinDate. + */ + private TrackedValue joinDate = unsetValue(); + /** + * Tracked value for itemsCheckedOut: itemsCheckedOut. + */ + private TrackedValue itemsCheckedOut = unsetValue(); + /** + * Tracked value for finesOwed: finesOwed. + */ + private TrackedValue finesOwed = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronRecord}. + */ + public PatronRecordBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronRecord} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public PatronRecordBuilder(PatronRecord instance) { + this.membershipId = initialValue(instance.membershipId()); + this.fullName = initialValue(instance.fullName()); + this.joinDate = initialValue(instance.joinDate()); + this.itemsCheckedOut = initialValue(instance.itemsCheckedOut()); + this.finesOwed = initialValue(instance.finesOwed()); + this.status = initialValue(instance.status()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PatronRecordBuilder builder = PatronRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.PatronRecord} + */ + public static PatronRecordBuilder create() { + return new PatronRecordBuilder(); + } + + /** + * Sets the value for finesOwed. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.finesOwed(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param finesOwed finesOwed + * @return current instance of builder + */ + public PatronRecordBuilder finesOwed(BigDecimal finesOwed) { + this.finesOwed = changedValue(finesOwed); + return this; + } + + /** + * Sets the value for finesOwed by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.finesOwed(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param finesOwedSupplier supplier for finesOwed + * @return current instance of builder + */ + public PatronRecordBuilder finesOwed(Supplier finesOwedSupplier) { + this.finesOwed = changedValue(finesOwedSupplier.get()); + return this; + } + + /** + * Sets the value for fullName. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fullName("example value");
    +   * }
    + * + * @param fullName fullName + * @return current instance of builder + */ + public PatronRecordBuilder fullName(String fullName) { + this.fullName = changedValue(fullName); + return this; + } + + /** + * Sets the value for fullName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fullName(sb -> sb.append("text"));
    +   * }
    + * + * @param fullNameStringBuilderConsumer consumer providing an instance of fullName + * @return current instance of builder + */ + public PatronRecordBuilder fullName(Consumer fullNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fullNameStringBuilderConsumer.accept(builder); + this.fullName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for fullName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fullName(() -> "example value");
    +   * }
    + * + * @param fullNameSupplier supplier for fullName + * @return current instance of builder + */ + public PatronRecordBuilder fullName(Supplier fullNameSupplier) { + this.fullName = changedValue(fullNameSupplier.get()); + return this; + } + + /** + * Sets the String value for fullName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.fullName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PatronRecordBuilder fullName(String format, Object... args) { + this.fullName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for itemsCheckedOut. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.itemsCheckedOut(42);
    +   * }
    + * + * @param itemsCheckedOut itemsCheckedOut + * @return current instance of builder + */ + public PatronRecordBuilder itemsCheckedOut(int itemsCheckedOut) { + this.itemsCheckedOut = changedValue(itemsCheckedOut); + return this; + } + + /** + * Sets the value for itemsCheckedOut by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.itemsCheckedOut(() -> 42);
    +   * }
    + * + * @param itemsCheckedOutSupplier supplier for itemsCheckedOut + * @return current instance of builder + */ + public PatronRecordBuilder itemsCheckedOut(Supplier itemsCheckedOutSupplier) { + this.itemsCheckedOut = changedValue(itemsCheckedOutSupplier.get()); + return this; + } + + /** + * Sets the value for joinDate. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.joinDate(LocalDate.now());
    +   * }
    + * + * @param joinDate joinDate + * @return current instance of builder + */ + public PatronRecordBuilder joinDate(LocalDate joinDate) { + this.joinDate = changedValue(joinDate); + return this; + } + + /** + * Sets the value for joinDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.joinDate(() -> LocalDate.now());
    +   * }
    + * + * @param joinDateSupplier supplier for joinDate + * @return current instance of builder + */ + public PatronRecordBuilder joinDate(Supplier joinDateSupplier) { + this.joinDate = changedValue(joinDateSupplier.get()); + return this; + } + + /** + * Sets the value for membershipId. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.membershipId("example value");
    +   * }
    + * + * @param membershipId membershipId + * @return current instance of builder + */ + public PatronRecordBuilder membershipId(String membershipId) { + this.membershipId = changedValue(membershipId); + return this; + } + + /** + * Sets the value for membershipId by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.membershipId(sb -> sb.append("text"));
    +   * }
    + * + * @param membershipIdStringBuilderConsumer consumer providing an instance of membershipId + * @return current instance of builder + */ + public PatronRecordBuilder membershipId(Consumer membershipIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + membershipIdStringBuilderConsumer.accept(builder); + this.membershipId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for membershipId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.membershipId(() -> "example value");
    +   * }
    + * + * @param membershipIdSupplier supplier for membershipId + * @return current instance of builder + */ + public PatronRecordBuilder membershipId(Supplier membershipIdSupplier) { + this.membershipId = changedValue(membershipIdSupplier.get()); + return this; + } + + /** + * Sets the String value for membershipId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.membershipId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PatronRecordBuilder membershipId(String format, Object... args) { + this.membershipId = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PatronRecordBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PatronRecordBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PatronRecordBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link PatronRecord#PatronRecord(String, String, LocalDate, int, BigDecimal, String) PatronRecord(String + * membershipId, String fullName, LocalDate joinDate, int itemsCheckedOut, BigDecimal finesOwed, String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PatronRecordBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PatronRecordBuilder 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 PatronRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PatronRecord result = builder.build();
    +   * }
    + */ + @Override + public PatronRecord build() { + if (!this.itemsCheckedOut.isSet()) { + throw new IllegalStateException("Required field 'itemsCheckedOut' must be set before calling build()"); + } + if (this.itemsCheckedOut.value() == null) { + throw new IllegalStateException("Field 'itemsCheckedOut' is marked as non-null but null value was provided"); + } + PatronRecord result = new PatronRecord(this.membershipId.value(), + this.fullName.value(), + this.joinDate.value(), + this.itemsCheckedOut.value(), + this.finesOwed.value(), + this.status.valueOr("ACTIVE")); + 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("membershipId", this.membershipId) + .append("fullName", this.fullName) + .append("joinDate", this.joinDate) + .append("itemsCheckedOut", this.itemsCheckedOut) + .append("finesOwed", this.finesOwed) + .append("status", this.status) + .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 PatronRecord with(Consumer b) { + PatronRecordBuilder builder; + try { + builder = new PatronRecordBuilder(PatronRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PatronRecordBuilder.With' should only be implemented by classes, which could be casted to 'PatronRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PatronRecordBuilder with() { + try { + return new PatronRecordBuilder(PatronRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PatronRecordBuilder.With' should only be implemented by classes, which could be casted to 'PatronRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PlannerRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PlannerRecordBuilder.java new file mode 100644 index 00000000..6ad19ed2 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PlannerRecordBuilder.java @@ -0,0 +1,546 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.PlannerRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.PlannerRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * PlannerRecord result = PlannerRecordBuilder.create()
    + *     .plannerId(UUID.randomUUID())
    + *     .plannerId(() -> UUID.randomUUID())
    + *     .plannerName("example value")
    + *     .plannerName("Hello %s", "World")
    + *     .plannerName(() -> "example value")
    + *     .plannerName(sb -> sb.append("text"))
    + *     .planningArea("example value")
    + *     .planningArea("Hello %s", "World")
    + *     .planningArea(() -> "example value")
    + *     .planningArea(sb -> sb.append("text"))
    + *     .plansCreated(42)
    + *     .plansCreated(() -> 42)
    + *     .region("example value")
    + *     .region("Hello %s", "World")
    + *     .region(() -> "example value")
    + *     .region(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = PlannerRecord.class) +public class PlannerRecordBuilder implements IBuilderBase { + + /** + * Tracked value for plannerId: plannerId. + */ + private TrackedValue plannerId = unsetValue(); + /** + * Tracked value for plannerName: plannerName. + */ + private TrackedValue plannerName = unsetValue(); + /** + * Tracked value for planningArea: planningArea. + */ + private TrackedValue planningArea = unsetValue(); + /** + * Tracked value for plansCreated: plansCreated. + */ + private TrackedValue plansCreated = unsetValue(); + /** + * Tracked value for region: region. + */ + private TrackedValue region = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.PlannerRecord}. + */ + public PlannerRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.PlannerRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public PlannerRecordBuilder(PlannerRecord instance) { + this.plannerId = initialValue(instance.plannerId()); + this.plannerName = initialValue(instance.plannerName()); + this.planningArea = initialValue(instance.planningArea()); + this.plansCreated = initialValue(instance.plansCreated()); + this.region = initialValue(instance.region()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.PlannerRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * PlannerRecordBuilder builder = PlannerRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.PlannerRecord} + */ + public static PlannerRecordBuilder create() { + return new PlannerRecordBuilder(); + } + + /** + * Sets the value for plannerId. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plannerId(UUID.randomUUID());
    +   * }
    + * + * @param plannerId plannerId + * @return current instance of builder + */ + public PlannerRecordBuilder plannerId(UUID plannerId) { + this.plannerId = changedValue(plannerId); + return this; + } + + /** + * Sets the value for plannerId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plannerId(() -> UUID.randomUUID());
    +   * }
    + * + * @param plannerIdSupplier supplier for plannerId + * @return current instance of builder + */ + public PlannerRecordBuilder plannerId(Supplier plannerIdSupplier) { + this.plannerId = changedValue(plannerIdSupplier.get()); + return this; + } + + /** + * Sets the value for plannerName. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plannerName("example value");
    +   * }
    + * + * @param plannerName plannerName + * @return current instance of builder + */ + public PlannerRecordBuilder plannerName(String plannerName) { + this.plannerName = changedValue(plannerName); + return this; + } + + /** + * Sets the value for plannerName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plannerName(sb -> sb.append("text"));
    +   * }
    + * + * @param plannerNameStringBuilderConsumer consumer providing an instance of plannerName + * @return current instance of builder + */ + public PlannerRecordBuilder plannerName(Consumer plannerNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + plannerNameStringBuilderConsumer.accept(builder); + this.plannerName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for plannerName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plannerName(() -> "example value");
    +   * }
    + * + * @param plannerNameSupplier supplier for plannerName + * @return current instance of builder + */ + public PlannerRecordBuilder plannerName(Supplier plannerNameSupplier) { + this.plannerName = changedValue(plannerNameSupplier.get()); + return this; + } + + /** + * Sets the String value for plannerName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plannerName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlannerRecordBuilder plannerName(String format, Object... args) { + this.plannerName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for planningArea. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.planningArea("example value");
    +   * }
    + * + * @param planningArea planningArea + * @return current instance of builder + */ + public PlannerRecordBuilder planningArea(String planningArea) { + this.planningArea = changedValue(planningArea); + return this; + } + + /** + * Sets the value for planningArea by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.planningArea(sb -> sb.append("text"));
    +   * }
    + * + * @param planningAreaStringBuilderConsumer consumer providing an instance of planningArea + * @return current instance of builder + */ + public PlannerRecordBuilder planningArea(Consumer planningAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + planningAreaStringBuilderConsumer.accept(builder); + this.planningArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for planningArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.planningArea(() -> "example value");
    +   * }
    + * + * @param planningAreaSupplier supplier for planningArea + * @return current instance of builder + */ + public PlannerRecordBuilder planningArea(Supplier planningAreaSupplier) { + this.planningArea = changedValue(planningAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for planningArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.planningArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlannerRecordBuilder planningArea(String format, Object... args) { + this.planningArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for plansCreated. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plansCreated(42);
    +   * }
    + * + * @param plansCreated plansCreated + * @return current instance of builder + */ + public PlannerRecordBuilder plansCreated(int plansCreated) { + this.plansCreated = changedValue(plansCreated); + return this; + } + + /** + * Sets the value for plansCreated by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.plansCreated(() -> 42);
    +   * }
    + * + * @param plansCreatedSupplier supplier for plansCreated + * @return current instance of builder + */ + public PlannerRecordBuilder plansCreated(Supplier plansCreatedSupplier) { + this.plansCreated = changedValue(plansCreatedSupplier.get()); + return this; + } + + /** + * Sets the value for region. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("example value");
    +   * }
    + * + * @param region region + * @return current instance of builder + */ + public PlannerRecordBuilder region(String region) { + this.region = changedValue(region); + return this; + } + + /** + * Sets the value for region by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(sb -> sb.append("text"));
    +   * }
    + * + * @param regionStringBuilderConsumer consumer providing an instance of region + * @return current instance of builder + */ + public PlannerRecordBuilder region(Consumer regionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + regionStringBuilderConsumer.accept(builder); + this.region = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for region by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region(() -> "example value");
    +   * }
    + * + * @param regionSupplier supplier for region + * @return current instance of builder + */ + public PlannerRecordBuilder region(Supplier regionSupplier) { + this.region = changedValue(regionSupplier.get()); + return this; + } + + /** + * Sets the String value for region by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link PlannerRecord#PlannerRecord(UUID, String, String, int, String) + * PlannerRecord(UUID plannerId, String plannerName, String planningArea, int plansCreated, String region)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.region("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PlannerRecordBuilder region(String format, Object... args) { + this.region = changedValue(String.format(format, args)); + 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 PlannerRecordBuilder 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 PlannerRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * PlannerRecord result = builder.build();
    +   * }
    + */ + @Override + public PlannerRecord build() { + if (!this.plansCreated.isSet()) { + throw new IllegalStateException("Required field 'plansCreated' must be set before calling build()"); + } + if (this.plansCreated.value() == null) { + throw new IllegalStateException("Field 'plansCreated' is marked as non-null but null value was provided"); + } + PlannerRecord result = new PlannerRecord(this.plannerId + .value(), this.plannerName.value(), this.planningArea.value(), this.plansCreated.value(), this.region.value()); + 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("plannerId", this.plannerId) + .append("plannerName", this.plannerName) + .append("planningArea", this.planningArea) + .append("plansCreated", this.plansCreated) + .append("region", this.region) + .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 PlannerRecord with(Consumer b) { + PlannerRecordBuilder builder; + try { + builder = new PlannerRecordBuilder(PlannerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlannerRecordBuilder.With' should only be implemented by classes, which could be casted to 'PlannerRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PlannerRecordBuilder with() { + try { + return new PlannerRecordBuilder(PlannerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PlannerRecordBuilder.With' should only be implemented by classes, which could be casted to 'PlannerRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PrinterBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PrinterBuilder.java new file mode 100644 index 00000000..ab271141 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/PrinterBuilder.java @@ -0,0 +1,790 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.Printer}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.Printer 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. + * + *

    Example:

    + * + *
    {@code
    + * Printer result = PrinterBuilder.create()
    + *     .capacityPerDay(42)
    + *     .capacityPerDay(() -> 42)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .printerId("example value")
    + *     .printerId("Hello %s", "World")
    + *     .printerId(() -> "example value")
    + *     .printerId(sb -> sb.append("text"))
    + *     .printingMethods(List.of("example value"))
    + *     .printingMethods(() -> List.of("example value"))
    + *     .printingMethods(t -> t.add("example value"))
    + *     .printingMethods("example value", "example value")
    + *     .add2PrintingMethods("example value")
    + *     .specialization("example value")
    + *     .specialization("Hello %s", "World")
    + *     .specialization(() -> "example value")
    + *     .specialization(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Printer.class) +public class PrinterBuilder implements IBuilderBase { + + /** + * Tracked value for capacityPerDay: capacityPerDay. + */ + private TrackedValue capacityPerDay = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for printerId: printerId. + */ + private TrackedValue printerId = unsetValue(); + /** + * Tracked value for printingMethods: printingMethods. + */ + private TrackedValue> printingMethods = unsetValue(); + /** + * Tracked value for specialization: specialization. + */ + private TrackedValue specialization = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Printer}. + */ + public PrinterBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Printer} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public PrinterBuilder(Printer instance) { + this.capacityPerDay = initialValue(instance.getCapacityPerDay()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.printerId = initialValue(instance.getPrinterId()); + this.printingMethods = initialValue(instance.getPrintingMethods()); + this.specialization = initialValue(instance.getSpecialization()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Printer}. + * + *

    Example:

    + * + *
    {@code
    +   * PrinterBuilder builder = PrinterBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Printer} + */ + public static PrinterBuilder create() { + return new PrinterBuilder(); + } + + /** + * Adds a single element to printingMethods. + *

    + * Generated from setter {@link Printer#setPrintingMethods(List) setPrintingMethods(List printingMethods)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2PrintingMethods("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public PrinterBuilder add2PrintingMethods(String element) { + List newCollection; + if (this.printingMethods.isSet()) { + newCollection = new ArrayList<>(this.printingMethods.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.printingMethods = changedValue(newCollection); + return this; + } + + /** + * Sets the value for capacityPerDay. + *

    + * Generated from setter {@link Printer#setCapacityPerDay(int) setCapacityPerDay(int capacityPerDay)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacityPerDay(42);
    +   * }
    + * + * @param capacityPerDay capacityPerDay + * @return current instance of builder + */ + public PrinterBuilder capacityPerDay(int capacityPerDay) { + this.capacityPerDay = changedValue(capacityPerDay); + return this; + } + + /** + * Sets the value for capacityPerDay by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setCapacityPerDay(int) setCapacityPerDay(int capacityPerDay)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.capacityPerDay(() -> 42);
    +   * }
    + * + * @param capacityPerDaySupplier supplier for capacityPerDay + * @return current instance of builder + */ + public PrinterBuilder capacityPerDay(Supplier capacityPerDaySupplier) { + this.capacityPerDay = changedValue(capacityPerDaySupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Printer#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public PrinterBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public PrinterBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Printer#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public PrinterBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public PrinterBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Printer#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public PrinterBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Printer#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public PrinterBuilder 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. + *

    + * Generated from setter {@link Printer#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public PrinterBuilder 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. + *

    + * Generated from setter {@link Printer#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PrinterBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for printerId. + *

    + * Generated from setter {@link Printer#setPrinterId(String) setPrinterId(String printerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printerId("example value");
    +   * }
    + * + * @param printerId printerId + * @return current instance of builder + */ + public PrinterBuilder printerId(String printerId) { + this.printerId = changedValue(printerId); + return this; + } + + /** + * Sets the value for printerId by executing the provided consumer. + *

    + * Generated from setter {@link Printer#setPrinterId(String) setPrinterId(String printerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printerId(sb -> sb.append("text"));
    +   * }
    + * + * @param printerIdStringBuilderConsumer consumer providing an instance of printerId + * @return current instance of builder + */ + public PrinterBuilder printerId(Consumer printerIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + printerIdStringBuilderConsumer.accept(builder); + this.printerId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for printerId by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setPrinterId(String) setPrinterId(String printerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printerId(() -> "example value");
    +   * }
    + * + * @param printerIdSupplier supplier for printerId + * @return current instance of builder + */ + public PrinterBuilder printerId(Supplier printerIdSupplier) { + this.printerId = changedValue(printerIdSupplier.get()); + return this; + } + + /** + * Sets the String value for printerId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Printer#setPrinterId(String) setPrinterId(String printerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printerId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PrinterBuilder printerId(String format, Object... args) { + this.printerId = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for printingMethods. + *

    + * Generated from setter {@link Printer#setPrintingMethods(List) setPrintingMethods(List printingMethods)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printingMethods("example value", "example value");
    +   * }
    + * + * @param printingMethods printingMethods + * @return current instance of builder + */ + public PrinterBuilder printingMethods(String... printingMethods) { + this.printingMethods = changedValue(List.of(printingMethods)); + return this; + } + + /** + * Sets the value for printingMethods. + *

    + * Generated from setter {@link Printer#setPrintingMethods(List) setPrintingMethods(List printingMethods)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printingMethods(List.of("example value"));
    +   * }
    + * + * @param printingMethods printingMethods + * @return current instance of builder + */ + public PrinterBuilder printingMethods(List printingMethods) { + this.printingMethods = changedValue(printingMethods); + return this; + } + + /** + * Sets the value for printingMethods using a builder consumer that produces the value. + *

    + * Generated from setter {@link Printer#setPrintingMethods(List) setPrintingMethods(List printingMethods)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printingMethods(t -> t.add("example value"));
    +   * }
    + * + * @param printingMethodsBuilderConsumer consumer providing an instance of a builder for printingMethods + * @return current instance of builder + */ + public PrinterBuilder printingMethods(Consumer> printingMethodsBuilderConsumer) { + ArrayListBuilder builder = this.printingMethods.isSet() + ? new ArrayListBuilder(this.printingMethods.value()) + : new ArrayListBuilder(); + printingMethodsBuilderConsumer.accept(builder); + this.printingMethods = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for printingMethods by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setPrintingMethods(List) setPrintingMethods(List printingMethods)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.printingMethods(() -> List.of("example value"));
    +   * }
    + * + * @param printingMethodsSupplier supplier for printingMethods + * @return current instance of builder + */ + public PrinterBuilder printingMethods(Supplier> printingMethodsSupplier) { + this.printingMethods = changedValue(printingMethodsSupplier.get()); + return this; + } + + /** + * Sets the value for specialization. + *

    + * Generated from setter {@link Printer#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("example value");
    +   * }
    + * + * @param specialization specialization + * @return current instance of builder + */ + public PrinterBuilder specialization(String specialization) { + this.specialization = changedValue(specialization); + return this; + } + + /** + * Sets the value for specialization by executing the provided consumer. + *

    + * Generated from setter {@link Printer#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(sb -> sb.append("text"));
    +   * }
    + * + * @param specializationStringBuilderConsumer consumer providing an instance of specialization + * @return current instance of builder + */ + public PrinterBuilder specialization(Consumer specializationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specializationStringBuilderConsumer.accept(builder); + this.specialization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialization by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(() -> "example value");
    +   * }
    + * + * @param specializationSupplier supplier for specialization + * @return current instance of builder + */ + public PrinterBuilder specialization(Supplier specializationSupplier) { + this.specialization = changedValue(specializationSupplier.get()); + return this; + } + + /** + * Sets the String value for specialization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Printer#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PrinterBuilder specialization(String format, Object... args) { + this.specialization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Printer#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public PrinterBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Printer#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public PrinterBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Printer#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public PrinterBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Printer#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public PrinterBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 PrinterBuilder 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 PrinterBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Printer result = builder.build();
    +   * }
    + */ + @Override + public Printer build() { + if (this.capacityPerDay.isSet() && this.capacityPerDay.value() == null) { + throw new IllegalStateException("Field 'capacityPerDay' is marked as non-null but null value was provided"); + } + Printer result = new Printer(); + this.capacityPerDay.ifSet(result::setCapacityPerDay); + this.createdAt.ifSet(result::setCreatedAt); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.printerId.ifSet(result::setPrinterId); + this.printingMethods.ifSet(result::setPrintingMethods); + this.specialization.ifSet(result::setSpecialization); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("capacityPerDay", this.capacityPerDay) + .append("createdAt", this.createdAt) + .append("id", this.id) + .append("name", this.name) + .append("printerId", this.printerId) + .append("printingMethods", this.printingMethods) + .append("specialization", this.specialization) + .append("status", this.status) + .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 Printer with(Consumer b) { + PrinterBuilder builder; + try { + builder = new PrinterBuilder(Printer.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PrinterBuilder.With' should only be implemented by classes, which could be casted to 'Printer'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default PrinterBuilder with() { + try { + return new PrinterBuilder(Printer.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'PrinterBuilder.With' should only be implemented by classes, which could be casted to 'Printer'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ProofreaderBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ProofreaderBuilder.java new file mode 100644 index 00000000..5fa0fba9 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ProofreaderBuilder.java @@ -0,0 +1,826 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +import org.javahelpers.simple.builders.core.interfaces.IBuilderBase; +import org.javahelpers.simple.builders.core.util.BuilderToStringStyle; +import org.javahelpers.simple.builders.core.util.TrackedValue; +import org.javahelpers.simple.builders.performance_test.library.organizations.CommercialPublisher; +import org.javahelpers.simple.builders.performance_test.library.organizations.CommercialPublisherBuilder; + +/** + * Builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Proofreader}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.Proofreader 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. + * + *

    Example:

    + * + *
    {@code
    + * Proofreader result = ProofreaderBuilder.create()
    + *     .accuracyRate(3.14)
    + *     .accuracyRate(() -> 3.14)
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .employeeId("example value")
    + *     .employeeId("Hello %s", "World")
    + *     .employeeId(() -> "example value")
    + *     .employeeId(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .languages(List.of("example value"))
    + *     .languages(() -> List.of("example value"))
    + *     .languages(t -> t.add("example value"))
    + *     .languages("example value", "example value")
    + *     .add2Languages("example value")
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .pagesPerHour(42)
    + *     .pagesPerHour(() -> 42)
    + *     .publisher(new CommercialPublisher())
    + *     .publisher(CommercialPublisher::new)
    + *     .publisher(commercialPublisherBuilder -> commercialPublisherBuilder)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Proofreader.class) +public class ProofreaderBuilder implements IBuilderBase { + + /** + * Tracked value for accuracyRate: accuracyRate. + */ + private TrackedValue accuracyRate = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for employeeId: employeeId. + */ + private TrackedValue employeeId = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for languages: languages. + */ + private TrackedValue> languages = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for pagesPerHour: pagesPerHour. + */ + private TrackedValue pagesPerHour = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.Proofreader}. + */ + public ProofreaderBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Proofreader} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public ProofreaderBuilder(Proofreader instance) { + this.accuracyRate = initialValue(instance.getAccuracyRate()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.employeeId = initialValue(instance.getEmployeeId()); + this.id = initialValue(instance.getId()); + this.languages = initialValue(instance.getLanguages()); + this.name = initialValue(instance.getName()); + this.pagesPerHour = initialValue(instance.getPagesPerHour()); + this.publisher = initialValue(instance.getPublisher()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Proofreader}. + * + *

    Example:

    + * + *
    {@code
    +   * ProofreaderBuilder builder = ProofreaderBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Proofreader} + */ + public static ProofreaderBuilder create() { + return new ProofreaderBuilder(); + } + + /** + * Sets the value for accuracyRate. + *

    + * Generated from setter {@link Proofreader#setAccuracyRate(double) setAccuracyRate(double accuracyRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accuracyRate(3.14);
    +   * }
    + * + * @param accuracyRate accuracyRate + * @return current instance of builder + */ + public ProofreaderBuilder accuracyRate(double accuracyRate) { + this.accuracyRate = changedValue(accuracyRate); + return this; + } + + /** + * Sets the value for accuracyRate by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setAccuracyRate(double) setAccuracyRate(double accuracyRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.accuracyRate(() -> 3.14);
    +   * }
    + * + * @param accuracyRateSupplier supplier for accuracyRate + * @return current instance of builder + */ + public ProofreaderBuilder accuracyRate(Supplier accuracyRateSupplier) { + this.accuracyRate = changedValue(accuracyRateSupplier.get()); + return this; + } + + /** + * Adds a single element to languages. + *

    + * Generated from setter {@link Proofreader#setLanguages(List) setLanguages(List languages)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Languages("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public ProofreaderBuilder add2Languages(String element) { + List newCollection; + if (this.languages.isSet()) { + newCollection = new ArrayList<>(this.languages.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.languages = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Proofreader#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public ProofreaderBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public ProofreaderBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for employeeId. + *

    + * Generated from setter {@link Proofreader#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId("example value");
    +   * }
    + * + * @param employeeId employeeId + * @return current instance of builder + */ + public ProofreaderBuilder employeeId(String employeeId) { + this.employeeId = changedValue(employeeId); + return this; + } + + /** + * Sets the value for employeeId by executing the provided consumer. + *

    + * Generated from setter {@link Proofreader#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId(sb -> sb.append("text"));
    +   * }
    + * + * @param employeeIdStringBuilderConsumer consumer providing an instance of employeeId + * @return current instance of builder + */ + public ProofreaderBuilder employeeId(Consumer employeeIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + employeeIdStringBuilderConsumer.accept(builder); + this.employeeId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for employeeId by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId(() -> "example value");
    +   * }
    + * + * @param employeeIdSupplier supplier for employeeId + * @return current instance of builder + */ + public ProofreaderBuilder employeeId(Supplier employeeIdSupplier) { + this.employeeId = changedValue(employeeIdSupplier.get()); + return this; + } + + /** + * Sets the String value for employeeId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Proofreader#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProofreaderBuilder employeeId(String format, Object... args) { + this.employeeId = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Proofreader#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public ProofreaderBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public ProofreaderBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for languages. + *

    + * Generated from setter {@link Proofreader#setLanguages(List) setLanguages(List languages)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languages("example value", "example value");
    +   * }
    + * + * @param languages languages + * @return current instance of builder + */ + public ProofreaderBuilder languages(String... languages) { + this.languages = changedValue(List.of(languages)); + return this; + } + + /** + * Sets the value for languages. + *

    + * Generated from setter {@link Proofreader#setLanguages(List) setLanguages(List languages)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languages(List.of("example value"));
    +   * }
    + * + * @param languages languages + * @return current instance of builder + */ + public ProofreaderBuilder languages(List languages) { + this.languages = changedValue(languages); + return this; + } + + /** + * Sets the value for languages using a builder consumer that produces the value. + *

    + * Generated from setter {@link Proofreader#setLanguages(List) setLanguages(List languages)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languages(t -> t.add("example value"));
    +   * }
    + * + * @param languagesBuilderConsumer consumer providing an instance of a builder for languages + * @return current instance of builder + */ + public ProofreaderBuilder languages(Consumer> languagesBuilderConsumer) { + ArrayListBuilder builder = this.languages.isSet() + ? new ArrayListBuilder(this.languages.value()) + : new ArrayListBuilder(); + languagesBuilderConsumer.accept(builder); + this.languages = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for languages by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setLanguages(List) setLanguages(List languages)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.languages(() -> List.of("example value"));
    +   * }
    + * + * @param languagesSupplier supplier for languages + * @return current instance of builder + */ + public ProofreaderBuilder languages(Supplier> languagesSupplier) { + this.languages = changedValue(languagesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Proofreader#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public ProofreaderBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Proofreader#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public ProofreaderBuilder 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. + *

    + * Generated from setter {@link Proofreader#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public ProofreaderBuilder 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. + *

    + * Generated from setter {@link Proofreader#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProofreaderBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pagesPerHour. + *

    + * Generated from setter {@link Proofreader#setPagesPerHour(int) setPagesPerHour(int pagesPerHour)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pagesPerHour(42);
    +   * }
    + * + * @param pagesPerHour pagesPerHour + * @return current instance of builder + */ + public ProofreaderBuilder pagesPerHour(int pagesPerHour) { + this.pagesPerHour = changedValue(pagesPerHour); + return this; + } + + /** + * Sets the value for pagesPerHour by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setPagesPerHour(int) setPagesPerHour(int pagesPerHour)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pagesPerHour(() -> 42);
    +   * }
    + * + * @param pagesPerHourSupplier supplier for pagesPerHour + * @return current instance of builder + */ + public ProofreaderBuilder pagesPerHour(Supplier pagesPerHourSupplier) { + this.pagesPerHour = changedValue(pagesPerHourSupplier.get()); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from setter {@link Proofreader#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(new CommercialPublisher());
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public ProofreaderBuilder publisher(CommercialPublisher publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher using a builder consumer that produces the value. + *

    + * Generated from setter {@link Proofreader#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(commercialPublisherBuilder -> commercialPublisherBuilder);
    +   * }
    + * + * @param publisherBuilderConsumer consumer providing an instance of a builder for publisher + * @return current instance of builder + */ + public ProofreaderBuilder publisher(Consumer publisherBuilderConsumer) { + CommercialPublisherBuilder builder = this.publisher.isSet() + ? new CommercialPublisherBuilder(this.publisher.value()) + : new CommercialPublisherBuilder(); + publisherBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(CommercialPublisher::new);
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public ProofreaderBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Proofreader#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public ProofreaderBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Proofreader#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public ProofreaderBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Proofreader#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public ProofreaderBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Proofreader#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ProofreaderBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 ProofreaderBuilder 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 ProofreaderBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Proofreader result = builder.build();
    +   * }
    + */ + @Override + public Proofreader build() { + if (this.accuracyRate.isSet() && this.accuracyRate.value() == null) { + throw new IllegalStateException("Field 'accuracyRate' is marked as non-null but null value was provided"); + } + if (this.pagesPerHour.isSet() && this.pagesPerHour.value() == null) { + throw new IllegalStateException("Field 'pagesPerHour' is marked as non-null but null value was provided"); + } + Proofreader result = new Proofreader(); + this.accuracyRate.ifSet(result::setAccuracyRate); + this.createdAt.ifSet(result::setCreatedAt); + this.employeeId.ifSet(result::setEmployeeId); + this.id.ifSet(result::setId); + this.languages.ifSet(result::setLanguages); + this.name.ifSet(result::setName); + this.pagesPerHour.ifSet(result::setPagesPerHour); + this.publisher.ifSet(result::setPublisher); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("accuracyRate", this.accuracyRate) + .append("createdAt", this.createdAt) + .append("employeeId", this.employeeId) + .append("id", this.id) + .append("languages", this.languages) + .append("name", this.name) + .append("pagesPerHour", this.pagesPerHour) + .append("publisher", this.publisher) + .append("status", this.status) + .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 Proofreader with(Consumer b) { + ProofreaderBuilder builder; + try { + builder = new ProofreaderBuilder(Proofreader.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProofreaderBuilder.With' should only be implemented by classes, which could be casted to 'Proofreader'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ProofreaderBuilder with() { + try { + return new ProofreaderBuilder(Proofreader.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ProofreaderBuilder.With' should only be implemented by classes, which could be casted to 'Proofreader'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RefereeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RefereeRecordBuilder.java new file mode 100644 index 00000000..5c2268a8 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RefereeRecordBuilder.java @@ -0,0 +1,577 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.RefereeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.RefereeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RefereeRecord result = RefereeRecordBuilder.create()
    + *     .refereeId(UUID.randomUUID())
    + *     .refereeId(() -> UUID.randomUUID())
    + *     .refereeName("example value")
    + *     .refereeName("Hello %s", "World")
    + *     .refereeName(() -> "example value")
    + *     .refereeName(sb -> sb.append("text"))
    + *     .field("example value")
    + *     .field("Hello %s", "World")
    + *     .field(() -> "example value")
    + *     .field(sb -> sb.append("text"))
    + *     .papersReviewed(42)
    + *     .papersReviewed(() -> 42)
    + *     .journals(List.of("example value"))
    + *     .journals(() -> List.of("example value"))
    + *     .journals(t -> t.add("example value"))
    + *     .journals("example value", "example value")
    + *     .add2Journals("example value")
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RefereeRecord.class) +public class RefereeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for refereeId: refereeId. + */ + private TrackedValue refereeId = unsetValue(); + /** + * Tracked value for refereeName: refereeName. + */ + private TrackedValue refereeName = unsetValue(); + /** + * Tracked value for field: field. + */ + private TrackedValue field = unsetValue(); + /** + * Tracked value for papersReviewed: papersReviewed. + */ + private TrackedValue papersReviewed = unsetValue(); + /** + * Tracked value for journals: journals. + */ + private TrackedValue> journals = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RefereeRecord}. + */ + public RefereeRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RefereeRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public RefereeRecordBuilder(RefereeRecord instance) { + this.refereeId = initialValue(instance.refereeId()); + this.refereeName = initialValue(instance.refereeName()); + this.field = initialValue(instance.field()); + this.papersReviewed = initialValue(instance.papersReviewed()); + this.journals = initialValue(instance.journals()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.RefereeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RefereeRecordBuilder builder = RefereeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.RefereeRecord} + */ + public static RefereeRecordBuilder create() { + return new RefereeRecordBuilder(); + } + + /** + * Adds a single element to journals. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Journals("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public RefereeRecordBuilder add2Journals(String element) { + List newCollection; + if (this.journals.isSet()) { + newCollection = new ArrayList<>(this.journals.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.journals = changedValue(newCollection); + return this; + } + + /** + * Sets the value for field. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("example value");
    +   * }
    + * + * @param field field + * @return current instance of builder + */ + public RefereeRecordBuilder field(String field) { + this.field = changedValue(field); + return this; + } + + /** + * Sets the value for field by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(sb -> sb.append("text"));
    +   * }
    + * + * @param fieldStringBuilderConsumer consumer providing an instance of field + * @return current instance of builder + */ + public RefereeRecordBuilder field(Consumer fieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fieldStringBuilderConsumer.accept(builder); + this.field = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for field by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(() -> "example value");
    +   * }
    + * + * @param fieldSupplier supplier for field + * @return current instance of builder + */ + public RefereeRecordBuilder field(Supplier fieldSupplier) { + this.field = changedValue(fieldSupplier.get()); + return this; + } + + /** + * Sets the String value for field by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RefereeRecordBuilder field(String format, Object... args) { + this.field = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for journals. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journals("example value", "example value");
    +   * }
    + * + * @param journals journals + * @return current instance of builder + */ + public RefereeRecordBuilder journals(String... journals) { + this.journals = changedValue(List.of(journals)); + return this; + } + + /** + * Sets the value for journals. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journals(List.of("example value"));
    +   * }
    + * + * @param journals journals + * @return current instance of builder + */ + public RefereeRecordBuilder journals(List journals) { + this.journals = changedValue(journals); + return this; + } + + /** + * Sets the value for journals using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journals(t -> t.add("example value"));
    +   * }
    + * + * @param journalsBuilderConsumer consumer providing an instance of a builder for journals + * @return current instance of builder + */ + public RefereeRecordBuilder journals(Consumer> journalsBuilderConsumer) { + ArrayListBuilder builder = this.journals.isSet() + ? new ArrayListBuilder(this.journals.value()) + : new ArrayListBuilder(); + journalsBuilderConsumer.accept(builder); + this.journals = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for journals by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journals(() -> List.of("example value"));
    +   * }
    + * + * @param journalsSupplier supplier for journals + * @return current instance of builder + */ + public RefereeRecordBuilder journals(Supplier> journalsSupplier) { + this.journals = changedValue(journalsSupplier.get()); + return this; + } + + /** + * Sets the value for papersReviewed. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.papersReviewed(42);
    +   * }
    + * + * @param papersReviewed papersReviewed + * @return current instance of builder + */ + public RefereeRecordBuilder papersReviewed(int papersReviewed) { + this.papersReviewed = changedValue(papersReviewed); + return this; + } + + /** + * Sets the value for papersReviewed by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.papersReviewed(() -> 42);
    +   * }
    + * + * @param papersReviewedSupplier supplier for papersReviewed + * @return current instance of builder + */ + public RefereeRecordBuilder papersReviewed(Supplier papersReviewedSupplier) { + this.papersReviewed = changedValue(papersReviewedSupplier.get()); + return this; + } + + /** + * Sets the value for refereeId. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.refereeId(UUID.randomUUID());
    +   * }
    + * + * @param refereeId refereeId + * @return current instance of builder + */ + public RefereeRecordBuilder refereeId(UUID refereeId) { + this.refereeId = changedValue(refereeId); + return this; + } + + /** + * Sets the value for refereeId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.refereeId(() -> UUID.randomUUID());
    +   * }
    + * + * @param refereeIdSupplier supplier for refereeId + * @return current instance of builder + */ + public RefereeRecordBuilder refereeId(Supplier refereeIdSupplier) { + this.refereeId = changedValue(refereeIdSupplier.get()); + return this; + } + + /** + * Sets the value for refereeName. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.refereeName("example value");
    +   * }
    + * + * @param refereeName refereeName + * @return current instance of builder + */ + public RefereeRecordBuilder refereeName(String refereeName) { + this.refereeName = changedValue(refereeName); + return this; + } + + /** + * Sets the value for refereeName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.refereeName(sb -> sb.append("text"));
    +   * }
    + * + * @param refereeNameStringBuilderConsumer consumer providing an instance of refereeName + * @return current instance of builder + */ + public RefereeRecordBuilder refereeName(Consumer refereeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + refereeNameStringBuilderConsumer.accept(builder); + this.refereeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for refereeName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.refereeName(() -> "example value");
    +   * }
    + * + * @param refereeNameSupplier supplier for refereeName + * @return current instance of builder + */ + public RefereeRecordBuilder refereeName(Supplier refereeNameSupplier) { + this.refereeName = changedValue(refereeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for refereeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RefereeRecord#RefereeRecord(UUID, String, String, int, List) + * RefereeRecord(UUID refereeId, String refereeName, String field, int papersReviewed, List journals)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.refereeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RefereeRecordBuilder refereeName(String format, Object... args) { + this.refereeName = changedValue(String.format(format, args)); + 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 RefereeRecordBuilder 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 RefereeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RefereeRecord result = builder.build();
    +   * }
    + */ + @Override + public RefereeRecord build() { + if (!this.papersReviewed.isSet()) { + throw new IllegalStateException("Required field 'papersReviewed' must be set before calling build()"); + } + if (this.papersReviewed.value() == null) { + throw new IllegalStateException("Field 'papersReviewed' is marked as non-null but null value was provided"); + } + RefereeRecord result = new RefereeRecord(this.refereeId + .value(), this.refereeName.value(), this.field.value(), this.papersReviewed.value(), this.journals.value()); + 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("refereeId", this.refereeId) + .append("refereeName", this.refereeName) + .append("field", this.field) + .append("papersReviewed", this.papersReviewed) + .append("journals", this.journals) + .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 RefereeRecord with(Consumer b) { + RefereeRecordBuilder builder; + try { + builder = new RefereeRecordBuilder(RefereeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RefereeRecordBuilder.With' should only be implemented by classes, which could be casted to 'RefereeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RefereeRecordBuilder with() { + try { + return new RefereeRecordBuilder(RefereeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RefereeRecordBuilder.With' should only be implemented by classes, which could be casted to 'RefereeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RepresentativeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RepresentativeRecordBuilder.java new file mode 100644 index 00000000..61e98883 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RepresentativeRecordBuilder.java @@ -0,0 +1,529 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.RepresentativeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.RepresentativeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RepresentativeRecord result = RepresentativeRecordBuilder.create()
    + *     .representativeId(UUID.randomUUID())
    + *     .representativeId(() -> UUID.randomUUID())
    + *     .representativeName("example value")
    + *     .representativeName("Hello %s", "World")
    + *     .representativeName(() -> "example value")
    + *     .representativeName(sb -> sb.append("text"))
    + *     .constituency("example value")
    + *     .constituency("Hello %s", "World")
    + *     .constituency(() -> "example value")
    + *     .constituency(sb -> sb.append("text"))
    + *     .termStart(LocalDate.now())
    + *     .termStart(() -> LocalDate.now())
    + *     .termEnd(LocalDate.now())
    + *     .termEnd(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RepresentativeRecord.class) +public class RepresentativeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for representativeId: representativeId. + */ + private TrackedValue representativeId = unsetValue(); + /** + * Tracked value for representativeName: representativeName. + */ + private TrackedValue representativeName = unsetValue(); + /** + * Tracked value for constituency: constituency. + */ + private TrackedValue constituency = unsetValue(); + /** + * Tracked value for termStart: termStart. + */ + private TrackedValue termStart = unsetValue(); + /** + * Tracked value for termEnd: termEnd. + */ + private TrackedValue termEnd = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RepresentativeRecord}. + */ + public RepresentativeRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RepresentativeRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public RepresentativeRecordBuilder(RepresentativeRecord instance) { + this.representativeId = initialValue(instance.representativeId()); + this.representativeName = initialValue(instance.representativeName()); + this.constituency = initialValue(instance.constituency()); + this.termStart = initialValue(instance.termStart()); + this.termEnd = initialValue(instance.termEnd()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RepresentativeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RepresentativeRecordBuilder builder = RepresentativeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.RepresentativeRecord} + */ + public static RepresentativeRecordBuilder create() { + return new RepresentativeRecordBuilder(); + } + + /** + * Sets the value for constituency. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.constituency("example value");
    +   * }
    + * + * @param constituency constituency + * @return current instance of builder + */ + public RepresentativeRecordBuilder constituency(String constituency) { + this.constituency = changedValue(constituency); + return this; + } + + /** + * Sets the value for constituency by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.constituency(sb -> sb.append("text"));
    +   * }
    + * + * @param constituencyStringBuilderConsumer consumer providing an instance of constituency + * @return current instance of builder + */ + public RepresentativeRecordBuilder constituency(Consumer constituencyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + constituencyStringBuilderConsumer.accept(builder); + this.constituency = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for constituency by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.constituency(() -> "example value");
    +   * }
    + * + * @param constituencySupplier supplier for constituency + * @return current instance of builder + */ + public RepresentativeRecordBuilder constituency(Supplier constituencySupplier) { + this.constituency = changedValue(constituencySupplier.get()); + return this; + } + + /** + * Sets the String value for constituency by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.constituency("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RepresentativeRecordBuilder constituency(String format, Object... args) { + this.constituency = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for representativeId. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.representativeId(UUID.randomUUID());
    +   * }
    + * + * @param representativeId representativeId + * @return current instance of builder + */ + public RepresentativeRecordBuilder representativeId(UUID representativeId) { + this.representativeId = changedValue(representativeId); + return this; + } + + /** + * Sets the value for representativeId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.representativeId(() -> UUID.randomUUID());
    +   * }
    + * + * @param representativeIdSupplier supplier for representativeId + * @return current instance of builder + */ + public RepresentativeRecordBuilder representativeId(Supplier representativeIdSupplier) { + this.representativeId = changedValue(representativeIdSupplier.get()); + return this; + } + + /** + * Sets the value for representativeName. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.representativeName("example value");
    +   * }
    + * + * @param representativeName representativeName + * @return current instance of builder + */ + public RepresentativeRecordBuilder representativeName(String representativeName) { + this.representativeName = changedValue(representativeName); + return this; + } + + /** + * Sets the value for representativeName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.representativeName(sb -> sb.append("text"));
    +   * }
    + * + * @param representativeNameStringBuilderConsumer consumer providing an instance of representativeName + * @return current instance of builder + */ + public RepresentativeRecordBuilder representativeName( + Consumer representativeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + representativeNameStringBuilderConsumer.accept(builder); + this.representativeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for representativeName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.representativeName(() -> "example value");
    +   * }
    + * + * @param representativeNameSupplier supplier for representativeName + * @return current instance of builder + */ + public RepresentativeRecordBuilder representativeName(Supplier representativeNameSupplier) { + this.representativeName = changedValue(representativeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for representativeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.representativeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RepresentativeRecordBuilder representativeName(String format, Object... args) { + this.representativeName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for termEnd. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termEnd(LocalDate.now());
    +   * }
    + * + * @param termEnd termEnd + * @return current instance of builder + */ + public RepresentativeRecordBuilder termEnd(LocalDate termEnd) { + this.termEnd = changedValue(termEnd); + return this; + } + + /** + * Sets the value for termEnd by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termEnd(() -> LocalDate.now());
    +   * }
    + * + * @param termEndSupplier supplier for termEnd + * @return current instance of builder + */ + public RepresentativeRecordBuilder termEnd(Supplier termEndSupplier) { + this.termEnd = changedValue(termEndSupplier.get()); + return this; + } + + /** + * Sets the value for termStart. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termStart(LocalDate.now());
    +   * }
    + * + * @param termStart termStart + * @return current instance of builder + */ + public RepresentativeRecordBuilder termStart(LocalDate termStart) { + this.termStart = changedValue(termStart); + return this; + } + + /** + * Sets the value for termStart by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link RepresentativeRecord#RepresentativeRecord(UUID, String, String, LocalDate, LocalDate) + * RepresentativeRecord(UUID representativeId, String representativeName, String constituency, LocalDate termStart, + * LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termStart(() -> LocalDate.now());
    +   * }
    + * + * @param termStartSupplier supplier for termStart + * @return current instance of builder + */ + public RepresentativeRecordBuilder termStart(Supplier termStartSupplier) { + this.termStart = changedValue(termStartSupplier.get()); + 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 RepresentativeRecordBuilder 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 RepresentativeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RepresentativeRecord result = builder.build();
    +   * }
    + */ + @Override + public RepresentativeRecord build() { + RepresentativeRecord result = new RepresentativeRecord(this.representativeId.value(), + this.representativeName.value(), + this.constituency.value(), + this.termStart.value(), + this.termEnd.value()); + 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("representativeId", this.representativeId) + .append("representativeName", this.representativeName) + .append("constituency", this.constituency) + .append("termStart", this.termStart) + .append("termEnd", this.termEnd) + .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 RepresentativeRecord with(Consumer b) { + RepresentativeRecordBuilder builder; + try { + builder = new RepresentativeRecordBuilder(RepresentativeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RepresentativeRecordBuilder.With' should only be implemented by classes, which could be casted to 'RepresentativeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RepresentativeRecordBuilder with() { + try { + return new RepresentativeRecordBuilder(RepresentativeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RepresentativeRecordBuilder.With' should only be implemented by classes, which could be casted to 'RepresentativeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResearcherRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResearcherRecordBuilder.java new file mode 100644 index 00000000..7087a8c2 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResearcherRecordBuilder.java @@ -0,0 +1,548 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.ResearcherRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.ResearcherRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ResearcherRecord result = ResearcherRecordBuilder.create()
    + *     .researcherId(UUID.randomUUID())
    + *     .researcherId(() -> UUID.randomUUID())
    + *     .researcherName("example value")
    + *     .researcherName("Hello %s", "World")
    + *     .researcherName(() -> "example value")
    + *     .researcherName(sb -> sb.append("text"))
    + *     .field("example value")
    + *     .field("Hello %s", "World")
    + *     .field(() -> "example value")
    + *     .field(sb -> sb.append("text"))
    + *     .publications(42)
    + *     .publications(() -> 42)
    + *     .institution("example value")
    + *     .institution("Hello %s", "World")
    + *     .institution(() -> "example value")
    + *     .institution(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResearcherRecord.class) +public class ResearcherRecordBuilder implements IBuilderBase { + + /** + * Tracked value for researcherId: researcherId. + */ + private TrackedValue researcherId = unsetValue(); + /** + * Tracked value for researcherName: researcherName. + */ + private TrackedValue researcherName = unsetValue(); + /** + * Tracked value for field: field. + */ + private TrackedValue field = unsetValue(); + /** + * Tracked value for publications: publications. + */ + private TrackedValue publications = unsetValue(); + /** + * Tracked value for institution: institution. + */ + private TrackedValue institution = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ResearcherRecord}. + */ + public ResearcherRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ResearcherRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResearcherRecordBuilder(ResearcherRecord instance) { + this.researcherId = initialValue(instance.researcherId()); + this.researcherName = initialValue(instance.researcherName()); + this.field = initialValue(instance.field()); + this.publications = initialValue(instance.publications()); + this.institution = initialValue(instance.institution()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ResearcherRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ResearcherRecordBuilder builder = ResearcherRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ResearcherRecord} + */ + public static ResearcherRecordBuilder create() { + return new ResearcherRecordBuilder(); + } + + /** + * Sets the value for field. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("example value");
    +   * }
    + * + * @param field field + * @return current instance of builder + */ + public ResearcherRecordBuilder field(String field) { + this.field = changedValue(field); + return this; + } + + /** + * Sets the value for field by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(sb -> sb.append("text"));
    +   * }
    + * + * @param fieldStringBuilderConsumer consumer providing an instance of field + * @return current instance of builder + */ + public ResearcherRecordBuilder field(Consumer fieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fieldStringBuilderConsumer.accept(builder); + this.field = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for field by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(() -> "example value");
    +   * }
    + * + * @param fieldSupplier supplier for field + * @return current instance of builder + */ + public ResearcherRecordBuilder field(Supplier fieldSupplier) { + this.field = changedValue(fieldSupplier.get()); + return this; + } + + /** + * Sets the String value for field by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearcherRecordBuilder field(String format, Object... args) { + this.field = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for institution. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution("example value");
    +   * }
    + * + * @param institution institution + * @return current instance of builder + */ + public ResearcherRecordBuilder institution(String institution) { + this.institution = changedValue(institution); + return this; + } + + /** + * Sets the value for institution by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution(sb -> sb.append("text"));
    +   * }
    + * + * @param institutionStringBuilderConsumer consumer providing an instance of institution + * @return current instance of builder + */ + public ResearcherRecordBuilder institution(Consumer institutionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + institutionStringBuilderConsumer.accept(builder); + this.institution = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for institution by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution(() -> "example value");
    +   * }
    + * + * @param institutionSupplier supplier for institution + * @return current instance of builder + */ + public ResearcherRecordBuilder institution(Supplier institutionSupplier) { + this.institution = changedValue(institutionSupplier.get()); + return this; + } + + /** + * Sets the String value for institution by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearcherRecordBuilder institution(String format, Object... args) { + this.institution = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publications. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publications(42);
    +   * }
    + * + * @param publications publications + * @return current instance of builder + */ + public ResearcherRecordBuilder publications(int publications) { + this.publications = changedValue(publications); + return this; + } + + /** + * Sets the value for publications by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publications(() -> 42);
    +   * }
    + * + * @param publicationsSupplier supplier for publications + * @return current instance of builder + */ + public ResearcherRecordBuilder publications(Supplier publicationsSupplier) { + this.publications = changedValue(publicationsSupplier.get()); + return this; + } + + /** + * Sets the value for researcherId. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherId(UUID.randomUUID());
    +   * }
    + * + * @param researcherId researcherId + * @return current instance of builder + */ + public ResearcherRecordBuilder researcherId(UUID researcherId) { + this.researcherId = changedValue(researcherId); + return this; + } + + /** + * Sets the value for researcherId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherId(() -> UUID.randomUUID());
    +   * }
    + * + * @param researcherIdSupplier supplier for researcherId + * @return current instance of builder + */ + public ResearcherRecordBuilder researcherId(Supplier researcherIdSupplier) { + this.researcherId = changedValue(researcherIdSupplier.get()); + return this; + } + + /** + * Sets the value for researcherName. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherName("example value");
    +   * }
    + * + * @param researcherName researcherName + * @return current instance of builder + */ + public ResearcherRecordBuilder researcherName(String researcherName) { + this.researcherName = changedValue(researcherName); + return this; + } + + /** + * Sets the value for researcherName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherName(sb -> sb.append("text"));
    +   * }
    + * + * @param researcherNameStringBuilderConsumer consumer providing an instance of researcherName + * @return current instance of builder + */ + public ResearcherRecordBuilder researcherName(Consumer researcherNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + researcherNameStringBuilderConsumer.accept(builder); + this.researcherName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for researcherName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherName(() -> "example value");
    +   * }
    + * + * @param researcherNameSupplier supplier for researcherName + * @return current instance of builder + */ + public ResearcherRecordBuilder researcherName(Supplier researcherNameSupplier) { + this.researcherName = changedValue(researcherNameSupplier.get()); + return this; + } + + /** + * Sets the String value for researcherName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResearcherRecord#ResearcherRecord(UUID, String, String, int, String) + * ResearcherRecord(UUID researcherId, String researcherName, String field, int publications, String institution)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.researcherName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResearcherRecordBuilder researcherName(String format, Object... args) { + this.researcherName = changedValue(String.format(format, args)); + 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 ResearcherRecordBuilder 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 ResearcherRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResearcherRecord result = builder.build();
    +   * }
    + */ + @Override + public ResearcherRecord build() { + if (!this.publications.isSet()) { + throw new IllegalStateException("Required field 'publications' must be set before calling build()"); + } + if (this.publications.value() == null) { + throw new IllegalStateException("Field 'publications' is marked as non-null but null value was provided"); + } + ResearcherRecord result = new ResearcherRecord(this.researcherId + .value(), this.researcherName.value(), this.field.value(), this.publications.value(), this.institution.value()); + 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("researcherId", this.researcherId) + .append("researcherName", this.researcherName) + .append("field", this.field) + .append("publications", this.publications) + .append("institution", this.institution) + .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 ResearcherRecord with(Consumer b) { + ResearcherRecordBuilder builder; + try { + builder = new ResearcherRecordBuilder(ResearcherRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearcherRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResearcherRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResearcherRecordBuilder with() { + try { + return new ResearcherRecordBuilder(ResearcherRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResearcherRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResearcherRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResidentRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResidentRecordBuilder.java new file mode 100644 index 00000000..87729ff0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ResidentRecordBuilder.java @@ -0,0 +1,546 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.ResidentRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.ResidentRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ResidentRecord result = ResidentRecordBuilder.create()
    + *     .residentId(UUID.randomUUID())
    + *     .residentId(() -> UUID.randomUUID())
    + *     .residentName("example value")
    + *     .residentName("Hello %s", "World")
    + *     .residentName(() -> "example value")
    + *     .residentName(sb -> sb.append("text"))
    + *     .program("example value")
    + *     .program("Hello %s", "World")
    + *     .program(() -> "example value")
    + *     .program(sb -> sb.append("text"))
    + *     .year(42)
    + *     .year(() -> 42)
    + *     .specialization("example value")
    + *     .specialization("Hello %s", "World")
    + *     .specialization(() -> "example value")
    + *     .specialization(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ResidentRecord.class) +public class ResidentRecordBuilder implements IBuilderBase { + + /** + * Tracked value for residentId: residentId. + */ + private TrackedValue residentId = unsetValue(); + /** + * Tracked value for residentName: residentName. + */ + private TrackedValue residentName = unsetValue(); + /** + * Tracked value for program: program. + */ + private TrackedValue program = unsetValue(); + /** + * Tracked value for year: year. + */ + private TrackedValue year = unsetValue(); + /** + * Tracked value for specialization: specialization. + */ + private TrackedValue specialization = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ResidentRecord}. + */ + public ResidentRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ResidentRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ResidentRecordBuilder(ResidentRecord instance) { + this.residentId = initialValue(instance.residentId()); + this.residentName = initialValue(instance.residentName()); + this.program = initialValue(instance.program()); + this.year = initialValue(instance.year()); + this.specialization = initialValue(instance.specialization()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ResidentRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ResidentRecordBuilder builder = ResidentRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ResidentRecord} + */ + public static ResidentRecordBuilder create() { + return new ResidentRecordBuilder(); + } + + /** + * Sets the value for program. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program("example value");
    +   * }
    + * + * @param program program + * @return current instance of builder + */ + public ResidentRecordBuilder program(String program) { + this.program = changedValue(program); + return this; + } + + /** + * Sets the value for program by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program(sb -> sb.append("text"));
    +   * }
    + * + * @param programStringBuilderConsumer consumer providing an instance of program + * @return current instance of builder + */ + public ResidentRecordBuilder program(Consumer programStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + programStringBuilderConsumer.accept(builder); + this.program = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for program by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program(() -> "example value");
    +   * }
    + * + * @param programSupplier supplier for program + * @return current instance of builder + */ + public ResidentRecordBuilder program(Supplier programSupplier) { + this.program = changedValue(programSupplier.get()); + return this; + } + + /** + * Sets the String value for program by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResidentRecordBuilder program(String format, Object... args) { + this.program = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for residentId. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentId(UUID.randomUUID());
    +   * }
    + * + * @param residentId residentId + * @return current instance of builder + */ + public ResidentRecordBuilder residentId(UUID residentId) { + this.residentId = changedValue(residentId); + return this; + } + + /** + * Sets the value for residentId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentId(() -> UUID.randomUUID());
    +   * }
    + * + * @param residentIdSupplier supplier for residentId + * @return current instance of builder + */ + public ResidentRecordBuilder residentId(Supplier residentIdSupplier) { + this.residentId = changedValue(residentIdSupplier.get()); + return this; + } + + /** + * Sets the value for residentName. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentName("example value");
    +   * }
    + * + * @param residentName residentName + * @return current instance of builder + */ + public ResidentRecordBuilder residentName(String residentName) { + this.residentName = changedValue(residentName); + return this; + } + + /** + * Sets the value for residentName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentName(sb -> sb.append("text"));
    +   * }
    + * + * @param residentNameStringBuilderConsumer consumer providing an instance of residentName + * @return current instance of builder + */ + public ResidentRecordBuilder residentName(Consumer residentNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + residentNameStringBuilderConsumer.accept(builder); + this.residentName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for residentName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentName(() -> "example value");
    +   * }
    + * + * @param residentNameSupplier supplier for residentName + * @return current instance of builder + */ + public ResidentRecordBuilder residentName(Supplier residentNameSupplier) { + this.residentName = changedValue(residentNameSupplier.get()); + return this; + } + + /** + * Sets the String value for residentName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.residentName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResidentRecordBuilder residentName(String format, Object... args) { + this.residentName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for specialization. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("example value");
    +   * }
    + * + * @param specialization specialization + * @return current instance of builder + */ + public ResidentRecordBuilder specialization(String specialization) { + this.specialization = changedValue(specialization); + return this; + } + + /** + * Sets the value for specialization by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(sb -> sb.append("text"));
    +   * }
    + * + * @param specializationStringBuilderConsumer consumer providing an instance of specialization + * @return current instance of builder + */ + public ResidentRecordBuilder specialization(Consumer specializationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specializationStringBuilderConsumer.accept(builder); + this.specialization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialization by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(() -> "example value");
    +   * }
    + * + * @param specializationSupplier supplier for specialization + * @return current instance of builder + */ + public ResidentRecordBuilder specialization(Supplier specializationSupplier) { + this.specialization = changedValue(specializationSupplier.get()); + return this; + } + + /** + * Sets the String value for specialization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ResidentRecordBuilder specialization(String format, Object... args) { + this.specialization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for year. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.year(42);
    +   * }
    + * + * @param year year + * @return current instance of builder + */ + public ResidentRecordBuilder year(int year) { + this.year = changedValue(year); + return this; + } + + /** + * Sets the value for year by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ResidentRecord#ResidentRecord(UUID, String, String, int, String) + * ResidentRecord(UUID residentId, String residentName, String program, int year, String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.year(() -> 42);
    +   * }
    + * + * @param yearSupplier supplier for year + * @return current instance of builder + */ + public ResidentRecordBuilder year(Supplier yearSupplier) { + this.year = changedValue(yearSupplier.get()); + 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 ResidentRecordBuilder 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 ResidentRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ResidentRecord result = builder.build();
    +   * }
    + */ + @Override + public ResidentRecord build() { + if (!this.year.isSet()) { + throw new IllegalStateException("Required field 'year' must be set before calling build()"); + } + if (this.year.value() == null) { + throw new IllegalStateException("Field 'year' is marked as non-null but null value was provided"); + } + ResidentRecord result = new ResidentRecord(this.residentId + .value(), this.residentName.value(), this.program.value(), this.year.value(), this.specialization.value()); + 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("residentId", this.residentId) + .append("residentName", this.residentName) + .append("program", this.program) + .append("year", this.year) + .append("specialization", this.specialization) + .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 ResidentRecord with(Consumer b) { + ResidentRecordBuilder builder; + try { + builder = new ResidentRecordBuilder(ResidentRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResidentRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResidentRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ResidentRecordBuilder with() { + try { + return new ResidentRecordBuilder(ResidentRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ResidentRecordBuilder.With' should only be implemented by classes, which could be casted to 'ResidentRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RestorerRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RestorerRecordBuilder.java new file mode 100644 index 00000000..b90353d4 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/RestorerRecordBuilder.java @@ -0,0 +1,523 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.RestorerRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.RestorerRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * RestorerRecord result = RestorerRecordBuilder.create()
    + *     .restorerId(UUID.randomUUID())
    + *     .restorerId(() -> UUID.randomUUID())
    + *     .restorerName("example value")
    + *     .restorerName("Hello %s", "World")
    + *     .restorerName(() -> "example value")
    + *     .restorerName(sb -> sb.append("text"))
    + *     .specialization("example value")
    + *     .specialization("Hello %s", "World")
    + *     .specialization(() -> "example value")
    + *     .specialization(sb -> sb.append("text"))
    + *     .itemsRestored(42)
    + *     .itemsRestored(() -> 42)
    + *     .yearsExperience(42)
    + *     .yearsExperience(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = RestorerRecord.class) +public class RestorerRecordBuilder implements IBuilderBase { + + /** + * Tracked value for restorerId: restorerId. + */ + private TrackedValue restorerId = unsetValue(); + /** + * Tracked value for restorerName: restorerName. + */ + private TrackedValue restorerName = unsetValue(); + /** + * Tracked value for specialization: specialization. + */ + private TrackedValue specialization = unsetValue(); + /** + * Tracked value for itemsRestored: itemsRestored. + */ + private TrackedValue itemsRestored = unsetValue(); + /** + * Tracked value for yearsExperience: yearsExperience. + */ + private TrackedValue yearsExperience = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RestorerRecord}. + */ + public RestorerRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.RestorerRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public RestorerRecordBuilder(RestorerRecord instance) { + this.restorerId = initialValue(instance.restorerId()); + this.restorerName = initialValue(instance.restorerName()); + this.specialization = initialValue(instance.specialization()); + this.itemsRestored = initialValue(instance.itemsRestored()); + this.yearsExperience = initialValue(instance.yearsExperience()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.RestorerRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * RestorerRecordBuilder builder = RestorerRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.RestorerRecord} + */ + public static RestorerRecordBuilder create() { + return new RestorerRecordBuilder(); + } + + /** + * Sets the value for itemsRestored. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.itemsRestored(42);
    +   * }
    + * + * @param itemsRestored itemsRestored + * @return current instance of builder + */ + public RestorerRecordBuilder itemsRestored(int itemsRestored) { + this.itemsRestored = changedValue(itemsRestored); + return this; + } + + /** + * Sets the value for itemsRestored by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.itemsRestored(() -> 42);
    +   * }
    + * + * @param itemsRestoredSupplier supplier for itemsRestored + * @return current instance of builder + */ + public RestorerRecordBuilder itemsRestored(Supplier itemsRestoredSupplier) { + this.itemsRestored = changedValue(itemsRestoredSupplier.get()); + return this; + } + + /** + * Sets the value for restorerId. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.restorerId(UUID.randomUUID());
    +   * }
    + * + * @param restorerId restorerId + * @return current instance of builder + */ + public RestorerRecordBuilder restorerId(UUID restorerId) { + this.restorerId = changedValue(restorerId); + return this; + } + + /** + * Sets the value for restorerId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.restorerId(() -> UUID.randomUUID());
    +   * }
    + * + * @param restorerIdSupplier supplier for restorerId + * @return current instance of builder + */ + public RestorerRecordBuilder restorerId(Supplier restorerIdSupplier) { + this.restorerId = changedValue(restorerIdSupplier.get()); + return this; + } + + /** + * Sets the value for restorerName. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.restorerName("example value");
    +   * }
    + * + * @param restorerName restorerName + * @return current instance of builder + */ + public RestorerRecordBuilder restorerName(String restorerName) { + this.restorerName = changedValue(restorerName); + return this; + } + + /** + * Sets the value for restorerName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.restorerName(sb -> sb.append("text"));
    +   * }
    + * + * @param restorerNameStringBuilderConsumer consumer providing an instance of restorerName + * @return current instance of builder + */ + public RestorerRecordBuilder restorerName(Consumer restorerNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + restorerNameStringBuilderConsumer.accept(builder); + this.restorerName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for restorerName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.restorerName(() -> "example value");
    +   * }
    + * + * @param restorerNameSupplier supplier for restorerName + * @return current instance of builder + */ + public RestorerRecordBuilder restorerName(Supplier restorerNameSupplier) { + this.restorerName = changedValue(restorerNameSupplier.get()); + return this; + } + + /** + * Sets the String value for restorerName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.restorerName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RestorerRecordBuilder restorerName(String format, Object... args) { + this.restorerName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for specialization. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("example value");
    +   * }
    + * + * @param specialization specialization + * @return current instance of builder + */ + public RestorerRecordBuilder specialization(String specialization) { + this.specialization = changedValue(specialization); + return this; + } + + /** + * Sets the value for specialization by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(sb -> sb.append("text"));
    +   * }
    + * + * @param specializationStringBuilderConsumer consumer providing an instance of specialization + * @return current instance of builder + */ + public RestorerRecordBuilder specialization(Consumer specializationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specializationStringBuilderConsumer.accept(builder); + this.specialization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialization by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(() -> "example value");
    +   * }
    + * + * @param specializationSupplier supplier for specialization + * @return current instance of builder + */ + public RestorerRecordBuilder specialization(Supplier specializationSupplier) { + this.specialization = changedValue(specializationSupplier.get()); + return this; + } + + /** + * Sets the String value for specialization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public RestorerRecordBuilder specialization(String format, Object... args) { + this.specialization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for yearsExperience. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(42);
    +   * }
    + * + * @param yearsExperience yearsExperience + * @return current instance of builder + */ + public RestorerRecordBuilder yearsExperience(int yearsExperience) { + this.yearsExperience = changedValue(yearsExperience); + return this; + } + + /** + * Sets the value for yearsExperience by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link RestorerRecord#RestorerRecord(UUID, String, String, int, int) + * RestorerRecord(UUID restorerId, String restorerName, String specialization, int itemsRestored, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(() -> 42);
    +   * }
    + * + * @param yearsExperienceSupplier supplier for yearsExperience + * @return current instance of builder + */ + public RestorerRecordBuilder yearsExperience(Supplier yearsExperienceSupplier) { + this.yearsExperience = changedValue(yearsExperienceSupplier.get()); + 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 RestorerRecordBuilder 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 RestorerRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * RestorerRecord result = builder.build();
    +   * }
    + */ + @Override + public RestorerRecord build() { + if (!this.itemsRestored.isSet()) { + throw new IllegalStateException("Required field 'itemsRestored' must be set before calling build()"); + } + if (this.itemsRestored.value() == null) { + throw new IllegalStateException("Field 'itemsRestored' is marked as non-null but null value was provided"); + } + if (!this.yearsExperience.isSet()) { + throw new IllegalStateException("Required field 'yearsExperience' must be set before calling build()"); + } + if (this.yearsExperience.value() == null) { + throw new IllegalStateException("Field 'yearsExperience' is marked as non-null but null value was provided"); + } + RestorerRecord result = new RestorerRecord(this.restorerId.value(), + this.restorerName.value(), + this.specialization.value(), + this.itemsRestored.value(), + this.yearsExperience.value()); + 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("restorerId", this.restorerId) + .append("restorerName", this.restorerName) + .append("specialization", this.specialization) + .append("itemsRestored", this.itemsRestored) + .append("yearsExperience", this.yearsExperience) + .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 RestorerRecord with(Consumer b) { + RestorerRecordBuilder builder; + try { + builder = new RestorerRecordBuilder(RestorerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RestorerRecordBuilder.With' should only be implemented by classes, which could be casted to 'RestorerRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default RestorerRecordBuilder with() { + try { + return new RestorerRecordBuilder(RestorerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'RestorerRecordBuilder.With' should only be implemented by classes, which could be casted to 'RestorerRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ReviewerRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ReviewerRecordBuilder.java new file mode 100644 index 00000000..33fe02c6 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ReviewerRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.ReviewerRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.ReviewerRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ReviewerRecord result = ReviewerRecordBuilder.create()
    + *     .reviewerId(UUID.randomUUID())
    + *     .reviewerId(() -> UUID.randomUUID())
    + *     .reviewerName("example value")
    + *     .reviewerName("Hello %s", "World")
    + *     .reviewerName(() -> "example value")
    + *     .reviewerName(sb -> sb.append("text"))
    + *     .expertiseArea("example value")
    + *     .expertiseArea("Hello %s", "World")
    + *     .expertiseArea(() -> "example value")
    + *     .expertiseArea(sb -> sb.append("text"))
    + *     .reviewsCompleted(42)
    + *     .reviewsCompleted(() -> 42)
    + *     .rating(3.14)
    + *     .rating(() -> 3.14)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ReviewerRecord.class) +public class ReviewerRecordBuilder implements IBuilderBase { + + /** + * Tracked value for reviewerId: reviewerId. + */ + private TrackedValue reviewerId = unsetValue(); + /** + * Tracked value for reviewerName: reviewerName. + */ + private TrackedValue reviewerName = unsetValue(); + /** + * Tracked value for expertiseArea: expertiseArea. + */ + private TrackedValue expertiseArea = unsetValue(); + /** + * Tracked value for reviewsCompleted: reviewsCompleted. + */ + private TrackedValue reviewsCompleted = unsetValue(); + /** + * Tracked value for rating: rating. + */ + private TrackedValue rating = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ReviewerRecord}. + */ + public ReviewerRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ReviewerRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ReviewerRecordBuilder(ReviewerRecord instance) { + this.reviewerId = initialValue(instance.reviewerId()); + this.reviewerName = initialValue(instance.reviewerName()); + this.expertiseArea = initialValue(instance.expertiseArea()); + this.reviewsCompleted = initialValue(instance.reviewsCompleted()); + this.rating = initialValue(instance.rating()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ReviewerRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ReviewerRecordBuilder builder = ReviewerRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ReviewerRecord} + */ + public static ReviewerRecordBuilder create() { + return new ReviewerRecordBuilder(); + } + + /** + * Sets the value for expertiseArea. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea("example value");
    +   * }
    + * + * @param expertiseArea expertiseArea + * @return current instance of builder + */ + public ReviewerRecordBuilder expertiseArea(String expertiseArea) { + this.expertiseArea = changedValue(expertiseArea); + return this; + } + + /** + * Sets the value for expertiseArea by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea(sb -> sb.append("text"));
    +   * }
    + * + * @param expertiseAreaStringBuilderConsumer consumer providing an instance of expertiseArea + * @return current instance of builder + */ + public ReviewerRecordBuilder expertiseArea(Consumer expertiseAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + expertiseAreaStringBuilderConsumer.accept(builder); + this.expertiseArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for expertiseArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea(() -> "example value");
    +   * }
    + * + * @param expertiseAreaSupplier supplier for expertiseArea + * @return current instance of builder + */ + public ReviewerRecordBuilder expertiseArea(Supplier expertiseAreaSupplier) { + this.expertiseArea = changedValue(expertiseAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for expertiseArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.expertiseArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReviewerRecordBuilder expertiseArea(String format, Object... args) { + this.expertiseArea = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for rating. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.rating(3.14);
    +   * }
    + * + * @param rating rating + * @return current instance of builder + */ + public ReviewerRecordBuilder rating(double rating) { + this.rating = changedValue(rating); + return this; + } + + /** + * Sets the value for rating by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.rating(() -> 3.14);
    +   * }
    + * + * @param ratingSupplier supplier for rating + * @return current instance of builder + */ + public ReviewerRecordBuilder rating(Supplier ratingSupplier) { + this.rating = changedValue(ratingSupplier.get()); + return this; + } + + /** + * Sets the value for reviewerId. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerId(UUID.randomUUID());
    +   * }
    + * + * @param reviewerId reviewerId + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewerId(UUID reviewerId) { + this.reviewerId = changedValue(reviewerId); + return this; + } + + /** + * Sets the value for reviewerId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerId(() -> UUID.randomUUID());
    +   * }
    + * + * @param reviewerIdSupplier supplier for reviewerId + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewerId(Supplier reviewerIdSupplier) { + this.reviewerId = changedValue(reviewerIdSupplier.get()); + return this; + } + + /** + * Sets the value for reviewerName. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerName("example value");
    +   * }
    + * + * @param reviewerName reviewerName + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewerName(String reviewerName) { + this.reviewerName = changedValue(reviewerName); + return this; + } + + /** + * Sets the value for reviewerName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerName(sb -> sb.append("text"));
    +   * }
    + * + * @param reviewerNameStringBuilderConsumer consumer providing an instance of reviewerName + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewerName(Consumer reviewerNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + reviewerNameStringBuilderConsumer.accept(builder); + this.reviewerName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for reviewerName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerName(() -> "example value");
    +   * }
    + * + * @param reviewerNameSupplier supplier for reviewerName + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewerName(Supplier reviewerNameSupplier) { + this.reviewerName = changedValue(reviewerNameSupplier.get()); + return this; + } + + /** + * Sets the String value for reviewerName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewerName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewerName(String format, Object... args) { + this.reviewerName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for reviewsCompleted. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewsCompleted(42);
    +   * }
    + * + * @param reviewsCompleted reviewsCompleted + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewsCompleted(int reviewsCompleted) { + this.reviewsCompleted = changedValue(reviewsCompleted); + return this; + } + + /** + * Sets the value for reviewsCompleted by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ReviewerRecord#ReviewerRecord(UUID, String, String, int, double) + * ReviewerRecord(UUID reviewerId, String reviewerName, String expertiseArea, int reviewsCompleted, double rating)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.reviewsCompleted(() -> 42);
    +   * }
    + * + * @param reviewsCompletedSupplier supplier for reviewsCompleted + * @return current instance of builder + */ + public ReviewerRecordBuilder reviewsCompleted(Supplier reviewsCompletedSupplier) { + this.reviewsCompleted = changedValue(reviewsCompletedSupplier.get()); + 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 ReviewerRecordBuilder 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 ReviewerRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ReviewerRecord result = builder.build();
    +   * }
    + */ + @Override + public ReviewerRecord build() { + if (!this.reviewsCompleted.isSet()) { + throw new IllegalStateException("Required field 'reviewsCompleted' must be set before calling build()"); + } + if (this.reviewsCompleted.value() == null) { + throw new IllegalStateException("Field 'reviewsCompleted' is marked as non-null but null value was provided"); + } + if (!this.rating.isSet()) { + throw new IllegalStateException("Required field 'rating' must be set before calling build()"); + } + if (this.rating.value() == null) { + throw new IllegalStateException("Field 'rating' is marked as non-null but null value was provided"); + } + ReviewerRecord result = new ReviewerRecord(this.reviewerId.value(), + this.reviewerName.value(), + this.expertiseArea.value(), + this.reviewsCompleted.value(), + this.rating.value()); + 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("reviewerId", this.reviewerId) + .append("reviewerName", this.reviewerName) + .append("expertiseArea", this.expertiseArea) + .append("reviewsCompleted", this.reviewsCompleted) + .append("rating", this.rating) + .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 ReviewerRecord with(Consumer b) { + ReviewerRecordBuilder builder; + try { + builder = new ReviewerRecordBuilder(ReviewerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ReviewerRecordBuilder.With' should only be implemented by classes, which could be casted to 'ReviewerRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ReviewerRecordBuilder with() { + try { + return new ReviewerRecordBuilder(ReviewerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ReviewerRecordBuilder.With' should only be implemented by classes, which could be casted to 'ReviewerRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ScholarRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ScholarRecordBuilder.java new file mode 100644 index 00000000..dc954843 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/ScholarRecordBuilder.java @@ -0,0 +1,546 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.ScholarRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.ScholarRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * ScholarRecord result = ScholarRecordBuilder.create()
    + *     .scholarId(UUID.randomUUID())
    + *     .scholarId(() -> UUID.randomUUID())
    + *     .scholarName("example value")
    + *     .scholarName("Hello %s", "World")
    + *     .scholarName(() -> "example value")
    + *     .scholarName(sb -> sb.append("text"))
    + *     .field("example value")
    + *     .field("Hello %s", "World")
    + *     .field(() -> "example value")
    + *     .field(sb -> sb.append("text"))
    + *     .institution("example value")
    + *     .institution("Hello %s", "World")
    + *     .institution(() -> "example value")
    + *     .institution(sb -> sb.append("text"))
    + *     .publications(42)
    + *     .publications(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = ScholarRecord.class) +public class ScholarRecordBuilder implements IBuilderBase { + + /** + * Tracked value for scholarId: scholarId. + */ + private TrackedValue scholarId = unsetValue(); + /** + * Tracked value for scholarName: scholarName. + */ + private TrackedValue scholarName = unsetValue(); + /** + * Tracked value for field: field. + */ + private TrackedValue field = unsetValue(); + /** + * Tracked value for institution: institution. + */ + private TrackedValue institution = unsetValue(); + /** + * Tracked value for publications: publications. + */ + private TrackedValue publications = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ScholarRecord}. + */ + public ScholarRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.ScholarRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public ScholarRecordBuilder(ScholarRecord instance) { + this.scholarId = initialValue(instance.scholarId()); + this.scholarName = initialValue(instance.scholarName()); + this.field = initialValue(instance.field()); + this.institution = initialValue(instance.institution()); + this.publications = initialValue(instance.publications()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ScholarRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarRecordBuilder builder = ScholarRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.ScholarRecord} + */ + public static ScholarRecordBuilder create() { + return new ScholarRecordBuilder(); + } + + /** + * Sets the value for field. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("example value");
    +   * }
    + * + * @param field field + * @return current instance of builder + */ + public ScholarRecordBuilder field(String field) { + this.field = changedValue(field); + return this; + } + + /** + * Sets the value for field by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(sb -> sb.append("text"));
    +   * }
    + * + * @param fieldStringBuilderConsumer consumer providing an instance of field + * @return current instance of builder + */ + public ScholarRecordBuilder field(Consumer fieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + fieldStringBuilderConsumer.accept(builder); + this.field = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for field by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field(() -> "example value");
    +   * }
    + * + * @param fieldSupplier supplier for field + * @return current instance of builder + */ + public ScholarRecordBuilder field(Supplier fieldSupplier) { + this.field = changedValue(fieldSupplier.get()); + return this; + } + + /** + * Sets the String value for field by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.field("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarRecordBuilder field(String format, Object... args) { + this.field = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for institution. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution("example value");
    +   * }
    + * + * @param institution institution + * @return current instance of builder + */ + public ScholarRecordBuilder institution(String institution) { + this.institution = changedValue(institution); + return this; + } + + /** + * Sets the value for institution by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution(sb -> sb.append("text"));
    +   * }
    + * + * @param institutionStringBuilderConsumer consumer providing an instance of institution + * @return current instance of builder + */ + public ScholarRecordBuilder institution(Consumer institutionStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + institutionStringBuilderConsumer.accept(builder); + this.institution = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for institution by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution(() -> "example value");
    +   * }
    + * + * @param institutionSupplier supplier for institution + * @return current instance of builder + */ + public ScholarRecordBuilder institution(Supplier institutionSupplier) { + this.institution = changedValue(institutionSupplier.get()); + return this; + } + + /** + * Sets the String value for institution by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.institution("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarRecordBuilder institution(String format, Object... args) { + this.institution = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for publications. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publications(42);
    +   * }
    + * + * @param publications publications + * @return current instance of builder + */ + public ScholarRecordBuilder publications(int publications) { + this.publications = changedValue(publications); + return this; + } + + /** + * Sets the value for publications by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publications(() -> 42);
    +   * }
    + * + * @param publicationsSupplier supplier for publications + * @return current instance of builder + */ + public ScholarRecordBuilder publications(Supplier publicationsSupplier) { + this.publications = changedValue(publicationsSupplier.get()); + return this; + } + + /** + * Sets the value for scholarId. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarId(UUID.randomUUID());
    +   * }
    + * + * @param scholarId scholarId + * @return current instance of builder + */ + public ScholarRecordBuilder scholarId(UUID scholarId) { + this.scholarId = changedValue(scholarId); + return this; + } + + /** + * Sets the value for scholarId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarId(() -> UUID.randomUUID());
    +   * }
    + * + * @param scholarIdSupplier supplier for scholarId + * @return current instance of builder + */ + public ScholarRecordBuilder scholarId(Supplier scholarIdSupplier) { + this.scholarId = changedValue(scholarIdSupplier.get()); + return this; + } + + /** + * Sets the value for scholarName. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarName("example value");
    +   * }
    + * + * @param scholarName scholarName + * @return current instance of builder + */ + public ScholarRecordBuilder scholarName(String scholarName) { + this.scholarName = changedValue(scholarName); + return this; + } + + /** + * Sets the value for scholarName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarName(sb -> sb.append("text"));
    +   * }
    + * + * @param scholarNameStringBuilderConsumer consumer providing an instance of scholarName + * @return current instance of builder + */ + public ScholarRecordBuilder scholarName(Consumer scholarNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + scholarNameStringBuilderConsumer.accept(builder); + this.scholarName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for scholarName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarName(() -> "example value");
    +   * }
    + * + * @param scholarNameSupplier supplier for scholarName + * @return current instance of builder + */ + public ScholarRecordBuilder scholarName(Supplier scholarNameSupplier) { + this.scholarName = changedValue(scholarNameSupplier.get()); + return this; + } + + /** + * Sets the String value for scholarName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link ScholarRecord#ScholarRecord(UUID, String, String, String, int) + * ScholarRecord(UUID scholarId, String scholarName, String field, String institution, int publications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.scholarName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public ScholarRecordBuilder scholarName(String format, Object... args) { + this.scholarName = changedValue(String.format(format, args)); + 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 ScholarRecordBuilder 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 ScholarRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * ScholarRecord result = builder.build();
    +   * }
    + */ + @Override + public ScholarRecord build() { + if (!this.publications.isSet()) { + throw new IllegalStateException("Required field 'publications' must be set before calling build()"); + } + if (this.publications.value() == null) { + throw new IllegalStateException("Field 'publications' is marked as non-null but null value was provided"); + } + ScholarRecord result = new ScholarRecord(this.scholarId + .value(), this.scholarName.value(), this.field.value(), this.institution.value(), this.publications.value()); + 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("scholarId", this.scholarId) + .append("scholarName", this.scholarName) + .append("field", this.field) + .append("institution", this.institution) + .append("publications", this.publications) + .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 ScholarRecord with(Consumer b) { + ScholarRecordBuilder builder; + try { + builder = new ScholarRecordBuilder(ScholarRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScholarRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default ScholarRecordBuilder with() { + try { + return new ScholarRecordBuilder(ScholarRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'ScholarRecordBuilder.With' should only be implemented by classes, which could be casted to 'ScholarRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SpecialistRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SpecialistRecordBuilder.java new file mode 100644 index 00000000..3c366796 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SpecialistRecordBuilder.java @@ -0,0 +1,599 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.SpecialistRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.SpecialistRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SpecialistRecord result = SpecialistRecordBuilder.create()
    + *     .specialistId(UUID.randomUUID())
    + *     .specialistId(() -> UUID.randomUUID())
    + *     .specialistName("example value")
    + *     .specialistName("Hello %s", "World")
    + *     .specialistName(() -> "example value")
    + *     .specialistName(sb -> sb.append("text"))
    + *     .specialty("example value")
    + *     .specialty("Hello %s", "World")
    + *     .specialty(() -> "example value")
    + *     .specialty(sb -> sb.append("text"))
    + *     .certifications(List.of("example value"))
    + *     .certifications(() -> List.of("example value"))
    + *     .certifications(t -> t.add("example value"))
    + *     .certifications("example value", "example value")
    + *     .add2Certifications("example value")
    + *     .yearsExperience(42)
    + *     .yearsExperience(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SpecialistRecord.class) +public class SpecialistRecordBuilder implements IBuilderBase { + + /** + * Tracked value for specialistId: specialistId. + */ + private TrackedValue specialistId = unsetValue(); + /** + * Tracked value for specialistName: specialistName. + */ + private TrackedValue specialistName = unsetValue(); + /** + * Tracked value for specialty: specialty. + */ + private TrackedValue specialty = unsetValue(); + /** + * Tracked value for certifications: certifications. + */ + private TrackedValue> certifications = unsetValue(); + /** + * Tracked value for yearsExperience: yearsExperience. + */ + private TrackedValue yearsExperience = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SpecialistRecord}. + */ + public SpecialistRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SpecialistRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SpecialistRecordBuilder(SpecialistRecord instance) { + this.specialistId = initialValue(instance.specialistId()); + this.specialistName = initialValue(instance.specialistName()); + this.specialty = initialValue(instance.specialty()); + this.certifications = initialValue(instance.certifications()); + this.yearsExperience = initialValue(instance.yearsExperience()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SpecialistRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SpecialistRecordBuilder builder = SpecialistRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.SpecialistRecord} + */ + public static SpecialistRecordBuilder create() { + return new SpecialistRecordBuilder(); + } + + /** + * Adds a single element to certifications. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Certifications("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public SpecialistRecordBuilder add2Certifications(String element) { + List newCollection; + if (this.certifications.isSet()) { + newCollection = new ArrayList<>(this.certifications.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.certifications = changedValue(newCollection); + return this; + } + + /** + * Sets the value for certifications. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications("example value", "example value");
    +   * }
    + * + * @param certifications certifications + * @return current instance of builder + */ + public SpecialistRecordBuilder certifications(String... certifications) { + this.certifications = changedValue(List.of(certifications)); + return this; + } + + /** + * Sets the value for certifications. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications(List.of("example value"));
    +   * }
    + * + * @param certifications certifications + * @return current instance of builder + */ + public SpecialistRecordBuilder certifications(List certifications) { + this.certifications = changedValue(certifications); + return this; + } + + /** + * Sets the value for certifications using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications(t -> t.add("example value"));
    +   * }
    + * + * @param certificationsBuilderConsumer consumer providing an instance of a builder for certifications + * @return current instance of builder + */ + public SpecialistRecordBuilder certifications(Consumer> certificationsBuilderConsumer) { + ArrayListBuilder builder = this.certifications.isSet() + ? new ArrayListBuilder(this.certifications.value()) + : new ArrayListBuilder(); + certificationsBuilderConsumer.accept(builder); + this.certifications = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for certifications by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications(() -> List.of("example value"));
    +   * }
    + * + * @param certificationsSupplier supplier for certifications + * @return current instance of builder + */ + public SpecialistRecordBuilder certifications(Supplier> certificationsSupplier) { + this.certifications = changedValue(certificationsSupplier.get()); + return this; + } + + /** + * Sets the value for specialistId. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialistId(UUID.randomUUID());
    +   * }
    + * + * @param specialistId specialistId + * @return current instance of builder + */ + public SpecialistRecordBuilder specialistId(UUID specialistId) { + this.specialistId = changedValue(specialistId); + return this; + } + + /** + * Sets the value for specialistId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialistId(() -> UUID.randomUUID());
    +   * }
    + * + * @param specialistIdSupplier supplier for specialistId + * @return current instance of builder + */ + public SpecialistRecordBuilder specialistId(Supplier specialistIdSupplier) { + this.specialistId = changedValue(specialistIdSupplier.get()); + return this; + } + + /** + * Sets the value for specialistName. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialistName("example value");
    +   * }
    + * + * @param specialistName specialistName + * @return current instance of builder + */ + public SpecialistRecordBuilder specialistName(String specialistName) { + this.specialistName = changedValue(specialistName); + return this; + } + + /** + * Sets the value for specialistName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialistName(sb -> sb.append("text"));
    +   * }
    + * + * @param specialistNameStringBuilderConsumer consumer providing an instance of specialistName + * @return current instance of builder + */ + public SpecialistRecordBuilder specialistName(Consumer specialistNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specialistNameStringBuilderConsumer.accept(builder); + this.specialistName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialistName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialistName(() -> "example value");
    +   * }
    + * + * @param specialistNameSupplier supplier for specialistName + * @return current instance of builder + */ + public SpecialistRecordBuilder specialistName(Supplier specialistNameSupplier) { + this.specialistName = changedValue(specialistNameSupplier.get()); + return this; + } + + /** + * Sets the String value for specialistName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialistName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialistRecordBuilder specialistName(String format, Object... args) { + this.specialistName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for specialty. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty("example value");
    +   * }
    + * + * @param specialty specialty + * @return current instance of builder + */ + public SpecialistRecordBuilder specialty(String specialty) { + this.specialty = changedValue(specialty); + return this; + } + + /** + * Sets the value for specialty by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty(sb -> sb.append("text"));
    +   * }
    + * + * @param specialtyStringBuilderConsumer consumer providing an instance of specialty + * @return current instance of builder + */ + public SpecialistRecordBuilder specialty(Consumer specialtyStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specialtyStringBuilderConsumer.accept(builder); + this.specialty = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialty by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty(() -> "example value");
    +   * }
    + * + * @param specialtySupplier supplier for specialty + * @return current instance of builder + */ + public SpecialistRecordBuilder specialty(Supplier specialtySupplier) { + this.specialty = changedValue(specialtySupplier.get()); + return this; + } + + /** + * Sets the String value for specialty by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialty("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SpecialistRecordBuilder specialty(String format, Object... args) { + this.specialty = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for yearsExperience. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(42);
    +   * }
    + * + * @param yearsExperience yearsExperience + * @return current instance of builder + */ + public SpecialistRecordBuilder yearsExperience(int yearsExperience) { + this.yearsExperience = changedValue(yearsExperience); + return this; + } + + /** + * Sets the value for yearsExperience by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SpecialistRecord#SpecialistRecord(UUID, String, String, List, int) + * SpecialistRecord(UUID specialistId, String specialistName, String specialty, List certifications, int + * yearsExperience)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.yearsExperience(() -> 42);
    +   * }
    + * + * @param yearsExperienceSupplier supplier for yearsExperience + * @return current instance of builder + */ + public SpecialistRecordBuilder yearsExperience(Supplier yearsExperienceSupplier) { + this.yearsExperience = changedValue(yearsExperienceSupplier.get()); + 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 SpecialistRecordBuilder 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 SpecialistRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SpecialistRecord result = builder.build();
    +   * }
    + */ + @Override + public SpecialistRecord build() { + if (!this.yearsExperience.isSet()) { + throw new IllegalStateException("Required field 'yearsExperience' must be set before calling build()"); + } + if (this.yearsExperience.value() == null) { + throw new IllegalStateException("Field 'yearsExperience' is marked as non-null but null value was provided"); + } + SpecialistRecord result = new SpecialistRecord(this.specialistId.value(), + this.specialistName.value(), + this.specialty.value(), + this.certifications.value(), + this.yearsExperience.value()); + 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("specialistId", this.specialistId) + .append("specialistName", this.specialistName) + .append("specialty", this.specialty) + .append("certifications", this.certifications) + .append("yearsExperience", this.yearsExperience) + .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 SpecialistRecord with(Consumer b) { + SpecialistRecordBuilder builder; + try { + builder = new SpecialistRecordBuilder(SpecialistRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SpecialistRecordBuilder.With' should only be implemented by classes, which could be casted to 'SpecialistRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SpecialistRecordBuilder with() { + try { + return new SpecialistRecordBuilder(SpecialistRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SpecialistRecordBuilder.With' should only be implemented by classes, which could be casted to 'SpecialistRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SponsorRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SponsorRecordBuilder.java new file mode 100644 index 00000000..aa11e361 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SponsorRecordBuilder.java @@ -0,0 +1,513 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.math.BigDecimal; +import java.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.SponsorRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.SponsorRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SponsorRecord result = SponsorRecordBuilder.create()
    + *     .sponsorId(UUID.randomUUID())
    + *     .sponsorId(() -> UUID.randomUUID())
    + *     .sponsorName("example value")
    + *     .sponsorName("Hello %s", "World")
    + *     .sponsorName(() -> "example value")
    + *     .sponsorName(sb -> sb.append("text"))
    + *     .sponsorshipLevel("example value")
    + *     .sponsorshipLevel("Hello %s", "World")
    + *     .sponsorshipLevel(() -> "example value")
    + *     .sponsorshipLevel(sb -> sb.append("text"))
    + *     .totalContributed(BigDecimal.valueOf(3.14))
    + *     .totalContributed(() -> BigDecimal.valueOf(3.14))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SponsorRecord.class) +public class SponsorRecordBuilder implements IBuilderBase { + + /** + * Tracked value for sponsorId: sponsorId. + */ + private TrackedValue sponsorId = unsetValue(); + /** + * Tracked value for sponsorName: sponsorName. + */ + private TrackedValue sponsorName = unsetValue(); + /** + * Tracked value for sponsorshipLevel: sponsorshipLevel. + */ + private TrackedValue sponsorshipLevel = unsetValue(); + /** + * Tracked value for totalContributed: totalContributed. + */ + private TrackedValue totalContributed = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SponsorRecord}. + */ + public SponsorRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SponsorRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SponsorRecordBuilder(SponsorRecord instance) { + this.sponsorId = initialValue(instance.sponsorId()); + this.sponsorName = initialValue(instance.sponsorName()); + this.sponsorshipLevel = initialValue(instance.sponsorshipLevel()); + this.totalContributed = initialValue(instance.totalContributed()); + this.startDate = initialValue(instance.startDate()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.SponsorRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SponsorRecordBuilder builder = SponsorRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.SponsorRecord} + */ + public static SponsorRecordBuilder create() { + return new SponsorRecordBuilder(); + } + + /** + * Sets the value for sponsorId. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorId(UUID.randomUUID());
    +   * }
    + * + * @param sponsorId sponsorId + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorId(UUID sponsorId) { + this.sponsorId = changedValue(sponsorId); + return this; + } + + /** + * Sets the value for sponsorId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorId(() -> UUID.randomUUID());
    +   * }
    + * + * @param sponsorIdSupplier supplier for sponsorId + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorId(Supplier sponsorIdSupplier) { + this.sponsorId = changedValue(sponsorIdSupplier.get()); + return this; + } + + /** + * Sets the value for sponsorName. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName("example value");
    +   * }
    + * + * @param sponsorName sponsorName + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorName(String sponsorName) { + this.sponsorName = changedValue(sponsorName); + return this; + } + + /** + * Sets the value for sponsorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName(sb -> sb.append("text"));
    +   * }
    + * + * @param sponsorNameStringBuilderConsumer consumer providing an instance of sponsorName + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorName(Consumer sponsorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sponsorNameStringBuilderConsumer.accept(builder); + this.sponsorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sponsorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName(() -> "example value");
    +   * }
    + * + * @param sponsorNameSupplier supplier for sponsorName + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorName(Supplier sponsorNameSupplier) { + this.sponsorName = changedValue(sponsorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for sponsorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorName(String format, Object... args) { + this.sponsorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for sponsorshipLevel. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorshipLevel("example value");
    +   * }
    + * + * @param sponsorshipLevel sponsorshipLevel + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorshipLevel(String sponsorshipLevel) { + this.sponsorshipLevel = changedValue(sponsorshipLevel); + return this; + } + + /** + * Sets the value for sponsorshipLevel by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorshipLevel(sb -> sb.append("text"));
    +   * }
    + * + * @param sponsorshipLevelStringBuilderConsumer consumer providing an instance of sponsorshipLevel + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorshipLevel(Consumer sponsorshipLevelStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + sponsorshipLevelStringBuilderConsumer.accept(builder); + this.sponsorshipLevel = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for sponsorshipLevel by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorshipLevel(() -> "example value");
    +   * }
    + * + * @param sponsorshipLevelSupplier supplier for sponsorshipLevel + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorshipLevel(Supplier sponsorshipLevelSupplier) { + this.sponsorshipLevel = changedValue(sponsorshipLevelSupplier.get()); + return this; + } + + /** + * Sets the String value for sponsorshipLevel by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sponsorshipLevel("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SponsorRecordBuilder sponsorshipLevel(String format, Object... args) { + this.sponsorshipLevel = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public SponsorRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public SponsorRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + return this; + } + + /** + * Sets the value for totalContributed. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalContributed(BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalContributed totalContributed + * @return current instance of builder + */ + public SponsorRecordBuilder totalContributed(BigDecimal totalContributed) { + this.totalContributed = changedValue(totalContributed); + return this; + } + + /** + * Sets the value for totalContributed by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link SponsorRecord#SponsorRecord(UUID, String, String, BigDecimal, LocalDate) SponsorRecord(UUID sponsorId, + * String sponsorName, String sponsorshipLevel, BigDecimal totalContributed, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.totalContributed(() -> BigDecimal.valueOf(3.14));
    +   * }
    + * + * @param totalContributedSupplier supplier for totalContributed + * @return current instance of builder + */ + public SponsorRecordBuilder totalContributed(Supplier totalContributedSupplier) { + this.totalContributed = changedValue(totalContributedSupplier.get()); + 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 SponsorRecordBuilder 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 SponsorRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SponsorRecord result = builder.build();
    +   * }
    + */ + @Override + public SponsorRecord build() { + SponsorRecord result = new SponsorRecord(this.sponsorId.value(), + this.sponsorName.value(), + this.sponsorshipLevel.value(), + this.totalContributed.value(), + this.startDate.value()); + 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("sponsorId", this.sponsorId) + .append("sponsorName", this.sponsorName) + .append("sponsorshipLevel", this.sponsorshipLevel) + .append("totalContributed", this.totalContributed) + .append("startDate", this.startDate) + .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 SponsorRecord with(Consumer b) { + SponsorRecordBuilder builder; + try { + builder = new SponsorRecordBuilder(SponsorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SponsorRecordBuilder.With' should only be implemented by classes, which could be casted to 'SponsorRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SponsorRecordBuilder with() { + try { + return new SponsorRecordBuilder(SponsorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SponsorRecordBuilder.With' should only be implemented by classes, which could be casted to 'SponsorRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StatisticianRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StatisticianRecordBuilder.java new file mode 100644 index 00000000..64196061 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StatisticianRecordBuilder.java @@ -0,0 +1,599 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.StatisticianRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.StatisticianRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * StatisticianRecord result = StatisticianRecordBuilder.create()
    + *     .statisticianId(UUID.randomUUID())
    + *     .statisticianId(() -> UUID.randomUUID())
    + *     .statisticianName("example value")
    + *     .statisticianName("Hello %s", "World")
    + *     .statisticianName(() -> "example value")
    + *     .statisticianName(sb -> sb.append("text"))
    + *     .specialization("example value")
    + *     .specialization("Hello %s", "World")
    + *     .specialization(() -> "example value")
    + *     .specialization(sb -> sb.append("text"))
    + *     .modelsDeveloped(42)
    + *     .modelsDeveloped(() -> 42)
    + *     .softwareUsed(List.of("example value"))
    + *     .softwareUsed(() -> List.of("example value"))
    + *     .softwareUsed(t -> t.add("example value"))
    + *     .softwareUsed("example value", "example value")
    + *     .add2SoftwareUsed("example value")
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StatisticianRecord.class) +public class StatisticianRecordBuilder implements IBuilderBase { + + /** + * Tracked value for statisticianId: statisticianId. + */ + private TrackedValue statisticianId = unsetValue(); + /** + * Tracked value for statisticianName: statisticianName. + */ + private TrackedValue statisticianName = unsetValue(); + /** + * Tracked value for specialization: specialization. + */ + private TrackedValue specialization = unsetValue(); + /** + * Tracked value for modelsDeveloped: modelsDeveloped. + */ + private TrackedValue modelsDeveloped = unsetValue(); + /** + * Tracked value for softwareUsed: softwareUsed. + */ + private TrackedValue> softwareUsed = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.StatisticianRecord}. + */ + public StatisticianRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.StatisticianRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public StatisticianRecordBuilder(StatisticianRecord instance) { + this.statisticianId = initialValue(instance.statisticianId()); + this.statisticianName = initialValue(instance.statisticianName()); + this.specialization = initialValue(instance.specialization()); + this.modelsDeveloped = initialValue(instance.modelsDeveloped()); + this.softwareUsed = initialValue(instance.softwareUsed()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.StatisticianRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * StatisticianRecordBuilder builder = StatisticianRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.StatisticianRecord} + */ + public static StatisticianRecordBuilder create() { + return new StatisticianRecordBuilder(); + } + + /** + * Adds a single element to softwareUsed. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2SoftwareUsed("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public StatisticianRecordBuilder add2SoftwareUsed(String element) { + List newCollection; + if (this.softwareUsed.isSet()) { + newCollection = new ArrayList<>(this.softwareUsed.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.softwareUsed = changedValue(newCollection); + return this; + } + + /** + * Sets the value for modelsDeveloped. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.modelsDeveloped(42);
    +   * }
    + * + * @param modelsDeveloped modelsDeveloped + * @return current instance of builder + */ + public StatisticianRecordBuilder modelsDeveloped(int modelsDeveloped) { + this.modelsDeveloped = changedValue(modelsDeveloped); + return this; + } + + /** + * Sets the value for modelsDeveloped by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.modelsDeveloped(() -> 42);
    +   * }
    + * + * @param modelsDevelopedSupplier supplier for modelsDeveloped + * @return current instance of builder + */ + public StatisticianRecordBuilder modelsDeveloped(Supplier modelsDevelopedSupplier) { + this.modelsDeveloped = changedValue(modelsDevelopedSupplier.get()); + return this; + } + + /** + * Sets the value for softwareUsed. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed("example value", "example value");
    +   * }
    + * + * @param softwareUsed softwareUsed + * @return current instance of builder + */ + public StatisticianRecordBuilder softwareUsed(String... softwareUsed) { + this.softwareUsed = changedValue(List.of(softwareUsed)); + return this; + } + + /** + * Sets the value for softwareUsed. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed(List.of("example value"));
    +   * }
    + * + * @param softwareUsed softwareUsed + * @return current instance of builder + */ + public StatisticianRecordBuilder softwareUsed(List softwareUsed) { + this.softwareUsed = changedValue(softwareUsed); + return this; + } + + /** + * Sets the value for softwareUsed using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed(t -> t.add("example value"));
    +   * }
    + * + * @param softwareUsedBuilderConsumer consumer providing an instance of a builder for softwareUsed + * @return current instance of builder + */ + public StatisticianRecordBuilder softwareUsed(Consumer> softwareUsedBuilderConsumer) { + ArrayListBuilder builder = this.softwareUsed.isSet() + ? new ArrayListBuilder(this.softwareUsed.value()) + : new ArrayListBuilder(); + softwareUsedBuilderConsumer.accept(builder); + this.softwareUsed = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for softwareUsed by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed(() -> List.of("example value"));
    +   * }
    + * + * @param softwareUsedSupplier supplier for softwareUsed + * @return current instance of builder + */ + public StatisticianRecordBuilder softwareUsed(Supplier> softwareUsedSupplier) { + this.softwareUsed = changedValue(softwareUsedSupplier.get()); + return this; + } + + /** + * Sets the value for specialization. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("example value");
    +   * }
    + * + * @param specialization specialization + * @return current instance of builder + */ + public StatisticianRecordBuilder specialization(String specialization) { + this.specialization = changedValue(specialization); + return this; + } + + /** + * Sets the value for specialization by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(sb -> sb.append("text"));
    +   * }
    + * + * @param specializationStringBuilderConsumer consumer providing an instance of specialization + * @return current instance of builder + */ + public StatisticianRecordBuilder specialization(Consumer specializationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specializationStringBuilderConsumer.accept(builder); + this.specialization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialization by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(() -> "example value");
    +   * }
    + * + * @param specializationSupplier supplier for specialization + * @return current instance of builder + */ + public StatisticianRecordBuilder specialization(Supplier specializationSupplier) { + this.specialization = changedValue(specializationSupplier.get()); + return this; + } + + /** + * Sets the String value for specialization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StatisticianRecordBuilder specialization(String format, Object... args) { + this.specialization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for statisticianId. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statisticianId(UUID.randomUUID());
    +   * }
    + * + * @param statisticianId statisticianId + * @return current instance of builder + */ + public StatisticianRecordBuilder statisticianId(UUID statisticianId) { + this.statisticianId = changedValue(statisticianId); + return this; + } + + /** + * Sets the value for statisticianId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statisticianId(() -> UUID.randomUUID());
    +   * }
    + * + * @param statisticianIdSupplier supplier for statisticianId + * @return current instance of builder + */ + public StatisticianRecordBuilder statisticianId(Supplier statisticianIdSupplier) { + this.statisticianId = changedValue(statisticianIdSupplier.get()); + return this; + } + + /** + * Sets the value for statisticianName. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statisticianName("example value");
    +   * }
    + * + * @param statisticianName statisticianName + * @return current instance of builder + */ + public StatisticianRecordBuilder statisticianName(String statisticianName) { + this.statisticianName = changedValue(statisticianName); + return this; + } + + /** + * Sets the value for statisticianName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statisticianName(sb -> sb.append("text"));
    +   * }
    + * + * @param statisticianNameStringBuilderConsumer consumer providing an instance of statisticianName + * @return current instance of builder + */ + public StatisticianRecordBuilder statisticianName(Consumer statisticianNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statisticianNameStringBuilderConsumer.accept(builder); + this.statisticianName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for statisticianName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statisticianName(() -> "example value");
    +   * }
    + * + * @param statisticianNameSupplier supplier for statisticianName + * @return current instance of builder + */ + public StatisticianRecordBuilder statisticianName(Supplier statisticianNameSupplier) { + this.statisticianName = changedValue(statisticianNameSupplier.get()); + return this; + } + + /** + * Sets the String value for statisticianName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link StatisticianRecord#StatisticianRecord(UUID, String, String, int, List) StatisticianRecord(UUID + * statisticianId, String statisticianName, String specialization, int modelsDeveloped, List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.statisticianName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StatisticianRecordBuilder statisticianName(String format, Object... args) { + this.statisticianName = changedValue(String.format(format, args)); + 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 StatisticianRecordBuilder 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 StatisticianRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StatisticianRecord result = builder.build();
    +   * }
    + */ + @Override + public StatisticianRecord build() { + if (!this.modelsDeveloped.isSet()) { + throw new IllegalStateException("Required field 'modelsDeveloped' must be set before calling build()"); + } + if (this.modelsDeveloped.value() == null) { + throw new IllegalStateException("Field 'modelsDeveloped' is marked as non-null but null value was provided"); + } + StatisticianRecord result = new StatisticianRecord(this.statisticianId.value(), + this.statisticianName.value(), + this.specialization.value(), + this.modelsDeveloped.value(), + this.softwareUsed.value()); + 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("statisticianId", this.statisticianId) + .append("statisticianName", this.statisticianName) + .append("specialization", this.specialization) + .append("modelsDeveloped", this.modelsDeveloped) + .append("softwareUsed", this.softwareUsed) + .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 StatisticianRecord with(Consumer b) { + StatisticianRecordBuilder builder; + try { + builder = new StatisticianRecordBuilder(StatisticianRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StatisticianRecordBuilder.With' should only be implemented by classes, which could be casted to 'StatisticianRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StatisticianRecordBuilder with() { + try { + return new StatisticianRecordBuilder(StatisticianRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StatisticianRecordBuilder.With' should only be implemented by classes, which could be casted to 'StatisticianRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StrategistRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StrategistRecordBuilder.java new file mode 100644 index 00000000..79e56ecf --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/StrategistRecordBuilder.java @@ -0,0 +1,525 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.StrategistRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.StrategistRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * StrategistRecord result = StrategistRecordBuilder.create()
    + *     .strategistId(UUID.randomUUID())
    + *     .strategistId(() -> UUID.randomUUID())
    + *     .strategistName("example value")
    + *     .strategistName("Hello %s", "World")
    + *     .strategistName(() -> "example value")
    + *     .strategistName(sb -> sb.append("text"))
    + *     .strategyArea("example value")
    + *     .strategyArea("Hello %s", "World")
    + *     .strategyArea(() -> "example value")
    + *     .strategyArea(sb -> sb.append("text"))
    + *     .strategiesDeveloped(42)
    + *     .strategiesDeveloped(() -> 42)
    + *     .experienceYears(42)
    + *     .experienceYears(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = StrategistRecord.class) +public class StrategistRecordBuilder implements IBuilderBase { + + /** + * Tracked value for strategistId: strategistId. + */ + private TrackedValue strategistId = unsetValue(); + /** + * Tracked value for strategistName: strategistName. + */ + private TrackedValue strategistName = unsetValue(); + /** + * Tracked value for strategyArea: strategyArea. + */ + private TrackedValue strategyArea = unsetValue(); + /** + * Tracked value for strategiesDeveloped: strategiesDeveloped. + */ + private TrackedValue strategiesDeveloped = unsetValue(); + /** + * Tracked value for experienceYears: experienceYears. + */ + private TrackedValue experienceYears = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.StrategistRecord}. + */ + public StrategistRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.StrategistRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public StrategistRecordBuilder(StrategistRecord instance) { + this.strategistId = initialValue(instance.strategistId()); + this.strategistName = initialValue(instance.strategistName()); + this.strategyArea = initialValue(instance.strategyArea()); + this.strategiesDeveloped = initialValue(instance.strategiesDeveloped()); + this.experienceYears = initialValue(instance.experienceYears()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.StrategistRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * StrategistRecordBuilder builder = StrategistRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.StrategistRecord} + */ + public static StrategistRecordBuilder create() { + return new StrategistRecordBuilder(); + } + + /** + * Sets the value for experienceYears. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.experienceYears(42);
    +   * }
    + * + * @param experienceYears experienceYears + * @return current instance of builder + */ + public StrategistRecordBuilder experienceYears(int experienceYears) { + this.experienceYears = changedValue(experienceYears); + return this; + } + + /** + * Sets the value for experienceYears by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.experienceYears(() -> 42);
    +   * }
    + * + * @param experienceYearsSupplier supplier for experienceYears + * @return current instance of builder + */ + public StrategistRecordBuilder experienceYears(Supplier experienceYearsSupplier) { + this.experienceYears = changedValue(experienceYearsSupplier.get()); + return this; + } + + /** + * Sets the value for strategiesDeveloped. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategiesDeveloped(42);
    +   * }
    + * + * @param strategiesDeveloped strategiesDeveloped + * @return current instance of builder + */ + public StrategistRecordBuilder strategiesDeveloped(int strategiesDeveloped) { + this.strategiesDeveloped = changedValue(strategiesDeveloped); + return this; + } + + /** + * Sets the value for strategiesDeveloped by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategiesDeveloped(() -> 42);
    +   * }
    + * + * @param strategiesDevelopedSupplier supplier for strategiesDeveloped + * @return current instance of builder + */ + public StrategistRecordBuilder strategiesDeveloped(Supplier strategiesDevelopedSupplier) { + this.strategiesDeveloped = changedValue(strategiesDevelopedSupplier.get()); + return this; + } + + /** + * Sets the value for strategistId. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategistId(UUID.randomUUID());
    +   * }
    + * + * @param strategistId strategistId + * @return current instance of builder + */ + public StrategistRecordBuilder strategistId(UUID strategistId) { + this.strategistId = changedValue(strategistId); + return this; + } + + /** + * Sets the value for strategistId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategistId(() -> UUID.randomUUID());
    +   * }
    + * + * @param strategistIdSupplier supplier for strategistId + * @return current instance of builder + */ + public StrategistRecordBuilder strategistId(Supplier strategistIdSupplier) { + this.strategistId = changedValue(strategistIdSupplier.get()); + return this; + } + + /** + * Sets the value for strategistName. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategistName("example value");
    +   * }
    + * + * @param strategistName strategistName + * @return current instance of builder + */ + public StrategistRecordBuilder strategistName(String strategistName) { + this.strategistName = changedValue(strategistName); + return this; + } + + /** + * Sets the value for strategistName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategistName(sb -> sb.append("text"));
    +   * }
    + * + * @param strategistNameStringBuilderConsumer consumer providing an instance of strategistName + * @return current instance of builder + */ + public StrategistRecordBuilder strategistName(Consumer strategistNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + strategistNameStringBuilderConsumer.accept(builder); + this.strategistName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for strategistName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategistName(() -> "example value");
    +   * }
    + * + * @param strategistNameSupplier supplier for strategistName + * @return current instance of builder + */ + public StrategistRecordBuilder strategistName(Supplier strategistNameSupplier) { + this.strategistName = changedValue(strategistNameSupplier.get()); + return this; + } + + /** + * Sets the String value for strategistName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategistName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StrategistRecordBuilder strategistName(String format, Object... args) { + this.strategistName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for strategyArea. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategyArea("example value");
    +   * }
    + * + * @param strategyArea strategyArea + * @return current instance of builder + */ + public StrategistRecordBuilder strategyArea(String strategyArea) { + this.strategyArea = changedValue(strategyArea); + return this; + } + + /** + * Sets the value for strategyArea by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategyArea(sb -> sb.append("text"));
    +   * }
    + * + * @param strategyAreaStringBuilderConsumer consumer providing an instance of strategyArea + * @return current instance of builder + */ + public StrategistRecordBuilder strategyArea(Consumer strategyAreaStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + strategyAreaStringBuilderConsumer.accept(builder); + this.strategyArea = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for strategyArea by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategyArea(() -> "example value");
    +   * }
    + * + * @param strategyAreaSupplier supplier for strategyArea + * @return current instance of builder + */ + public StrategistRecordBuilder strategyArea(Supplier strategyAreaSupplier) { + this.strategyArea = changedValue(strategyAreaSupplier.get()); + return this; + } + + /** + * Sets the String value for strategyArea by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link StrategistRecord#StrategistRecord(UUID, String, String, int, int) + * StrategistRecord(UUID strategistId, String strategistName, String strategyArea, int strategiesDeveloped, int + * experienceYears)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.strategyArea("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public StrategistRecordBuilder strategyArea(String format, Object... args) { + this.strategyArea = changedValue(String.format(format, args)); + 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 StrategistRecordBuilder 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 StrategistRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * StrategistRecord result = builder.build();
    +   * }
    + */ + @Override + public StrategistRecord build() { + if (!this.strategiesDeveloped.isSet()) { + throw new IllegalStateException("Required field 'strategiesDeveloped' must be set before calling build()"); + } + if (this.strategiesDeveloped.value() == null) { + throw new IllegalStateException("Field 'strategiesDeveloped' is marked as non-null but null value was provided"); + } + if (!this.experienceYears.isSet()) { + throw new IllegalStateException("Required field 'experienceYears' must be set before calling build()"); + } + if (this.experienceYears.value() == null) { + throw new IllegalStateException("Field 'experienceYears' is marked as non-null but null value was provided"); + } + StrategistRecord result = new StrategistRecord(this.strategistId.value(), + this.strategistName.value(), + this.strategyArea.value(), + this.strategiesDeveloped.value(), + this.experienceYears.value()); + 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("strategistId", this.strategistId) + .append("strategistName", this.strategistName) + .append("strategyArea", this.strategyArea) + .append("strategiesDeveloped", this.strategiesDeveloped) + .append("experienceYears", this.experienceYears) + .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 StrategistRecord with(Consumer b) { + StrategistRecordBuilder builder; + try { + builder = new StrategistRecordBuilder(StrategistRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StrategistRecordBuilder.With' should only be implemented by classes, which could be casted to 'StrategistRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default StrategistRecordBuilder with() { + try { + return new StrategistRecordBuilder(StrategistRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'StrategistRecordBuilder.With' should only be implemented by classes, which could be casted to 'StrategistRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SubscriptionAgentBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SubscriptionAgentBuilder.java new file mode 100644 index 00000000..aa85e64f --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SubscriptionAgentBuilder.java @@ -0,0 +1,757 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.SubscriptionAgent}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.SubscriptionAgent 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. + * + *

    Example:

    + * + *
    {@code
    + * SubscriptionAgent result = SubscriptionAgentBuilder.create()
    + *     .agentId("example value")
    + *     .agentId("Hello %s", "World")
    + *     .agentId(() -> "example value")
    + *     .agentId(sb -> sb.append("text"))
    + *     .clientLibraries(List.of("example value"))
    + *     .clientLibraries(() -> List.of("example value"))
    + *     .clientLibraries(t -> t.add("example value"))
    + *     .clientLibraries("example value", "example value")
    + *     .add2ClientLibraries("example value")
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .journalTitles(42)
    + *     .journalTitles(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .renewalRate(3.14)
    + *     .renewalRate(() -> 3.14)
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SubscriptionAgent.class) +public class SubscriptionAgentBuilder implements IBuilderBase { + + /** + * Tracked value for agentId: agentId. + */ + private TrackedValue agentId = unsetValue(); + /** + * Tracked value for clientLibraries: clientLibraries. + */ + private TrackedValue> clientLibraries = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for journalTitles: journalTitles. + */ + private TrackedValue journalTitles = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for renewalRate: renewalRate. + */ + private TrackedValue renewalRate = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SubscriptionAgent}. + */ + public SubscriptionAgentBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SubscriptionAgent} by a instance. + * + * @param instance object instance for initialisiation + */ + public SubscriptionAgentBuilder(SubscriptionAgent instance) { + this.agentId = initialValue(instance.getAgentId()); + this.clientLibraries = initialValue(instance.getClientLibraries()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.id = initialValue(instance.getId()); + this.journalTitles = initialValue(instance.getJournalTitles()); + this.name = initialValue(instance.getName()); + this.renewalRate = initialValue(instance.getRenewalRate()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SubscriptionAgent}. + * + *

    Example:

    + * + *
    {@code
    +   * SubscriptionAgentBuilder builder = SubscriptionAgentBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.SubscriptionAgent} + */ + public static SubscriptionAgentBuilder create() { + return new SubscriptionAgentBuilder(); + } + + /** + * Adds a single element to clientLibraries. + *

    + * Generated from setter {@link SubscriptionAgent#setClientLibraries(List) setClientLibraries(List + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ClientLibraries("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public SubscriptionAgentBuilder add2ClientLibraries(String element) { + List newCollection; + if (this.clientLibraries.isSet()) { + newCollection = new ArrayList<>(this.clientLibraries.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.clientLibraries = changedValue(newCollection); + return this; + } + + /** + * Sets the value for agentId. + *

    + * Generated from setter {@link SubscriptionAgent#setAgentId(String) setAgentId(String agentId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.agentId("example value");
    +   * }
    + * + * @param agentId agentId + * @return current instance of builder + */ + public SubscriptionAgentBuilder agentId(String agentId) { + this.agentId = changedValue(agentId); + return this; + } + + /** + * Sets the value for agentId by executing the provided consumer. + *

    + * Generated from setter {@link SubscriptionAgent#setAgentId(String) setAgentId(String agentId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.agentId(sb -> sb.append("text"));
    +   * }
    + * + * @param agentIdStringBuilderConsumer consumer providing an instance of agentId + * @return current instance of builder + */ + public SubscriptionAgentBuilder agentId(Consumer agentIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + agentIdStringBuilderConsumer.accept(builder); + this.agentId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for agentId by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setAgentId(String) setAgentId(String agentId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.agentId(() -> "example value");
    +   * }
    + * + * @param agentIdSupplier supplier for agentId + * @return current instance of builder + */ + public SubscriptionAgentBuilder agentId(Supplier agentIdSupplier) { + this.agentId = changedValue(agentIdSupplier.get()); + return this; + } + + /** + * Sets the String value for agentId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SubscriptionAgent#setAgentId(String) setAgentId(String agentId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.agentId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubscriptionAgentBuilder agentId(String format, Object... args) { + this.agentId = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for clientLibraries. + *

    + * Generated from setter {@link SubscriptionAgent#setClientLibraries(List) setClientLibraries(List + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientLibraries("example value", "example value");
    +   * }
    + * + * @param clientLibraries clientLibraries + * @return current instance of builder + */ + public SubscriptionAgentBuilder clientLibraries(String... clientLibraries) { + this.clientLibraries = changedValue(List.of(clientLibraries)); + return this; + } + + /** + * Sets the value for clientLibraries. + *

    + * Generated from setter {@link SubscriptionAgent#setClientLibraries(List) setClientLibraries(List + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientLibraries(List.of("example value"));
    +   * }
    + * + * @param clientLibraries clientLibraries + * @return current instance of builder + */ + public SubscriptionAgentBuilder clientLibraries(List clientLibraries) { + this.clientLibraries = changedValue(clientLibraries); + return this; + } + + /** + * Sets the value for clientLibraries using a builder consumer that produces the value. + *

    + * Generated from setter {@link SubscriptionAgent#setClientLibraries(List) setClientLibraries(List + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientLibraries(t -> t.add("example value"));
    +   * }
    + * + * @param clientLibrariesBuilderConsumer consumer providing an instance of a builder for clientLibraries + * @return current instance of builder + */ + public SubscriptionAgentBuilder clientLibraries(Consumer> clientLibrariesBuilderConsumer) { + ArrayListBuilder builder = this.clientLibraries.isSet() + ? new ArrayListBuilder(this.clientLibraries.value()) + : new ArrayListBuilder(); + clientLibrariesBuilderConsumer.accept(builder); + this.clientLibraries = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for clientLibraries by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setClientLibraries(List) setClientLibraries(List + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientLibraries(() -> List.of("example value"));
    +   * }
    + * + * @param clientLibrariesSupplier supplier for clientLibraries + * @return current instance of builder + */ + public SubscriptionAgentBuilder clientLibraries(Supplier> clientLibrariesSupplier) { + this.clientLibraries = changedValue(clientLibrariesSupplier.get()); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SubscriptionAgent#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SubscriptionAgentBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SubscriptionAgentBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SubscriptionAgent#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SubscriptionAgentBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SubscriptionAgentBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for journalTitles. + *

    + * Generated from setter {@link SubscriptionAgent#setJournalTitles(int) setJournalTitles(int journalTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalTitles(42);
    +   * }
    + * + * @param journalTitles journalTitles + * @return current instance of builder + */ + public SubscriptionAgentBuilder journalTitles(int journalTitles) { + this.journalTitles = changedValue(journalTitles); + return this; + } + + /** + * Sets the value for journalTitles by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setJournalTitles(int) setJournalTitles(int journalTitles)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.journalTitles(() -> 42);
    +   * }
    + * + * @param journalTitlesSupplier supplier for journalTitles + * @return current instance of builder + */ + public SubscriptionAgentBuilder journalTitles(Supplier journalTitlesSupplier) { + this.journalTitles = changedValue(journalTitlesSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SubscriptionAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SubscriptionAgentBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SubscriptionAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SubscriptionAgentBuilder 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. + *

    + * Generated from setter {@link SubscriptionAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SubscriptionAgentBuilder 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. + *

    + * Generated from setter {@link SubscriptionAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubscriptionAgentBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for renewalRate. + *

    + * Generated from setter {@link SubscriptionAgent#setRenewalRate(double) setRenewalRate(double renewalRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.renewalRate(3.14);
    +   * }
    + * + * @param renewalRate renewalRate + * @return current instance of builder + */ + public SubscriptionAgentBuilder renewalRate(double renewalRate) { + this.renewalRate = changedValue(renewalRate); + return this; + } + + /** + * Sets the value for renewalRate by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setRenewalRate(double) setRenewalRate(double renewalRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.renewalRate(() -> 3.14);
    +   * }
    + * + * @param renewalRateSupplier supplier for renewalRate + * @return current instance of builder + */ + public SubscriptionAgentBuilder renewalRate(Supplier renewalRateSupplier) { + this.renewalRate = changedValue(renewalRateSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SubscriptionAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SubscriptionAgentBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SubscriptionAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SubscriptionAgentBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SubscriptionAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SubscriptionAgentBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SubscriptionAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SubscriptionAgentBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 SubscriptionAgentBuilder 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 SubscriptionAgentBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SubscriptionAgent result = builder.build();
    +   * }
    + */ + @Override + public SubscriptionAgent build() { + if (this.journalTitles.isSet() && this.journalTitles.value() == null) { + throw new IllegalStateException("Field 'journalTitles' is marked as non-null but null value was provided"); + } + if (this.renewalRate.isSet() && this.renewalRate.value() == null) { + throw new IllegalStateException("Field 'renewalRate' is marked as non-null but null value was provided"); + } + SubscriptionAgent result = new SubscriptionAgent(); + this.agentId.ifSet(result::setAgentId); + this.clientLibraries.ifSet(result::setClientLibraries); + this.createdAt.ifSet(result::setCreatedAt); + this.id.ifSet(result::setId); + this.journalTitles.ifSet(result::setJournalTitles); + this.name.ifSet(result::setName); + this.renewalRate.ifSet(result::setRenewalRate); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("agentId", this.agentId) + .append("clientLibraries", this.clientLibraries) + .append("createdAt", this.createdAt) + .append("id", this.id) + .append("journalTitles", this.journalTitles) + .append("name", this.name) + .append("renewalRate", this.renewalRate) + .append("status", this.status) + .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 SubscriptionAgent with(Consumer b) { + SubscriptionAgentBuilder builder; + try { + builder = new SubscriptionAgentBuilder(SubscriptionAgent.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubscriptionAgentBuilder.With' should only be implemented by classes, which could be casted to 'SubscriptionAgent'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SubscriptionAgentBuilder with() { + try { + return new SubscriptionAgentBuilder(SubscriptionAgent.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SubscriptionAgentBuilder.With' should only be implemented by classes, which could be casted to 'SubscriptionAgent'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupervisorRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupervisorRecordBuilder.java new file mode 100644 index 00000000..0aed8370 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupervisorRecordBuilder.java @@ -0,0 +1,548 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.UUID; +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.performance_test.library.persons.SupervisorRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.SupervisorRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * SupervisorRecord result = SupervisorRecordBuilder.create()
    + *     .supervisorId(UUID.randomUUID())
    + *     .supervisorId(() -> UUID.randomUUID())
    + *     .supervisorName("example value")
    + *     .supervisorName("Hello %s", "World")
    + *     .supervisorName(() -> "example value")
    + *     .supervisorName(sb -> sb.append("text"))
    + *     .department("example value")
    + *     .department("Hello %s", "World")
    + *     .department(() -> "example value")
    + *     .department(sb -> sb.append("text"))
    + *     .teamSize(42)
    + *     .teamSize(() -> 42)
    + *     .shift("example value")
    + *     .shift("Hello %s", "World")
    + *     .shift(() -> "example value")
    + *     .shift(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SupervisorRecord.class) +public class SupervisorRecordBuilder implements IBuilderBase { + + /** + * Tracked value for supervisorId: supervisorId. + */ + private TrackedValue supervisorId = unsetValue(); + /** + * Tracked value for supervisorName: supervisorName. + */ + private TrackedValue supervisorName = unsetValue(); + /** + * Tracked value for department: department. + */ + private TrackedValue department = unsetValue(); + /** + * Tracked value for teamSize: teamSize. + */ + private TrackedValue teamSize = unsetValue(); + /** + * Tracked value for shift: shift. + */ + private TrackedValue shift = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SupervisorRecord}. + */ + public SupervisorRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SupervisorRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public SupervisorRecordBuilder(SupervisorRecord instance) { + this.supervisorId = initialValue(instance.supervisorId()); + this.supervisorName = initialValue(instance.supervisorName()); + this.department = initialValue(instance.department()); + this.teamSize = initialValue(instance.teamSize()); + this.shift = initialValue(instance.shift()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SupervisorRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * SupervisorRecordBuilder builder = SupervisorRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.SupervisorRecord} + */ + public static SupervisorRecordBuilder create() { + return new SupervisorRecordBuilder(); + } + + /** + * Sets the value for department. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.department("example value");
    +   * }
    + * + * @param department department + * @return current instance of builder + */ + public SupervisorRecordBuilder department(String department) { + this.department = changedValue(department); + return this; + } + + /** + * Sets the value for department by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.department(sb -> sb.append("text"));
    +   * }
    + * + * @param departmentStringBuilderConsumer consumer providing an instance of department + * @return current instance of builder + */ + public SupervisorRecordBuilder department(Consumer departmentStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + departmentStringBuilderConsumer.accept(builder); + this.department = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for department by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.department(() -> "example value");
    +   * }
    + * + * @param departmentSupplier supplier for department + * @return current instance of builder + */ + public SupervisorRecordBuilder department(Supplier departmentSupplier) { + this.department = changedValue(departmentSupplier.get()); + return this; + } + + /** + * Sets the String value for department by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.department("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupervisorRecordBuilder department(String format, Object... args) { + this.department = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for shift. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift("example value");
    +   * }
    + * + * @param shift shift + * @return current instance of builder + */ + public SupervisorRecordBuilder shift(String shift) { + this.shift = changedValue(shift); + return this; + } + + /** + * Sets the value for shift by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift(sb -> sb.append("text"));
    +   * }
    + * + * @param shiftStringBuilderConsumer consumer providing an instance of shift + * @return current instance of builder + */ + public SupervisorRecordBuilder shift(Consumer shiftStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + shiftStringBuilderConsumer.accept(builder); + this.shift = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for shift by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift(() -> "example value");
    +   * }
    + * + * @param shiftSupplier supplier for shift + * @return current instance of builder + */ + public SupervisorRecordBuilder shift(Supplier shiftSupplier) { + this.shift = changedValue(shiftSupplier.get()); + return this; + } + + /** + * Sets the String value for shift by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.shift("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupervisorRecordBuilder shift(String format, Object... args) { + this.shift = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for supervisorId. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supervisorId(UUID.randomUUID());
    +   * }
    + * + * @param supervisorId supervisorId + * @return current instance of builder + */ + public SupervisorRecordBuilder supervisorId(UUID supervisorId) { + this.supervisorId = changedValue(supervisorId); + return this; + } + + /** + * Sets the value for supervisorId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supervisorId(() -> UUID.randomUUID());
    +   * }
    + * + * @param supervisorIdSupplier supplier for supervisorId + * @return current instance of builder + */ + public SupervisorRecordBuilder supervisorId(Supplier supervisorIdSupplier) { + this.supervisorId = changedValue(supervisorIdSupplier.get()); + return this; + } + + /** + * Sets the value for supervisorName. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supervisorName("example value");
    +   * }
    + * + * @param supervisorName supervisorName + * @return current instance of builder + */ + public SupervisorRecordBuilder supervisorName(String supervisorName) { + this.supervisorName = changedValue(supervisorName); + return this; + } + + /** + * Sets the value for supervisorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supervisorName(sb -> sb.append("text"));
    +   * }
    + * + * @param supervisorNameStringBuilderConsumer consumer providing an instance of supervisorName + * @return current instance of builder + */ + public SupervisorRecordBuilder supervisorName(Consumer supervisorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + supervisorNameStringBuilderConsumer.accept(builder); + this.supervisorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for supervisorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supervisorName(() -> "example value");
    +   * }
    + * + * @param supervisorNameSupplier supplier for supervisorName + * @return current instance of builder + */ + public SupervisorRecordBuilder supervisorName(Supplier supervisorNameSupplier) { + this.supervisorName = changedValue(supervisorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for supervisorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supervisorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupervisorRecordBuilder supervisorName(String format, Object... args) { + this.supervisorName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for teamSize. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.teamSize(42);
    +   * }
    + * + * @param teamSize teamSize + * @return current instance of builder + */ + public SupervisorRecordBuilder teamSize(int teamSize) { + this.teamSize = changedValue(teamSize); + return this; + } + + /** + * Sets the value for teamSize by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link SupervisorRecord#SupervisorRecord(UUID, String, String, int, String) + * SupervisorRecord(UUID supervisorId, String supervisorName, String department, int teamSize, String shift)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.teamSize(() -> 42);
    +   * }
    + * + * @param teamSizeSupplier supplier for teamSize + * @return current instance of builder + */ + public SupervisorRecordBuilder teamSize(Supplier teamSizeSupplier) { + this.teamSize = changedValue(teamSizeSupplier.get()); + 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 SupervisorRecordBuilder 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 SupervisorRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SupervisorRecord result = builder.build();
    +   * }
    + */ + @Override + public SupervisorRecord build() { + if (!this.teamSize.isSet()) { + throw new IllegalStateException("Required field 'teamSize' must be set before calling build()"); + } + if (this.teamSize.value() == null) { + throw new IllegalStateException("Field 'teamSize' is marked as non-null but null value was provided"); + } + SupervisorRecord result = new SupervisorRecord(this.supervisorId + .value(), this.supervisorName.value(), this.department.value(), this.teamSize.value(), this.shift.value()); + 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("supervisorId", this.supervisorId) + .append("supervisorName", this.supervisorName) + .append("department", this.department) + .append("teamSize", this.teamSize) + .append("shift", this.shift) + .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 SupervisorRecord with(Consumer b) { + SupervisorRecordBuilder builder; + try { + builder = new SupervisorRecordBuilder(SupervisorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SupervisorRecordBuilder.With' should only be implemented by classes, which could be casted to 'SupervisorRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SupervisorRecordBuilder with() { + try { + return new SupervisorRecordBuilder(SupervisorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SupervisorRecordBuilder.With' should only be implemented by classes, which could be casted to 'SupervisorRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupplierRepresentativeBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupplierRepresentativeBuilder.java new file mode 100644 index 00000000..54d135db --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/SupplierRepresentativeBuilder.java @@ -0,0 +1,805 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.SupplierRepresentative}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.SupplierRepresentative 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. + * + *

    Example:

    + * + *
    {@code
    + * SupplierRepresentative result = SupplierRepresentativeBuilder.create()
    + *     .clientLibraries(42)
    + *     .clientLibraries(() -> 42)
    + *     .contractTerms("example value")
    + *     .contractTerms("Hello %s", "World")
    + *     .contractTerms(() -> "example value")
    + *     .contractTerms(sb -> sb.append("text"))
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .productCategories(List.of("example value"))
    + *     .productCategories(() -> List.of("example value"))
    + *     .productCategories(t -> t.add("example value"))
    + *     .productCategories("example value", "example value")
    + *     .add2ProductCategories("example value")
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .supplierId("example value")
    + *     .supplierId("Hello %s", "World")
    + *     .supplierId(() -> "example value")
    + *     .supplierId(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = SupplierRepresentative.class) +public class SupplierRepresentativeBuilder implements IBuilderBase { + + /** + * Tracked value for clientLibraries: clientLibraries. + */ + private TrackedValue clientLibraries = unsetValue(); + /** + * Tracked value for contractTerms: contractTerms. + */ + private TrackedValue contractTerms = unsetValue(); + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for productCategories: productCategories. + */ + private TrackedValue> productCategories = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for supplierId: supplierId. + */ + private TrackedValue supplierId = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SupplierRepresentative}. + */ + public SupplierRepresentativeBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SupplierRepresentative} by a instance. + * + * @param instance object instance for initialisiation + */ + public SupplierRepresentativeBuilder(SupplierRepresentative instance) { + this.clientLibraries = initialValue(instance.getClientLibraries()); + this.contractTerms = initialValue(instance.getContractTerms()); + this.createdAt = initialValue(instance.getCreatedAt()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.productCategories = initialValue(instance.getProductCategories()); + this.status = initialValue(instance.getStatus()); + this.supplierId = initialValue(instance.getSupplierId()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.SupplierRepresentative}. + * + *

    Example:

    + * + *
    {@code
    +   * SupplierRepresentativeBuilder builder = SupplierRepresentativeBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.SupplierRepresentative} + */ + public static SupplierRepresentativeBuilder create() { + return new SupplierRepresentativeBuilder(); + } + + /** + * Adds a single element to productCategories. + *

    + * Generated from setter {@link SupplierRepresentative#setProductCategories(List) setProductCategories(List + * productCategories)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2ProductCategories("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public SupplierRepresentativeBuilder add2ProductCategories(String element) { + List newCollection; + if (this.productCategories.isSet()) { + newCollection = new ArrayList<>(this.productCategories.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.productCategories = changedValue(newCollection); + return this; + } + + /** + * Sets the value for clientLibraries. + *

    + * Generated from setter {@link SupplierRepresentative#setClientLibraries(int) setClientLibraries(int + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientLibraries(42);
    +   * }
    + * + * @param clientLibraries clientLibraries + * @return current instance of builder + */ + public SupplierRepresentativeBuilder clientLibraries(int clientLibraries) { + this.clientLibraries = changedValue(clientLibraries); + return this; + } + + /** + * Sets the value for clientLibraries by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setClientLibraries(int) setClientLibraries(int + * clientLibraries)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.clientLibraries(() -> 42);
    +   * }
    + * + * @param clientLibrariesSupplier supplier for clientLibraries + * @return current instance of builder + */ + public SupplierRepresentativeBuilder clientLibraries(Supplier clientLibrariesSupplier) { + this.clientLibraries = changedValue(clientLibrariesSupplier.get()); + return this; + } + + /** + * Sets the value for contractTerms. + *

    + * Generated from setter {@link SupplierRepresentative#setContractTerms(String) setContractTerms(String + * contractTerms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contractTerms("example value");
    +   * }
    + * + * @param contractTerms contractTerms + * @return current instance of builder + */ + public SupplierRepresentativeBuilder contractTerms(String contractTerms) { + this.contractTerms = changedValue(contractTerms); + return this; + } + + /** + * Sets the value for contractTerms by executing the provided consumer. + *

    + * Generated from setter {@link SupplierRepresentative#setContractTerms(String) setContractTerms(String + * contractTerms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contractTerms(sb -> sb.append("text"));
    +   * }
    + * + * @param contractTermsStringBuilderConsumer consumer providing an instance of contractTerms + * @return current instance of builder + */ + public SupplierRepresentativeBuilder contractTerms(Consumer contractTermsStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + contractTermsStringBuilderConsumer.accept(builder); + this.contractTerms = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for contractTerms by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setContractTerms(String) setContractTerms(String + * contractTerms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contractTerms(() -> "example value");
    +   * }
    + * + * @param contractTermsSupplier supplier for contractTerms + * @return current instance of builder + */ + public SupplierRepresentativeBuilder contractTerms(Supplier contractTermsSupplier) { + this.contractTerms = changedValue(contractTermsSupplier.get()); + return this; + } + + /** + * Sets the String value for contractTerms by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SupplierRepresentative#setContractTerms(String) setContractTerms(String + * contractTerms)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.contractTerms("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupplierRepresentativeBuilder contractTerms(String format, Object... args) { + this.contractTerms = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link SupplierRepresentative#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public SupplierRepresentativeBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public SupplierRepresentativeBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link SupplierRepresentative#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public SupplierRepresentativeBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public SupplierRepresentativeBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link SupplierRepresentative#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public SupplierRepresentativeBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link SupplierRepresentative#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public SupplierRepresentativeBuilder 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. + *

    + * Generated from setter {@link SupplierRepresentative#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public SupplierRepresentativeBuilder 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. + *

    + * Generated from setter {@link SupplierRepresentative#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupplierRepresentativeBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for productCategories. + *

    + * Generated from setter {@link SupplierRepresentative#setProductCategories(List) setProductCategories(List + * productCategories)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productCategories("example value", "example value");
    +   * }
    + * + * @param productCategories productCategories + * @return current instance of builder + */ + public SupplierRepresentativeBuilder productCategories(String... productCategories) { + this.productCategories = changedValue(List.of(productCategories)); + return this; + } + + /** + * Sets the value for productCategories. + *

    + * Generated from setter {@link SupplierRepresentative#setProductCategories(List) setProductCategories(List + * productCategories)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productCategories(List.of("example value"));
    +   * }
    + * + * @param productCategories productCategories + * @return current instance of builder + */ + public SupplierRepresentativeBuilder productCategories(List productCategories) { + this.productCategories = changedValue(productCategories); + return this; + } + + /** + * Sets the value for productCategories using a builder consumer that produces the value. + *

    + * Generated from setter {@link SupplierRepresentative#setProductCategories(List) setProductCategories(List + * productCategories)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productCategories(t -> t.add("example value"));
    +   * }
    + * + * @param productCategoriesBuilderConsumer consumer providing an instance of a builder for productCategories + * @return current instance of builder + */ + public SupplierRepresentativeBuilder productCategories( + Consumer> productCategoriesBuilderConsumer) { + ArrayListBuilder builder = this.productCategories.isSet() + ? new ArrayListBuilder(this.productCategories.value()) + : new ArrayListBuilder(); + productCategoriesBuilderConsumer.accept(builder); + this.productCategories = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for productCategories by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setProductCategories(List) setProductCategories(List + * productCategories)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.productCategories(() -> List.of("example value"));
    +   * }
    + * + * @param productCategoriesSupplier supplier for productCategories + * @return current instance of builder + */ + public SupplierRepresentativeBuilder productCategories(Supplier> productCategoriesSupplier) { + this.productCategories = changedValue(productCategoriesSupplier.get()); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link SupplierRepresentative#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public SupplierRepresentativeBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link SupplierRepresentative#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public SupplierRepresentativeBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public SupplierRepresentativeBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SupplierRepresentative#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupplierRepresentativeBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for supplierId. + *

    + * Generated from setter {@link SupplierRepresentative#setSupplierId(String) setSupplierId(String supplierId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierId("example value");
    +   * }
    + * + * @param supplierId supplierId + * @return current instance of builder + */ + public SupplierRepresentativeBuilder supplierId(String supplierId) { + this.supplierId = changedValue(supplierId); + return this; + } + + /** + * Sets the value for supplierId by executing the provided consumer. + *

    + * Generated from setter {@link SupplierRepresentative#setSupplierId(String) setSupplierId(String supplierId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierId(sb -> sb.append("text"));
    +   * }
    + * + * @param supplierIdStringBuilderConsumer consumer providing an instance of supplierId + * @return current instance of builder + */ + public SupplierRepresentativeBuilder supplierId(Consumer supplierIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + supplierIdStringBuilderConsumer.accept(builder); + this.supplierId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for supplierId by invoking the provided supplier. + *

    + * Generated from setter {@link SupplierRepresentative#setSupplierId(String) setSupplierId(String supplierId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierId(() -> "example value");
    +   * }
    + * + * @param supplierIdSupplier supplier for supplierId + * @return current instance of builder + */ + public SupplierRepresentativeBuilder supplierId(Supplier supplierIdSupplier) { + this.supplierId = changedValue(supplierIdSupplier.get()); + return this; + } + + /** + * Sets the String value for supplierId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link SupplierRepresentative#setSupplierId(String) setSupplierId(String supplierId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public SupplierRepresentativeBuilder supplierId(String format, Object... args) { + this.supplierId = changedValue(String.format(format, args)); + 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 SupplierRepresentativeBuilder 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 SupplierRepresentativeBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * SupplierRepresentative result = builder.build();
    +   * }
    + */ + @Override + public SupplierRepresentative build() { + if (this.clientLibraries.isSet() && this.clientLibraries.value() == null) { + throw new IllegalStateException("Field 'clientLibraries' is marked as non-null but null value was provided"); + } + SupplierRepresentative result = new SupplierRepresentative(); + this.clientLibraries.ifSet(result::setClientLibraries); + this.contractTerms.ifSet(result::setContractTerms); + this.createdAt.ifSet(result::setCreatedAt); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.productCategories.ifSet(result::setProductCategories); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.supplierId.ifSet(result::setSupplierId); + 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("clientLibraries", this.clientLibraries) + .append("contractTerms", this.contractTerms) + .append("createdAt", this.createdAt) + .append("id", this.id) + .append("name", this.name) + .append("productCategories", this.productCategories) + .append("status", this.status) + .append("supplierId", this.supplierId) + .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 SupplierRepresentative with(Consumer b) { + SupplierRepresentativeBuilder builder; + try { + builder = new SupplierRepresentativeBuilder(SupplierRepresentative.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SupplierRepresentativeBuilder.With' should only be implemented by classes, which could be casted to 'SupplierRepresentative'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default SupplierRepresentativeBuilder with() { + try { + return new SupplierRepresentativeBuilder(SupplierRepresentative.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'SupplierRepresentativeBuilder.With' should only be implemented by classes, which could be casted to 'SupplierRepresentative'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TechnicianRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TechnicianRecordBuilder.java new file mode 100644 index 00000000..586a0965 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TechnicianRecordBuilder.java @@ -0,0 +1,599 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.TechnicianRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.TechnicianRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TechnicianRecord result = TechnicianRecordBuilder.create()
    + *     .technicianId(UUID.randomUUID())
    + *     .technicianId(() -> UUID.randomUUID())
    + *     .technicianName("example value")
    + *     .technicianName("Hello %s", "World")
    + *     .technicianName(() -> "example value")
    + *     .technicianName(sb -> sb.append("text"))
    + *     .technicalField("example value")
    + *     .technicalField("Hello %s", "World")
    + *     .technicalField(() -> "example value")
    + *     .technicalField(sb -> sb.append("text"))
    + *     .equipmentMaintained(42)
    + *     .equipmentMaintained(() -> 42)
    + *     .certifications(List.of("example value"))
    + *     .certifications(() -> List.of("example value"))
    + *     .certifications(t -> t.add("example value"))
    + *     .certifications("example value", "example value")
    + *     .add2Certifications("example value")
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TechnicianRecord.class) +public class TechnicianRecordBuilder implements IBuilderBase { + + /** + * Tracked value for technicianId: technicianId. + */ + private TrackedValue technicianId = unsetValue(); + /** + * Tracked value for technicianName: technicianName. + */ + private TrackedValue technicianName = unsetValue(); + /** + * Tracked value for technicalField: technicalField. + */ + private TrackedValue technicalField = unsetValue(); + /** + * Tracked value for equipmentMaintained: equipmentMaintained. + */ + private TrackedValue equipmentMaintained = unsetValue(); + /** + * Tracked value for certifications: certifications. + */ + private TrackedValue> certifications = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TechnicianRecord}. + */ + public TechnicianRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TechnicianRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TechnicianRecordBuilder(TechnicianRecord instance) { + this.technicianId = initialValue(instance.technicianId()); + this.technicianName = initialValue(instance.technicianName()); + this.technicalField = initialValue(instance.technicalField()); + this.equipmentMaintained = initialValue(instance.equipmentMaintained()); + this.certifications = initialValue(instance.certifications()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TechnicianRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TechnicianRecordBuilder builder = TechnicianRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.TechnicianRecord} + */ + public static TechnicianRecordBuilder create() { + return new TechnicianRecordBuilder(); + } + + /** + * Adds a single element to certifications. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2Certifications("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TechnicianRecordBuilder add2Certifications(String element) { + List newCollection; + if (this.certifications.isSet()) { + newCollection = new ArrayList<>(this.certifications.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.certifications = changedValue(newCollection); + return this; + } + + /** + * Sets the value for certifications. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications("example value", "example value");
    +   * }
    + * + * @param certifications certifications + * @return current instance of builder + */ + public TechnicianRecordBuilder certifications(String... certifications) { + this.certifications = changedValue(List.of(certifications)); + return this; + } + + /** + * Sets the value for certifications. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications(List.of("example value"));
    +   * }
    + * + * @param certifications certifications + * @return current instance of builder + */ + public TechnicianRecordBuilder certifications(List certifications) { + this.certifications = changedValue(certifications); + return this; + } + + /** + * Sets the value for certifications using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications(t -> t.add("example value"));
    +   * }
    + * + * @param certificationsBuilderConsumer consumer providing an instance of a builder for certifications + * @return current instance of builder + */ + public TechnicianRecordBuilder certifications(Consumer> certificationsBuilderConsumer) { + ArrayListBuilder builder = this.certifications.isSet() + ? new ArrayListBuilder(this.certifications.value()) + : new ArrayListBuilder(); + certificationsBuilderConsumer.accept(builder); + this.certifications = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for certifications by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.certifications(() -> List.of("example value"));
    +   * }
    + * + * @param certificationsSupplier supplier for certifications + * @return current instance of builder + */ + public TechnicianRecordBuilder certifications(Supplier> certificationsSupplier) { + this.certifications = changedValue(certificationsSupplier.get()); + return this; + } + + /** + * Sets the value for equipmentMaintained. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.equipmentMaintained(42);
    +   * }
    + * + * @param equipmentMaintained equipmentMaintained + * @return current instance of builder + */ + public TechnicianRecordBuilder equipmentMaintained(int equipmentMaintained) { + this.equipmentMaintained = changedValue(equipmentMaintained); + return this; + } + + /** + * Sets the value for equipmentMaintained by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.equipmentMaintained(() -> 42);
    +   * }
    + * + * @param equipmentMaintainedSupplier supplier for equipmentMaintained + * @return current instance of builder + */ + public TechnicianRecordBuilder equipmentMaintained(Supplier equipmentMaintainedSupplier) { + this.equipmentMaintained = changedValue(equipmentMaintainedSupplier.get()); + return this; + } + + /** + * Sets the value for technicalField. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalField("example value");
    +   * }
    + * + * @param technicalField technicalField + * @return current instance of builder + */ + public TechnicianRecordBuilder technicalField(String technicalField) { + this.technicalField = changedValue(technicalField); + return this; + } + + /** + * Sets the value for technicalField by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalField(sb -> sb.append("text"));
    +   * }
    + * + * @param technicalFieldStringBuilderConsumer consumer providing an instance of technicalField + * @return current instance of builder + */ + public TechnicianRecordBuilder technicalField(Consumer technicalFieldStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + technicalFieldStringBuilderConsumer.accept(builder); + this.technicalField = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for technicalField by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalField(() -> "example value");
    +   * }
    + * + * @param technicalFieldSupplier supplier for technicalField + * @return current instance of builder + */ + public TechnicianRecordBuilder technicalField(Supplier technicalFieldSupplier) { + this.technicalField = changedValue(technicalFieldSupplier.get()); + return this; + } + + /** + * Sets the String value for technicalField by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicalField("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TechnicianRecordBuilder technicalField(String format, Object... args) { + this.technicalField = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for technicianId. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicianId(UUID.randomUUID());
    +   * }
    + * + * @param technicianId technicianId + * @return current instance of builder + */ + public TechnicianRecordBuilder technicianId(UUID technicianId) { + this.technicianId = changedValue(technicianId); + return this; + } + + /** + * Sets the value for technicianId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicianId(() -> UUID.randomUUID());
    +   * }
    + * + * @param technicianIdSupplier supplier for technicianId + * @return current instance of builder + */ + public TechnicianRecordBuilder technicianId(Supplier technicianIdSupplier) { + this.technicianId = changedValue(technicianIdSupplier.get()); + return this; + } + + /** + * Sets the value for technicianName. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicianName("example value");
    +   * }
    + * + * @param technicianName technicianName + * @return current instance of builder + */ + public TechnicianRecordBuilder technicianName(String technicianName) { + this.technicianName = changedValue(technicianName); + return this; + } + + /** + * Sets the value for technicianName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicianName(sb -> sb.append("text"));
    +   * }
    + * + * @param technicianNameStringBuilderConsumer consumer providing an instance of technicianName + * @return current instance of builder + */ + public TechnicianRecordBuilder technicianName(Consumer technicianNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + technicianNameStringBuilderConsumer.accept(builder); + this.technicianName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for technicianName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicianName(() -> "example value");
    +   * }
    + * + * @param technicianNameSupplier supplier for technicianName + * @return current instance of builder + */ + public TechnicianRecordBuilder technicianName(Supplier technicianNameSupplier) { + this.technicianName = changedValue(technicianNameSupplier.get()); + return this; + } + + /** + * Sets the String value for technicianName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TechnicianRecord#TechnicianRecord(UUID, String, String, int, List) + * TechnicianRecord(UUID technicianId, String technicianName, String technicalField, int equipmentMaintained, + * List certifications)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.technicianName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TechnicianRecordBuilder technicianName(String format, Object... args) { + this.technicianName = changedValue(String.format(format, args)); + 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 TechnicianRecordBuilder 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 TechnicianRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TechnicianRecord result = builder.build();
    +   * }
    + */ + @Override + public TechnicianRecord build() { + if (!this.equipmentMaintained.isSet()) { + throw new IllegalStateException("Required field 'equipmentMaintained' must be set before calling build()"); + } + if (this.equipmentMaintained.value() == null) { + throw new IllegalStateException("Field 'equipmentMaintained' is marked as non-null but null value was provided"); + } + TechnicianRecord result = new TechnicianRecord(this.technicianId.value(), + this.technicianName.value(), + this.technicalField.value(), + this.equipmentMaintained.value(), + this.certifications.value()); + 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("technicianId", this.technicianId) + .append("technicianName", this.technicianName) + .append("technicalField", this.technicalField) + .append("equipmentMaintained", this.equipmentMaintained) + .append("certifications", this.certifications) + .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 TechnicianRecord with(Consumer b) { + TechnicianRecordBuilder builder; + try { + builder = new TechnicianRecordBuilder(TechnicianRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TechnicianRecordBuilder.With' should only be implemented by classes, which could be casted to 'TechnicianRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TechnicianRecordBuilder with() { + try { + return new TechnicianRecordBuilder(TechnicianRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TechnicianRecordBuilder.With' should only be implemented by classes, which could be casted to 'TechnicianRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TraineeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TraineeRecordBuilder.java new file mode 100644 index 00000000..4c49de7a --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TraineeRecordBuilder.java @@ -0,0 +1,504 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.TraineeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.TraineeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TraineeRecord result = TraineeRecordBuilder.create()
    + *     .traineeId(UUID.randomUUID())
    + *     .traineeId(() -> UUID.randomUUID())
    + *     .traineeName("example value")
    + *     .traineeName("Hello %s", "World")
    + *     .traineeName(() -> "example value")
    + *     .traineeName(sb -> sb.append("text"))
    + *     .program("example value")
    + *     .program("Hello %s", "World")
    + *     .program(() -> "example value")
    + *     .program(sb -> sb.append("text"))
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .completedModules(42)
    + *     .completedModules(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TraineeRecord.class) +public class TraineeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for traineeId: traineeId. + */ + private TrackedValue traineeId = unsetValue(); + /** + * Tracked value for traineeName: traineeName. + */ + private TrackedValue traineeName = unsetValue(); + /** + * Tracked value for program: program. + */ + private TrackedValue program = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + /** + * Tracked value for completedModules: completedModules. + */ + private TrackedValue completedModules = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TraineeRecord}. + */ + public TraineeRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TraineeRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TraineeRecordBuilder(TraineeRecord instance) { + this.traineeId = initialValue(instance.traineeId()); + this.traineeName = initialValue(instance.traineeName()); + this.program = initialValue(instance.program()); + this.startDate = initialValue(instance.startDate()); + this.completedModules = initialValue(instance.completedModules()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.TraineeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TraineeRecordBuilder builder = TraineeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.TraineeRecord} + */ + public static TraineeRecordBuilder create() { + return new TraineeRecordBuilder(); + } + + /** + * Sets the value for completedModules. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.completedModules(42);
    +   * }
    + * + * @param completedModules completedModules + * @return current instance of builder + */ + public TraineeRecordBuilder completedModules(int completedModules) { + this.completedModules = changedValue(completedModules); + return this; + } + + /** + * Sets the value for completedModules by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.completedModules(() -> 42);
    +   * }
    + * + * @param completedModulesSupplier supplier for completedModules + * @return current instance of builder + */ + public TraineeRecordBuilder completedModules(Supplier completedModulesSupplier) { + this.completedModules = changedValue(completedModulesSupplier.get()); + return this; + } + + /** + * Sets the value for program. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program("example value");
    +   * }
    + * + * @param program program + * @return current instance of builder + */ + public TraineeRecordBuilder program(String program) { + this.program = changedValue(program); + return this; + } + + /** + * Sets the value for program by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program(sb -> sb.append("text"));
    +   * }
    + * + * @param programStringBuilderConsumer consumer providing an instance of program + * @return current instance of builder + */ + public TraineeRecordBuilder program(Consumer programStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + programStringBuilderConsumer.accept(builder); + this.program = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for program by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program(() -> "example value");
    +   * }
    + * + * @param programSupplier supplier for program + * @return current instance of builder + */ + public TraineeRecordBuilder program(Supplier programSupplier) { + this.program = changedValue(programSupplier.get()); + return this; + } + + /** + * Sets the String value for program by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.program("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TraineeRecordBuilder program(String format, Object... args) { + this.program = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public TraineeRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public TraineeRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + return this; + } + + /** + * Sets the value for traineeId. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.traineeId(UUID.randomUUID());
    +   * }
    + * + * @param traineeId traineeId + * @return current instance of builder + */ + public TraineeRecordBuilder traineeId(UUID traineeId) { + this.traineeId = changedValue(traineeId); + return this; + } + + /** + * Sets the value for traineeId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.traineeId(() -> UUID.randomUUID());
    +   * }
    + * + * @param traineeIdSupplier supplier for traineeId + * @return current instance of builder + */ + public TraineeRecordBuilder traineeId(Supplier traineeIdSupplier) { + this.traineeId = changedValue(traineeIdSupplier.get()); + return this; + } + + /** + * Sets the value for traineeName. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.traineeName("example value");
    +   * }
    + * + * @param traineeName traineeName + * @return current instance of builder + */ + public TraineeRecordBuilder traineeName(String traineeName) { + this.traineeName = changedValue(traineeName); + return this; + } + + /** + * Sets the value for traineeName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.traineeName(sb -> sb.append("text"));
    +   * }
    + * + * @param traineeNameStringBuilderConsumer consumer providing an instance of traineeName + * @return current instance of builder + */ + public TraineeRecordBuilder traineeName(Consumer traineeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + traineeNameStringBuilderConsumer.accept(builder); + this.traineeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for traineeName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.traineeName(() -> "example value");
    +   * }
    + * + * @param traineeNameSupplier supplier for traineeName + * @return current instance of builder + */ + public TraineeRecordBuilder traineeName(Supplier traineeNameSupplier) { + this.traineeName = changedValue(traineeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for traineeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TraineeRecord#TraineeRecord(UUID, String, String, LocalDate, int) + * TraineeRecord(UUID traineeId, String traineeName, String program, LocalDate startDate, int completedModules)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.traineeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TraineeRecordBuilder traineeName(String format, Object... args) { + this.traineeName = changedValue(String.format(format, args)); + 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 TraineeRecordBuilder 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 TraineeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TraineeRecord result = builder.build();
    +   * }
    + */ + @Override + public TraineeRecord build() { + if (!this.completedModules.isSet()) { + throw new IllegalStateException("Required field 'completedModules' must be set before calling build()"); + } + if (this.completedModules.value() == null) { + throw new IllegalStateException("Field 'completedModules' is marked as non-null but null value was provided"); + } + TraineeRecord result = new TraineeRecord(this.traineeId.value(), + this.traineeName.value(), + this.program.value(), + this.startDate.value(), + this.completedModules.value()); + 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("traineeId", this.traineeId) + .append("traineeName", this.traineeName) + .append("program", this.program) + .append("startDate", this.startDate) + .append("completedModules", this.completedModules) + .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 TraineeRecord with(Consumer b) { + TraineeRecordBuilder builder; + try { + builder = new TraineeRecordBuilder(TraineeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TraineeRecordBuilder.With' should only be implemented by classes, which could be casted to 'TraineeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TraineeRecordBuilder with() { + try { + return new TraineeRecordBuilder(TraineeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TraineeRecordBuilder.With' should only be implemented by classes, which could be casted to 'TraineeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TranslatorRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TranslatorRecordBuilder.java new file mode 100644 index 00000000..21465c9c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TranslatorRecordBuilder.java @@ -0,0 +1,628 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.TranslatorRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.TranslatorRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TranslatorRecord result = TranslatorRecordBuilder.create()
    + *     .translatorId(UUID.randomUUID())
    + *     .translatorId(() -> UUID.randomUUID())
    + *     .translatorName("example value")
    + *     .translatorName("Hello %s", "World")
    + *     .translatorName(() -> "example value")
    + *     .translatorName(sb -> sb.append("text"))
    + *     .sourceLanguages(List.of("example value"))
    + *     .sourceLanguages(() -> List.of("example value"))
    + *     .sourceLanguages(t -> t.add("example value"))
    + *     .sourceLanguages("example value", "example value")
    + *     .add2SourceLanguages("example value")
    + *     .targetLanguages(List.of("example value"))
    + *     .targetLanguages(() -> List.of("example value"))
    + *     .targetLanguages(t -> t.add("example value"))
    + *     .targetLanguages("example value", "example value")
    + *     .add2TargetLanguages("example value")
    + *     .translatedWorks(42)
    + *     .translatedWorks(() -> 42)
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TranslatorRecord.class) +public class TranslatorRecordBuilder implements IBuilderBase { + + /** + * Tracked value for translatorId: translatorId. + */ + private TrackedValue translatorId = unsetValue(); + /** + * Tracked value for translatorName: translatorName. + */ + private TrackedValue translatorName = unsetValue(); + /** + * Tracked value for sourceLanguages: sourceLanguages. + */ + private TrackedValue> sourceLanguages = unsetValue(); + /** + * Tracked value for targetLanguages: targetLanguages. + */ + private TrackedValue> targetLanguages = unsetValue(); + /** + * Tracked value for translatedWorks: translatedWorks. + */ + private TrackedValue translatedWorks = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TranslatorRecord}. + */ + public TranslatorRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TranslatorRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TranslatorRecordBuilder(TranslatorRecord instance) { + this.translatorId = initialValue(instance.translatorId()); + this.translatorName = initialValue(instance.translatorName()); + this.sourceLanguages = initialValue(instance.sourceLanguages()); + this.targetLanguages = initialValue(instance.targetLanguages()); + this.translatedWorks = initialValue(instance.translatedWorks()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TranslatorRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TranslatorRecordBuilder builder = TranslatorRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.TranslatorRecord} + */ + public static TranslatorRecordBuilder create() { + return new TranslatorRecordBuilder(); + } + + /** + * Adds a single element to sourceLanguages. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2SourceLanguages("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TranslatorRecordBuilder add2SourceLanguages(String element) { + List newCollection; + if (this.sourceLanguages.isSet()) { + newCollection = new ArrayList<>(this.sourceLanguages.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.sourceLanguages = changedValue(newCollection); + return this; + } + + /** + * Adds a single element to targetLanguages. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2TargetLanguages("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TranslatorRecordBuilder add2TargetLanguages(String element) { + List newCollection; + if (this.targetLanguages.isSet()) { + newCollection = new ArrayList<>(this.targetLanguages.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.targetLanguages = changedValue(newCollection); + return this; + } + + /** + * Sets the value for sourceLanguages. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sourceLanguages("example value", "example value");
    +   * }
    + * + * @param sourceLanguages sourceLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder sourceLanguages(String... sourceLanguages) { + this.sourceLanguages = changedValue(List.of(sourceLanguages)); + return this; + } + + /** + * Sets the value for sourceLanguages. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sourceLanguages(List.of("example value"));
    +   * }
    + * + * @param sourceLanguages sourceLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder sourceLanguages(List sourceLanguages) { + this.sourceLanguages = changedValue(sourceLanguages); + return this; + } + + /** + * Sets the value for sourceLanguages using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sourceLanguages(t -> t.add("example value"));
    +   * }
    + * + * @param sourceLanguagesBuilderConsumer consumer providing an instance of a builder for sourceLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder sourceLanguages(Consumer> sourceLanguagesBuilderConsumer) { + ArrayListBuilder builder = this.sourceLanguages.isSet() + ? new ArrayListBuilder(this.sourceLanguages.value()) + : new ArrayListBuilder(); + sourceLanguagesBuilderConsumer.accept(builder); + this.sourceLanguages = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for sourceLanguages by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.sourceLanguages(() -> List.of("example value"));
    +   * }
    + * + * @param sourceLanguagesSupplier supplier for sourceLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder sourceLanguages(Supplier> sourceLanguagesSupplier) { + this.sourceLanguages = changedValue(sourceLanguagesSupplier.get()); + return this; + } + + /** + * Sets the value for targetLanguages. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.targetLanguages("example value", "example value");
    +   * }
    + * + * @param targetLanguages targetLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder targetLanguages(String... targetLanguages) { + this.targetLanguages = changedValue(List.of(targetLanguages)); + return this; + } + + /** + * Sets the value for targetLanguages. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.targetLanguages(List.of("example value"));
    +   * }
    + * + * @param targetLanguages targetLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder targetLanguages(List targetLanguages) { + this.targetLanguages = changedValue(targetLanguages); + return this; + } + + /** + * Sets the value for targetLanguages using a builder consumer that produces the value. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.targetLanguages(t -> t.add("example value"));
    +   * }
    + * + * @param targetLanguagesBuilderConsumer consumer providing an instance of a builder for targetLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder targetLanguages(Consumer> targetLanguagesBuilderConsumer) { + ArrayListBuilder builder = this.targetLanguages.isSet() + ? new ArrayListBuilder(this.targetLanguages.value()) + : new ArrayListBuilder(); + targetLanguagesBuilderConsumer.accept(builder); + this.targetLanguages = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for targetLanguages by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.targetLanguages(() -> List.of("example value"));
    +   * }
    + * + * @param targetLanguagesSupplier supplier for targetLanguages + * @return current instance of builder + */ + public TranslatorRecordBuilder targetLanguages(Supplier> targetLanguagesSupplier) { + this.targetLanguages = changedValue(targetLanguagesSupplier.get()); + return this; + } + + /** + * Sets the value for translatedWorks. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatedWorks(42);
    +   * }
    + * + * @param translatedWorks translatedWorks + * @return current instance of builder + */ + public TranslatorRecordBuilder translatedWorks(int translatedWorks) { + this.translatedWorks = changedValue(translatedWorks); + return this; + } + + /** + * Sets the value for translatedWorks by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatedWorks(() -> 42);
    +   * }
    + * + * @param translatedWorksSupplier supplier for translatedWorks + * @return current instance of builder + */ + public TranslatorRecordBuilder translatedWorks(Supplier translatedWorksSupplier) { + this.translatedWorks = changedValue(translatedWorksSupplier.get()); + return this; + } + + /** + * Sets the value for translatorId. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatorId(UUID.randomUUID());
    +   * }
    + * + * @param translatorId translatorId + * @return current instance of builder + */ + public TranslatorRecordBuilder translatorId(UUID translatorId) { + this.translatorId = changedValue(translatorId); + return this; + } + + /** + * Sets the value for translatorId by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatorId(() -> UUID.randomUUID());
    +   * }
    + * + * @param translatorIdSupplier supplier for translatorId + * @return current instance of builder + */ + public TranslatorRecordBuilder translatorId(Supplier translatorIdSupplier) { + this.translatorId = changedValue(translatorIdSupplier.get()); + return this; + } + + /** + * Sets the value for translatorName. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatorName("example value");
    +   * }
    + * + * @param translatorName translatorName + * @return current instance of builder + */ + public TranslatorRecordBuilder translatorName(String translatorName) { + this.translatorName = changedValue(translatorName); + return this; + } + + /** + * Sets the value for translatorName by executing the provided consumer. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatorName(sb -> sb.append("text"));
    +   * }
    + * + * @param translatorNameStringBuilderConsumer consumer providing an instance of translatorName + * @return current instance of builder + */ + public TranslatorRecordBuilder translatorName(Consumer translatorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + translatorNameStringBuilderConsumer.accept(builder); + this.translatorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for translatorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatorName(() -> "example value");
    +   * }
    + * + * @param translatorNameSupplier supplier for translatorName + * @return current instance of builder + */ + public TranslatorRecordBuilder translatorName(Supplier translatorNameSupplier) { + this.translatorName = changedValue(translatorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for translatorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor {@link TranslatorRecord#TranslatorRecord(UUID, String, List, List, int) + * TranslatorRecord(UUID translatorId, String translatorName, List sourceLanguages, List + * targetLanguages, int translatedWorks)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.translatorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TranslatorRecordBuilder translatorName(String format, Object... args) { + this.translatorName = changedValue(String.format(format, args)); + 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 TranslatorRecordBuilder 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 TranslatorRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TranslatorRecord result = builder.build();
    +   * }
    + */ + @Override + public TranslatorRecord build() { + if (!this.translatedWorks.isSet()) { + throw new IllegalStateException("Required field 'translatedWorks' must be set before calling build()"); + } + if (this.translatedWorks.value() == null) { + throw new IllegalStateException("Field 'translatedWorks' is marked as non-null but null value was provided"); + } + TranslatorRecord result = new TranslatorRecord(this.translatorId.value(), + this.translatorName.value(), + this.sourceLanguages.value(), + this.targetLanguages.value(), + this.translatedWorks.value()); + 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("translatorId", this.translatorId) + .append("translatorName", this.translatorName) + .append("sourceLanguages", this.sourceLanguages) + .append("targetLanguages", this.targetLanguages) + .append("translatedWorks", this.translatedWorks) + .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 TranslatorRecord with(Consumer b) { + TranslatorRecordBuilder builder; + try { + builder = new TranslatorRecordBuilder(TranslatorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TranslatorRecordBuilder.With' should only be implemented by classes, which could be casted to 'TranslatorRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TranslatorRecordBuilder with() { + try { + return new TranslatorRecordBuilder(TranslatorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TranslatorRecordBuilder.With' should only be implemented by classes, which could be casted to 'TranslatorRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TrusteeRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TrusteeRecordBuilder.java new file mode 100644 index 00000000..0d7d1feb --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TrusteeRecordBuilder.java @@ -0,0 +1,509 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.TrusteeRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.TrusteeRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * TrusteeRecord result = TrusteeRecordBuilder.create()
    + *     .trusteeId(UUID.randomUUID())
    + *     .trusteeId(() -> UUID.randomUUID())
    + *     .trusteeName("example value")
    + *     .trusteeName("Hello %s", "World")
    + *     .trusteeName(() -> "example value")
    + *     .trusteeName(sb -> sb.append("text"))
    + *     .boardName("example value")
    + *     .boardName("Hello %s", "World")
    + *     .boardName(() -> "example value")
    + *     .boardName(sb -> sb.append("text"))
    + *     .termStart(LocalDate.now())
    + *     .termStart(() -> LocalDate.now())
    + *     .termEnd(LocalDate.now())
    + *     .termEnd(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = TrusteeRecord.class) +public class TrusteeRecordBuilder implements IBuilderBase { + + /** + * Tracked value for trusteeId: trusteeId. + */ + private TrackedValue trusteeId = unsetValue(); + /** + * Tracked value for trusteeName: trusteeName. + */ + private TrackedValue trusteeName = unsetValue(); + /** + * Tracked value for boardName: boardName. + */ + private TrackedValue boardName = unsetValue(); + /** + * Tracked value for termStart: termStart. + */ + private TrackedValue termStart = unsetValue(); + /** + * Tracked value for termEnd: termEnd. + */ + private TrackedValue termEnd = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TrusteeRecord}. + */ + public TrusteeRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.TrusteeRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public TrusteeRecordBuilder(TrusteeRecord instance) { + this.trusteeId = initialValue(instance.trusteeId()); + this.trusteeName = initialValue(instance.trusteeName()); + this.boardName = initialValue(instance.boardName()); + this.termStart = initialValue(instance.termStart()); + this.termEnd = initialValue(instance.termEnd()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.TrusteeRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * TrusteeRecordBuilder builder = TrusteeRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.TrusteeRecord} + */ + public static TrusteeRecordBuilder create() { + return new TrusteeRecordBuilder(); + } + + /** + * Sets the value for boardName. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.boardName("example value");
    +   * }
    + * + * @param boardName boardName + * @return current instance of builder + */ + public TrusteeRecordBuilder boardName(String boardName) { + this.boardName = changedValue(boardName); + return this; + } + + /** + * Sets the value for boardName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.boardName(sb -> sb.append("text"));
    +   * }
    + * + * @param boardNameStringBuilderConsumer consumer providing an instance of boardName + * @return current instance of builder + */ + public TrusteeRecordBuilder boardName(Consumer boardNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + boardNameStringBuilderConsumer.accept(builder); + this.boardName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for boardName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.boardName(() -> "example value");
    +   * }
    + * + * @param boardNameSupplier supplier for boardName + * @return current instance of builder + */ + public TrusteeRecordBuilder boardName(Supplier boardNameSupplier) { + this.boardName = changedValue(boardNameSupplier.get()); + return this; + } + + /** + * Sets the String value for boardName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.boardName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TrusteeRecordBuilder boardName(String format, Object... args) { + this.boardName = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for termEnd. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termEnd(LocalDate.now());
    +   * }
    + * + * @param termEnd termEnd + * @return current instance of builder + */ + public TrusteeRecordBuilder termEnd(LocalDate termEnd) { + this.termEnd = changedValue(termEnd); + return this; + } + + /** + * Sets the value for termEnd by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termEnd(() -> LocalDate.now());
    +   * }
    + * + * @param termEndSupplier supplier for termEnd + * @return current instance of builder + */ + public TrusteeRecordBuilder termEnd(Supplier termEndSupplier) { + this.termEnd = changedValue(termEndSupplier.get()); + return this; + } + + /** + * Sets the value for termStart. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termStart(LocalDate.now());
    +   * }
    + * + * @param termStart termStart + * @return current instance of builder + */ + public TrusteeRecordBuilder termStart(LocalDate termStart) { + this.termStart = changedValue(termStart); + return this; + } + + /** + * Sets the value for termStart by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.termStart(() -> LocalDate.now());
    +   * }
    + * + * @param termStartSupplier supplier for termStart + * @return current instance of builder + */ + public TrusteeRecordBuilder termStart(Supplier termStartSupplier) { + this.termStart = changedValue(termStartSupplier.get()); + return this; + } + + /** + * Sets the value for trusteeId. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trusteeId(UUID.randomUUID());
    +   * }
    + * + * @param trusteeId trusteeId + * @return current instance of builder + */ + public TrusteeRecordBuilder trusteeId(UUID trusteeId) { + this.trusteeId = changedValue(trusteeId); + return this; + } + + /** + * Sets the value for trusteeId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trusteeId(() -> UUID.randomUUID());
    +   * }
    + * + * @param trusteeIdSupplier supplier for trusteeId + * @return current instance of builder + */ + public TrusteeRecordBuilder trusteeId(Supplier trusteeIdSupplier) { + this.trusteeId = changedValue(trusteeIdSupplier.get()); + return this; + } + + /** + * Sets the value for trusteeName. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trusteeName("example value");
    +   * }
    + * + * @param trusteeName trusteeName + * @return current instance of builder + */ + public TrusteeRecordBuilder trusteeName(String trusteeName) { + this.trusteeName = changedValue(trusteeName); + return this; + } + + /** + * Sets the value for trusteeName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trusteeName(sb -> sb.append("text"));
    +   * }
    + * + * @param trusteeNameStringBuilderConsumer consumer providing an instance of trusteeName + * @return current instance of builder + */ + public TrusteeRecordBuilder trusteeName(Consumer trusteeNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + trusteeNameStringBuilderConsumer.accept(builder); + this.trusteeName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for trusteeName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trusteeName(() -> "example value");
    +   * }
    + * + * @param trusteeNameSupplier supplier for trusteeName + * @return current instance of builder + */ + public TrusteeRecordBuilder trusteeName(Supplier trusteeNameSupplier) { + this.trusteeName = changedValue(trusteeNameSupplier.get()); + return this; + } + + /** + * Sets the String value for trusteeName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link TrusteeRecord#TrusteeRecord(UUID, String, String, LocalDate, LocalDate) TrusteeRecord(UUID trusteeId, String + * trusteeName, String boardName, LocalDate termStart, LocalDate termEnd)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.trusteeName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TrusteeRecordBuilder trusteeName(String format, Object... args) { + this.trusteeName = changedValue(String.format(format, args)); + 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 TrusteeRecordBuilder 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 TrusteeRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * TrusteeRecord result = builder.build();
    +   * }
    + */ + @Override + public TrusteeRecord build() { + TrusteeRecord result = new TrusteeRecord(this.trusteeId + .value(), this.trusteeName.value(), this.boardName.value(), this.termStart.value(), this.termEnd.value()); + 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("trusteeId", this.trusteeId) + .append("trusteeName", this.trusteeName) + .append("boardName", this.boardName) + .append("termStart", this.termStart) + .append("termEnd", this.termEnd) + .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 TrusteeRecord with(Consumer b) { + TrusteeRecordBuilder builder; + try { + builder = new TrusteeRecordBuilder(TrusteeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TrusteeRecordBuilder.With' should only be implemented by classes, which could be casted to 'TrusteeRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TrusteeRecordBuilder with() { + try { + return new TrusteeRecordBuilder(TrusteeRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TrusteeRecordBuilder.With' should only be implemented by classes, which could be casted to 'TrusteeRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TypesetterBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TypesetterBuilder.java new file mode 100644 index 00000000..3f70e76e --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/TypesetterBuilder.java @@ -0,0 +1,867 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +import org.javahelpers.simple.builders.core.interfaces.IBuilderBase; +import org.javahelpers.simple.builders.core.util.BuilderToStringStyle; +import org.javahelpers.simple.builders.core.util.TrackedValue; +import org.javahelpers.simple.builders.performance_test.library.organizations.CommercialPublisher; +import org.javahelpers.simple.builders.performance_test.library.organizations.CommercialPublisherBuilder; + +/** + * Builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Typesetter}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.Typesetter 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. + * + *

    Example:

    + * + *
    {@code
    + * Typesetter result = TypesetterBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .employeeId("example value")
    + *     .employeeId("Hello %s", "World")
    + *     .employeeId(() -> "example value")
    + *     .employeeId(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .pagesPerDay(42)
    + *     .pagesPerDay(() -> 42)
    + *     .publisher(new CommercialPublisher())
    + *     .publisher(CommercialPublisher::new)
    + *     .publisher(commercialPublisherBuilder -> commercialPublisherBuilder)
    + *     .softwareUsed(List.of("example value"))
    + *     .softwareUsed(() -> List.of("example value"))
    + *     .softwareUsed(t -> t.add("example value"))
    + *     .softwareUsed("example value", "example value")
    + *     .add2SoftwareUsed("example value")
    + *     .specialization("example value")
    + *     .specialization("Hello %s", "World")
    + *     .specialization(() -> "example value")
    + *     .specialization(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Typesetter.class) +public class TypesetterBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for employeeId: employeeId. + */ + private TrackedValue employeeId = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for pagesPerDay: pagesPerDay. + */ + private TrackedValue pagesPerDay = unsetValue(); + /** + * Tracked value for publisher: publisher. + */ + private TrackedValue publisher = unsetValue(); + /** + * Tracked value for softwareUsed: softwareUsed. + */ + private TrackedValue> softwareUsed = unsetValue(); + /** + * Tracked value for specialization: specialization. + */ + private TrackedValue specialization = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.Typesetter}. + */ + public TypesetterBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Typesetter} + * by a instance. + * + * @param instance object instance for initialisiation + */ + public TypesetterBuilder(Typesetter instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.employeeId = initialValue(instance.getEmployeeId()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.pagesPerDay = initialValue(instance.getPagesPerDay()); + this.publisher = initialValue(instance.getPublisher()); + this.softwareUsed = initialValue(instance.getSoftwareUsed()); + this.specialization = initialValue(instance.getSpecialization()); + this.status = initialValue(instance.getStatus()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Typesetter}. + * + *

    Example:

    + * + *
    {@code
    +   * TypesetterBuilder builder = TypesetterBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Typesetter} + */ + public static TypesetterBuilder create() { + return new TypesetterBuilder(); + } + + /** + * Adds a single element to softwareUsed. + *

    + * Generated from setter {@link Typesetter#setSoftwareUsed(List) setSoftwareUsed(List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2SoftwareUsed("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public TypesetterBuilder add2SoftwareUsed(String element) { + List newCollection; + if (this.softwareUsed.isSet()) { + newCollection = new ArrayList<>(this.softwareUsed.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.softwareUsed = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Typesetter#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public TypesetterBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public TypesetterBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for employeeId. + *

    + * Generated from setter {@link Typesetter#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId("example value");
    +   * }
    + * + * @param employeeId employeeId + * @return current instance of builder + */ + public TypesetterBuilder employeeId(String employeeId) { + this.employeeId = changedValue(employeeId); + return this; + } + + /** + * Sets the value for employeeId by executing the provided consumer. + *

    + * Generated from setter {@link Typesetter#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId(sb -> sb.append("text"));
    +   * }
    + * + * @param employeeIdStringBuilderConsumer consumer providing an instance of employeeId + * @return current instance of builder + */ + public TypesetterBuilder employeeId(Consumer employeeIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + employeeIdStringBuilderConsumer.accept(builder); + this.employeeId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for employeeId by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId(() -> "example value");
    +   * }
    + * + * @param employeeIdSupplier supplier for employeeId + * @return current instance of builder + */ + public TypesetterBuilder employeeId(Supplier employeeIdSupplier) { + this.employeeId = changedValue(employeeIdSupplier.get()); + return this; + } + + /** + * Sets the String value for employeeId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Typesetter#setEmployeeId(String) setEmployeeId(String employeeId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.employeeId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TypesetterBuilder employeeId(String format, Object... args) { + this.employeeId = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Typesetter#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public TypesetterBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public TypesetterBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Typesetter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public TypesetterBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Typesetter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public TypesetterBuilder 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. + *

    + * Generated from setter {@link Typesetter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public TypesetterBuilder 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. + *

    + * Generated from setter {@link Typesetter#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TypesetterBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for pagesPerDay. + *

    + * Generated from setter {@link Typesetter#setPagesPerDay(int) setPagesPerDay(int pagesPerDay)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pagesPerDay(42);
    +   * }
    + * + * @param pagesPerDay pagesPerDay + * @return current instance of builder + */ + public TypesetterBuilder pagesPerDay(int pagesPerDay) { + this.pagesPerDay = changedValue(pagesPerDay); + return this; + } + + /** + * Sets the value for pagesPerDay by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setPagesPerDay(int) setPagesPerDay(int pagesPerDay)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.pagesPerDay(() -> 42);
    +   * }
    + * + * @param pagesPerDaySupplier supplier for pagesPerDay + * @return current instance of builder + */ + public TypesetterBuilder pagesPerDay(Supplier pagesPerDaySupplier) { + this.pagesPerDay = changedValue(pagesPerDaySupplier.get()); + return this; + } + + /** + * Sets the value for publisher. + *

    + * Generated from setter {@link Typesetter#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(new CommercialPublisher());
    +   * }
    + * + * @param publisher publisher + * @return current instance of builder + */ + public TypesetterBuilder publisher(CommercialPublisher publisher) { + this.publisher = changedValue(publisher); + return this; + } + + /** + * Sets the value for publisher using a builder consumer that produces the value. + *

    + * Generated from setter {@link Typesetter#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(commercialPublisherBuilder -> commercialPublisherBuilder);
    +   * }
    + * + * @param publisherBuilderConsumer consumer providing an instance of a builder for publisher + * @return current instance of builder + */ + public TypesetterBuilder publisher(Consumer publisherBuilderConsumer) { + CommercialPublisherBuilder builder = this.publisher.isSet() + ? new CommercialPublisherBuilder(this.publisher.value()) + : new CommercialPublisherBuilder(); + publisherBuilderConsumer.accept(builder); + this.publisher = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for publisher by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setPublisher(CommercialPublisher) setPublisher(CommercialPublisher + * publisher)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.publisher(CommercialPublisher::new);
    +   * }
    + * + * @param publisherSupplier supplier for publisher + * @return current instance of builder + */ + public TypesetterBuilder publisher(Supplier publisherSupplier) { + this.publisher = changedValue(publisherSupplier.get()); + return this; + } + + /** + * Sets the value for softwareUsed. + *

    + * Generated from setter {@link Typesetter#setSoftwareUsed(List) setSoftwareUsed(List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed("example value", "example value");
    +   * }
    + * + * @param softwareUsed softwareUsed + * @return current instance of builder + */ + public TypesetterBuilder softwareUsed(String... softwareUsed) { + this.softwareUsed = changedValue(List.of(softwareUsed)); + return this; + } + + /** + * Sets the value for softwareUsed. + *

    + * Generated from setter {@link Typesetter#setSoftwareUsed(List) setSoftwareUsed(List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed(List.of("example value"));
    +   * }
    + * + * @param softwareUsed softwareUsed + * @return current instance of builder + */ + public TypesetterBuilder softwareUsed(List softwareUsed) { + this.softwareUsed = changedValue(softwareUsed); + return this; + } + + /** + * Sets the value for softwareUsed using a builder consumer that produces the value. + *

    + * Generated from setter {@link Typesetter#setSoftwareUsed(List) setSoftwareUsed(List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed(t -> t.add("example value"));
    +   * }
    + * + * @param softwareUsedBuilderConsumer consumer providing an instance of a builder for softwareUsed + * @return current instance of builder + */ + public TypesetterBuilder softwareUsed(Consumer> softwareUsedBuilderConsumer) { + ArrayListBuilder builder = this.softwareUsed.isSet() + ? new ArrayListBuilder(this.softwareUsed.value()) + : new ArrayListBuilder(); + softwareUsedBuilderConsumer.accept(builder); + this.softwareUsed = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for softwareUsed by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setSoftwareUsed(List) setSoftwareUsed(List softwareUsed)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.softwareUsed(() -> List.of("example value"));
    +   * }
    + * + * @param softwareUsedSupplier supplier for softwareUsed + * @return current instance of builder + */ + public TypesetterBuilder softwareUsed(Supplier> softwareUsedSupplier) { + this.softwareUsed = changedValue(softwareUsedSupplier.get()); + return this; + } + + /** + * Sets the value for specialization. + *

    + * Generated from setter {@link Typesetter#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("example value");
    +   * }
    + * + * @param specialization specialization + * @return current instance of builder + */ + public TypesetterBuilder specialization(String specialization) { + this.specialization = changedValue(specialization); + return this; + } + + /** + * Sets the value for specialization by executing the provided consumer. + *

    + * Generated from setter {@link Typesetter#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(sb -> sb.append("text"));
    +   * }
    + * + * @param specializationStringBuilderConsumer consumer providing an instance of specialization + * @return current instance of builder + */ + public TypesetterBuilder specialization(Consumer specializationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + specializationStringBuilderConsumer.accept(builder); + this.specialization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for specialization by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization(() -> "example value");
    +   * }
    + * + * @param specializationSupplier supplier for specialization + * @return current instance of builder + */ + public TypesetterBuilder specialization(Supplier specializationSupplier) { + this.specialization = changedValue(specializationSupplier.get()); + return this; + } + + /** + * Sets the String value for specialization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Typesetter#setSpecialization(String) setSpecialization(String specialization)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.specialization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TypesetterBuilder specialization(String format, Object... args) { + this.specialization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Typesetter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public TypesetterBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Typesetter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public TypesetterBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Typesetter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public TypesetterBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Typesetter#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public TypesetterBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + 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 TypesetterBuilder 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 TypesetterBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Typesetter result = builder.build();
    +   * }
    + */ + @Override + public Typesetter build() { + if (this.pagesPerDay.isSet() && this.pagesPerDay.value() == null) { + throw new IllegalStateException("Field 'pagesPerDay' is marked as non-null but null value was provided"); + } + Typesetter result = new Typesetter(); + this.createdAt.ifSet(result::setCreatedAt); + this.employeeId.ifSet(result::setEmployeeId); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.pagesPerDay.ifSet(result::setPagesPerDay); + this.publisher.ifSet(result::setPublisher); + this.softwareUsed.ifSet(result::setSoftwareUsed); + this.specialization.ifSet(result::setSpecialization); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + 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("createdAt", this.createdAt) + .append("employeeId", this.employeeId) + .append("id", this.id) + .append("name", this.name) + .append("pagesPerDay", this.pagesPerDay) + .append("publisher", this.publisher) + .append("softwareUsed", this.softwareUsed) + .append("specialization", this.specialization) + .append("status", this.status) + .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 Typesetter with(Consumer b) { + TypesetterBuilder builder; + try { + builder = new TypesetterBuilder(Typesetter.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TypesetterBuilder.With' should only be implemented by classes, which could be casted to 'Typesetter'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default TypesetterBuilder with() { + try { + return new TypesetterBuilder(Typesetter.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'TypesetterBuilder.With' should only be implemented by classes, which could be casted to 'Typesetter'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorBuilder.java new file mode 100644 index 00000000..3ddd3cc0 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorBuilder.java @@ -0,0 +1,757 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.Visitor}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.Visitor 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. + * + *

    Example:

    + * + *
    {@code
    + * Visitor result = VisitorBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .hostLibrary("example value")
    + *     .hostLibrary("Hello %s", "World")
    + *     .hostLibrary(() -> "example value")
    + *     .hostLibrary(sb -> sb.append("text"))
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .purpose("example value")
    + *     .purpose("Hello %s", "World")
    + *     .purpose(() -> "example value")
    + *     .purpose(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .visitDate(LocalDate.now())
    + *     .visitDate(() -> LocalDate.now())
    + *     .visitorId("example value")
    + *     .visitorId("Hello %s", "World")
    + *     .visitorId(() -> "example value")
    + *     .visitorId(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = Visitor.class) +public class VisitorBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for hostLibrary: hostLibrary. + */ + private TrackedValue hostLibrary = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for purpose: purpose. + */ + private TrackedValue purpose = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for visitDate: visitDate. + */ + private TrackedValue visitDate = unsetValue(); + /** + * Tracked value for visitorId: visitorId. + */ + private TrackedValue visitorId = unsetValue(); + + /** + * Empty constructor of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Visitor}. + */ + public VisitorBuilder() { + } + + /** + * Initialisation of builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Visitor} by a + * instance. + * + * @param instance object instance for initialisiation + */ + public VisitorBuilder(Visitor instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.hostLibrary = initialValue(instance.getHostLibrary()); + this.id = initialValue(instance.getId()); + this.name = initialValue(instance.getName()); + this.purpose = initialValue(instance.getPurpose()); + this.status = initialValue(instance.getStatus()); + this.visitDate = initialValue(instance.getVisitDate()); + this.visitorId = initialValue(instance.getVisitorId()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Visitor}. + * + *

    Example:

    + * + *
    {@code
    +   * VisitorBuilder builder = VisitorBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.Visitor} + */ + public static VisitorBuilder create() { + return new VisitorBuilder(); + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link Visitor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public VisitorBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public VisitorBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for hostLibrary. + *

    + * Generated from setter {@link Visitor#setHostLibrary(String) setHostLibrary(String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary("example value");
    +   * }
    + * + * @param hostLibrary hostLibrary + * @return current instance of builder + */ + public VisitorBuilder hostLibrary(String hostLibrary) { + this.hostLibrary = changedValue(hostLibrary); + return this; + } + + /** + * Sets the value for hostLibrary by executing the provided consumer. + *

    + * Generated from setter {@link Visitor#setHostLibrary(String) setHostLibrary(String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary(sb -> sb.append("text"));
    +   * }
    + * + * @param hostLibraryStringBuilderConsumer consumer providing an instance of hostLibrary + * @return current instance of builder + */ + public VisitorBuilder hostLibrary(Consumer hostLibraryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + hostLibraryStringBuilderConsumer.accept(builder); + this.hostLibrary = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for hostLibrary by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setHostLibrary(String) setHostLibrary(String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary(() -> "example value");
    +   * }
    + * + * @param hostLibrarySupplier supplier for hostLibrary + * @return current instance of builder + */ + public VisitorBuilder hostLibrary(Supplier hostLibrarySupplier) { + this.hostLibrary = changedValue(hostLibrarySupplier.get()); + return this; + } + + /** + * Sets the String value for hostLibrary by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Visitor#setHostLibrary(String) setHostLibrary(String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorBuilder hostLibrary(String format, Object... args) { + this.hostLibrary = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link Visitor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public VisitorBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public VisitorBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link Visitor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public VisitorBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link Visitor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public VisitorBuilder 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. + *

    + * Generated from setter {@link Visitor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public VisitorBuilder 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. + *

    + * Generated from setter {@link Visitor#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for purpose. + *

    + * Generated from setter {@link Visitor#setPurpose(String) setPurpose(String purpose)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose("example value");
    +   * }
    + * + * @param purpose purpose + * @return current instance of builder + */ + public VisitorBuilder purpose(String purpose) { + this.purpose = changedValue(purpose); + return this; + } + + /** + * Sets the value for purpose by executing the provided consumer. + *

    + * Generated from setter {@link Visitor#setPurpose(String) setPurpose(String purpose)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose(sb -> sb.append("text"));
    +   * }
    + * + * @param purposeStringBuilderConsumer consumer providing an instance of purpose + * @return current instance of builder + */ + public VisitorBuilder purpose(Consumer purposeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + purposeStringBuilderConsumer.accept(builder); + this.purpose = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for purpose by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setPurpose(String) setPurpose(String purpose)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose(() -> "example value");
    +   * }
    + * + * @param purposeSupplier supplier for purpose + * @return current instance of builder + */ + public VisitorBuilder purpose(Supplier purposeSupplier) { + this.purpose = changedValue(purposeSupplier.get()); + return this; + } + + /** + * Sets the String value for purpose by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Visitor#setPurpose(String) setPurpose(String purpose)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorBuilder purpose(String format, Object... args) { + this.purpose = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link Visitor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public VisitorBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link Visitor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public VisitorBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public VisitorBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Visitor#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for visitDate. + *

    + * Generated from setter {@link Visitor#setVisitDate(LocalDate) setVisitDate(LocalDate visitDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitDate(LocalDate.now());
    +   * }
    + * + * @param visitDate visitDate + * @return current instance of builder + */ + public VisitorBuilder visitDate(LocalDate visitDate) { + this.visitDate = changedValue(visitDate); + return this; + } + + /** + * Sets the value for visitDate by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setVisitDate(LocalDate) setVisitDate(LocalDate visitDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitDate(() -> LocalDate.now());
    +   * }
    + * + * @param visitDateSupplier supplier for visitDate + * @return current instance of builder + */ + public VisitorBuilder visitDate(Supplier visitDateSupplier) { + this.visitDate = changedValue(visitDateSupplier.get()); + return this; + } + + /** + * Sets the value for visitorId. + *

    + * Generated from setter {@link Visitor#setVisitorId(String) setVisitorId(String visitorId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorId("example value");
    +   * }
    + * + * @param visitorId visitorId + * @return current instance of builder + */ + public VisitorBuilder visitorId(String visitorId) { + this.visitorId = changedValue(visitorId); + return this; + } + + /** + * Sets the value for visitorId by executing the provided consumer. + *

    + * Generated from setter {@link Visitor#setVisitorId(String) setVisitorId(String visitorId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorId(sb -> sb.append("text"));
    +   * }
    + * + * @param visitorIdStringBuilderConsumer consumer providing an instance of visitorId + * @return current instance of builder + */ + public VisitorBuilder visitorId(Consumer visitorIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + visitorIdStringBuilderConsumer.accept(builder); + this.visitorId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for visitorId by invoking the provided supplier. + *

    + * Generated from setter {@link Visitor#setVisitorId(String) setVisitorId(String visitorId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorId(() -> "example value");
    +   * }
    + * + * @param visitorIdSupplier supplier for visitorId + * @return current instance of builder + */ + public VisitorBuilder visitorId(Supplier visitorIdSupplier) { + this.visitorId = changedValue(visitorIdSupplier.get()); + return this; + } + + /** + * Sets the String value for visitorId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link Visitor#setVisitorId(String) setVisitorId(String visitorId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorBuilder visitorId(String format, Object... args) { + this.visitorId = changedValue(String.format(format, args)); + 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 VisitorBuilder 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 VisitorBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * Visitor result = builder.build();
    +   * }
    + */ + @Override + public Visitor build() { + Visitor result = new Visitor(); + this.createdAt.ifSet(result::setCreatedAt); + this.hostLibrary.ifSet(result::setHostLibrary); + this.id.ifSet(result::setId); + this.name.ifSet(result::setName); + this.purpose.ifSet(result::setPurpose); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.visitDate.ifSet(result::setVisitDate); + this.visitorId.ifSet(result::setVisitorId); + 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("createdAt", this.createdAt) + .append("hostLibrary", this.hostLibrary) + .append("id", this.id) + .append("name", this.name) + .append("purpose", this.purpose) + .append("status", this.status) + .append("visitDate", this.visitDate) + .append("visitorId", this.visitorId) + .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 Visitor with(Consumer b) { + VisitorBuilder builder; + try { + builder = new VisitorBuilder(Visitor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VisitorBuilder.With' should only be implemented by classes, which could be casted to 'Visitor'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VisitorBuilder with() { + try { + return new VisitorBuilder(Visitor.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VisitorBuilder.With' should only be implemented by classes, which could be casted to 'Visitor'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorRecordBuilder.java new file mode 100644 index 00000000..f62cad1c --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VisitorRecordBuilder.java @@ -0,0 +1,617 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.VisitorRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.VisitorRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * VisitorRecord result = VisitorRecordBuilder.create()
    + *     .visitorId(UUID.randomUUID())
    + *     .visitorId(() -> UUID.randomUUID())
    + *     .visitorName("example value")
    + *     .visitorName("Hello %s", "World")
    + *     .visitorName(() -> "example value")
    + *     .visitorName(sb -> sb.append("text"))
    + *     .visitDate(LocalDate.now())
    + *     .visitDate(() -> LocalDate.now())
    + *     .purpose("example value")
    + *     .purpose("Hello %s", "World")
    + *     .purpose(() -> "example value")
    + *     .purpose(sb -> sb.append("text"))
    + *     .durationMinutes(42)
    + *     .durationMinutes(() -> 42)
    + *     .hostLibrary("example value")
    + *     .hostLibrary("Hello %s", "World")
    + *     .hostLibrary(() -> "example value")
    + *     .hostLibrary(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = VisitorRecord.class) +public class VisitorRecordBuilder implements IBuilderBase { + + /** + * Tracked value for visitorId: visitorId. + */ + private TrackedValue visitorId = unsetValue(); + /** + * Tracked value for visitorName: visitorName. + */ + private TrackedValue visitorName = unsetValue(); + /** + * Tracked value for visitDate: visitDate. + */ + private TrackedValue visitDate = unsetValue(); + /** + * Tracked value for purpose: purpose. + */ + private TrackedValue purpose = unsetValue(); + /** + * Tracked value for durationMinutes: durationMinutes. + */ + private TrackedValue durationMinutes = unsetValue(); + /** + * Tracked value for hostLibrary: hostLibrary. + */ + private TrackedValue hostLibrary = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.VisitorRecord}. + */ + public VisitorRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.VisitorRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public VisitorRecordBuilder(VisitorRecord instance) { + this.visitorId = initialValue(instance.visitorId()); + this.visitorName = initialValue(instance.visitorName()); + this.visitDate = initialValue(instance.visitDate()); + this.purpose = initialValue(instance.purpose()); + this.durationMinutes = initialValue(instance.durationMinutes()); + this.hostLibrary = initialValue(instance.hostLibrary()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.VisitorRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * VisitorRecordBuilder builder = VisitorRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.VisitorRecord} + */ + public static VisitorRecordBuilder create() { + return new VisitorRecordBuilder(); + } + + /** + * Sets the value for durationMinutes. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(42);
    +   * }
    + * + * @param durationMinutes durationMinutes + * @return current instance of builder + */ + public VisitorRecordBuilder durationMinutes(int durationMinutes) { + this.durationMinutes = changedValue(durationMinutes); + return this; + } + + /** + * Sets the value for durationMinutes by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.durationMinutes(() -> 42);
    +   * }
    + * + * @param durationMinutesSupplier supplier for durationMinutes + * @return current instance of builder + */ + public VisitorRecordBuilder durationMinutes(Supplier durationMinutesSupplier) { + this.durationMinutes = changedValue(durationMinutesSupplier.get()); + return this; + } + + /** + * Sets the value for hostLibrary. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary("example value");
    +   * }
    + * + * @param hostLibrary hostLibrary + * @return current instance of builder + */ + public VisitorRecordBuilder hostLibrary(String hostLibrary) { + this.hostLibrary = changedValue(hostLibrary); + return this; + } + + /** + * Sets the value for hostLibrary by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary(sb -> sb.append("text"));
    +   * }
    + * + * @param hostLibraryStringBuilderConsumer consumer providing an instance of hostLibrary + * @return current instance of builder + */ + public VisitorRecordBuilder hostLibrary(Consumer hostLibraryStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + hostLibraryStringBuilderConsumer.accept(builder); + this.hostLibrary = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for hostLibrary by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary(() -> "example value");
    +   * }
    + * + * @param hostLibrarySupplier supplier for hostLibrary + * @return current instance of builder + */ + public VisitorRecordBuilder hostLibrary(Supplier hostLibrarySupplier) { + this.hostLibrary = changedValue(hostLibrarySupplier.get()); + return this; + } + + /** + * Sets the String value for hostLibrary by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hostLibrary("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorRecordBuilder hostLibrary(String format, Object... args) { + this.hostLibrary = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for purpose. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose("example value");
    +   * }
    + * + * @param purpose purpose + * @return current instance of builder + */ + public VisitorRecordBuilder purpose(String purpose) { + this.purpose = changedValue(purpose); + return this; + } + + /** + * Sets the value for purpose by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose(sb -> sb.append("text"));
    +   * }
    + * + * @param purposeStringBuilderConsumer consumer providing an instance of purpose + * @return current instance of builder + */ + public VisitorRecordBuilder purpose(Consumer purposeStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + purposeStringBuilderConsumer.accept(builder); + this.purpose = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for purpose by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose(() -> "example value");
    +   * }
    + * + * @param purposeSupplier supplier for purpose + * @return current instance of builder + */ + public VisitorRecordBuilder purpose(Supplier purposeSupplier) { + this.purpose = changedValue(purposeSupplier.get()); + return this; + } + + /** + * Sets the String value for purpose by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.purpose("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorRecordBuilder purpose(String format, Object... args) { + this.purpose = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for visitDate. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitDate(LocalDate.now());
    +   * }
    + * + * @param visitDate visitDate + * @return current instance of builder + */ + public VisitorRecordBuilder visitDate(LocalDate visitDate) { + this.visitDate = changedValue(visitDate); + return this; + } + + /** + * Sets the value for visitDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitDate(() -> LocalDate.now());
    +   * }
    + * + * @param visitDateSupplier supplier for visitDate + * @return current instance of builder + */ + public VisitorRecordBuilder visitDate(Supplier visitDateSupplier) { + this.visitDate = changedValue(visitDateSupplier.get()); + return this; + } + + /** + * Sets the value for visitorId. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorId(UUID.randomUUID());
    +   * }
    + * + * @param visitorId visitorId + * @return current instance of builder + */ + public VisitorRecordBuilder visitorId(UUID visitorId) { + this.visitorId = changedValue(visitorId); + return this; + } + + /** + * Sets the value for visitorId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorId(() -> UUID.randomUUID());
    +   * }
    + * + * @param visitorIdSupplier supplier for visitorId + * @return current instance of builder + */ + public VisitorRecordBuilder visitorId(Supplier visitorIdSupplier) { + this.visitorId = changedValue(visitorIdSupplier.get()); + return this; + } + + /** + * Sets the value for visitorName. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorName("example value");
    +   * }
    + * + * @param visitorName visitorName + * @return current instance of builder + */ + public VisitorRecordBuilder visitorName(String visitorName) { + this.visitorName = changedValue(visitorName); + return this; + } + + /** + * Sets the value for visitorName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorName(sb -> sb.append("text"));
    +   * }
    + * + * @param visitorNameStringBuilderConsumer consumer providing an instance of visitorName + * @return current instance of builder + */ + public VisitorRecordBuilder visitorName(Consumer visitorNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + visitorNameStringBuilderConsumer.accept(builder); + this.visitorName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for visitorName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorName(() -> "example value");
    +   * }
    + * + * @param visitorNameSupplier supplier for visitorName + * @return current instance of builder + */ + public VisitorRecordBuilder visitorName(Supplier visitorNameSupplier) { + this.visitorName = changedValue(visitorNameSupplier.get()); + return this; + } + + /** + * Sets the String value for visitorName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link VisitorRecord#VisitorRecord(UUID, String, LocalDate, String, int, String) VisitorRecord(UUID visitorId, + * String visitorName, LocalDate visitDate, String purpose, int durationMinutes, String hostLibrary)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.visitorName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VisitorRecordBuilder visitorName(String format, Object... args) { + this.visitorName = changedValue(String.format(format, args)); + 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 VisitorRecordBuilder 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 VisitorRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * VisitorRecord result = builder.build();
    +   * }
    + */ + @Override + public VisitorRecord build() { + if (!this.durationMinutes.isSet()) { + throw new IllegalStateException("Required field 'durationMinutes' must be set before calling build()"); + } + if (this.durationMinutes.value() == null) { + throw new IllegalStateException("Field 'durationMinutes' is marked as non-null but null value was provided"); + } + VisitorRecord result = new VisitorRecord(this.visitorId.value(), + this.visitorName.value(), + this.visitDate.value(), + this.purpose.value(), + this.durationMinutes.value(), + this.hostLibrary.value()); + 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("visitorId", this.visitorId) + .append("visitorName", this.visitorName) + .append("visitDate", this.visitDate) + .append("purpose", this.purpose) + .append("durationMinutes", this.durationMinutes) + .append("hostLibrary", this.hostLibrary) + .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 VisitorRecord with(Consumer b) { + VisitorRecordBuilder builder; + try { + builder = new VisitorRecordBuilder(VisitorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VisitorRecordBuilder.With' should only be implemented by classes, which could be casted to 'VisitorRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VisitorRecordBuilder with() { + try { + return new VisitorRecordBuilder(VisitorRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VisitorRecordBuilder.With' should only be implemented by classes, which could be casted to 'VisitorRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VolunteerRecordBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VolunteerRecordBuilder.java new file mode 100644 index 00000000..4cd38fe4 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/VolunteerRecordBuilder.java @@ -0,0 +1,519 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.UUID; +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.performance_test.library.persons.VolunteerRecord}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.VolunteerRecord 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. + * + *

    Example:

    + * + *
    {@code
    + * VolunteerRecord result = VolunteerRecordBuilder.create()
    + *     .volunteerId(UUID.randomUUID())
    + *     .volunteerId(() -> UUID.randomUUID())
    + *     .volunteerName("example value")
    + *     .volunteerName("Hello %s", "World")
    + *     .volunteerName(() -> "example value")
    + *     .volunteerName(sb -> sb.append("text"))
    + *     .organization("example value")
    + *     .organization("Hello %s", "World")
    + *     .organization(() -> "example value")
    + *     .organization(sb -> sb.append("text"))
    + *     .hoursPerMonth(42)
    + *     .hoursPerMonth(() -> 42)
    + *     .startDate(LocalDate.now())
    + *     .startDate(() -> LocalDate.now())
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = VolunteerRecord.class) +public class VolunteerRecordBuilder implements IBuilderBase { + + /** + * Tracked value for volunteerId: volunteerId. + */ + private TrackedValue volunteerId = unsetValue(); + /** + * Tracked value for volunteerName: volunteerName. + */ + private TrackedValue volunteerName = unsetValue(); + /** + * Tracked value for organization: organization. + */ + private TrackedValue organization = unsetValue(); + /** + * Tracked value for hoursPerMonth: hoursPerMonth. + */ + private TrackedValue hoursPerMonth = unsetValue(); + /** + * Tracked value for startDate: startDate. + */ + private TrackedValue startDate = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.VolunteerRecord}. + */ + public VolunteerRecordBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.VolunteerRecord} by a instance. + * + * @param instance object instance for initialisiation + */ + public VolunteerRecordBuilder(VolunteerRecord instance) { + this.volunteerId = initialValue(instance.volunteerId()); + this.volunteerName = initialValue(instance.volunteerName()); + this.organization = initialValue(instance.organization()); + this.hoursPerMonth = initialValue(instance.hoursPerMonth()); + this.startDate = initialValue(instance.startDate()); + } + + /** + * Creating a new builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.VolunteerRecord}. + * + *

    Example:

    + * + *
    {@code
    +   * VolunteerRecordBuilder builder = VolunteerRecordBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.VolunteerRecord} + */ + public static VolunteerRecordBuilder create() { + return new VolunteerRecordBuilder(); + } + + /** + * Sets the value for hoursPerMonth. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hoursPerMonth(42);
    +   * }
    + * + * @param hoursPerMonth hoursPerMonth + * @return current instance of builder + */ + public VolunteerRecordBuilder hoursPerMonth(int hoursPerMonth) { + this.hoursPerMonth = changedValue(hoursPerMonth); + return this; + } + + /** + * Sets the value for hoursPerMonth by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.hoursPerMonth(() -> 42);
    +   * }
    + * + * @param hoursPerMonthSupplier supplier for hoursPerMonth + * @return current instance of builder + */ + public VolunteerRecordBuilder hoursPerMonth(Supplier hoursPerMonthSupplier) { + this.hoursPerMonth = changedValue(hoursPerMonthSupplier.get()); + return this; + } + + /** + * Sets the value for organization. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("example value");
    +   * }
    + * + * @param organization organization + * @return current instance of builder + */ + public VolunteerRecordBuilder organization(String organization) { + this.organization = changedValue(organization); + return this; + } + + /** + * Sets the value for organization by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(sb -> sb.append("text"));
    +   * }
    + * + * @param organizationStringBuilderConsumer consumer providing an instance of organization + * @return current instance of builder + */ + public VolunteerRecordBuilder organization(Consumer organizationStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + organizationStringBuilderConsumer.accept(builder); + this.organization = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for organization by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization(() -> "example value");
    +   * }
    + * + * @param organizationSupplier supplier for organization + * @return current instance of builder + */ + public VolunteerRecordBuilder organization(Supplier organizationSupplier) { + this.organization = changedValue(organizationSupplier.get()); + return this; + } + + /** + * Sets the String value for organization by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.organization("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VolunteerRecordBuilder organization(String format, Object... args) { + this.organization = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for startDate. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(LocalDate.now());
    +   * }
    + * + * @param startDate startDate + * @return current instance of builder + */ + public VolunteerRecordBuilder startDate(LocalDate startDate) { + this.startDate = changedValue(startDate); + return this; + } + + /** + * Sets the value for startDate by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.startDate(() -> LocalDate.now());
    +   * }
    + * + * @param startDateSupplier supplier for startDate + * @return current instance of builder + */ + public VolunteerRecordBuilder startDate(Supplier startDateSupplier) { + this.startDate = changedValue(startDateSupplier.get()); + return this; + } + + /** + * Sets the value for volunteerId. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volunteerId(UUID.randomUUID());
    +   * }
    + * + * @param volunteerId volunteerId + * @return current instance of builder + */ + public VolunteerRecordBuilder volunteerId(UUID volunteerId) { + this.volunteerId = changedValue(volunteerId); + return this; + } + + /** + * Sets the value for volunteerId by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volunteerId(() -> UUID.randomUUID());
    +   * }
    + * + * @param volunteerIdSupplier supplier for volunteerId + * @return current instance of builder + */ + public VolunteerRecordBuilder volunteerId(Supplier volunteerIdSupplier) { + this.volunteerId = changedValue(volunteerIdSupplier.get()); + return this; + } + + /** + * Sets the value for volunteerName. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volunteerName("example value");
    +   * }
    + * + * @param volunteerName volunteerName + * @return current instance of builder + */ + public VolunteerRecordBuilder volunteerName(String volunteerName) { + this.volunteerName = changedValue(volunteerName); + return this; + } + + /** + * Sets the value for volunteerName by executing the provided consumer. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volunteerName(sb -> sb.append("text"));
    +   * }
    + * + * @param volunteerNameStringBuilderConsumer consumer providing an instance of volunteerName + * @return current instance of builder + */ + public VolunteerRecordBuilder volunteerName(Consumer volunteerNameStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + volunteerNameStringBuilderConsumer.accept(builder); + this.volunteerName = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for volunteerName by invoking the provided supplier. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volunteerName(() -> "example value");
    +   * }
    + * + * @param volunteerNameSupplier supplier for volunteerName + * @return current instance of builder + */ + public VolunteerRecordBuilder volunteerName(Supplier volunteerNameSupplier) { + this.volunteerName = changedValue(volunteerNameSupplier.get()); + return this; + } + + /** + * Sets the String value for volunteerName by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from parameter in constructor + * {@link VolunteerRecord#VolunteerRecord(UUID, String, String, int, LocalDate) VolunteerRecord(UUID volunteerId, + * String volunteerName, String organization, int hoursPerMonth, LocalDate startDate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.volunteerName("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public VolunteerRecordBuilder volunteerName(String format, Object... args) { + this.volunteerName = changedValue(String.format(format, args)); + 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 VolunteerRecordBuilder 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 VolunteerRecordBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * VolunteerRecord result = builder.build();
    +   * }
    + */ + @Override + public VolunteerRecord build() { + if (!this.hoursPerMonth.isSet()) { + throw new IllegalStateException("Required field 'hoursPerMonth' must be set before calling build()"); + } + if (this.hoursPerMonth.value() == null) { + throw new IllegalStateException("Field 'hoursPerMonth' is marked as non-null but null value was provided"); + } + VolunteerRecord result = new VolunteerRecord(this.volunteerId.value(), + this.volunteerName.value(), + this.organization.value(), + this.hoursPerMonth.value(), + this.startDate.value()); + 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("volunteerId", this.volunteerId) + .append("volunteerName", this.volunteerName) + .append("organization", this.organization) + .append("hoursPerMonth", this.hoursPerMonth) + .append("startDate", this.startDate) + .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 VolunteerRecord with(Consumer b) { + VolunteerRecordBuilder builder; + try { + builder = new VolunteerRecordBuilder(VolunteerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VolunteerRecordBuilder.With' should only be implemented by classes, which could be casted to 'VolunteerRecord'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default VolunteerRecordBuilder with() { + try { + return new VolunteerRecordBuilder(VolunteerRecord.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'VolunteerRecordBuilder.With' should only be implemented by classes, which could be casted to 'VolunteerRecord'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/WholesaleAgentBuilder.java b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/WholesaleAgentBuilder.java new file mode 100644 index 00000000..2de10fc7 --- /dev/null +++ b/performance-test/generated-performance-builder/org/javahelpers/simple/builders/performance_test/library/persons/WholesaleAgentBuilder.java @@ -0,0 +1,755 @@ +package org.javahelpers.simple.builders.performance_test.library.persons; + +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.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +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.builders.ArrayListBuilder; +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.performance_test.library.persons.WholesaleAgent}. + *

    + * This builder provides a fluent API for creating instances of + * org.javahelpers.simple.builders.performance_test.library.persons.WholesaleAgent 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. + * + *

    Example:

    + * + *
    {@code
    + * WholesaleAgent result = WholesaleAgentBuilder.create()
    + *     .createdAt(LocalDate.now())
    + *     .createdAt(() -> LocalDate.now())
    + *     .discountRate(3.14)
    + *     .discountRate(() -> 3.14)
    + *     .id(UUID.randomUUID())
    + *     .id(() -> UUID.randomUUID())
    + *     .minimumOrder(42)
    + *     .minimumOrder(() -> 42)
    + *     .name("example value")
    + *     .name("Hello %s", "World")
    + *     .name(() -> "example value")
    + *     .name(sb -> sb.append("text"))
    + *     .status("example value")
    + *     .status("Hello %s", "World")
    + *     .status(() -> "example value")
    + *     .status(sb -> sb.append("text"))
    + *     .supplierNetwork(List.of("example value"))
    + *     .supplierNetwork(() -> List.of("example value"))
    + *     .supplierNetwork(t -> t.add("example value"))
    + *     .supplierNetwork("example value", "example value")
    + *     .add2SupplierNetwork("example value")
    + *     .wholesalerId("example value")
    + *     .wholesalerId("Hello %s", "World")
    + *     .wholesalerId(() -> "example value")
    + *     .wholesalerId(sb -> sb.append("text"))
    + *     .build();
    + * }
    + */ +@Generated("Generated by org.javahelpers.simple.builders.processor.BuilderProcessor") +@BuilderImplementation(forClass = WholesaleAgent.class) +public class WholesaleAgentBuilder implements IBuilderBase { + + /** + * Tracked value for createdAt: createdAt. + */ + private TrackedValue createdAt = unsetValue(); + /** + * Tracked value for discountRate: discountRate. + */ + private TrackedValue discountRate = unsetValue(); + /** + * Tracked value for id: id. + */ + private TrackedValue id = unsetValue(); + /** + * Tracked value for minimumOrder: minimumOrder. + */ + private TrackedValue minimumOrder = unsetValue(); + /** + * Tracked value for name: name. + */ + private TrackedValue name = unsetValue(); + /** + * Tracked value for status: status. + */ + private TrackedValue status = unsetValue(); + /** + * Tracked value for supplierNetwork: supplierNetwork. + */ + private TrackedValue> supplierNetwork = unsetValue(); + /** + * Tracked value for wholesalerId: wholesalerId. + */ + private TrackedValue wholesalerId = unsetValue(); + + /** + * Empty constructor of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.WholesaleAgent}. + */ + public WholesaleAgentBuilder() { + } + + /** + * Initialisation of builder for + * {@code org.javahelpers.simple.builders.performance_test.library.persons.WholesaleAgent} by a instance. + * + * @param instance object instance for initialisiation + */ + public WholesaleAgentBuilder(WholesaleAgent instance) { + this.createdAt = initialValue(instance.getCreatedAt()); + this.discountRate = initialValue(instance.getDiscountRate()); + this.id = initialValue(instance.getId()); + this.minimumOrder = initialValue(instance.getMinimumOrder()); + this.name = initialValue(instance.getName()); + this.status = initialValue(instance.getStatus()); + this.supplierNetwork = initialValue(instance.getSupplierNetwork()); + this.wholesalerId = initialValue(instance.getWholesalerId()); + } + + /** + * Creating a new builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.WholesaleAgent}. + * + *

    Example:

    + * + *
    {@code
    +   * WholesaleAgentBuilder builder = WholesaleAgentBuilder.create();
    +   * }
    + * + * @return builder for {@code org.javahelpers.simple.builders.performance_test.library.persons.WholesaleAgent} + */ + public static WholesaleAgentBuilder create() { + return new WholesaleAgentBuilder(); + } + + /** + * Adds a single element to supplierNetwork. + *

    + * Generated from setter {@link WholesaleAgent#setSupplierNetwork(List) setSupplierNetwork(List + * supplierNetwork)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.add2SupplierNetwork("example value");
    +   * }
    + * + * @param element the element to add + * @return current instance of builder + */ + public WholesaleAgentBuilder add2SupplierNetwork(String element) { + List newCollection; + if (this.supplierNetwork.isSet()) { + newCollection = new ArrayList<>(this.supplierNetwork.value()); + } else { + newCollection = new ArrayList<>(); + } + newCollection.add(element); + this.supplierNetwork = changedValue(newCollection); + return this; + } + + /** + * Sets the value for createdAt. + *

    + * Generated from setter {@link WholesaleAgent#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(LocalDate.now());
    +   * }
    + * + * @param createdAt createdAt + * @return current instance of builder + */ + public WholesaleAgentBuilder createdAt(LocalDate createdAt) { + this.createdAt = changedValue(createdAt); + return this; + } + + /** + * Sets the value for createdAt by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setCreatedAt(LocalDate) setCreatedAt(LocalDate createdAt)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.createdAt(() -> LocalDate.now());
    +   * }
    + * + * @param createdAtSupplier supplier for createdAt + * @return current instance of builder + */ + public WholesaleAgentBuilder createdAt(Supplier createdAtSupplier) { + this.createdAt = changedValue(createdAtSupplier.get()); + return this; + } + + /** + * Sets the value for discountRate. + *

    + * Generated from setter {@link WholesaleAgent#setDiscountRate(double) setDiscountRate(double discountRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.discountRate(3.14);
    +   * }
    + * + * @param discountRate discountRate + * @return current instance of builder + */ + public WholesaleAgentBuilder discountRate(double discountRate) { + this.discountRate = changedValue(discountRate); + return this; + } + + /** + * Sets the value for discountRate by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setDiscountRate(double) setDiscountRate(double discountRate)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.discountRate(() -> 3.14);
    +   * }
    + * + * @param discountRateSupplier supplier for discountRate + * @return current instance of builder + */ + public WholesaleAgentBuilder discountRate(Supplier discountRateSupplier) { + this.discountRate = changedValue(discountRateSupplier.get()); + return this; + } + + /** + * Sets the value for id. + *

    + * Generated from setter {@link WholesaleAgent#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(UUID.randomUUID());
    +   * }
    + * + * @param id id + * @return current instance of builder + */ + public WholesaleAgentBuilder id(UUID id) { + this.id = changedValue(id); + return this; + } + + /** + * Sets the value for id by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setId(UUID) setId(UUID id)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.id(() -> UUID.randomUUID());
    +   * }
    + * + * @param idSupplier supplier for id + * @return current instance of builder + */ + public WholesaleAgentBuilder id(Supplier idSupplier) { + this.id = changedValue(idSupplier.get()); + return this; + } + + /** + * Sets the value for minimumOrder. + *

    + * Generated from setter {@link WholesaleAgent#setMinimumOrder(int) setMinimumOrder(int minimumOrder)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.minimumOrder(42);
    +   * }
    + * + * @param minimumOrder minimumOrder + * @return current instance of builder + */ + public WholesaleAgentBuilder minimumOrder(int minimumOrder) { + this.minimumOrder = changedValue(minimumOrder); + return this; + } + + /** + * Sets the value for minimumOrder by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setMinimumOrder(int) setMinimumOrder(int minimumOrder)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.minimumOrder(() -> 42);
    +   * }
    + * + * @param minimumOrderSupplier supplier for minimumOrder + * @return current instance of builder + */ + public WholesaleAgentBuilder minimumOrder(Supplier minimumOrderSupplier) { + this.minimumOrder = changedValue(minimumOrderSupplier.get()); + return this; + } + + /** + * Sets the value for name. + *

    + * Generated from setter {@link WholesaleAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("example value");
    +   * }
    + * + * @param name name + * @return current instance of builder + */ + public WholesaleAgentBuilder name(String name) { + this.name = changedValue(name); + return this; + } + + /** + * Sets the value for name by executing the provided consumer. + *

    + * Generated from setter {@link WholesaleAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(sb -> sb.append("text"));
    +   * }
    + * + * @param nameStringBuilderConsumer consumer providing an instance of name + * @return current instance of builder + */ + public WholesaleAgentBuilder 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. + *

    + * Generated from setter {@link WholesaleAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name(() -> "example value");
    +   * }
    + * + * @param nameSupplier supplier for name + * @return current instance of builder + */ + public WholesaleAgentBuilder 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. + *

    + * Generated from setter {@link WholesaleAgent#setName(String) setName(String name)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.name("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WholesaleAgentBuilder name(String format, Object... args) { + this.name = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for status. + *

    + * Generated from setter {@link WholesaleAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("example value");
    +   * }
    + * + * @param status status + * @return current instance of builder + */ + public WholesaleAgentBuilder status(String status) { + this.status = changedValue(status); + return this; + } + + /** + * Sets the value for status by executing the provided consumer. + *

    + * Generated from setter {@link WholesaleAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(sb -> sb.append("text"));
    +   * }
    + * + * @param statusStringBuilderConsumer consumer providing an instance of status + * @return current instance of builder + */ + public WholesaleAgentBuilder status(Consumer statusStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + statusStringBuilderConsumer.accept(builder); + this.status = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for status by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status(() -> "example value");
    +   * }
    + * + * @param statusSupplier supplier for status + * @return current instance of builder + */ + public WholesaleAgentBuilder status(Supplier statusSupplier) { + this.status = changedValue(statusSupplier.get()); + return this; + } + + /** + * Sets the String value for status by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link WholesaleAgent#setStatus(String) setStatus(String status)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.status("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WholesaleAgentBuilder status(String format, Object... args) { + this.status = changedValue(String.format(format, args)); + return this; + } + + /** + * Sets the value for supplierNetwork. + *

    + * Generated from setter {@link WholesaleAgent#setSupplierNetwork(List) setSupplierNetwork(List + * supplierNetwork)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierNetwork("example value", "example value");
    +   * }
    + * + * @param supplierNetwork supplierNetwork + * @return current instance of builder + */ + public WholesaleAgentBuilder supplierNetwork(String... supplierNetwork) { + this.supplierNetwork = changedValue(List.of(supplierNetwork)); + return this; + } + + /** + * Sets the value for supplierNetwork. + *

    + * Generated from setter {@link WholesaleAgent#setSupplierNetwork(List) setSupplierNetwork(List + * supplierNetwork)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierNetwork(List.of("example value"));
    +   * }
    + * + * @param supplierNetwork supplierNetwork + * @return current instance of builder + */ + public WholesaleAgentBuilder supplierNetwork(List supplierNetwork) { + this.supplierNetwork = changedValue(supplierNetwork); + return this; + } + + /** + * Sets the value for supplierNetwork using a builder consumer that produces the value. + *

    + * Generated from setter {@link WholesaleAgent#setSupplierNetwork(List) setSupplierNetwork(List + * supplierNetwork)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierNetwork(t -> t.add("example value"));
    +   * }
    + * + * @param supplierNetworkBuilderConsumer consumer providing an instance of a builder for supplierNetwork + * @return current instance of builder + */ + public WholesaleAgentBuilder supplierNetwork(Consumer> supplierNetworkBuilderConsumer) { + ArrayListBuilder builder = this.supplierNetwork.isSet() + ? new ArrayListBuilder(this.supplierNetwork.value()) + : new ArrayListBuilder(); + supplierNetworkBuilderConsumer.accept(builder); + this.supplierNetwork = changedValue(builder.build()); + return this; + } + + /** + * Sets the value for supplierNetwork by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setSupplierNetwork(List) setSupplierNetwork(List + * supplierNetwork)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.supplierNetwork(() -> List.of("example value"));
    +   * }
    + * + * @param supplierNetworkSupplier supplier for supplierNetwork + * @return current instance of builder + */ + public WholesaleAgentBuilder supplierNetwork(Supplier> supplierNetworkSupplier) { + this.supplierNetwork = changedValue(supplierNetworkSupplier.get()); + return this; + } + + /** + * Sets the value for wholesalerId. + *

    + * Generated from setter {@link WholesaleAgent#setWholesalerId(String) setWholesalerId(String wholesalerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wholesalerId("example value");
    +   * }
    + * + * @param wholesalerId wholesalerId + * @return current instance of builder + */ + public WholesaleAgentBuilder wholesalerId(String wholesalerId) { + this.wholesalerId = changedValue(wholesalerId); + return this; + } + + /** + * Sets the value for wholesalerId by executing the provided consumer. + *

    + * Generated from setter {@link WholesaleAgent#setWholesalerId(String) setWholesalerId(String wholesalerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wholesalerId(sb -> sb.append("text"));
    +   * }
    + * + * @param wholesalerIdStringBuilderConsumer consumer providing an instance of wholesalerId + * @return current instance of builder + */ + public WholesaleAgentBuilder wholesalerId(Consumer wholesalerIdStringBuilderConsumer) { + StringBuilder builder = new StringBuilder(); + wholesalerIdStringBuilderConsumer.accept(builder); + this.wholesalerId = changedValue(builder.toString()); + return this; + } + + /** + * Sets the value for wholesalerId by invoking the provided supplier. + *

    + * Generated from setter {@link WholesaleAgent#setWholesalerId(String) setWholesalerId(String wholesalerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wholesalerId(() -> "example value");
    +   * }
    + * + * @param wholesalerIdSupplier supplier for wholesalerId + * @return current instance of builder + */ + public WholesaleAgentBuilder wholesalerId(Supplier wholesalerIdSupplier) { + this.wholesalerId = changedValue(wholesalerIdSupplier.get()); + return this; + } + + /** + * Sets the String value for wholesalerId by using String.format(format, args). See + * {@link String#format(String, Object...)} for details. + *

    + * Generated from setter {@link WholesaleAgent#setWholesalerId(String) setWholesalerId(String wholesalerId)} + * + *

    Example:

    + * + *
    {@code
    +   * builder.wholesalerId("Hello %s", "World");
    +   * }
    + * + * @param format A format string + * @param args Arguments referenced by the format specifiers in the format string. + * @return current instance of builder + */ + public WholesaleAgentBuilder wholesalerId(String format, Object... args) { + this.wholesalerId = changedValue(String.format(format, args)); + 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 WholesaleAgentBuilder 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 WholesaleAgentBuilder 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. + * + *

    Example:

    + * + *
    {@code
    +   * WholesaleAgent result = builder.build();
    +   * }
    + */ + @Override + public WholesaleAgent build() { + if (this.discountRate.isSet() && this.discountRate.value() == null) { + throw new IllegalStateException("Field 'discountRate' is marked as non-null but null value was provided"); + } + if (this.minimumOrder.isSet() && this.minimumOrder.value() == null) { + throw new IllegalStateException("Field 'minimumOrder' is marked as non-null but null value was provided"); + } + WholesaleAgent result = new WholesaleAgent(); + this.createdAt.ifSet(result::setCreatedAt); + this.discountRate.ifSet(result::setDiscountRate); + this.id.ifSet(result::setId); + this.minimumOrder.ifSet(result::setMinimumOrder); + this.name.ifSet(result::setName); + this.status.ifSet(result::setStatus).orElse("ACTIVE"); + this.supplierNetwork.ifSet(result::setSupplierNetwork); + this.wholesalerId.ifSet(result::setWholesalerId); + 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("createdAt", this.createdAt) + .append("discountRate", this.discountRate) + .append("id", this.id) + .append("minimumOrder", this.minimumOrder) + .append("name", this.name) + .append("status", this.status) + .append("supplierNetwork", this.supplierNetwork) + .append("wholesalerId", this.wholesalerId) + .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 WholesaleAgent with(Consumer b) { + WholesaleAgentBuilder builder; + try { + builder = new WholesaleAgentBuilder(WholesaleAgent.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WholesaleAgentBuilder.With' should only be implemented by classes, which could be casted to 'WholesaleAgent'", + ex); + } + b.accept(builder); + return builder.build(); + } + + /** + * Creates a builder initialized from this instance. + * + * @return a builder initialized with this instance's values + */ + default WholesaleAgentBuilder with() { + try { + return new WholesaleAgentBuilder(WholesaleAgent.class.cast(this)); + } catch (ClassCastException ex) { + throw new IllegalArgumentException( + "The interface 'WholesaleAgentBuilder.With' should only be implemented by classes, which could be casted to 'WholesaleAgent'", + ex); + } + } + } +} \ No newline at end of file diff --git a/performance-test/scripts/run_performance_analysis.py b/performance-test/scripts/run_performance_analysis.py new file mode 100644 index 00000000..e71725e8 --- /dev/null +++ b/performance-test/scripts/run_performance_analysis.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python3 +"""Run the performance-test compilation N times and aggregate JSON reports. + +Usage: + python3 scripts/run_performance_analysis.py [runs] + + runs - number of compilation runs (default: 10) + +Each run does a clean compile with performanceTracking enabled and writes +a JSON report to target/performance-reports/run-.json. After all runs, +an aggregated summary is written to target/performance-reports/summary.json. +""" + +import json +import shutil +import subprocess +import sys +import time +from pathlib import Path +from typing import Optional + +BASE_DIR = Path(__file__).resolve().parent.parent +REPORT_DIR = BASE_DIR / "target" / "performance-reports" + + +def run_one(run_index: int) -> Optional[dict]: + """Run a single clean compile and return the parsed JSON report.""" + report_file = REPORT_DIR / f"run-{run_index:02d}.json" + + print(f" Run {run_index}: compiling...", flush=True) + start = time.time() + + result = subprocess.run( + [ + "mvn", "clean", "compile", + "-Dsimplebuilder.performanceTracking=true", + f"-Dsimplebuilder.performanceOutputFile={report_file}", + "-q", + ], + cwd=BASE_DIR, + capture_output=True, + text=True, + ) + + elapsed = time.time() - start + + if result.returncode != 0: + print(f" Run {run_index}: FAILED (exit {result.returncode}, {elapsed:.1f}s)") + print(result.stderr[-500:] if result.stderr else "(no stderr)") + return None + + if not report_file.exists(): + print(f" Run {run_index}: compiled OK but no JSON report found ({elapsed:.1f}s)") + return None + + with report_file.open() as f: + data = json.load(f) + + print( + f" Run {run_index}: OK - {data['totalClasses']} classes, " + f"{data['totalProcessingTimeSeconds']}s processor, " + f"{elapsed:.1f}s total wall time", + flush=True, + ) + return data + + +def aggregate(runs: list[dict]) -> dict: + """Aggregate results from multiple runs into a summary.""" + n = len(runs) + if n == 0: + return {"error": "no successful runs"} + + total_times = [r["totalProcessingTimeSeconds"] for r in runs] + avg_times = [r["averagePerClassMs"] for r in runs] + wall_times = [r.get("_wallTimeSeconds", 0) for r in runs] + + summary = { + "runCount": n, + "processorTime": { + "min": min(total_times), + "max": max(total_times), + "avg": sum(total_times) / n, + "values": total_times, + }, + "averagePerClassMs": { + "min": min(avg_times), + "max": max(avg_times), + "avg": sum(avg_times) / n, + "values": avg_times, + }, + "wallTime": { + "min": min(wall_times), + "max": max(wall_times), + "avg": sum(wall_times) / n, + "values": wall_times, + }, + "totalClasses": runs[0]["totalClasses"], + } + + # Aggregate phase breakdown (average elapsedNanos across runs) + first_phases = runs[0]["phaseBreakdown"] + phase_avgs = {} # type: dict[str, float] + + def collect_phase_avg(phases: dict, all_runs_phases: list[dict], path: str = ""): + for phase_name, phase_data in phases.items(): + full_path = f"{path}.{phase_name}" if path else phase_name + nanos_list = [] + for run_phases in all_runs_phases: + p = run_phases + for part in full_path.split("."): + if part in p: + p = p[part] + elif "children" in p and part in p["children"]: + p = p["children"][part] + else: + p = None + break + if p and "elapsedNanos" in p: + nanos_list.append(p["elapsedNanos"]) + if nanos_list: + phase_avgs[full_path] = sum(nanos_list) / len(nanos_list) + children = phase_data.get("children") + if children: + collect_phase_avg(children, [rp.get("phaseBreakdown", {}) for rp in runs], full_path) + + collect_phase_avg(first_phases, [r["phaseBreakdown"] for r in runs]) + summary["phaseAverageNanos"] = phase_avgs + + # Aggregate top 10 slowest classes (by average elapsedMs across runs) + class_times = {} # type: dict[str, list[float]] + class_info: dict[str, dict] = {} + for run in runs: + for cm in run["classMetrics"]: + name = cm["className"] + class_times.setdefault(name, []).append(cm["elapsedMs"]) + class_info[name] = { + "fieldCount": cm["fieldCount"], + "collectionCount": cm["collectionCount"], + } + + class_avgs = [] + for name, times in class_times.items(): + class_avgs.append({ + "className": name, + "avgMs": sum(times) / len(times), + "minMs": min(times), + "maxMs": max(times), + "fieldCount": class_info[name]["fieldCount"], + "collectionCount": class_info[name]["collectionCount"], + }) + class_avgs.sort(key=lambda x: x["avgMs"], reverse=True) + summary["topClassesByAvg"] = class_avgs[:20] + + # Aggregate generator stats + gen_times = {} # type: dict[str, dict[str, list]] + for run in runs: + for gs in run["generatorStats"]: + name = gs["name"] + gen_times.setdefault(name, {"elapsedNanos": [], "calls": [], "avgMsPerCall": []}) + gen_times[name]["elapsedNanos"].append(gs["elapsedNanos"]) + gen_times[name]["calls"].append(gs["calls"]) + gen_times[name]["avgMsPerCall"].append(gs["avgMsPerCall"]) + + summary["generatorStats"] = [] + for name, vals in gen_times.items(): + summary["generatorStats"].append({ + "name": name, + "avgElapsedNanos": sum(vals["elapsedNanos"]) / len(vals["elapsedNanos"]), + "avgCalls": sum(vals["calls"]) / len(vals["calls"]), + "avgMsPerCall": sum(vals["avgMsPerCall"]) / len(vals["avgMsPerCall"]), + }) + summary["generatorStats"].sort(key=lambda x: x["avgElapsedNanos"], reverse=True) + + # Aggregate enhancer stats + enh_times = {} # type: dict[str, dict[str, list]] + for run in runs: + for es in run["enhancerStats"]: + name = es["name"] + enh_times.setdefault(name, {"elapsedNanos": [], "calls": [], "avgMsPerCall": []}) + enh_times[name]["elapsedNanos"].append(es["elapsedNanos"]) + enh_times[name]["calls"].append(es["calls"]) + enh_times[name]["avgMsPerCall"].append(es["avgMsPerCall"]) + + summary["enhancerStats"] = [] + for name, vals in enh_times.items(): + summary["enhancerStats"].append({ + "name": name, + "avgElapsedNanos": sum(vals["elapsedNanos"]) / len(vals["elapsedNanos"]), + "avgCalls": sum(vals["calls"]) / len(vals["calls"]), + "avgMsPerCall": sum(vals["avgMsPerCall"]) / len(vals["avgMsPerCall"]), + }) + summary["enhancerStats"].sort(key=lambda x: x["avgElapsedNanos"], reverse=True) + + return summary + + +def main() -> None: + num_runs = int(sys.argv[1]) if len(sys.argv) > 1 else 10 + + if REPORT_DIR.exists(): + shutil.rmtree(REPORT_DIR) + REPORT_DIR.mkdir(parents=True) + + print(f"Running {num_runs} performance analysis runs...") + print(f"Report directory: {REPORT_DIR}") + print() + + runs: list[dict] = [] + for i in range(1, num_runs + 1): + run_start = time.time() + data = run_one(i) + if data is not None: + data["_wallTimeSeconds"] = time.time() - run_start + runs.append(data) + + print() + print(f"Successful runs: {len(runs)}/{num_runs}") + + if not runs: + print("No successful runs to aggregate.") + sys.exit(1) + + summary = aggregate(runs) + summary_file = REPORT_DIR / "summary.json" + with summary_file.open("w") as f: + json.dump(summary, f, indent=2) + + print() + print("=== Summary ===") + print(f" Runs: {summary['runCount']}") + print(f" Classes per run: {summary['totalClasses']}") + print(f" Processor time avg: {summary['processorTime']['avg']:.1f}s " + f"(min: {summary['processorTime']['min']:.1f}s, max: {summary['processorTime']['max']:.1f}s)") + print(f" Avg per class: {summary['averagePerClassMs']['avg']:.1f}ms " + f"(min: {summary['averagePerClassMs']['min']:.1f}ms, max: {summary['averagePerClassMs']['max']:.1f}ms)") + print(f" Wall time avg: {summary['wallTime']['avg']:.1f}s") + print() + print(" Top 5 classes by avg time:") + for c in summary["topClassesByAvg"][:5]: + print(f" {c['className']}: {c['avgMs']:.1f}ms avg " + f"({c['minMs']:.1f}-{c['maxMs']:.1f}ms, {c['fieldCount']} fields, {c['collectionCount']} collections)") + print() + print(f"Summary written to: {summary_file}") + + +if __name__ == "__main__": + main() diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java index 4703b5b0..6dfcbd60 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/CompilerArgumentsEnum.java @@ -137,6 +137,9 @@ public enum CompilerArgumentsEnum { /** Option for performance tracking during annotation processing. */ PERFORMANCE_TRACKING("performanceTracking"), + /** Option for performance report JSON output file path. */ + PERFORMANCE_OUTPUT_FILE("performanceOutputFile"), + // === Error Handling === /** * Option for strict/fail-fast generation mode. When enabled, builder (and Jackson module) diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java index ca2c832d..4caeee8e 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/ProcessingContext.java @@ -77,8 +77,11 @@ public ProcessingContext( CompilerArgumentsReader argReader = new CompilerArgumentsReader(processingEnv); boolean perfTrackingEnabled = argReader.readBooleanValue(CompilerArgumentsEnum.PERFORMANCE_TRACKING); + String perfOutputFile = argReader.readValue(CompilerArgumentsEnum.PERFORMANCE_OUTPUT_FILE); this.performanceTracker = - perfTrackingEnabled ? new ActivePerformanceTracker() : new NoOpPerformanceTracker(); + perfTrackingEnabled + ? new ActivePerformanceTracker(perfOutputFile) + : new NoOpPerformanceTracker(); // GeneratorRegistry will be lazily initialized on first access } diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java index 53a4d419..e38c519b 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java @@ -24,6 +24,12 @@ package org.javahelpers.simple.builders.processor.processing.logging; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Instant; import java.util.ArrayList; import java.util.Comparator; import java.util.LinkedHashMap; @@ -108,13 +114,19 @@ public final class ActivePerformanceTracker implements PerformanceTracker { private long totalStartTime; private int totalClasses = 0; + private final String outputFilePath; private String currentClassName; private long classStartTime; - /** Creates a new ActivePerformanceTracker and records the overall start time. */ - public ActivePerformanceTracker() { + /** + * Creates a new ActivePerformanceTracker and records the overall start time. + * + * @param outputFilePath optional path for JSON report output; null or empty disables file output + */ + public ActivePerformanceTracker(String outputFilePath) { this.totalStartTime = System.nanoTime(); + this.outputFilePath = outputFilePath; } @Override @@ -278,6 +290,16 @@ public void generateReport(ProcessingLogger logger) { avgMs)); } } + + // Write JSON report if output file is configured + if (outputFilePath != null && !outputFilePath.isBlank()) { + try { + writeJsonReport(totalTime); + logger.info("Performance JSON report written to: %s", outputFilePath); + } catch (IOException e) { + logger.warning("Failed to write performance JSON report: %s", e.getMessage()); + } + } } /** Record for per-class performance metrics. */ @@ -301,4 +323,231 @@ private void reportPhase( } } } + + /** + * Writes the performance report as structured JSON to the configured output file. + * + * @param totalNanos total processing time in nanoseconds + * @throws IOException if the file cannot be written + */ + private void writeJsonReport(long totalNanos) throws IOException { + double totalSeconds = totalNanos / 1_000_000_000.0; + double avgPerClassMs = totalClasses > 0 ? (totalNanos / 1_000_000.0) / totalClasses : 0; + + StringBuilder sb = new StringBuilder(4096); + String indent = " "; + String indent2 = indent + indent; + String indent3 = indent + indent + indent; + + sb.append("{\n"); + sb.append(indent) + .append(jsonString("timestamp")) + .append(": ") + .append(jsonString(Instant.now().toString())) + .append(",\n"); + sb.append(indent) + .append(jsonString("totalClasses")) + .append(": ") + .append(totalClasses) + .append(",\n"); + sb.append(indent) + .append(jsonString("totalProcessingTimeNanos")) + .append(": ") + .append(totalNanos) + .append(",\n"); + sb.append(indent) + .append(jsonString("totalProcessingTimeSeconds")) + .append(": ") + .append(String.format(Locale.US, "%.3f", totalSeconds)) + .append(",\n"); + sb.append(indent) + .append(jsonString("averagePerClassMs")) + .append(": ") + .append(String.format(Locale.US, "%.3f", avgPerClassMs)) + .append(",\n"); + + // Phase breakdown + sb.append(indent).append(jsonString("phaseBreakdown")).append(": {\n"); + for (int i = 0; i < TOP_LEVEL_PHASES.size(); i++) { + appendPhaseJson( + sb, TOP_LEVEL_PHASES.get(i), totalNanos, indent2, i == TOP_LEVEL_PHASES.size() - 1); + } + sb.append(indent).append("},\n"); + + // Class metrics (all, sorted by elapsed descending) + List sortedClasses = new ArrayList<>(classMetrics); + sortedClasses.sort(Comparator.comparingLong(ClassMetric::elapsedNanos).reversed()); + sb.append(indent).append(jsonString("classMetrics")).append(": [\n"); + for (int i = 0; i < sortedClasses.size(); i++) { + ClassMetric cm = sortedClasses.get(i); + double ms = cm.elapsedNanos() / 1_000_000.0; + sb.append(indent2).append("{\n"); + sb.append(indent3) + .append(jsonString("className")) + .append(": ") + .append(jsonString(cm.className())) + .append(",\n"); + sb.append(indent3) + .append(jsonString("elapsedNanos")) + .append(": ") + .append(cm.elapsedNanos()) + .append(",\n"); + sb.append(indent3) + .append(jsonString("elapsedMs")) + .append(": ") + .append(String.format(Locale.US, "%.3f", ms)) + .append(",\n"); + sb.append(indent3) + .append(jsonString("fieldCount")) + .append(": ") + .append(cm.fieldCount()) + .append(",\n"); + sb.append(indent3) + .append(jsonString("collectionCount")) + .append(": ") + .append(cm.collectionCount()) + .append("\n"); + sb.append(indent2).append(i < sortedClasses.size() - 1 ? "},\n" : "}\n"); + } + sb.append(indent).append("],\n"); + + // Generator stats + List> sortedGenerators = new ArrayList<>(generatorTimes.entrySet()); + sortedGenerators.sort(Map.Entry.comparingByValue().reversed()); + sb.append(indent).append(jsonString("generatorStats")).append(": [\n"); + for (int i = 0; i < sortedGenerators.size(); i++) { + Map.Entry entry = sortedGenerators.get(i); + int calls = generatorCalls.getOrDefault(entry.getKey(), 0); + double avgMs = calls > 0 ? (entry.getValue() / 1_000_000.0) / calls : 0; + sb.append(indent2).append("{\n"); + sb.append(indent3) + .append(jsonString("name")) + .append(": ") + .append(jsonString(entry.getKey())) + .append(",\n"); + sb.append(indent3) + .append(jsonString("elapsedNanos")) + .append(": ") + .append(entry.getValue()) + .append(",\n"); + sb.append(indent3).append(jsonString("calls")).append(": ").append(calls).append(",\n"); + sb.append(indent3) + .append(jsonString("avgMsPerCall")) + .append(": ") + .append(String.format(Locale.US, "%.3f", avgMs)) + .append("\n"); + sb.append(indent2).append(i < sortedGenerators.size() - 1 ? "},\n" : "}\n"); + } + sb.append(indent).append("],\n"); + + // Enhancer stats + List> sortedEnhancers = new ArrayList<>(enhancerTimes.entrySet()); + sortedEnhancers.sort(Map.Entry.comparingByValue().reversed()); + sb.append(indent).append(jsonString("enhancerStats")).append(": [\n"); + for (int i = 0; i < sortedEnhancers.size(); i++) { + Map.Entry entry = sortedEnhancers.get(i); + int calls = enhancerCalls.getOrDefault(entry.getKey(), 0); + double avgMs = calls > 0 ? (entry.getValue() / 1_000_000.0) / calls : 0; + sb.append(indent2).append("{\n"); + sb.append(indent3) + .append(jsonString("name")) + .append(": ") + .append(jsonString(entry.getKey())) + .append(",\n"); + sb.append(indent3) + .append(jsonString("elapsedNanos")) + .append(": ") + .append(entry.getValue()) + .append(",\n"); + sb.append(indent3).append(jsonString("calls")).append(": ").append(calls).append(",\n"); + sb.append(indent3) + .append(jsonString("avgMsPerCall")) + .append(": ") + .append(String.format(Locale.US, "%.3f", avgMs)) + .append("\n"); + sb.append(indent2).append(i < sortedEnhancers.size() - 1 ? "},\n" : "}\n"); + } + sb.append(indent).append("]\n"); + + sb.append("}\n"); + + Path outPath = Paths.get(outputFilePath); + if (outPath.getParent() != null) { + Files.createDirectories(outPath.getParent()); + } + Files.writeString(outPath, sb.toString(), StandardCharsets.UTF_8); + } + + /** + * Appends a phase entry (with children) as JSON. + * + * @param sb the string builder to append to + * @param phase the phase name + * @param parentNanos the parent phase total in nanoseconds (for percentage calculation) + * @param indent the indentation string for this level + * @param isLast whether this is the last sibling at this level + */ + private void appendPhaseJson( + StringBuilder sb, String phase, long parentNanos, String indent, boolean isLast) { + long nanos = phaseTimes.getOrDefault(phase, 0L); + double seconds = nanos / 1_000_000_000.0; + double percentage = parentNanos > 0 ? (nanos * 100.0 / parentNanos) : 0; + String childIndent = indent + " "; + + sb.append(indent).append(jsonString(phase)).append(": {\n"); + sb.append(childIndent) + .append(jsonString("elapsedNanos")) + .append(": ") + .append(nanos) + .append(",\n"); + sb.append(childIndent) + .append(jsonString("elapsedSeconds")) + .append(": ") + .append(String.format(Locale.US, "%.3f", seconds)) + .append(",\n"); + sb.append(childIndent) + .append(jsonString("percentage")) + .append(": ") + .append(String.format(Locale.US, "%.1f", percentage)); + + List children = PHASE_CHILDREN.get(phase); + if (children != null && !children.isEmpty()) { + sb.append(",\n"); + sb.append(childIndent).append(jsonString("children")).append(": {\n"); + for (int i = 0; i < children.size(); i++) { + appendPhaseJson(sb, children.get(i), nanos, childIndent + " ", i == children.size() - 1); + } + sb.append(childIndent).append("}\n"); + } else { + sb.append("\n"); + } + sb.append(indent).append(isLast ? "}\n" : "},\n"); + } + + /** + * Escapes a string value for JSON output. + * + * @param value the raw string + * @return the JSON-escaped string wrapped in double quotes + */ + private static String jsonString(String value) { + if (value == null) { + return "null"; + } + StringBuilder escaped = new StringBuilder(value.length() + 2); + escaped.append('"'); + for (int i = 0; i < value.length(); i++) { + char c = value.charAt(i); + switch (c) { + case '"' -> escaped.append("\\\""); + case '\\' -> escaped.append("\\\\"); + case '\n' -> escaped.append("\\n"); + case '\r' -> escaped.append("\\r"); + case '\t' -> escaped.append("\\t"); + default -> escaped.append(c); + } + } + escaped.append('"'); + return escaped.toString(); + } } From cea56110439d70211b80f7e0a43da878650c7eac Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sat, 22 Aug 2026 18:05:01 +0200 Subject: [PATCH 11/35] Hardening the ActivePerformanceTracker --- .../processing/logging/ActivePerformanceTracker.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java index e38c519b..a2c61403 100644 --- a/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java +++ b/processor/src/main/java/org/javahelpers/simple/builders/processor/processing/logging/ActivePerformanceTracker.java @@ -296,7 +296,7 @@ public void generateReport(ProcessingLogger logger) { try { writeJsonReport(totalTime); logger.info("Performance JSON report written to: %s", outputFilePath); - } catch (IOException e) { + } catch (IOException | java.nio.file.InvalidPathException | SecurityException e) { logger.warning("Failed to write performance JSON report: %s", e.getMessage()); } } @@ -544,7 +544,15 @@ private static String jsonString(String value) { case '\n' -> escaped.append("\\n"); case '\r' -> escaped.append("\\r"); case '\t' -> escaped.append("\\t"); - default -> escaped.append(c); + case '\b' -> escaped.append("\\b"); + case '\f' -> escaped.append("\\f"); + default -> { + if (c < 0x20) { + escaped.append(String.format("\\u%04x", (int) c)); + } else { + escaped.append(c); + } + } } } escaped.append('"'); From dfa067d4c9bb1ac261566334624d697aa847bfe5 Mon Sep 17 00:00:00 2001 From: AndreasIgel Date: Sun, 23 Aug 2026 02:28:26 +0200 Subject: [PATCH 12/35] Adding run-profiles for all potential builder-types, adapting script for generating classes and adding documentation --- performance-test/docs/PERFORMANCE_ANALYSIS.md | 243 ++++++++++++++++++ performance-test/pom.xml | 172 +++++++++++++ performance-test/scripts/generate_classes.py | 212 +++++++++++++-- 3 files changed, 602 insertions(+), 25 deletions(-) create mode 100644 performance-test/docs/PERFORMANCE_ANALYSIS.md diff --git a/performance-test/docs/PERFORMANCE_ANALYSIS.md b/performance-test/docs/PERFORMANCE_ANALYSIS.md new file mode 100644 index 00000000..dc9fcb7c --- /dev/null +++ b/performance-test/docs/PERFORMANCE_ANALYSIS.md @@ -0,0 +1,243 @@ +# Performance Analysis Guide + +This guide explains how to run performance analysis for different builder +frameworks using the scripts in the `performance-test` module. + +## Overview + +The performance test module generates a large set of Java classes (records and +plain classes) from a JSON catalog, then compiles them with a builder annotation +processor to measure processing time. Three scripts work together: + +| Script | Purpose | +|---|---| +| `generate_classes.py` | Generate Java source files with a chosen builder annotation | +| `run_performance_analysis.py` | Run N compilations and aggregate timing results | +| `compare_performance.py` | Compare results from multiple analysis runs side-by-side | + +## Supported Builder Types + +| `--builder-type` | Annotation | Maven Profile | JSON Report | Notes | +|---|---|---|---|---| +| `simple-builder` | `@SimpleBuilder` | `simplebuilder` | Yes | Full feature set (default) | +| `simple-minimal-builder` | `@MinimalBuilder` | `minimalbuilder` | Yes | All optional features disabled | +| `record-builder` | `@RecordBuilder` | `recordbuilder` | No | RecordBuilder library (wall-time only) | +| `lombok` | `@Builder` | `lombok` | No | Lombok (wall-time only) | + +Profiles with JSON reports produce detailed phase/class/generator/enhancer +metrics. Profiles without JSON reports only measure overall wall time. + +## Step-by-Step: Running an Analysis + +### 1. Generate Classes + +Generate Java source files with the desired builder annotation: + +```bash +# SimpleBuilder (default) +python3 scripts/generate_classes.py + +# MinimalBuilder +python3 scripts/generate_classes.py --builder-type simple-minimal-builder + +# RecordBuilder +python3 scripts/generate_classes.py --builder-type record-builder + +# Lombok +python3 scripts/generate_classes.py --builder-type lombok +``` + +**Important:** Always regenerate classes when switching builder types. The +generated source files use different annotations and imports for each framework. + +Use `--force` to overwrite existing files: + +```bash +python3 scripts/generate_classes.py --builder-type lombok --force +``` + +Use `--dry-run` to preview without writing: + +```bash +python3 scripts/generate_classes.py --builder-type record-builder --dry-run +``` + +#### Custom Annotations + +For annotations not covered by the presets, use individual parameters: + +```bash +python3 scripts/generate_classes.py \ + --annotation MyBuilder \ + --annotation-import com.example.MyBuilder \ + --record-implements-suffix MyBuilder.With \ + --default-import com.example.Default \ + --ignore-import com.example.IgnoreInBuilder +``` + +Individual parameters override preset values when used together with +`--builder-type`. + +### 2. Run Performance Analysis + +Run N compilations and collect timing data: + +```bash +# SimpleBuilder — 30 runs, labeled "sb-30runs" +python3 scripts/run_performance_analysis.py \ + --runs 30 --label sb-30runs --profile simplebuilder + +# MinimalBuilder — 30 runs, labeled "mb-30runs" +python3 scripts/run_performance_analysis.py \ + --runs 30 --label mb-30runs --profile minimalbuilder + +# RecordBuilder — 30 runs, wall-time only +python3 scripts/run_performance_analysis.py \ + --runs 30 --label rb-30runs --profile recordbuilder + +# Lombok — 30 runs, wall-time only +python3 scripts/run_performance_analysis.py \ + --runs 30 --label lombok-30runs --profile lombok +``` + +Results are written to `target/performance-reports/