@Test public void fromRaw() throws Exception { assertEquals("Text", adapter.fromRaw("Text", null, null, null)); assertEquals("Text", adapter.fromRaw("Text", ImpExValues.STRING, null, null)); assertEquals(Boolean.TRUE, adapter.fromRaw("true", ImpExValues.BOOLEAN, null, null)); assertEquals(Boolean.FALSE, adapter.fromRaw("false", ImpExValues.BOOLEAN, null, null)); assertEquals(Long.valueOf(0L), adapter.fromRaw("0", ImpExValues.LONG, null, null)); assertEquals(Long.valueOf(100L), adapter.fromRaw("100", ImpExValues.LONG, null, null)); assertEquals(Integer.valueOf(100), adapter.fromRaw("100", ImpExValues.INT, null, null)); assertEquals(new BigDecimal(100), adapter.fromRaw("100", ImpExValues.DECIMAL, null, null)); assertEquals(DateUtils.ldParseSDT("2017-01-01"), adapter.fromRaw("2017-01-01", ImpExValues.DATE, null, null)); assertEquals(DateUtils.ldtParseSDT("2017-01-01"), adapter.fromRaw("2017-01-01", ImpExValues.DATETIME, null, null)); assertEquals(DateUtils.ldtParseSDT("2017-01-01 14:25:00"), adapter.fromRaw("2017-01-01 14:25:00", ImpExValues.DATETIME, null, null)); assertEquals(DateUtils.zdtParseSDT("2017-01-01 14:25:00"), adapter.fromRaw("2017-01-01 14:25:00", ImpExValues.ZONEDTIME, null, null)); assertEquals(DateUtils.iParseSDT("2017-01-01 14:25:00"), adapter.fromRaw("2017-01-01 14:25:00", ImpExValues.INSTANT, null, null)); Instant now = Instant.now(); Instant converted = (Instant) adapter.fromRaw(String.valueOf(now.toEpochMilli()), ImpExValues.INSTANT, null, null); assertEquals(DateUtils.format(now, "yyyyMMddHHmmss"), DateUtils.format(converted, "yyyyMMddHHmmss")); }
@Override public Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple) { if (requiredType == null) { return rawValue; } final CsvValueAdapter specific = getTypeSpecific(requiredType); if (specific != null) { return specific.fromRaw(rawValue, requiredType, csvImpExColumn, tuple); } if (!MAPPING.containsKey(requiredType)) { return rawValue; } return this.extendedConversionService.convert(rawValue, TypeDescriptor.valueOf(rawValue.getClass()), TypeDescriptor.valueOf(MAPPING.get(requiredType))); }
CsvImportValueAdapter extends AbstractExtensibleValueAdapter<CsvValueAdapter> implements CsvValueAdapter { @Override public Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple) { if (requiredType == null) { return rawValue; } final CsvValueAdapter specific = getTypeSpecific(requiredType); if (specific != null) { return specific.fromRaw(rawValue, requiredType, csvImpExColumn, tuple); } if (!MAPPING.containsKey(requiredType)) { return rawValue; } return this.extendedConversionService.convert(rawValue, TypeDescriptor.valueOf(rawValue.getClass()), TypeDescriptor.valueOf(MAPPING.get(requiredType))); } }
CsvImportValueAdapter extends AbstractExtensibleValueAdapter<CsvValueAdapter> implements CsvValueAdapter { @Override public Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple) { if (requiredType == null) { return rawValue; } final CsvValueAdapter specific = getTypeSpecific(requiredType); if (specific != null) { return specific.fromRaw(rawValue, requiredType, csvImpExColumn, tuple); } if (!MAPPING.containsKey(requiredType)) { return rawValue; } return this.extendedConversionService.convert(rawValue, TypeDescriptor.valueOf(rawValue.getClass()), TypeDescriptor.valueOf(MAPPING.get(requiredType))); } CsvImportValueAdapter(final GenericConversionService extendedConversionService); }
CsvImportValueAdapter extends AbstractExtensibleValueAdapter<CsvValueAdapter> implements CsvValueAdapter { @Override public Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple) { if (requiredType == null) { return rawValue; } final CsvValueAdapter specific = getTypeSpecific(requiredType); if (specific != null) { return specific.fromRaw(rawValue, requiredType, csvImpExColumn, tuple); } if (!MAPPING.containsKey(requiredType)) { return rawValue; } return this.extendedConversionService.convert(rawValue, TypeDescriptor.valueOf(rawValue.getClass()), TypeDescriptor.valueOf(MAPPING.get(requiredType))); } CsvImportValueAdapter(final GenericConversionService extendedConversionService); @Override Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple); }
CsvImportValueAdapter extends AbstractExtensibleValueAdapter<CsvValueAdapter> implements CsvValueAdapter { @Override public Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple) { if (requiredType == null) { return rawValue; } final CsvValueAdapter specific = getTypeSpecific(requiredType); if (specific != null) { return specific.fromRaw(rawValue, requiredType, csvImpExColumn, tuple); } if (!MAPPING.containsKey(requiredType)) { return rawValue; } return this.extendedConversionService.convert(rawValue, TypeDescriptor.valueOf(rawValue.getClass()), TypeDescriptor.valueOf(MAPPING.get(requiredType))); } CsvImportValueAdapter(final GenericConversionService extendedConversionService); @Override Object fromRaw(final Object rawValue, final String requiredType, final CsvImpExColumn csvImpExColumn, final CsvImpExTuple tuple);  }