Object to determine whether the object is empty

If the default is from the Map <String, Object> key value according to the value taken out type Object

 

Determining whether the object is of type Object null

. 1   public  static  Boolean isEmpty (Object obj)
 2    {
 . 3      IF (obj == null ) // Object type judgment is null and null comparison
 . 4      {
 . 5        return  to true ;
 . 6      }
 . 7      IF ((obj the instanceof List)) //   the instanceof  type judgment object belongs
 . 8      {
 . 9        return ((List) obj) .size () == 0 ; // length are determined list is empty is set to judge from a list
 10      }
 . 11      IF ((obj the instanceof String) )
 12      {
 13       return . ((String) obj) .trim () the equals ( "" ); // determines whether the object is empty Stirng type, and is a null contrast, a point is equal ( "")
 14      }
 15      return  to false ;
 16    }

 

Guess you like

Origin www.cnblogs.com/vegetableDD/p/11726204.html