public static Object coerceString(String value, Class<?> clazz)
  {
    if (value == null)
    {
      return null;
    }
    else if (String.class.equals(clazz))
    {
      return value;
    }
    else if (Short.TYPE.equals(clazz) || Short.class.equals(clazz))
    {
      return Short.valueOf(value);
    }
    else if (Double.TYPE.equals(clazz) || Double.class.equals(clazz))
    {
      return Double.valueOf(value);
    }
    else if (Float.TYPE.equals(clazz) || Float.class.equals(clazz))
    {
      return Float.valueOf(value);
    }
    else if (Boolean.class.equals(clazz) || Boolean.TYPE.equals(clazz))
    {
      return Boolean.valueOf(value);
    }
    else if (Integer.TYPE.equals(clazz) || Integer.class.equals(clazz))
    {
      return Integer.valueOf(value);
    }
    else if (Long.TYPE.equals(clazz) || Long.class.equals(clazz))
    {
      return Long.valueOf(value);
    }
    else if (ByteString.class.equals(clazz))
    {
      return ByteString.copyAvroString(value, true);
    }
    else if (clazz.isEnum())
    {
      return DataTemplateUtil.coerceOutput(value, clazz);
    }

    throw new IllegalArgumentException("Cannot coerce String to type: " + value + " -> " + clazz.getName());
  }
@Test
  public void test()
  {
    Assert.assertSame(ValueConverter.coerceString(null, Object.class), null);

    Assert.assertEquals(ValueConverter.coerceString("Test String", String.class), "Test String");

    Assert.assertSame(ValueConverter.coerceString("true", boolean.class), true);
    Assert.assertSame(ValueConverter.coerceString("false", Boolean.class), false);

    Assert.assertEquals(ValueConverter.coerceString("1", short.class), (short) 1);
    Assert.assertEquals(ValueConverter.coerceString("2", Short.class), (short) 2);

    Assert.assertEquals(ValueConverter.coerceString("3", int.class), 3);
    Assert.assertEquals(ValueConverter.coerceString("4", Integer.class), 4);

    Assert.assertEquals(ValueConverter.coerceString("5", long.class), 5L);
    Assert.assertEquals(ValueConverter.coerceString("6", Long.class), 6L);

    Assert.assertEquals(ValueConverter.coerceString("7.8", float.class), 7.8F);
    Assert.assertEquals(ValueConverter.coerceString("9.10", Float.class), 9.1F);
    Assert.assertEquals(ValueConverter.coerceString("11", Float.class), 11F);

    Assert.assertEquals(ValueConverter.coerceString("12.13", double.class), 12.13D);
    Assert.assertEquals(ValueConverter.coerceString("14.15", Double.class), 14.15D);

    Assert.assertEquals(ValueConverter.coerceString(_bytes16, ByteString.class), ByteString.copyAvroString(_bytes16, true));

    Assert.assertSame(ValueConverter.coerceString("APPLE", Fruits.class), Fruits.APPLE);
    Assert.assertSame(ValueConverter.coerceString("ORANGE", Fruits.class), Fruits.ORANGE);
    Assert.assertSame(ValueConverter.coerceString("BLUEBERRY", Fruits.class), Fruits.$UNKNOWN);
  }