return str == null ? "" : str.trim();Could be rewritten as
return Optional.ofNullable(str).map(String::trim).orElse("");
While the replacement is not always shorter, this could be a helpful step for further refactoring (e.g. changing the method return value to an Optional).
Note that when not-null branch of the condition returns null, the corresponding mapping step will produce an empty Optional possibly changing the semantics. If it cannot be statically proven that semantics will be preserved, quick-fix action name will contain "(may change semantics)" notice and inspection highlighting will be turned off.
This inspection only reports if the language level of the project or module is 8 or higher
New in 2018.1