code: public static boolean isInteger(String _str, boolean _allowNegative) {
          if (_str == null) {
              return false;
          }
  
          String regex = "[0-9]+$";
          if (_allowNegative) {
              regex = "^-?" + regex;
          } else {
              regex = "^" + regex;
          }
          return _str.matches(regex);
      }
docs: Check if string is an either positive or negative integer.
  
  @param _str string to validate
  @param _allowNegative negative integer allowed
  @return true if integer, false otherwise