public Object getAsJavaType( String valueName, Class<?> destinationType, InjectionTypeConverter converter )
    throws KettleValueException {
    int idx = rowMeta.indexOfValue( valueName );
    if ( idx < 0 ) {
      throw new KettleValueException( "Unknown column '" + valueName + "'" );
    }

    ValueMetaInterface metaType = rowMeta.getValueMeta( idx );
    // find by source value type
    switch ( metaType.getType() ) {
      case ValueMetaInterface.TYPE_STRING:
        String vs = rowMeta.getString( data, idx );
        return getStringAsJavaType( vs, destinationType, converter );
      case ValueMetaInterface.TYPE_BOOLEAN:
        Boolean vb = rowMeta.getBoolean( data, idx );
        if ( String.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2string( vb );
        } else if ( int.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2intPrimitive( vb );
        } else if ( Integer.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2integer( vb );
        } else if ( long.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2longPrimitive( vb );
        } else if ( Long.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2long( vb );
        } else if ( boolean.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2booleanPrimitive( vb );
        } else if ( Boolean.class.isAssignableFrom( destinationType ) ) {
          return converter.boolean2boolean( vb );
        } else if ( destinationType.isEnum() ) {
          return converter.boolean2enum( destinationType, vb );
        } else {
          throw new RuntimeException( "Wrong value conversion to " + destinationType );
        }
      case ValueMetaInterface.TYPE_INTEGER:
        Long vi = rowMeta.getInteger( data, idx );
        if ( String.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2string( vi );
        } else if ( int.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2intPrimitive( vi );
        } else if ( Integer.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2integer( vi );
        } else if ( long.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2longPrimitive( vi );
        } else if ( Long.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2long( vi );
        } else if ( boolean.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2booleanPrimitive( vi );
        } else if ( Boolean.class.isAssignableFrom( destinationType ) ) {
          return converter.integer2boolean( vi );
        } else if ( destinationType.isEnum() ) {
          return converter.integer2enum( destinationType, vi );
        } else {
          throw new RuntimeException( "Wrong value conversion to " + destinationType );
        }
      case ValueMetaInterface.TYPE_NUMBER:
        Double vn = rowMeta.getNumber( data, idx );
        if ( String.class.isAssignableFrom( destinationType ) ) {
          return converter.number2string( vn );
        } else if ( int.class.isAssignableFrom( destinationType ) ) {
          return converter.number2intPrimitive( vn );
        } else if ( Integer.class.isAssignableFrom( destinationType ) ) {
          return converter.number2integer( vn );
        } else if ( long.class.isAssignableFrom( destinationType ) ) {
          return converter.number2longPrimitive( vn );
        } else if ( Long.class.isAssignableFrom( destinationType ) ) {
          return converter.number2long( vn );
        } else if ( boolean.class.isAssignableFrom( destinationType ) ) {
          return converter.number2booleanPrimitive( vn );
        } else if ( Boolean.class.isAssignableFrom( destinationType ) ) {
          return converter.number2boolean( vn );
        } else if ( destinationType.isEnum() ) {
          return converter.number2enum( destinationType, vn );
        } else {
          throw new RuntimeException( "Wrong value conversion to " + destinationType );
        }
    }

    throw new KettleValueException( "Unknown conversion from " + metaType.getTypeDesc() + " into " + destinationType );
  }
@Test
  public void testIntegerConversion() throws Exception {

    row = new RowMetaAndData( rowsMeta, null, null, 7L );
    assertEquals( true, row.getAsJavaType( "int", boolean.class, converter ) );
    assertEquals( true, row.getAsJavaType( "int", Boolean.class, converter ) );
    assertEquals( 7, row.getAsJavaType( "int", int.class, converter ) );
    assertEquals( 7, row.getAsJavaType( "int", Integer.class, converter ) );
    assertEquals( 7L, row.getAsJavaType( "int", long.class, converter ) );
    assertEquals( 7L, row.getAsJavaType( "int", Long.class, converter ) );
    assertEquals( "7", row.getAsJavaType( "int", String.class, converter ) );

    row = new RowMetaAndData( rowsMeta, null, null, 0L );
    assertEquals( false, row.getAsJavaType( "int", boolean.class, converter ) );
    assertEquals( false, row.getAsJavaType( "int", Boolean.class, converter ) );

    row = new RowMetaAndData( rowsMeta, null, null, null );
    assertEquals( null, row.getAsJavaType( "int", String.class, converter ) );
    assertEquals( null, row.getAsJavaType( "int", Integer.class, converter ) );
    assertEquals( null, row.getAsJavaType( "int", Long.class, converter ) );
    assertEquals( null, row.getAsJavaType( "int", Boolean.class, converter ) );
  }