You can either check every possible primitive, or if you know that there will be no BigXxx or AtomicXxx, you can also check:
if(e.value() instanceof Number || e.value() instanceof Boolean || e.value() instanceof Character)
List of subclasses of Number :
AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short
List of primitives :
boolean, byte, short, int, long, char, float, double
But, considering that there are only 8 primitive types, you can also check all of them and put this test in the utility method.
ps: Please note that Guava and answers related to a possible duplicate also include Void, which is consistent with the fact that System.out.println(void.class.isPrimitive()); outputs true.
source share