Mark Payne created NIFI-7144:
--------------------------------
Summary: Allow PropertyDescriptors to specify that values should
be trimmed of white space
Key: NIFI-7144
URL: https://issues.apache.org/jira/browse/NIFI-7144
Project: Apache NiFi
Issue Type: New Feature
Components: Core Framework
Reporter: Mark Payne
It is common for users to type in a value for a property and accidentally add
white space at the beginning or end - especially if the user is copying and
pasting a value in. Most processors, controller services, and Reporting Tasks
are not written to take this into account. They don't typically call `.trim()`
on the value.
It's a very easy thing to overlook and not even think about when writing the
Processor/extension. As a result, we should update the
`PropertyDescriptor.Builder` to allow for a new method: `Builder
trimValue(boolean trim)`. This way, auto-complete can help to remind developers
whether or not to set it. And it will be obvious looking at extensions whether
or not the values are being trimmed, which in and of itself can function as a
reminder.
An example would be:
{code:java}
static final PropertyDescriptor NUMBER = new PropertyDescriptor.Builder()
.name("number")
.displayName("Favorite Number")
.addValidator(StandardValidators.INTEGER_VALIDATOR)
.trimValue(true)
.build();{code}
If the Property Descriptor is created in this way, with `trimValue` set to
true, any time that the property is obtained by calling
`ProcessContext.getProperty(NUMBER)`, the PropertyValue should automatically
represent the value after having whitespace trimmed. (Same applies for
ValidationContext). Additionally, any validation that occurs should occur only
the trimmed value. In short, no "user code" should be able obtain the untrimmed
value, as the user code has declared that it wants white space removed.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)