Reformat floatutil.

This commit is contained in:
drtshock 2015-06-05 10:38:06 -05:00
parent 3634cab1a5
commit 5e605f992a
3 changed files with 11 additions and 17 deletions

View file

@ -34,7 +34,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.4-R0.1-SNAPSHOT</version>
<version>1.8.7-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>BOSEconomy</groupId>

View file

@ -3,33 +3,27 @@ package com.earth2me.essentials.utils;
/**
* parseFloat and parseDouble proxies that are protected against non-finite values.
*/
public class FloatUtil
{
private FloatUtil() {}
public class FloatUtil {
private FloatUtil() {
}
public static float parseFloat(String s) throws NumberFormatException
{
public static float parseFloat(String s) throws NumberFormatException {
float f = Float.parseFloat(s);
if (Float.isNaN(f))
{
if (Float.isNaN(f)) {
throw new NumberFormatException("NaN is not valid");
}
if (Float.isInfinite(f))
{
if (Float.isInfinite(f)) {
throw new NumberFormatException("Infinity is not valid");
}
return f;
}
public static double parseDouble(String s) throws NumberFormatException
{
public static double parseDouble(String s) throws NumberFormatException {
double d = Double.parseDouble(s);
if (Double.isNaN(d))
{
if (Double.isNaN(d)) {
throw new NumberFormatException("NaN is not valid");
}
if (Double.isInfinite(d))
{
if (Double.isInfinite(d)) {
throw new NumberFormatException("Infinity is not valid");
}
return d;

View file

@ -47,7 +47,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.3-R0.1-SNAPSHOT</version>
<version>1.8.7-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>