java - Equivalent of Guava's Strings.isNullOrEmpty() for Long, Integer, etc -
is there .isnullorzero() in util libs guava java boxed numeric primitive types?
a integer, long can not empty if not null
; can 0 in case. integer or long can write -
public static boolean isnullorzero( final object obj) { if(null == obj) return true; if( obj instanceof integer ){ integer = (integer) obj; return (i == 0); } if( obj instanceof long ){ long l = (long) obj; return (l == 0); } }
for collection, if not null can empty. can write own isnullorempty()
method -
public static boolean isnullorempty( final collection< ? > collection ) { return (collection == null || collection.isempty() ); }
Comments
Post a Comment