You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/04/27 17:57:03 UTC

[GitHub] [nifi] Lehel44 commented on a diff in pull request #5977: NIFI-9936: Added enum support in PropertyDescriptor Builder for Allow…

Lehel44 commented on code in PR #5977:
URL: https://github.com/apache/nifi/pull/5977#discussion_r860100082


##########
nifi-api/src/main/java/org/apache/nifi/components/PropertyDescriptor.java:
##########
@@ -396,6 +396,20 @@ public <E extends Enum<E>> Builder allowableValues(final E[] values) {
             return this;
         }
 
+        /**
+         * Stores allowable values from an enum class.
+         * @param enumClass an enum class that implements the Allowable interface and contains a set of values
+         * @param <E> generic parameter for an enum class that implements the Allowable interface
+         * @return the builder
+         */
+        public <E extends Enum<E> & DescribedValue> Builder allowableValues(final Class<E> enumClass) {
+            this.allowableValues = new ArrayList<>();
+            for (E enumValue : enumClass.getEnumConstants()) {
+                this.allowableValues.add(new AllowableValue(enumValue.name(), enumValue.getDisplayName(), enumValue.getDescription()));

Review Comment:
   Oh wow, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org