How about using Number.floatValue()
?
Object result = valueCalculator.invoke(sourceObject);
Float f = ((Number)result).floatValue();
System.out.println(f);
... or however you want to use it.
Here I'm assuming the return type is one of these - BigDecimal
, BigInteger
, Byte
, Double
, Float
, Integer
, Long
, and Short
(which are all subclasses of Number
).