@Test public void convertToBooleanNull() { Boolean b = converter.toBoolean(null, null, null); assertNull(b); }
@AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) public Boolean toBoolean(String value, String sourceFormat, String targetFormat) { if (value == null) { return null; } Pattern pattern; if (sourceFormat != null && !sourceFormat.isEmpty()) { pattern = Pattern.compile(sourceFormat, Pattern.CASE_INSENSITIVE); } else { pattern = TRUE_PATTERN; } if (pattern.matcher(value).matches()) { return Boolean.TRUE; } try { Number n = NumberFormat.getInstance().parse(value); if (n.intValue() == 0) { return Boolean.FALSE; } return Boolean.TRUE; } catch (ParseException e) { e.getMessage(); } return Boolean.FALSE; }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) public Boolean toBoolean(String value, String sourceFormat, String targetFormat) { if (value == null) { return null; } Pattern pattern; if (sourceFormat != null && !sourceFormat.isEmpty()) { pattern = Pattern.compile(sourceFormat, Pattern.CASE_INSENSITIVE); } else { pattern = TRUE_PATTERN; } if (pattern.matcher(value).matches()) { return Boolean.TRUE; } try { Number n = NumberFormat.getInstance().parse(value); if (n.intValue() == 0) { return Boolean.FALSE; } return Boolean.TRUE; } catch (ParseException e) { e.getMessage(); } return Boolean.FALSE; } }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) public Boolean toBoolean(String value, String sourceFormat, String targetFormat) { if (value == null) { return null; } Pattern pattern; if (sourceFormat != null && !sourceFormat.isEmpty()) { pattern = Pattern.compile(sourceFormat, Pattern.CASE_INSENSITIVE); } else { pattern = TRUE_PATTERN; } if (pattern.matcher(value).matches()) { return Boolean.TRUE; } try { Number n = NumberFormat.getInstance().parse(value); if (n.intValue() == 0) { return Boolean.FALSE; } return Boolean.TRUE; } catch (ParseException e) { e.getMessage(); } return Boolean.FALSE; }  }
StringConverter implements AtlasConverter<String> { @AtlasConversionInfo(sourceType = FieldType.STRING, targetType = FieldType.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) public Boolean toBoolean(String value, String sourceFormat, String targetFormat) { if (value == null) { return null; } Pattern pattern; if (sourceFormat != null && !sourceFormat.isEmpty()) { pattern = Pattern.compile(sourceFormat, Pattern.CASE_INSENSITIVE); } else { pattern = TRUE_PATTERN; } if (pattern.matcher(value).matches()) { return Boolean.TRUE; } try { Number n = NumberFormat.getInstance().parse(value); if (n.intValue() == 0) { return Boolean.FALSE; } return Boolean.TRUE; } catch (ParseException e) { e.getMessage(); } return Boolean.FALSE; }  @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.BOOLEAN, concerns = AtlasConversionConcern.CONVENTION) public Boolean toBoolean(String value, String sourceFormat, String targetFormat) { if (value == null) { return null; } Pattern pattern; if (sourceFormat != null && !sourceFormat.isEmpty()) { pattern = Pattern.compile(sourceFormat, Pattern.CASE_INSENSITIVE); } else { pattern = TRUE_PATTERN; } if (pattern.matcher(value).matches()) { return Boolean.TRUE; } try { Number n = NumberFormat.getInstance().parse(value); if (n.intValue() == 0) { return Boolean.FALSE; } return Boolean.TRUE; } catch (ParseException e) { e.getMessage(); } return Boolean.FALSE; }  @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);  }