Re: null parameter constructors in StringConverters

2025-08-18 Thread Nir Lisker
Alright, I'll document the current behavior. On Tue, Aug 19, 2025 at 1:43 AM Kevin Rushforth wrote: > I am not sure it is worth changing the behavior either. It allowing null > were ambiguous (or harmful), then it might be worth it. As it is, it seems > better to just document the current behavi

Re: null parameter constructors in StringConverters

2025-08-18 Thread Kevin Rushforth
I am not sure it is worth changing the behavior either. It allowing null were ambiguous (or harmful), then it might be worth it. As it is, it seems better to just document the current behavior. -- Kevin On 8/18/2025 2:34 PM, John Hendrikx wrote: I think it may come down to whether rejecting

Re: null parameter constructors in StringConverters

2025-08-18 Thread John Hendrikx
I think it may come down to whether rejecting `null` would be helpful for users of these constructors to find problems in their code.  I agree that the DateTimeStringConverter is not really a chained constructor with a clear (and public) master constructor that is documented to allow `null` for cer

Re: null parameter constructors in StringConverters

2025-08-18 Thread Nir Lisker
> > But I think I see what you mean better now, for example, there is (Locale > locale, String pattern) and (String pattern). If you intending to pass > `null` as Locale, why not just use the pattern-only constructor? I think > that still could make sense, OK, but what about `pattern` being null

Re: null parameter constructors in StringConverters

2025-08-18 Thread John Hendrikx
If certain patterns make no sense, then I think the master constructor should reject them (if there is one, or perhaps one should be created as a private one). For example, if there is a width/height constructor, but I only specify width and not height, then I think its fine to reject (null, heigh

Re: null parameter constructors in StringConverters

2025-08-18 Thread Nir Lisker
> > Aren't these constructors chained? Not all of them. There are 3 tangential creation paths for DateTimeStringConverter and subclasses: 1. Through dateStyle/timeStyle ints with an optional locale that creates the DateFormat with `DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale)` (si

Re: null parameter constructors in StringConverters

2025-08-18 Thread John Hendrikx
Aren't these constructors chained?  I believe it is quite common practice to use nulls when calling a chained constructor to get a default for that parameter.  If a certain type of convenience constructor is missing, a caller can pass in `null` for the parameter they'd like defaulted.  It's not too