[ 
https://issues.apache.org/jira/browse/NIFI-12452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17796424#comment-17796424
 ] 

ASF subversion and git services commented on NIFI-12452:
--------------------------------------------------------

Commit c272574dccba9fa212af2ba60853b88afebb6380 in nifi's branch 
refs/heads/main from EndzeitBegins
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=c272574dcc ]

NIFI-12452 Improved support for DescribedValue in Descriptors

- Removed calls to Builder.defaultValue(null) in several Components

This closes #8102

Signed-off-by: David Handermann <exceptionfact...@apache.org>


> Improve support for Enum & DescribedValue for allowableValues
> -------------------------------------------------------------
>
>                 Key: NIFI-12452
>                 URL: https://issues.apache.org/jira/browse/NIFI-12452
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Core Framework
>            Reporter: endzeit
>            Priority: Major
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> The {{PropertyDescriptor.Builder}} supports providing a {{Class}} that is 
> both an {{Enum}} and {{{}DescribedValue{}}}. This improves type safety, by 
> avoiding the passing of sheer arbitrary {{String}} values. 
> I'd like to propose extensions to both the {{PropertyDescriptor.Builder}} 
> class as well as the {{PropertyValue}} interface.
> ----
> The {{PropertyDescriptor.Builder}} should allow not only a raw {{String}} to 
> be provided as {{{}defaultValue(){}}}, but also provide an overload that 
> instead accepts an {{{}DescribedValue{}}}.
> {code:java}
> public Builder defaultValue(final DescribedValue value) {code}
> This allows to replace
> {code:java}
> .allowableValues(Foo.class)
> .defaultValue(Foo.BAR.getValue()) {code}
> with
> {code:java}
> .allowableValues(Foo.class)
> .defaultValue(Foo.BAR) {code}
> ----
> The {{PropertyValue}} should allow to receive the value as one of the Enum 
> constants, similar to one of the existing {{as...}} methods.
> {code:java}
> <E extends Enum<E> & DescribedValue> E asAllowableValue(Class<E> clazz) {code}
> This way processor implementations rely on type-safe mappings of allowable 
> values instead of matching on {{String}} values manually. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to