Java - Write code to get Null If empty String using tenary operator

Requirements

Write code to get Null If empty String using tenary operator

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(getNullIfemptyString(str));
    }/*from   w ww  .j av a  2s  . c o  m*/

    public static String getNullIfemptyString(String str) {
        return (str == null) || (str.trim().length() == 0) ? null : str;
    }
}