Dan, Thanks for raising this question for discussion. Although it is convenient, it does not seem common enough to warrant the addition, on initial consideration. Although there are a number of convenience methods in PropertyValue for common types, and Charset is used in a handful of places, I'm not sure it is common enough to warrant this type of API change. With that background, I would be interested to hear from others, but my initial thought is that PropertyValue methods should be focused on more common primitive and enum types.
Regards, David Handermann On Thu, Jan 9, 2025 at 8:30 AM Dan S <[email protected]> wrote: > > BLUF > I would like to propose adding a method to > org.apache.nifi.components.PropertyValue whose signature would be > > Charset asCharset(); > > (where Charset is a java.nio.charset.Charset object) > > Background > While working NIFI-14135 <https://issues.apache.org/jira/browse/NIFI-14135>, I > noticed there are almost 40 lines between processors and controller > services which have the line > > final Charset charset = > Charset.forName(context.getProperty(CHARACTER_SET).getValue()); > > and there are some which have code that look like > > final String charsetName = context.getProperty(CHARSET).getValue(); > > but eventually have code later which converts the string into a Charset > object (e.g. Charset.forName(charsetName) ). > > It would seem to me this can all be simplified if we had a method in > org.apache.nifi.components.PropertyValue which converted the property value > to a java.nio.charset.Charset. > > Please let me know your thoughts on this proposal. Thanks!
