@Test(expected = AtlasConversionException.class) public void convertToFloatUnparsable() throws Exception { String s = "QWERTY"; converter.toFloat(s); }
@AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) public Float toFloat(String value) throws AtlasConversionException { if (value == null) { return null; } try { Float.parseFloat(value); } catch (NumberFormatException nfe) { throw new AtlasConversionException(nfe); } BigDecimal bd = new BigDecimal(value); if (bd.floatValue() == 0.0f || bd.floatValue() == -0.0) { return Float.valueOf(value); } if (bd.floatValue() < Float.MIN_VALUE || bd.floatValue() > Float.MAX_VALUE) { throw new AtlasConversionException( String.format("String %s is greater than Float.MAX_VALUE or less than Float.MIN_VALUE", value)); } return Float.valueOf(value); }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) public Float toFloat(String value) throws AtlasConversionException { if (value == null) { return null; } try { Float.parseFloat(value); } catch (NumberFormatException nfe) { throw new AtlasConversionException(nfe); } BigDecimal bd = new BigDecimal(value); if (bd.floatValue() == 0.0f || bd.floatValue() == -0.0) { return Float.valueOf(value); } if (bd.floatValue() < Float.MIN_VALUE || bd.floatValue() > Float.MAX_VALUE) { throw new AtlasConversionException( String.format("String %s is greater than Float.MAX_VALUE or less than Float.MIN_VALUE", value)); } return Float.valueOf(value); } }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) public Float toFloat(String value) throws AtlasConversionException { if (value == null) { return null; } try { Float.parseFloat(value); } catch (NumberFormatException nfe) { throw new AtlasConversionException(nfe); } BigDecimal bd = new BigDecimal(value); if (bd.floatValue() == 0.0f || bd.floatValue() == -0.0) { return Float.valueOf(value); } if (bd.floatValue() < Float.MIN_VALUE || bd.floatValue() > Float.MAX_VALUE) { throw new AtlasConversionException( String.format("String %s is greater than Float.MAX_VALUE or less than Float.MIN_VALUE", value)); } return Float.valueOf(value); }  }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) public Float toFloat(String value) throws AtlasConversionException { if (value == null) { return null; } try { Float.parseFloat(value); } catch (NumberFormatException nfe) { throw new AtlasConversionException(nfe); } BigDecimal bd = new BigDecimal(value); if (bd.floatValue() == 0.0f || bd.floatValue() == -0.0) { return Float.valueOf(value); } if (bd.floatValue() < Float.MIN_VALUE || bd.floatValue() > Float.MAX_VALUE) { throw new AtlasConversionException( String.format("String %s is greater than Float.MAX_VALUE or less than Float.MIN_VALUE", value)); } return Float.valueOf(value); }  @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DECIMAL, concerns = AtlasConversionConcern.FORMAT) BigDecimal toBigDecimal(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BIG_INTEGER, concerns = AtlasConversionConcern.FORMAT) BigInteger toBigInteger(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) Boolean toBoolean(String value, String sourceFormat, String targetFormat); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BYTE, concerns = { AtlasConversionConcern.RANGE, AtlasConversionConcern.FORMAT, AtlasConversionConcern.FRACTIONAL_PART}) Byte toByte(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.CHAR, concerns = AtlasConversionConcern.RANGE) Character toCharacter(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE_TIME) Date toDate(String date, String sourceFormat, String targetFormat); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DOUBLE, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) Double toDouble(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) Float toFloat(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.INTEGER, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART }) Integer toInteger(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE) LocalDate toLocalDate(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.TIME) LocalTime toLocalTime(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE_TIME) LocalDateTime toLocalDateTime(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.LONG, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART }) Long toLong(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.SHORT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART }) Short toShort(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.STRING) String toString(String value, String sourceFormat, String targetFormat); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.NUMBER, concerns = { AtlasConversionConcern.FORMAT }) Number toNumber(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE_TIME_TZ) ZonedDateTime toZonedDateTime(String value); }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) public Float toFloat(String value) throws AtlasConversionException { if (value == null) { return null; } try { Float.parseFloat(value); } catch (NumberFormatException nfe) { throw new AtlasConversionException(nfe); } BigDecimal bd = new BigDecimal(value); if (bd.floatValue() == 0.0f || bd.floatValue() == -0.0) { return Float.valueOf(value); } if (bd.floatValue() < Float.MIN_VALUE || bd.floatValue() > Float.MAX_VALUE) { throw new AtlasConversionException( String.format("String %s is greater than Float.MAX_VALUE or less than Float.MIN_VALUE", value)); } return Float.valueOf(value); }  @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DECIMAL, concerns = AtlasConversionConcern.FORMAT) BigDecimal toBigDecimal(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BIG_INTEGER, concerns = AtlasConversionConcern.FORMAT) BigInteger toBigInteger(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) Boolean toBoolean(String value, String sourceFormat, String targetFormat); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BYTE, concerns = { AtlasConversionConcern.RANGE, AtlasConversionConcern.FORMAT, AtlasConversionConcern.FRACTIONAL_PART}) Byte toByte(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.CHAR, concerns = AtlasConversionConcern.RANGE) Character toCharacter(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE_TIME) Date toDate(String date, String sourceFormat, String targetFormat); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DOUBLE, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) Double toDouble(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.FLOAT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE }) Float toFloat(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.INTEGER, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART }) Integer toInteger(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE) LocalDate toLocalDate(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.TIME) LocalTime toLocalTime(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE_TIME) LocalDateTime toLocalDateTime(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.LONG, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART }) Long toLong(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.SHORT, concerns = { AtlasConversionConcern.FORMAT, AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART }) Short toShort(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.STRING) String toString(String value, String sourceFormat, String targetFormat); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.NUMBER, concerns = { AtlasConversionConcern.FORMAT }) Number toNumber(String value); @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.DATE_TIME_TZ) ZonedDateTime toZonedDateTime(String value);  }