diff --git a/README.md b/README.md index 3e8a734e..ca701256 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ The mustache templates can be acquired through multiple ways. io.github.chrimle openapi-to-java-records-mustache-templates - 2.2.0 + 2.2.1 ``` @@ -271,8 +271,11 @@ public record Person( } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link GenderEnum } with the matching value diff --git a/docs/index.md b/docs/index.md index 862381d8..1485c60b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -24,7 +24,7 @@ The mustache templates can be acquired through multiple ways. io.github.chrimle openapi-to-java-records-mustache-templates - 2.2.0 + 2.2.1 ``` @@ -259,8 +259,11 @@ public record Person( } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link GenderEnum } with the matching value diff --git a/pom.xml b/pom.xml index 2ab7e7c3..803872d0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.github.chrimle openapi-to-java-records-mustache-templates - 2.2.0 + 2.2.1 OpenAPI to Java records :: Mustache Templates diff --git a/src/main/resources/api.yaml b/src/main/resources/api.yaml index cda34091..65c34a71 100644 --- a/src/main/resources/api.yaml +++ b/src/main/resources/api.yaml @@ -137,6 +137,15 @@ components: - Some description of ENUM1 - Some description of ENUM2 - Some description of ENUM3 + ExampleEnumWithIntegerValues: + type: integer + description: Example of an Enum with integer values + enum: + - 100 + - 200 + - 300 + - 400 + - 500 DeprecatedExampleEnum: type: string deprecated: true @@ -161,12 +170,12 @@ components: - Some description of ENUM2 - Some description of ENUM3 exampleInnerTwo: - type: string - description: Example of another inner enum class + type: integer + description: Example of another inner enum class with integer values enum: - - ENUM1 - - ENUM2 - - ENUM3 + - 404 + - 501 + - 503 RecordWithAllConstraints: type: object description: Example of a Record which has fields with constraints diff --git a/src/main/resources/templates/generateBuilders.mustache b/src/main/resources/templates/generateBuilders.mustache index 42eeceae..fad758ef 100644 --- a/src/main/resources/templates/generateBuilders.mustache +++ b/src/main/resources/templates/generateBuilders.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is a custom template, and is used by `pojo.mustache`. diff --git a/src/main/resources/templates/javadoc.mustache b/src/main/resources/templates/javadoc.mustache index a025f519..3492c418 100644 --- a/src/main/resources/templates/javadoc.mustache +++ b/src/main/resources/templates/javadoc.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is a custom template, and is used by `pojo.mustache` and `modelEnum.mustache`. diff --git a/src/main/resources/templates/licenseInfo.mustache b/src/main/resources/templates/licenseInfo.mustache index 416315c4..ea690bd6 100644 --- a/src/main/resources/templates/licenseInfo.mustache +++ b/src/main/resources/templates/licenseInfo.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is overriding an official 'openapi-generator-maven-plugin' template. @@ -33,6 +33,6 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ \ No newline at end of file diff --git a/src/main/resources/templates/modelEnum.mustache b/src/main/resources/templates/modelEnum.mustache index 6137e672..ad78109f 100644 --- a/src/main/resources/templates/modelEnum.mustache +++ b/src/main/resources/templates/modelEnum.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is overriding an official 'openapi-generator-maven-plugin' template. @@ -54,16 +54,19 @@ } /** - * Case-{{#useEnumCaseInsensitive}}in{{/useEnumCaseInsensitive}}sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * {{#isString}}Case-{{#useEnumCaseInsensitive}}in{{/useEnumCaseInsensitive}}sensitively m{{/isString}}{{^isString}}M{{/isString}}atches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link {{classname}} } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static {{classname}} fromValue(final String value) { + public static {{classname}} fromValue(final {{{dataType}}} value) { for (final {{classname}} constant : {{classname}}.values()) { - if (constant.getValue().equals{{#useEnumCaseInsensitive}}IgnoreCase{{/useEnumCaseInsensitive}}(value)) { + if (constant.getValue().equals{{#useEnumCaseInsensitive}}{{#isString}}IgnoreCase{{/isString}}{{/useEnumCaseInsensitive}}(value)) { return constant; } } diff --git a/src/main/resources/templates/pojo.mustache b/src/main/resources/templates/pojo.mustache index 4ae5f366..080c8f21 100644 --- a/src/main/resources/templates/pojo.mustache +++ b/src/main/resources/templates/pojo.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is overriding an official 'openapi-generator-maven-plugin' template. @@ -75,16 +75,19 @@ } /** - * Case-{{#useEnumCaseInsensitive}}in{{/useEnumCaseInsensitive}}sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * {{#isString}}Case-{{#useEnumCaseInsensitive}}in{{/useEnumCaseInsensitive}}sensitively m{{/isString}}{{^isString}}M{{/isString}}atches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link {{datatypeWithEnum}} } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static {{datatypeWithEnum}} fromValue(final String value) { + public static {{datatypeWithEnum}} fromValue(final {{{dataType}}} value) { for (final {{datatypeWithEnum}} constant : {{datatypeWithEnum}}.values()) { - if (constant.getValue().equals{{#useEnumCaseInsensitive}}IgnoreCase{{/useEnumCaseInsensitive}}(value)) { + if (constant.getValue().equals{{#useEnumCaseInsensitive}}{{#isString}}IgnoreCase{{/isString}}{{/useEnumCaseInsensitive}}(value)) { return constant; } } diff --git a/src/main/resources/templates/serializableModel.mustache b/src/main/resources/templates/serializableModel.mustache index 3862fa90..58ca18d9 100644 --- a/src/main/resources/templates/serializableModel.mustache +++ b/src/main/resources/templates/serializableModel.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is a custom template, and is used by `pojo.mustache`. diff --git a/src/main/resources/templates/useBeanValidation.mustache b/src/main/resources/templates/useBeanValidation.mustache index 1f33ddf9..768deae4 100644 --- a/src/main/resources/templates/useBeanValidation.mustache +++ b/src/main/resources/templates/useBeanValidation.mustache @@ -15,7 +15,7 @@ }}{{! Source: openapi-to-java-records-mustache-templates - Version: 2.2.0 + Version: 2.2.1 This template is a custom template, and is used by `pojo.mustache`. diff --git a/src/test/java/io/github/chrimle/example/GeneratedClass.java b/src/test/java/io/github/chrimle/example/GeneratedClass.java index f4857b6c..f38aa953 100644 --- a/src/test/java/io/github/chrimle/example/GeneratedClass.java +++ b/src/test/java/io/github/chrimle/example/GeneratedClass.java @@ -33,7 +33,8 @@ public enum GeneratedClass { RECORD_WITH_ALL_CONSTRAINTS("RecordWithAllConstraints", false, false), RECORD_WITH_INNER_ENUMS("RecordWithInnerEnums", false, false), EXAMPLE_INNER_ENUM("RecordWithInnerEnums$ExampleInnerEnum", false, true), - EXAMPLE_INNER_TWO_ENUM("RecordWithInnerEnums$ExampleInnerTwoEnum", false, true); + EXAMPLE_INNER_TWO_ENUM("RecordWithInnerEnums$ExampleInnerTwoEnum", false, true), + EXAMPLE_ENUM_WITH_INTEGER_VALUES("ExampleEnumWithIntegerValues", false, true); public static final String PACKAGE_NAME = "io.github.chrimle.example"; public final String simpleClassName; diff --git a/src/test/java/io/github/chrimle/example/GeneratedField.java b/src/test/java/io/github/chrimle/example/GeneratedField.java index e8a7805c..0dcec8e3 100644 --- a/src/test/java/io/github/chrimle/example/GeneratedField.java +++ b/src/test/java/io/github/chrimle/example/GeneratedField.java @@ -52,6 +52,7 @@ public record GeneratedField( boolean isBeanValidationNullable, boolean isCustomClass, boolean isEmail, + T enumValue, Optional defaultValue, Optional pattern, Optional minLength, @@ -64,7 +65,11 @@ public record GeneratedField( Optional decimalMax) { public static Builder of(final String name, final Class type) { - return new Builder<>(name, type); + return new Builder<>(name, type, null); + } + + public static Builder of(final String name, final Class type, final T enumValue) { + return new Builder<>(name, type, enumValue); } public static class Builder { @@ -74,6 +79,7 @@ public static class Builder { private boolean isBeanValidationNullable = true; private boolean isCustomClass = false; private boolean isEmail = false; + private T enumValue; private Optional defaultValue = Optional.empty(); private Optional pattern = Optional.empty(); private Optional minLength = Optional.empty(); @@ -85,9 +91,10 @@ public static class Builder { private Optional decimalMin = Optional.empty(); private Optional decimalMax = Optional.empty(); - public Builder(final String name, final Class type) { + public Builder(final String name, final Class type, final T enumValue) { this.name = name; this.type = type; + this.enumValue = enumValue; } public Builder isNullable(final boolean isNullable) { @@ -110,6 +117,11 @@ public Builder isEmail(final boolean isEmail) { return this; } + public Builder enumValue(final T enumValue) { + this.enumValue = enumValue; + return this; + } + public Builder defaultValue(final T defaultValue) { this.defaultValue = Optional.ofNullable(defaultValue); return this; @@ -168,6 +180,7 @@ public GeneratedField build() { isBeanValidationNullable, isCustomClass, isEmail, + enumValue, defaultValue, pattern, minLength, diff --git a/src/test/java/io/github/chrimle/example/TestSuite.java b/src/test/java/io/github/chrimle/example/TestSuite.java index 166b753a..f6829f20 100644 --- a/src/test/java/io/github/chrimle/example/TestSuite.java +++ b/src/test/java/io/github/chrimle/example/TestSuite.java @@ -49,8 +49,29 @@ public void testAll(final PluginExecution pluginExecution) { private static GeneratedSource getGeneratedSourceForGeneratedClass( final GeneratedClass generatedClass, final PluginExecution pluginExecution) { return switch (generatedClass) { - case DEPRECATED_EXAMPLE_ENUM, EXAMPLE_ENUM, EXAMPLE_INNER_ENUM, EXAMPLE_INNER_TWO_ENUM -> - new GeneratedSource(pluginExecution, generatedClass); + case DEPRECATED_EXAMPLE_ENUM, EXAMPLE_ENUM, EXAMPLE_INNER_ENUM -> + new GeneratedSource( + pluginExecution, + generatedClass, + GeneratedField.of("ENUM1", String.class, "ENUM1").build(), + GeneratedField.of("ENUM2", String.class, "ENUM2").build(), + GeneratedField.of("ENUM3", String.class, "ENUM3").build()); + case EXAMPLE_INNER_TWO_ENUM -> + new GeneratedSource( + pluginExecution, + generatedClass, + GeneratedField.of("NUMBER_404", Integer.class, 404).build(), + GeneratedField.of("NUMBER_501", Integer.class, 501).build(), + GeneratedField.of("NUMBER_503", Integer.class, 503).build()); + case EXAMPLE_ENUM_WITH_INTEGER_VALUES -> + new GeneratedSource( + pluginExecution, + generatedClass, + GeneratedField.of("NUMBER_100", Integer.class, 100).build(), + GeneratedField.of("NUMBER_200", Integer.class, 200).build(), + GeneratedField.of("NUMBER_300", Integer.class, 300).build(), + GeneratedField.of("NUMBER_400", Integer.class, 400).build(), + GeneratedField.of("NUMBER_500", Integer.class, 500).build()); case DEPRECATED_EXAMPLE_RECORD, EXAMPLE_RECORD -> new GeneratedSource( pluginExecution, generatedClass, GeneratedField.of("field1", Boolean.class).build()); diff --git a/src/test/java/io/github/chrimle/example/utils/GeneratedEnumTestUtils.java b/src/test/java/io/github/chrimle/example/utils/GeneratedEnumTestUtils.java index d37fb3fb..d72beeec 100644 --- a/src/test/java/io/github/chrimle/example/utils/GeneratedEnumTestUtils.java +++ b/src/test/java/io/github/chrimle/example/utils/GeneratedEnumTestUtils.java @@ -16,10 +16,13 @@ */ package io.github.chrimle.example.utils; +import io.github.chrimle.example.GeneratedField; import io.github.chrimle.example.GeneratedSource; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.List; +import java.util.Optional; import org.junit.jupiter.api.Assertions; /** Generalized Test-class for testing Generated Enum-classes */ @@ -30,8 +33,8 @@ public static void assertEnumClass(final GeneratedSource generatedSource) { final Class classUnderTest = generatedSource.getClassUnderTest(); AssertionUtils.assertIsEnum(classUnderTest); - assertEnumNames(classUnderTest); - assertEnumValues(classUnderTest); + assertEnumNames(generatedSource); + assertEnumValues(generatedSource); AssertionUtils.assertClassIsAnnotatedAsDeprecated( classUnderTest, generatedSource.isDeprecated()); AssertionUtils.assertClassIsAnnotatedWithAdditionalTypeAnnotations( @@ -39,19 +42,39 @@ public static void assertEnumClass(final GeneratedSource generatedSource) { assertEnumHasCaseInsensitiveFromValueMethod(generatedSource); } - private static void assertEnumNames(final Class classUnderTest) { - Assertions.assertEquals(3, classUnderTest.getEnumConstants().length); - for (int i = 1; i <= 3; i++) { - Assertions.assertEquals( - "ENUM" + i, ((Enum) classUnderTest.getEnumConstants()[i - 1]).name()); + private static void assertEnumNames(final GeneratedSource generatedSource) { + final Enum[] enumConstants = + (Enum[]) generatedSource.getClassUnderTest().getEnumConstants(); + final GeneratedField[] generatedFields = generatedSource.generatedFields(); + + Assertions.assertEquals(generatedFields.length, enumConstants.length); + for (final GeneratedField generatedField : generatedFields) { + final String enumName = generatedField.name(); + Assertions.assertTrue( + Arrays.stream(enumConstants).map(Enum::name).anyMatch(enumName::equals)); } } - private static void assertEnumValues(final Class classUnderTest) { - Assertions.assertEquals(3, classUnderTest.getEnumConstants().length); - for (int i = 1; i <= 3; i++) { - final Object enumValue = classUnderTest.getEnumConstants()[i - 1]; - AssertionUtils.assertInstanceMethodReturns(enumValue, "getValue", "ENUM" + i); + private static void assertEnumValues(final GeneratedSource generatedSource) { + final Enum[] enumConstants = + (Enum[]) generatedSource.getClassUnderTest().getEnumConstants(); + final GeneratedField[] generatedFields = generatedSource.generatedFields(); + + for (final GeneratedField generatedField : generatedFields) { + final String enumName = generatedField.name(); + final Object enumValue = generatedField.enumValue(); + + final Optional> enumConstant = + Arrays.stream(enumConstants).filter(anEnum -> anEnum.name().equals(enumName)).findFirst(); + + Assertions.assertTrue( + enumConstant.isPresent(), + "Enum-class '" + + generatedSource.getClassUnderTest().getCanonicalName() + + "' does not have an enum constant with the name: " + + enumName); + + AssertionUtils.assertInstanceMethodReturns(enumConstant.get(), "getValue", enumValue); } } @@ -60,32 +83,72 @@ private static void assertEnumHasCaseInsensitiveFromValueMethod( // Assert 'fromValue'-method exists final Method fromValueMethod = AssertionUtils.assertClassHasMethod( - generatedSource.getClassUnderTest(), "fromValue", String.class); + generatedSource.getClassUnderTest(), "fromValue", generatedSource.fieldClasses()[0]); // Assert 'IllegalArgumentException' is thrown for unknown Enum-values InvocationTargetException invocationTargetException = Assertions.assertThrows( - InvocationTargetException.class, () -> fromValueMethod.invoke(null, "invalid")); + InvocationTargetException.class, + () -> + fromValueMethod.invoke( + null, getInvalidTestingValue(generatedSource.fieldClasses()[0]))); Assertions.assertInstanceOf( IllegalArgumentException.class, invocationTargetException.getCause()); - for (final String name : List.of("enum", "Enum", "EnUm", "ENUM", "eNuM")) { - for (int i = 1; i <= 3; i++) { - final String value = name + i; - if (generatedSource.useEnumCaseInsensitive()) { - // Assert all enum values can be mapped to case-insensitively - Assertions.assertDoesNotThrow(() -> fromValueMethod.invoke(null, value)); - } else if ("ENUM".equals(name)) { - Assertions.assertDoesNotThrow(() -> fromValueMethod.invoke(null, value)); - } else { - // Assert 'IllegalArgumentException' is thrown when case-sensitive - Assertions.assertInstanceOf( - IllegalArgumentException.class, - Assertions.assertThrows( - InvocationTargetException.class, () -> fromValueMethod.invoke(null, value)) - .getCause()); + if (String.class.equals(generatedSource.fieldClasses()[0])) { + for (final String name : List.of("enum", "Enum", "EnUm", "ENUM", "eNuM")) { + for (int i = 1; i <= 3; i++) { + final String value = name + i; + if (generatedSource.useEnumCaseInsensitive()) { + // Assert all enum values can be mapped to case-insensitively + Assertions.assertDoesNotThrow(() -> fromValueMethod.invoke(null, value)); + } else if ("ENUM".equals(name)) { + Assertions.assertDoesNotThrow(() -> fromValueMethod.invoke(null, value)); + } else { + // Assert 'IllegalArgumentException' is thrown when case-sensitive + Assertions.assertInstanceOf( + IllegalArgumentException.class, + Assertions.assertThrows( + InvocationTargetException.class, () -> fromValueMethod.invoke(null, value)) + .getCause()); + } } } + } else if (Integer.class.equals(generatedSource.fieldClasses()[0])) { + for (final Object validValue : + Arrays.stream(generatedSource.generatedFields()) + .map(GeneratedField::enumValue) + .toList()) { + Assertions.assertDoesNotThrow(() -> fromValueMethod.invoke(null, validValue)); + } + for (final Integer invalidValue : List.of(-12, 0, 1, 42)) { + Assertions.assertInstanceOf( + IllegalArgumentException.class, + Assertions.assertThrows( + InvocationTargetException.class, + () -> fromValueMethod.invoke(null, invalidValue)) + .getCause()); + } + // Testing `null` does not match with any enum constant's value + Assertions.assertInstanceOf( + IllegalArgumentException.class, + Assertions.assertThrows( + InvocationTargetException.class, + () -> fromValueMethod.invoke(null, (Object) null)) + .getCause()); + } + } + + private static T getInvalidTestingValue(final Class type) { + if (type == null) { + throw new IllegalArgumentException("Cannot resolve testing value for type 'null'!"); + } + if (String.class.equals(type)) { + return type.cast("invalid"); + } + if (Integer.class.equals(type)) { + return type.cast(42); } + return null; } } diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleEnum.java index cc3271ba..382e7d9b 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -51,8 +51,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleRecord.java index d93d3304..19233620 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnum.java index 09e44777..74e5e3f1 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -57,8 +57,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..f841ab7d --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleEnumWithIntegerValues.java @@ -0,0 +1,71 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.additionalEnumTypeAnnotations; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * Example of an Enum with integer values + */ +@io.github.chrimle.example.annotations.TestAnnotationOne +@io.github.chrimle.example.annotations.TestAnnotationTwo +@io.github.chrimle.example.annotations.TestAnnotationThree +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecord.java index 1bc7688a..43bc254f 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithDefaultFields.java index 6c1ec893..5c6f931a 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java index 46964db5..ccd89709 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java index 7bfd4801..631d1b73 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithAllConstraints.java index f80b429c..a087c9c6 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithInnerEnums.java index b768d16f..236f7c74 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalEnumTypeAnnotations/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -31,7 +31,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @javax.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -80,8 +80,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -98,19 +101,19 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ @io.github.chrimle.example.annotations.TestAnnotationOne @io.github.chrimle.example.annotations.TestAnnotationTwo @io.github.chrimle.example.annotations.TestAnnotationThree public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -119,19 +122,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant; diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleEnum.java index 31dd336e..d9dcb3a1 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -48,8 +48,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleRecord.java index 26a1e441..b9e030b1 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnum.java index 58ec126a..f512786b 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -54,8 +54,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..e9d323f5 --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleEnumWithIntegerValues.java @@ -0,0 +1,68 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.additionalModelTypeAnnotations; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecord.java index 57db1d34..7399e292 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithDefaultFields.java index ea3d109c..705d32cb 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java index e199f77a..e91dafbc 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java index 89c0edbf..8e9d4385 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithAllConstraints.java index 1e4002b3..647b161d 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithInnerEnums.java index 22198d24..1cdb37d4 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/additionalModelTypeAnnotations/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -31,7 +31,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ @io.github.chrimle.example.annotations.TestAnnotationOne @io.github.chrimle.example.annotations.TestAnnotationTwo @@ -80,8 +80,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -98,16 +101,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -116,19 +119,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant; diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleEnum.java index 9dcfe2c1..a0a313dd 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -48,8 +48,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleRecord.java index 532b4b68..e50d5045 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnum.java index 373ff6fe..72ad7a7d 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -54,8 +54,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..b1b6f92a --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleEnumWithIntegerValues.java @@ -0,0 +1,68 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.generateBuilders; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecord.java index d6c566d6..3194fd9e 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithDefaultFields.java index b6f0fabc..53c718e6 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithNullableFieldsOfEachType.java index a6260a1d..3aaf4725 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithRequiredFieldsOfEachType.java index 8547e5ac..ed9c95ec 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithAllConstraints.java index b4b40353..d5044871 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithInnerEnums.java index 8e855715..1ab5d737 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/generateBuilders/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -31,7 +31,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @javax.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -66,7 +66,7 @@ public Builder exampleInner(final ExampleInnerEnum exampleInner) { * Sets the value of {@link RecordWithInnerEnums#exampleInnerTwo }. * *

NOTE: Pass-by-reference is used! - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values * @return this {@link Builder}-instance for method-chaining */ public Builder exampleInnerTwo(final ExampleInnerTwoEnum exampleInnerTwo) { @@ -127,8 +127,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -145,16 +148,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -163,19 +166,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant; diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleEnum.java index 78e1bc2d..992de1e1 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -49,8 +49,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleRecord.java index af4e19b2..0484061c 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnum.java index 265f5c47..b5909a85 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -55,8 +55,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..9f6ac5d2 --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleEnumWithIntegerValues.java @@ -0,0 +1,69 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.serializableModel; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecord.java index 3ccf0570..01556838 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithDefaultFields.java index 96b590f4..e140a243 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithNullableFieldsOfEachType.java index 0192590f..99050ec3 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithRequiredFieldsOfEachType.java index 4fc64230..f900fdc7 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithAllConstraints.java index 41982ce7..6699ecf8 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithInnerEnums.java index 142d4bfe..7402fc3f 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/serializableModel/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -32,7 +32,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @javax.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -81,8 +81,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -99,16 +102,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -117,19 +120,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant; diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleEnum.java index b11152d4..207945f1 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -48,8 +48,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleRecord.java index f5fdfa51..65ab77f8 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnum.java index 1086b715..1b8db72c 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -54,8 +54,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..cffce471 --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleEnumWithIntegerValues.java @@ -0,0 +1,68 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.standard; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecord.java index 42906169..7a0d0976 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithDefaultFields.java index 0f490121..881aad59 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithNullableFieldsOfEachType.java index 74ab7c23..eb0e3bbe 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithRequiredFieldsOfEachType.java index bad8e15c..61be4899 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithAllConstraints.java index 90bee240..e7f0c16b 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithInnerEnums.java index c22c21b0..4133fa13 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/standard/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -31,7 +31,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @javax.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -77,8 +77,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -95,16 +98,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -113,19 +116,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant; diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleEnum.java index 0a7676fe..fce76a31 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -50,8 +50,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleRecord.java index 11d5eeaa..096805e4 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnum.java index a196bf13..a98f0495 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -56,8 +56,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..16684dd6 --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleEnumWithIntegerValues.java @@ -0,0 +1,70 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.useBeanValidation; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecord.java index 4f444c22..77b1a28b 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithDefaultFields.java index 47094806..fc322594 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithNullableFieldsOfEachType.java index 80be733e..2ad188ee 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithRequiredFieldsOfEachType.java index c5f94c1c..5ef125e9 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithAllConstraints.java index bc591178..3e769209 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithInnerEnums.java index 2e234c55..02acb9c8 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useBeanValidation/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -33,7 +33,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @javax.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -79,8 +79,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -97,16 +100,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -115,19 +118,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant; diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleEnum.java index e0459369..a59caaeb 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -48,8 +48,11 @@ public String getValue() { } /** - * Case-insensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-insensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleRecord.java index 6b975ad2..a0fa0b4f 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnum.java index 3bb63ce2..aa1b7fc2 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -54,8 +54,11 @@ public String getValue() { } /** - * Case-insensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-insensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..b8930baa --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleEnumWithIntegerValues.java @@ -0,0 +1,68 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.useEnumCaseInsensitive; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecord.java index 4686f517..1dbee683 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithDefaultFields.java index bc939a27..4e2a2024 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithNullableFieldsOfEachType.java index 5ed64d6d..6bfce350 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithRequiredFieldsOfEachType.java index a23cf76e..c1456d5b 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithAllConstraints.java index e73af7ce..1eb04c3a 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithInnerEnums.java index e9938236..a279ac79 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useEnumCaseInsensitive/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -31,7 +31,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @javax.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -77,8 +77,11 @@ public String getValue() { } /** - * Case-insensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-insensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -95,16 +98,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -113,21 +116,24 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-insensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { - if (constant.getValue().equalsIgnoreCase(value)) { + if (constant.getValue().equals(value)) { return constant; } } diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleEnum.java index 92925e86..dd8f7050 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -48,8 +48,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link DeprecatedExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleRecord.java index dd1d84db..822808eb 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/DeprecatedExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnum.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnum.java index 8edd82e9..b64fb780 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnum.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnum.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -54,8 +54,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleEnum } with the matching value diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnumWithIntegerValues.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnumWithIntegerValues.java new file mode 100644 index 00000000..1255278b --- /dev/null +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleEnumWithIntegerValues.java @@ -0,0 +1,68 @@ +/* + * Example OpenAPI Spec. + * An example OpenAPI-spec to generate example Java records. + * + * The version of the OpenAPI document: 0.0.1 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + * This class was generated using custom mustache templates from + * openapi-to-java-records-mustache-templates. For further information, + * questions, requesting features or reporting issues, please visit: + * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. + * Generated with Version: 2.2.1 + * + */ + +package io.github.chrimle.example.useJakartaEe; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * Example of an Enum with integer values + */ +public enum ExampleEnumWithIntegerValues { + NUMBER_100(100), + NUMBER_200(200), + NUMBER_300(300), + NUMBER_400(400), + NUMBER_500(500); + + private final Integer value; + + ExampleEnumWithIntegerValues(final Integer value) { + this.value = value; + } + + /** + * Gets the {@code value} of this enum. + * + * @return value of this enum + */ + public Integer getValue() { + return value; + } + + /** + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. + * + * @param value of the Enum + * @return a {@link ExampleEnumWithIntegerValues } with the matching value + * @throws IllegalArgumentException if no enum has a value matching the given value + */ + public static ExampleEnumWithIntegerValues fromValue(final Integer value) { + for (final ExampleEnumWithIntegerValues constant : ExampleEnumWithIntegerValues.values()) { + if (constant.getValue().equals(value)) { + return constant; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecord.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecord.java index 7c3f0f4a..17615be7 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecord.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecord.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithDefaultFields.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithDefaultFields.java index 1432904e..acc50fea 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithDefaultFields.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithDefaultFields.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithNullableFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithNullableFieldsOfEachType.java index 610625ed..cf15ec8f 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithNullableFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithNullableFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithRequiredFieldsOfEachType.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithRequiredFieldsOfEachType.java index 5da37bd4..dc3d39b6 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithRequiredFieldsOfEachType.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/ExampleRecordWithRequiredFieldsOfEachType.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithAllConstraints.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithAllConstraints.java index 15b34217..1d7dfad8 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithAllConstraints.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithAllConstraints.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ diff --git a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithInnerEnums.java b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithInnerEnums.java index 3a2fb330..9933cecb 100644 --- a/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithInnerEnums.java +++ b/target/generated-sources/openapi/src/src/gen/java/main/io/github/chrimle/example/useJakartaEe/RecordWithInnerEnums.java @@ -12,7 +12,7 @@ * openapi-to-java-records-mustache-templates. For further information, * questions, requesting features or reporting issues, please visit: * https://github.com/Chrimle/openapi-to-java-records-mustache-templates. - * Generated with Version: 2.2.0 + * Generated with Version: 2.2.1 * */ @@ -31,7 +31,7 @@ * Example of a Record with inner enum classes * * @param exampleInner Example of an inner enum class - * @param exampleInnerTwo Example of another inner enum class + * @param exampleInnerTwo Example of another inner enum class with integer values */ public record RecordWithInnerEnums( @jakarta.annotation.Nonnull ExampleInnerEnum exampleInner, @@ -77,8 +77,11 @@ public String getValue() { } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Case-sensitively matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerEnum } with the matching value @@ -95,16 +98,16 @@ public static ExampleInnerEnum fromValue(final String value) { } /** - * Example of another inner enum class + * Example of another inner enum class with integer values */ public enum ExampleInnerTwoEnum { - ENUM1("ENUM1"), - ENUM2("ENUM2"), - ENUM3("ENUM3"); + NUMBER_404(404), + NUMBER_501(501), + NUMBER_503(503); - private final String value; + private final Integer value; - ExampleInnerTwoEnum(final String value) { + ExampleInnerTwoEnum(final Integer value) { this.value = value; } @@ -113,19 +116,22 @@ public enum ExampleInnerTwoEnum { * * @return value of this enum */ - public String getValue() { + public Integer getValue() { return value; } /** - * Case-sensitively parses the given string to an enum constant whose {@link #getValue()} - * matches the provided value. + * Matches the given {@code value} to an enum constant using {@link + * #getValue()}. + * + *

NOTE: if multiple enum constants have a matching value, the first enum constant is + * returned, by the order they are declared. * * @param value of the Enum * @return a {@link ExampleInnerTwoEnum } with the matching value * @throws IllegalArgumentException if no enum has a value matching the given value */ - public static ExampleInnerTwoEnum fromValue(final String value) { + public static ExampleInnerTwoEnum fromValue(final Integer value) { for (final ExampleInnerTwoEnum constant : ExampleInnerTwoEnum.values()) { if (constant.getValue().equals(value)) { return constant;