-
Notifications
You must be signed in to change notification settings - Fork 565
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
4.x: Allowed values are now checked when validating a builder. #7400
4.x: Allowed values are now checked when validating a builder. #7400
Conversation
builder/processor/src/main/java/io/helidon/builder/processor/GenerateAbstractBuilder.java
Outdated
Show resolved
Hide resolved
builder/processor/src/main/java/io/helidon/builder/processor/PrototypeProperty.java
Outdated
Show resolved
Hide resolved
.../processor/processor/src/main/java/io/helidon/common/processor/ToAnnotationValueVisitor.java
Outdated
Show resolved
Hide resolved
common/types/src/main/java/io/helidon/common/types/Annotation.java
Outdated
Show resolved
Hide resolved
common/types/src/main/java/io/helidon/common/types/Annotation.java
Outdated
Show resolved
Hide resolved
@@ -52,7 +52,7 @@ interface MyConfigBeanBlueprint { | |||
*/ | |||
@ConfiguredOption(key = "port", value = "8080", allowedValues = { | |||
@ConfiguredValue(value = "8080", description = "t1"), | |||
@ConfiguredValue(value = "false", description = "t2")}) | |||
@ConfiguredValue(value = "80", description = "t2")}) |
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.
what is really needed here is a range of good values. I think ultimately for this we need to refer to a method or class to instantiate to perform dynamic validations for complex cases.
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.
false
is never a good value for an integer port. Not sure what you mean by this. If you need better validation, you can always have a custom decorator
Description
When using
@ConfiguredOption(allowedValues=...)
the generated builders now validate (during build) that the option is within the allowed values.null
, a check is made of itsString.valueOf()
against the String allowed value setThis change required modifying
Annotation
to support typed values and nested annotations, this has been done as well.Documentation
This enhancement enforces an existing API in
ConfiguredOption
.Annotation now supports nested annotations and typed values. Methods to obtain a typed value are now added to the
Annotation
type (inhelidon-common-types
)Resolves #6403
Resolves #6231