Part 1
There is no satisfactory solution for this, since it java.lang.Numberdoes not indicate anything that would be useful for calculating the successor Number.
instanceof . , instanceof Number, , . BigInteger, AtomicLong Number (, Rational ..).
2
, , . 3 , autoboxing/unboxing , -:
Integer plusOne(Integer);
Code:
0: aload_1
1: invokevirtual #84; //int Integer.intValue()
4: iconst_1
5: iadd
6: invokestatic #20; //Integer Integer.valueOf(int)
9: areturn
Double plusOne(Double);
Code:
0: aload_1
1: invokevirtual #91; //double Double.doubleValue()
4: dconst_1
5: dadd
6: invokestatic #97; //Double Double.valueOf(double)
9: areturn
Long plusOne(Long);
Code:
0: aload_1
1: invokevirtual #102; //Long Long.longValue()
4: lconst_1
5: ladd
6: invokestatic #108; //Long Long.valueOf(long)
9: areturn
xxxValue() valueOf() , , 1 , (iconst_1, dconst_1 lconst_1).
<T=Integer|Long|Double>, , .