protected static void pushCastToType(MethodVisitor methodVisitor, Object type) {
        String internalName = getInternalNameForCast(type);
        methodVisitor.visitTypeInsn(CHECKCAST, internalName);
        Type primitiveType = null;
        if (type instanceof Class) {
            Class typeClass = (Class) type;
            if (typeClass.isPrimitive()) {
                primitiveType = Type.getType(typeClass);
            }
        } else if (type instanceof Type) {
            final Optional<Class> pt = ClassUtils.getPrimitiveType(((Type) type).getClassName());
            if (pt.isPresent()) {
                primitiveType = Type.getType(pt.get());
            }
        }

        if (primitiveType != null) {
            org.objectweb.asm.commons.Method valueMethod = null;
            switch (primitiveType.getSort()) {
                case Type.BOOLEAN:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("boolean booleanValue()");
                    break;
                case Type.CHAR:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("char charValue()");
                    break;
                case Type.BYTE:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("byte byteValue()");
                    break;
                case Type.SHORT:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("short shortValue()");
                    break;
                case Type.INT:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("int intValue()");
                    break;
                case Type.LONG:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("long longValue()");
                    break;
                case Type.DOUBLE:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("double doubleValue()");
                    break;
                case Type.FLOAT:
                    valueMethod = org.objectweb.asm.commons.Method.getMethod("float floatValue()");
                    break;
                default:
                    // no-ip
            }

            if (valueMethod != null) {
                methodVisitor.visitMethodInsn(INVOKEVIRTUAL, internalName, valueMethod.getName(), valueMethod.getDescriptor(), false);
            }
        }
    }
protected static void pushCastToType ( MethodVisitor methodVisitor , Object type ) { String internalName = getInternalNameForCast ( type ) ; methodVisitor . visitTypeInsn ( CHECKCAST , internalName ) ; Type primitiveType = null ; if ( type instanceof Class ) { Class typeClass = ( Class ) type ; if ( typeClass . isPrimitive ( ) ) { primitiveType = Type . getType ( typeClass ) ; } } else if ( type instanceof Type ) { final Optional < Class > pt = ClassUtils . getPrimitiveType ( ( ( Type ) type ) . getClassName ( ) ) ; if ( pt . isPresent ( ) ) { primitiveType = Type . getType ( pt . get ( ) ) ; } } if ( primitiveType != null ) { org . objectweb . asm . commons . Method valueMethod = null ; switch ( primitiveType . getSort ( ) ) { case Type . BOOLEAN : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "boolean booleanValue()" ) ; break ; case Type . CHAR : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "char charValue()" ) ; break ; case Type . BYTE : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "byte byteValue()" ) ; break ; case Type . SHORT : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "short shortValue()" ) ; break ; case Type . INT : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "int intValue()" ) ; break ; case Type . LONG : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "long longValue()" ) ; break ; case Type . DOUBLE : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "double doubleValue()" ) ; break ; case Type . FLOAT : valueMethod = org . objectweb . asm . commons . Method . getMethod ( "float floatValue()" ) ; break ; default : } if ( valueMethod != null ) { methodVisitor . visitMethodInsn ( INVOKEVIRTUAL , internalName , valueMethod . getName ( ) , valueMethod . getDescriptor ( ) , false ) ; } } }
@param methodVisitor The {@link MethodVisitor}
@param type          The type