Created
November 12, 2021 11:51
-
-
Save Vladimir-Urik/008c63069af037ee7e229a9bac1e94ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cz.pvpcraft.gggedr.stats.common.utils; | |
public class ValidatorUtils { | |
public static boolean isInteger(String s) { | |
try { | |
Integer.parseInt(s); | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
return true; | |
} | |
public static boolean isDouble(String s) { | |
try { | |
Double.parseDouble(s); | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
return true; | |
} | |
public static boolean isLong(String s) { | |
try { | |
Long.parseLong(s); | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
return true; | |
} | |
public static boolean isFloat(String s) { | |
try { | |
Float.parseFloat(s); | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
return true; | |
} | |
public static boolean isShort(String s) { | |
try { | |
Short.parseShort(s); | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
return true; | |
} | |
public static boolean isByte(String s) { | |
try { | |
Byte.parseByte(s); | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
return true; | |
} | |
public static boolean isBoolean(String s) { | |
return s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false"); | |
} | |
public static boolean isChar(String s) { | |
return s.length() == 1; | |
} | |
public static boolean isNick(String s) { | |
return s.length() > 2 && s.length() < 16; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment