On Mon, 29 Nov 2021 18:44:11 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:

>> It's not meant to be "part of the method spec", it's just that it's silly to 
>> display a summary/detail box unless you have something to show in the 
>> details. Think of it as a very trivial application of Postel's law. BTW, 
>> this kind of flexibility in choosing the appropriate container is one of the 
>> things that led me to choose `Optional` argument instead of overloaded 
>> methods. It just looks nicer to my eyes.
>
> I'd be inclined for either `detail` to be `Optional<Content>` or for there to 
> be an overload that allows `Optional<String>` that calls the sibling with 
> `Optional<Content>`

> it's just that it's silly to display a summary/detail box unless you have 
> something to show in the details.

Agreed. This is just another case of whether it is better to assert/check that 
the input is sensible, or to silently do something reasonable in the face of 
unreasonable arguments.

If the arg was `Optional<Content>` instead of `Optional<String>` it would be 
more reasonable to just do the "null or blank" check on the string, and assume 
that the `Optional<Content>` is well-formed and sensible.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6579

Reply via email to