Closed jmartisk closed 4 years ago
What if we don't change the existing api and introduce new methods for the optional parameters like .optionalDescription(@Nullable description)
Except I'm not sure about the @Nullable
annotation, for that we would need to import some third party library, like the Checker framework or something. Or is there something standard bundled with the JDK? Just JDK internal stuff that isn't really meant to be used like this.
For example, calling
metadataBuilder.description(null)
throws an error even though description is not a required field. I don't see a reason for that. The undesired consequence is that if someone is building a new Metadata object and doesn't know in advance which fields will be null (the values passed from somewhere else), they have to introduceif
conditions into the code, and thus can't properly use the fluent API of the builder.