This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 555a7973ede31234af1ab74ff66c98e30932c34b Author: Claus Ibsen <[email protected]> AuthorDate: Tue Sep 1 15:55:23 2020 +0200 CAMEL-15478: Camel API components maven plugin should generate enums with human name as accepted value and also used for component json metadata and tooling. --- .../src/main/resources/api-method-enum.vm | 15 ++++++++++++++- .../src/main/resources/api-name-enum.vm | 2 +- .../src/main/resources/api-route-test.vm | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm index a248537..2b5dc9d 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm +++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm @@ -59,7 +59,8 @@ public enum $enumName implements ApiMethod { arg("$arg.Name", $helper.getType($arg.Type))#end)#if ( $foreach.hasNext ),$newLine#else;#end #end - $newLine + private static final ${enumName}[] VALUES = values(); + private final ApiMethod apiMethod; private ${enumName}(Class<?> resultType, String name, ApiMethodArg... args) { @@ -70,6 +71,18 @@ public enum $enumName implements ApiMethod { public String getName() { return apiMethod.getName(); } @Override + public String toString() { return apiMethod.getName(); } + + public static $enumName fromValue(String value) throws IllegalArgumentException { + for (int i = 0; i < VALUES.length; i++) { + if (VALUES[i].getName().equalsIgnoreCase(value)) { + return VALUES[i]; + } + } + throw new IllegalArgumentException("Invalid value " + value); + } + + @Override public Class<?> getResultType() { return apiMethod.getResultType(); } @Override diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm index 7c53852..f901600 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm +++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm @@ -69,7 +69,7 @@ public enum $apiNameEnum implements ApiName { public static $apiNameEnum fromValue(String value) throws IllegalArgumentException { for (int i = 0; i < VALUES.length; i++) { - if (VALUES[i].name.equals(value)) { + if (VALUES[i].name.equalsIgnoreCase(value)) { return VALUES[i]; } } diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm index 4bca5c0..32fce9e 100644 --- a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm +++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm @@ -52,7 +52,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test class for {@link ${proxyType.Name}} APIs. - * TODO Move the file to src/test/java, populate parameter values, and remove @Ignore annotations. + * TODO Move the file to src/test/java, populate parameter values, and remove @Disabled annotations. * The class source won't be generated again if the generator MOJO finds it under src/test/java. */ public class ${testName} extends Abstract${componentName}TestSupport {
