generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 8
Unhelpful error message when a required parameter is not configured #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
81f821a
Parameter name in error messages when parameter is missing
fmeheust defae3b
Trying new approach
fmeheust e568b29
New approach
fmeheust b278d2e
Fixing test errors
fmeheust 5c56b63
Only add not null values
fmeheust 5478ba7
undo changes
fmeheust 6c9c062
Refactoring
fmeheust 7807451
Comments
fmeheust a18b308
Removed default value setter
fmeheust 0a57a3f
Use default value on ressource parameter with value and default value
fmeheust dfd639f
Reduced number of loops for parsing parameter set
fmeheust c0a1269
Changes requested in code review.
fmeheust 4398729
Merge branch 'main' into missing-parameter
fmeheust File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,11 @@ <T> Builder addParameter( | |
* the parsed input includes an assignment such as "x=0", then "0" is input | ||
* to the {@code valueSetter}. | ||
* </p><p> | ||
* The {@code valueSetter} must be able to handle a null input. A null input will occur | ||
* when no value is set for the parameter. The {@code valueSetter} may simply pass | ||
* the null value onto the {@code ParameterSetBuilder}, or it may pass in a default | ||
* value. | ||
* </p><p> | ||
* This method is designed for cases where a single parameter in text format | ||
* may map to multiple {@link Parameter} objects. The {@code valueSetter} | ||
* function can perform multiple calls to set each parameter, as in this | ||
|
@@ -212,52 +217,5 @@ <T> Builder addParameter( | |
Builder addParameter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the JavaDoc above, let's add update it to specify that a valueSetter function must be able to handle a /**
* <p>
* Adds a parameter that a parser identifies by a given
* {@code name}, and invokes a {@code valueSetter} function for assigning
* the value. The inputs to the {@code valueSetter} function are the value
* as it appears in text form and a {@link ParameterSetBuilder} that builds
* the parsed {@link ParameterSet}. If the name passed to this method is "x", and
* the parsed input includes an assignment such as "x=0", then "0" is input
* to the {@code valueSetter}.
* </p><p>
* The {@code valueSetter} must be able to handle a null input. A null input will occur
* when no value is set for the parameter. The {@code valueSetter} may simply pass
* the null value onto the {@code ParameterSetBuilder}, or it may pass in a default
* value.
* </p><p>
* This method is designed for cases where a single parameter in text format
* may map to multiple {@link Parameter} objects. The {@code valueSetter}
* function can perform multiple calls to set each parameter, as in this
* example:
* </p>
* <pre>{@code
* builder.addParameter("coordinate", (value, parameterSetBuilder) -> {
* // Split "x,y,z" formatted value
* String[] xyz = value.split(",");
* parameterSetBuilder.add("coordinate", X, xyz[0]);
* parameterSetBuilder.add("coordinate", Y, xyz[1]);
* parameterSetBuilder.add("coordinate", Z, xyz[2]);
* });
* }</pre>
*
* @param name Name of the parsed parameter. Not null.
* @param valueSetter Parses and sets the value of parameter(s) from text
* input. Not null.
* @return This builder.
*/ |
||
String name, BiConsumer<String, ParameterSetBuilder> valueSetter); | ||
|
||
/** | ||
* <p> | ||
* Adds a parameter that a parser identifies by a given | ||
* {@code name}, and invokes a {@code defaultValueSetter} to assign a value | ||
* if the name is not present, or invokes a {@code valueSetter} function for | ||
* assigning the value if the name is present. The input to the | ||
* {@code defaultValueSetter} function is a {@link ParameterSetBuilder} that | ||
* builds the parsed {@link ParameterSet}. The input to the | ||
* {@code valueSetter} is the value as it appears in text form, and a | ||
* {@link ParameterSetBuilder} that builds the parsed {@link ParameterSet}. If | ||
* the name passed to this method is "x", and the parsed input includes an | ||
* assignment such as "x=0", then "0" is input to the {@code valueSetter}. | ||
* </p><p> | ||
* This method is designed for cases where a single parameter in text format | ||
* may map to multiple {@link Parameter} objects. The | ||
* {@code defaultValueSetter} and {@code valueSetter} functions can perform | ||
* multiple calls to set each parameter, as in this example: | ||
* </p> | ||
* <pre>{@code | ||
* builder.addParameter( | ||
* "coordinate", | ||
* (parameterSetBuilder) -> { | ||
* // Assign the default value of 0 to X, Y, and Z | ||
* parameterSetBuilder.add("coordinate", X, 0); | ||
* parameterSetBuilder.add("coordinate", Y, 0); | ||
* parameterSetBuilder.add("coordinate", Z, 0); | ||
* }, | ||
* (value, parameterSetBuilder) -> { | ||
* // Split "x,y,z" formatted value | ||
* String[] xyz = value.split(","); | ||
* parameterSetBuilder.add("coordinate", X, xyz[0]); | ||
* parameterSetBuilder.add("coordinate", Y, xyz[1]); | ||
* parameterSetBuilder.add("coordinate", Z, xyz[2]); | ||
* }); | ||
* }</pre> | ||
* | ||
* @param name Name of the parsed parameter. Not null. | ||
* @param defaultValueSetter Parses and sets the default value of | ||
* parameter(s). Not null. | ||
* @param valueSetter Parses and sets the value of parameter(s) from text | ||
* input. Not null. | ||
* @return This builder | ||
*/ | ||
Builder addParameter( | ||
String name, | ||
Consumer<ParameterSetBuilder> defaultValueSetter, | ||
BiConsumer<String, ParameterSetBuilder> valueSetter); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interface class where this method is defined, ParameterSetBuilder.java, we can update the JavaDoc: