mirror of
https://github.com/stleary/JSON-java.git
synced 2025-10-01 14:25:55 -04:00
more sonarcube cleanup
This commit is contained in:
parent
9bb26bdb34
commit
6ed2880f55
@ -1398,11 +1398,13 @@ public class JSONObject {
|
||||
}
|
||||
// don't check if it's a string in case of unchecked Number subclasses
|
||||
try {
|
||||
// the other opt functions handle implicit conversions, i.e.
|
||||
// jo.put("double",1.1d);
|
||||
// jo.optInt("double"); -- will return 1, not an error
|
||||
// this conversion to BigDecimal then to BigInteger is to maintain
|
||||
// that type cast support that may truncate the decimal.
|
||||
/**
|
||||
* the other opt functions handle implicit conversions, i.e.
|
||||
* jo.put("double",1.1d);
|
||||
* jo.optInt("double"); -- will return 1, not an error
|
||||
* this conversion to BigDecimal then to BigInteger is to maintain
|
||||
* that type cast support that may truncate the decimal.
|
||||
*/
|
||||
final String valStr = val.toString();
|
||||
if(isDecimalNotation(valStr)) {
|
||||
return new BigDecimal(valStr).toBigInteger();
|
||||
@ -1506,11 +1508,7 @@ public class JSONObject {
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
final float floatValue = val.floatValue();
|
||||
// if (Float.isNaN(floatValue) || Float.isInfinite(floatValue)) {
|
||||
// return defaultValue;
|
||||
// }
|
||||
return floatValue;
|
||||
return val.floatValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1542,11 +1540,7 @@ public class JSONObject {
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
final Float floatValue = val.floatValue();
|
||||
// if (Float.isNaN(floatValue) || Float.isInfinite(floatValue)) {
|
||||
// return defaultValue;
|
||||
// }
|
||||
return floatValue;
|
||||
return val.floatValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1917,7 +1911,7 @@ public class JSONObject {
|
||||
// if the first letter in the key is not uppercase, then skip.
|
||||
// This is to maintain backwards compatibility before PR406
|
||||
// (https://github.com/stleary/JSON-java/pull/406/)
|
||||
if (key.length() == 0 || Character.isLowerCase(key.charAt(0))) {
|
||||
if (key.isEmpty() || Character.isLowerCase(key.charAt(0))) {
|
||||
return null;
|
||||
}
|
||||
if (key.length() == 1) {
|
||||
@ -1964,6 +1958,7 @@ public class JSONObject {
|
||||
try {
|
||||
((Closeable) input).close();
|
||||
} catch (IOException ignore) {
|
||||
// close has failed; best effort has been made
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1983,7 +1978,7 @@ public class JSONObject {
|
||||
* or one of its super class definitions
|
||||
*/
|
||||
private static <A extends Annotation> A getAnnotation(final Method m, final Class<A> annotationClass) {
|
||||
// if we have invalid data the result is null
|
||||
// If we have invalid data the result is null
|
||||
if (m == null || annotationClass == null) {
|
||||
return null;
|
||||
}
|
||||
@ -1992,7 +1987,7 @@ public class JSONObject {
|
||||
return m.getAnnotation(annotationClass);
|
||||
}
|
||||
|
||||
// if we've already reached the Object class, return null;
|
||||
// If we've already reached the Object class, return null;
|
||||
Class<?> c = m.getDeclaringClass();
|
||||
if (c.getSuperclass() == null) {
|
||||
return null;
|
||||
@ -2004,13 +1999,13 @@ public class JSONObject {
|
||||
Method im = i.getMethod(m.getName(), m.getParameterTypes());
|
||||
return getAnnotation(im, annotationClass);
|
||||
} catch (final SecurityException ex) {
|
||||
continue;
|
||||
// ignore this exception
|
||||
} catch (final NoSuchMethodException ex) {
|
||||
continue;
|
||||
// ignore this excpetion
|
||||
}
|
||||
}
|
||||
|
||||
//If the superclass is Object, no annotations will be found any more
|
||||
// If the superclass is Object, no annotations will be found any more
|
||||
if (Object.class.equals(c.getSuperclass()))
|
||||
return null;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user