Hi devs,
I’d like to propose that we start using Optional as return values in our APIs, in order to make it clear the user that the value can be null.
See https://dzone.com/articles/java-8-optional-usage-and-best-practices
For example for the User API this would mean:
public interface UserProperties extends ConfigurationSource
{
/**
* @return true if the user is configured to display hidden documents in the wiki
*/
boolean displayHiddenDocuments();
/**
* @return true if the user is active in the wiki. An active user can log in.
*/
boolean isActive();
/**
* @return the first name of the user or null if not set
*/
Optional<String> getFirstName();
/**
* @return the last name of the user or null if not set
*/
Optional<String> getLastName();
/**
* @return the email address of the user and null if not set
*/
Optional<String> getEmail();
/**
* @return the type of the user (simple user, advanced user)
* @see <a href="https://bit.ly/37TUlCp">user profile</a>
*/
UserType getType();
/**
* @return the default editor to use when editing content for this user (text editor, wysiwyg editor)
*/
Editor getEditor();
...
WDYT?
Thanks