Example usage for org.eclipse.jdt.core.dom NumberLiteral resolveBoxing

List of usage examples for org.eclipse.jdt.core.dom NumberLiteral resolveBoxing

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom NumberLiteral resolveBoxing.

Prototype

public final boolean resolveBoxing() 

Source Link

Document

Returns whether this expression node is the site of a boxing conversion (JLS3 5.1.7).

Usage

From source file:org.evosuite.junit.TestExtractingVisitor.java

License:Open Source License

private Class<?> retrieveTypeClass(NumberLiteral numberLiteral) {
    Object value = numberLiteral.resolveConstantExpressionValue();
    if (numberLiteral.resolveBoxing()) {
        return value.getClass();
    }/*from  w w  w  .  jav a 2s. c om*/
    if (value instanceof Integer) {
        return Integer.TYPE;
    }
    if (value instanceof Long) {
        return Long.TYPE;
    }
    if (value instanceof Double) {
        return Double.TYPE;
    }
    if (value instanceof Float) {
        return Float.TYPE;
    }
    if (value instanceof Short) {
        return Short.TYPE;
    }
    if (value instanceof Byte) {
        return Byte.TYPE;
    }
    throw new UnsupportedOperationException(
            "Retrieval of type " + numberLiteral.getClass() + " not implemented yet!");
}