MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / toFloatValue

Method toFloatValue

CodenameOne/src/com/codename1/io/Util.java:2512–2543  ·  view source on GitHub ↗
(Object number)

Source from the content-addressed store, hash-verified

2510 ///
2511 /// a float value or an exception
2512 public static float toFloatValue(Object number) {
2513 // we should convert this to use Number
2514 if (number instanceof Float) {
2515 return ((Float) number).floatValue();
2516 }
2517 if (number instanceof Long) {
2518 return ((Long) number).floatValue();
2519 }
2520 if (number instanceof Integer) {
2521 return ((Integer) number).floatValue();
2522 }
2523 if (number instanceof String) {
2524 return Float.parseFloat((String) number);
2525 }
2526 if (number instanceof Double) {
2527 return ((Double) number).floatValue();
2528 }
2529 /*if(number instanceof Short) {
2530 return ((Short)number).floatValue();
2531 }
2532 if(number instanceof Byte) {
2533 return ((Byte)number).floatValue();
2534 }*/
2535 if (number instanceof Boolean) {
2536 Boolean b = (Boolean) number;
2537 if (b.booleanValue()) {
2538 return 1;
2539 }
2540 return 0;
2541 }
2542 throw new IllegalArgumentException("Not a number: " + number);
2543 }
2544
2545 /// Returns the number object as a double
2546 ///

Callers 7

setSimpleObjectMethod · 0.95
convertMethod · 0.95
refreshThemeMethod · 0.95
invokeStatic16Method · 0.80

Calls 3

parseFloatMethod · 0.95
booleanValueMethod · 0.95
floatValueMethod · 0.45

Tested by

no test coverage detected