Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-12452

Improve support for Enum & DescribedValue for allowableValues

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0-M2
    • Core Framework
    • None

    Description

      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.

      public Builder defaultValue(final DescribedValue value) 

      This allows to replace

      .allowableValues(Foo.class)
      .defaultValue(Foo.BAR.getValue()) 

      with

      .allowableValues(Foo.class)
      .defaultValue(Foo.BAR) 

      The PropertyValue should allow to receive the value as one of the Enum constants, similar to one of the existing as... methods.

      <E extends Enum<E> & DescribedValue> E asAllowableValue(Class<E> clazz) 

      This way processor implementations rely on type-safe mappings of allowable values instead of matching on String values manually. 

      Attachments

        Activity

          People

            EndzeitBegins endzeit
            EndzeitBegins endzeit
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10h 50m
                10h 50m