diff --git a/src/main/java/tech/jhipster/lite/common/domain/Enums.java b/src/main/java/tech/jhipster/lite/common/domain/Enums.java index 6b04c18d599..e21c6cbb020 100644 --- a/src/main/java/tech/jhipster/lite/common/domain/Enums.java +++ b/src/main/java/tech/jhipster/lite/common/domain/Enums.java @@ -45,6 +45,6 @@ private , To extends Enum> To get(Enum from, C }; } - private static record CacheKey, To extends Enum>(Class from, Class to) {} + private record CacheKey, To extends Enum>(Class from, Class to) {} } } diff --git a/src/main/java/tech/jhipster/lite/common/domain/Memoizers.java b/src/main/java/tech/jhipster/lite/common/domain/Memoizers.java index b65bf277bb7..4c6923e2455 100644 --- a/src/main/java/tech/jhipster/lite/common/domain/Memoizers.java +++ b/src/main/java/tech/jhipster/lite/common/domain/Memoizers.java @@ -40,8 +40,8 @@ private MemoizedResult toMemoizedResult(MemoizedInput input) { return new MemoizedResult<>(function.apply(input.input())); } - private static record MemoizedInput(Input input) {} + private record MemoizedInput(Input input) {} - private static record MemoizedResult(Result result) {} + private record MemoizedResult(Result result) {} } } diff --git a/src/main/java/tech/jhipster/lite/error/infrastructure/primary/GeneratorErrorsHandler.java b/src/main/java/tech/jhipster/lite/error/infrastructure/primary/GeneratorErrorsHandler.java index 79cfccfd2ff..f6429f022ae 100644 --- a/src/main/java/tech/jhipster/lite/error/infrastructure/primary/GeneratorErrorsHandler.java +++ b/src/main/java/tech/jhipster/lite/error/infrastructure/primary/GeneratorErrorsHandler.java @@ -1,6 +1,7 @@ package tech.jhipster.lite.error.infrastructure.primary; import java.util.Locale; +import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; @@ -33,7 +34,7 @@ public GeneratorErrorsHandler(@Qualifier("generatorErrorMessageSource") MessageS @ExceptionHandler(GeneratorException.class) ProblemDetail handleGeneratorException(GeneratorException exception) { - HttpStatus status = Enums.map(exception.status(), HttpStatus.class); + HttpStatus status = Optional.ofNullable(Enums.map(exception.status(), HttpStatus.class)).orElse(HttpStatus.INTERNAL_SERVER_ERROR); ProblemDetail problem = ProblemDetail.forStatusAndDetail(status, buildDetail(exception)); problem.setTitle(getMessage(exception.key(), "title")); diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/domain/SpringdocModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/domain/SpringdocModuleFactory.java index 1579dbb930b..dbc20f69fac 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/domain/SpringdocModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/domain/SpringdocModuleFactory.java @@ -62,7 +62,7 @@ private JHipsterModule buildModule(JHipsterModuleProperties properties, SpringDo //@formatter:on } - private static record SpringDocDependencies(JavaDependency ui, JavaDependency api) { + private record SpringDocDependencies(JavaDependency ui, JavaDependency api) { private static final String SPRINGDOC_GROUP_ID = "org.springdoc"; private static final String SPRINGDOC_OPENAPI_WEBMVC_VERSION_KEY = "springdoc-openapi-starter-webmvc"; private static final String SPRINGDOC_OPENAPI_WEBFLUX_VERSION_KEY = "springdoc-openapi-starter-webflux"; diff --git a/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java b/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java index 9b5454645ff..df92810f6a5 100644 --- a/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java +++ b/src/main/java/tech/jhipster/lite/module/domain/JHipsterModule.java @@ -554,5 +554,5 @@ public JHipsterModule build() { } } - private static record PropertiesKey(SpringProfile profile, SpringPropertyType type) {} + private record PropertiesKey(SpringProfile profile, SpringPropertyType type) {} } diff --git a/src/main/java/tech/jhipster/lite/module/domain/properties/JHipsterServerPort.java b/src/main/java/tech/jhipster/lite/module/domain/properties/JHipsterServerPort.java index 1301b03e0f6..1801c6bdbc9 100644 --- a/src/main/java/tech/jhipster/lite/module/domain/properties/JHipsterServerPort.java +++ b/src/main/java/tech/jhipster/lite/module/domain/properties/JHipsterServerPort.java @@ -19,7 +19,7 @@ private int buildPort(Integer port) { return DEFAULT_PORT; } - return port.intValue(); + return port; } public int get() { diff --git a/src/main/java/tech/jhipster/lite/module/domain/replacement/JHipsterModuleMandatoryReplacementsFactory.java b/src/main/java/tech/jhipster/lite/module/domain/replacement/JHipsterModuleMandatoryReplacementsFactory.java index 964896a21ac..e094f54cde7 100644 --- a/src/main/java/tech/jhipster/lite/module/domain/replacement/JHipsterModuleMandatoryReplacementsFactory.java +++ b/src/main/java/tech/jhipster/lite/module/domain/replacement/JHipsterModuleMandatoryReplacementsFactory.java @@ -53,7 +53,7 @@ protected ContentReplacer buildReplacer(JHipsterProjectFilePath file, ElementRep } } - private static record MandatoryFileReplacer(JHipsterProjectFilePath file, MandatoryReplacer replacement) implements ContentReplacer { + private record MandatoryFileReplacer(JHipsterProjectFilePath file, MandatoryReplacer replacement) implements ContentReplacer { public MandatoryFileReplacer { Assert.notNull("file", file); Assert.notNull("replacement", replacement); @@ -70,7 +70,7 @@ public void handleError(Throwable e) { } } - private static record MandatoryReplacer(ElementReplacer replacer, String updatedValue) { + private record MandatoryReplacer(ElementReplacer replacer, String updatedValue) { public MandatoryReplacer { Assert.notNull("replacer", replacer); Assert.notNull("updatedValue", updatedValue); diff --git a/src/main/resources/generator/server/javatool/enums/main/Enums.java.mustache b/src/main/resources/generator/server/javatool/enums/main/Enums.java.mustache index 32f21cdb7f1..fa4b8173f03 100644 --- a/src/main/resources/generator/server/javatool/enums/main/Enums.java.mustache +++ b/src/main/resources/generator/server/javatool/enums/main/Enums.java.mustache @@ -45,6 +45,6 @@ public final class Enums { }; } - private static record CacheKey, To extends Enum>(Class from, Class to) {} + private record CacheKey, To extends Enum>(Class from, Class to) {} } } diff --git a/src/main/resources/generator/server/javatool/memoizers/Memoizers.java.mustache b/src/main/resources/generator/server/javatool/memoizers/Memoizers.java.mustache index 3b9710f99ee..bb19891bcb4 100644 --- a/src/main/resources/generator/server/javatool/memoizers/Memoizers.java.mustache +++ b/src/main/resources/generator/server/javatool/memoizers/Memoizers.java.mustache @@ -40,8 +40,8 @@ public final class Memoizers { return new MemoizedResult<>(function.apply(input.input())); } - private static record MemoizedInput(Input input) {} + private record MemoizedInput(Input input) {} - private static record MemoizedResult(Result result) {} + private record MemoizedResult(Result result) {} } } diff --git a/src/main/resources/generator/server/springboot/mvc/internationalized-errors/main/ApplicationErrorsHandler.java.mustache b/src/main/resources/generator/server/springboot/mvc/internationalized-errors/main/ApplicationErrorsHandler.java.mustache index 0cace1337cd..696c0406250 100644 --- a/src/main/resources/generator/server/springboot/mvc/internationalized-errors/main/ApplicationErrorsHandler.java.mustache +++ b/src/main/resources/generator/server/springboot/mvc/internationalized-errors/main/ApplicationErrorsHandler.java.mustache @@ -1,6 +1,7 @@ package {{ packageName }}.error.infrastructure.primary; import java.util.Locale; +import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; @@ -33,7 +34,7 @@ class {{ baseName }}ErrorsHandler { @ExceptionHandler({{ baseName }}Exception.class) ProblemDetail handle{{ baseName }}Exception({{ baseName }}Exception exception) { - HttpStatus status = Enums.map(exception.status(), HttpStatus.class); + HttpStatus status = Optional.ofNullable(Enums.map(exception.status(), HttpStatus.class)).orElse(HttpStatus.INTERNAL_SERVER_ERROR); ProblemDetail problem = ProblemDetail.forStatusAndDetail(status, buildDetail(exception)); problem.setTitle(getMessage(exception.key(), "title"));