Closed tgallagher2017 closed 2 years ago
Yes, I'll make some test cases with new annotation examples.
I added testing module with supporting classes that can be used as examples.
Sorry for the delay in doing these tests.
Cedric,
Sorry for the delay in building test modules for this PR, but I finally got them up there. let me know if there is anything else you need before approving this.
Thanks, Tim
On Fri, Mar 26, 2021 at 12:17 AM Cedric Beust @.***> wrote:
@.**** commented on this pull request.
Really sorry for the delay, I missed your PR for some reason.
Could you please add tests and amend the documentation?
Thanks!
In src/main/java/com/beust/jcommander/IParameterizedParser.java https://github.com/cbeust/jcommander/pull/511#discussion_r602038487:
@@ -0,0 +1,24 @@ +package com.beust.jcommander; + +import java.util.List; + +/**
- Thin interface allows the Parameterized parsing mechanism, which reflects an object to find the
- JCommander annotations, to be replaced at runtime for cases where the source code can not
cannot
In src/main/java/com/beust/jcommander/IParameterizedParser.java https://github.com/cbeust/jcommander/pull/511#discussion_r602038578:
@@ -0,0 +1,24 @@ +package com.beust.jcommander; + +import java.util.List; + +/**
- Thin interface allows the Parameterized parsing mechanism, which reflects an object to find the
- JCommander annotations, to be replaced at runtime for cases where the source code can not
- be directly annotated with JCommander annotations, but may have other annotations such as
- Json annotations that can be used to reflect as JCommander parameters.
JSON
In src/main/java/com/beust/jcommander/JCommander.java https://github.com/cbeust/jcommander/pull/511#discussion_r602038761:
@@ -598,7 +605,7 @@ public void createDescriptions() { private void addDescription(Object object) { Class<?> cls = object.getClass();
- List
parameterizeds = Parameterized.parseArg(object); - List
parameterizeds = this.parameterizedParser.parseArg(object); No need for this.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cbeust/jcommander/pull/511#pullrequestreview-621810888, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGRBVLHHXR3OEF6DGNXPC63TFQRHTANCNFSM4YUSARFA .
Hey Cedric,
I'm hoping you can get to this soon because our company is going to publish another version of our command line product, and it would be nice to have a build directly from you instead of using an inhouse version of it. Thanks for all the work.
Tim
On Wed, Dec 8, 2021 at 11:34 AM Cedric Beust @.***> wrote:
@.**** commented on this pull request.
In src/test/java/com/beust/jcommander/parameterized/parser/JsonAnnotationParameterizedParser.java https://github.com/cbeust/jcommander/pull/511#discussion_r765130292:
+// result.add(new Parameterized(new WrappedParameter(param), null, null, method)); +// } +// }
- }
- return result;
- }
- /**
- Basic check for primitive or Java class that should be used directly.
- *
- @param field
- @return true if Java primitive or part of the Java or Sun package.
- */
- public boolean isPrimitiveOrString(Field field) {
- final Class type = field.getType();
No need for final.
Also, isn't the compiler complaining about the raw Class types?
In src/test/java/com/beust/jcommander/parameterized/parser/JsonAnnotationParameterizedParser.java https://github.com/cbeust/jcommander/pull/511#discussion_r765130919:
+
- // get the list of types that are extended or implemented by the root class
- // and all of its parent types
- Set<Class<?>> types = describeClassTree(rootClass);
- // analyze each type
- for (Class<?> curClazz : types) {
- // check fields
- for (Field field : curClazz.getDeclaredFields()) {
- JsonProperty fieldAnnotation = (JsonProperty) field.getAnnotation(JsonProperty.class);
- JsonPropertyDescription descrAnnotation = (JsonPropertyDescription) field.getAnnotation(JsonPropertyDescription.class);
- MyDelegate myDelegate = (MyDelegate) field.getAnnotation(MyDelegate.class);
- if (fieldAnnotation != null) {
- // this is a map of annotation field names uses to create the Parameter annotation
- // at runtime
- Map<String, Object> map = new HashMap<>();
Why use a hash map and not an actual class?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cbeust/jcommander/pull/511#pullrequestreview-826800811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGRBVLGDB5QHDUIXRBE6GWTUP6QKNANCNFSM4YUSARFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Mmmh the build is breaking because fasterxml
is in your PR but not in the build file, what happened?
Done and published, 1.82
should appear on Maven Central in a few hours.
Thanks a bunch.
On Mon, Jan 10, 2022 at 9:30 PM Cedric Beust @.***> wrote:
Done and published, 1.82 should appear on Maven Central in a few hours.
— Reply to this email directly, view it on GitHub https://github.com/cbeust/jcommander/pull/511#issuecomment-1009590113, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGRBVLCJGT3OUPSC6GNOFALUVOW7RANCNFSM4YUSARFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
Created an interface that allows the Parameterized parsing mechanism, which reflects an object to find the JCommander annotations, to be replaced at runtime for cases where the source code can not be directly annotated with JCommander annotations, but may have other annotations such as Json annotations that can be used to reflect as JCommander parameters.