Skip to content

Commit

Permalink
NIFI-12573 Improve support for Enum values in PropertyDescriptor.Builder
Browse files Browse the repository at this point in the history
NIFI-12574 Add clearDefaultValue to PropertyDescriptor.Builder
  • Loading branch information
EndzeitBegins committed Jan 7, 2024
1 parent d9cd62a commit 19bc4ac
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ public AllowableValue(final String value) {
* Constructs a new AllowableValue with the given value and display name and
* no description
*
* @param value that is allowed
* @param value that is allowed
* @param displayName to display for the value
*
* @throws NullPointerException if either argument is null
*/
public AllowableValue(final String value, final String displayName) {
Expand All @@ -56,10 +55,9 @@ public AllowableValue(final String value, final String displayName) {
* Constructs a new AllowableValue with the given value, display name, and
* description
*
* @param value that is valid
* @param value that is valid
* @param displayName to show for the value
* @param description of the value
*
* @throws NullPointerException if identifier or value is null
*/
public AllowableValue(final String value, final String displayName, final String description) {
Expand All @@ -68,6 +66,13 @@ public AllowableValue(final String value, final String displayName, final String
this.description = description;
}

public static AllowableValue fromDescribedValue(final DescribedValue describedValue) {
if (describedValue instanceof AllowableValue allowableValue)
return allowableValue;

return new AllowableValue(describedValue.getValue(), describedValue.getDisplayName(), describedValue.getDescription());
}

/**
* @return the value of this AllowableValue
*/
Expand Down Expand Up @@ -106,8 +111,7 @@ public boolean equals(final Object obj) {
return true;
}

if (obj instanceof AllowableValue) {
final AllowableValue other = (AllowableValue) obj;
if (obj instanceof AllowableValue other) {
return (this.value.equals(other.getValue()));
} else if (obj instanceof String) {
return this.value.equals(obj);
Expand Down

0 comments on commit 19bc4ac

Please sign in to comment.