public static String checkNotNullNorEmpty ( final String reference , final Object errorMessage ) { if ( reference == null ) { throw new NullPointerException ( String . valueOf ( errorMessage ) ) ; } if ( reference . isEmpty ( ) ) { throw new IllegalArgumentException ( String . valueOf ( errorMessage ) ) ; } return reference ; }
Ensures that a string reference passed as a parameter to the calling method is not null . nor empty .