Guest User

Untitled

a guest
Jan 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. class util {
  2. /**
  3. * This method returns true if the collection is null or is empty.
  4. * @param collection
  5. * @return true | false
  6. */
  7. public static boolean isEmpty( Collection<?> collection ){
  8. if( collection == null || collection.isEmpty() ){
  9. return true;
  10. }
  11. return false;
  12. }
  13.  
  14. /**
  15. * This method returns true of the map is null or is empty.
  16. * @param map
  17. * @return true | false
  18. */
  19. public static boolean isEmpty( Map<?, ?> map ){
  20. if( map == null || map.isEmpty() ){
  21. return true;
  22. }
  23. return false;
  24. }
  25.  
  26. /**
  27. * This method returns true if the objet is null.
  28. * @param object
  29. * @return true | false
  30. */
  31. public static boolean isEmpty( Object object ){
  32. if( object == null ){
  33. return true;
  34. }
  35. return false;
  36. }
  37.  
  38. /**
  39. * This method returns true if the input array is null or its length is zero.
  40. * @param array
  41. * @return true | false
  42. */
  43. public static boolean isEmpty( Object[] array ){
  44. if( array == null || array.length == 0 ){
  45. return true;
  46. }
  47. return false;
  48. }
  49.  
  50. /**
  51. * This method returns true if the input string is null or its length is zero.
  52. * @param string
  53. * @return true | false
  54. */
  55. public static boolean isEmpty( String string ){
  56. if( string == null || string.trim().length() == 0 ){
  57. return true;
  58. }
  59. return false;
  60. }
  61. }
Add Comment
Please, Sign In to add comment