@Test(expected = ConverterException.class) public void testRaiseError() { converter.convert("abc", TypeToken.of(Integer.class)); }
@Override public Object convert(Object source, TypeToken<?> targetTypeToken) { if (targetTypeToken.isPrimitive()) { targetTypeToken = PrimitiveTypeUtils.toWrapperTypeToken(targetTypeToken); } if (canHandle(source, targetTypeToken)) { return NumberUtils.parseNumber((String) source, (Class) targetTypeToken.getType()); } else { throw new ConverterException("can not convert '" + source + "' to " + targetTypeToken.getRawType()); } }
StringToNumberConverter extends AbstractConverter { @Override public Object convert(Object source, TypeToken<?> targetTypeToken) { if (targetTypeToken.isPrimitive()) { targetTypeToken = PrimitiveTypeUtils.toWrapperTypeToken(targetTypeToken); } if (canHandle(source, targetTypeToken)) { return NumberUtils.parseNumber((String) source, (Class) targetTypeToken.getType()); } else { throw new ConverterException("can not convert '" + source + "' to " + targetTypeToken.getRawType()); } } }
StringToNumberConverter extends AbstractConverter { @Override public Object convert(Object source, TypeToken<?> targetTypeToken) { if (targetTypeToken.isPrimitive()) { targetTypeToken = PrimitiveTypeUtils.toWrapperTypeToken(targetTypeToken); } if (canHandle(source, targetTypeToken)) { return NumberUtils.parseNumber((String) source, (Class) targetTypeToken.getType()); } else { throw new ConverterException("can not convert '" + source + "' to " + targetTypeToken.getRawType()); } }  }
StringToNumberConverter extends AbstractConverter { @Override public Object convert(Object source, TypeToken<?> targetTypeToken) { if (targetTypeToken.isPrimitive()) { targetTypeToken = PrimitiveTypeUtils.toWrapperTypeToken(targetTypeToken); } if (canHandle(source, targetTypeToken)) { return NumberUtils.parseNumber((String) source, (Class) targetTypeToken.getType()); } else { throw new ConverterException("can not convert '" + source + "' to " + targetTypeToken.getRawType()); } }  @Override Object convert(Object source, TypeToken<?> targetTypeToken); @Override boolean canHandle(Object source, TypeToken<?> targetTypeToken); }
StringToNumberConverter extends AbstractConverter { @Override public Object convert(Object source, TypeToken<?> targetTypeToken) { if (targetTypeToken.isPrimitive()) { targetTypeToken = PrimitiveTypeUtils.toWrapperTypeToken(targetTypeToken); } if (canHandle(source, targetTypeToken)) { return NumberUtils.parseNumber((String) source, (Class) targetTypeToken.getType()); } else { throw new ConverterException("can not convert '" + source + "' to " + targetTypeToken.getRawType()); } }  @Override Object convert(Object source, TypeToken<?> targetTypeToken); @Override boolean canHandle(Object source, TypeToken<?> targetTypeToken);  }