@Test public void testConvertTypeFromShort() throws AtlasConversionException { assertEquals(BigInteger.valueOf(1), service.convertType((short)1, FieldType.SHORT, FieldType.BIG_INTEGER)); assertEquals(true, service.convertType((short)1, FieldType.SHORT, FieldType.BOOLEAN)); assertEquals((byte)0x01, service.convertType((short)1, FieldType.SHORT, FieldType.BYTE)); assertEquals((char)1, service.convertType((short)1, FieldType.SHORT, FieldType.CHAR)); assertEquals(LocalDate.class, service.convertType((short)1, FieldType.SHORT, FieldType.DATE).getClass()); assertEquals(Date.class, service.convertType((short)1, FieldType.SHORT, FieldType.DATE_TIME).getClass()); assertEquals(ZonedDateTime.class, service.convertType((short)1, FieldType.SHORT, FieldType.DATE_TZ).getClass()); assertEquals(ZonedDateTime.class, service.convertType((short)1, FieldType.SHORT, FieldType.TIME_TZ).getClass()); assertEquals(ZonedDateTime.class, service.convertType((short)1, FieldType.SHORT, FieldType.DATE_TIME_TZ).getClass()); assertEquals(BigDecimal.valueOf(1), service.convertType((short)1, FieldType.SHORT, FieldType.DECIMAL)); assertEquals(1.0d, service.convertType((short)1, FieldType.SHORT, FieldType.DOUBLE)); assertEquals(1.0f, service.convertType((short)1, FieldType.SHORT, FieldType.FLOAT)); assertEquals(1, service.convertType((short)1, FieldType.SHORT, FieldType.INTEGER)); assertEquals(1L, service.convertType((short)1, FieldType.SHORT, FieldType.LONG)); assertEquals((short)1, service.convertType((short)1, FieldType.SHORT, FieldType.NUMBER)); assertEquals((short)1, service.convertType((short)1, FieldType.SHORT, FieldType.SHORT)); assertEquals("1", service.convertType((short)1, FieldType.SHORT, FieldType.STRING)); assertEquals(LocalTime.class, service.convertType((short)1, FieldType.SHORT, FieldType.TIME).getClass()); }
@Override public Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType) throws AtlasConversionException { if (origSourceType == null || targetType == null) { throw new AtlasConversionException("FieldTypes must be specified on convertType method."); } if (isAssignableFieldType(origSourceType, targetType)) { return sourceValue; } return convertType(sourceValue, null, classFromFieldType(targetType), null); }
DefaultAtlasConversionService implements AtlasConversionService { @Override public Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType) throws AtlasConversionException { if (origSourceType == null || targetType == null) { throw new AtlasConversionException("FieldTypes must be specified on convertType method."); } if (isAssignableFieldType(origSourceType, targetType)) { return sourceValue; } return convertType(sourceValue, null, classFromFieldType(targetType), null); } }
DefaultAtlasConversionService implements AtlasConversionService { @Override public Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType) throws AtlasConversionException { if (origSourceType == null || targetType == null) { throw new AtlasConversionException("FieldTypes must be specified on convertType method."); } if (isAssignableFieldType(origSourceType, targetType)) { return sourceValue; } return convertType(sourceValue, null, classFromFieldType(targetType), null); } private  DefaultAtlasConversionService(); }
DefaultAtlasConversionService implements AtlasConversionService { @Override public Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType) throws AtlasConversionException { if (origSourceType == null || targetType == null) { throw new AtlasConversionException("FieldTypes must be specified on convertType method."); } if (isAssignableFieldType(origSourceType, targetType)) { return sourceValue; } return convertType(sourceValue, null, classFromFieldType(targetType), null); } private  DefaultAtlasConversionService(); static DefaultAtlasConversionService getInstance(); static Set<String> listPrimitiveClassNames(); @Override Optional<AtlasConverter<?>> findMatchingConverter(FieldType source, FieldType target); @Override Optional<AtlasConverter<?>> findMatchingConverter(String sourceClassName, String targetClassName); @Override Object copyPrimitive(Object sourceValue); @Override Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType); @Override Object convertType(Object sourceValue, String sourceFormat, FieldType targetType, String targetFormat); @Override Object convertType(Object sourceValue, String sourceFormat, Class<?> targetType, String targetFormat); @Override boolean isConvertionAvailableFor(Object sourceValue, Class<?> targetType); @Override Boolean isPrimitive(String className); @Override Boolean isPrimitive(Class<?> clazz); @Override Boolean isPrimitive(FieldType fieldType); @Override Boolean isBoxedPrimitive(Class<?> clazz); @Override Class<?> boxOrUnboxPrimitive(String clazzName); @Override Class<?> boxOrUnboxPrimitive(Class<?> clazz); @Override FieldType fieldTypeFromClass(Class<?> clazz); @Override FieldType fieldTypeFromClass(String className); @Override Class<?> classFromFieldType(FieldType fieldType); @Override Boolean isAssignableFieldType(FieldType source, FieldType target); }
DefaultAtlasConversionService implements AtlasConversionService { @Override public Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType) throws AtlasConversionException { if (origSourceType == null || targetType == null) { throw new AtlasConversionException("FieldTypes must be specified on convertType method."); } if (isAssignableFieldType(origSourceType, targetType)) { return sourceValue; } return convertType(sourceValue, null, classFromFieldType(targetType), null); } private  DefaultAtlasConversionService(); static DefaultAtlasConversionService getInstance(); static Set<String> listPrimitiveClassNames(); @Override Optional<AtlasConverter<?>> findMatchingConverter(FieldType source, FieldType target); @Override Optional<AtlasConverter<?>> findMatchingConverter(String sourceClassName, String targetClassName); @Override Object copyPrimitive(Object sourceValue); @Override Object convertType(Object sourceValue, FieldType origSourceType, FieldType targetType); @Override Object convertType(Object sourceValue, String sourceFormat, FieldType targetType, String targetFormat); @Override Object convertType(Object sourceValue, String sourceFormat, Class<?> targetType, String targetFormat); @Override boolean isConvertionAvailableFor(Object sourceValue, Class<?> targetType); @Override Boolean isPrimitive(String className); @Override Boolean isPrimitive(Class<?> clazz); @Override Boolean isPrimitive(FieldType fieldType); @Override Boolean isBoxedPrimitive(Class<?> clazz); @Override Class<?> boxOrUnboxPrimitive(String clazzName); @Override Class<?> boxOrUnboxPrimitive(Class<?> clazz); @Override FieldType fieldTypeFromClass(Class<?> clazz); @Override FieldType fieldTypeFromClass(String className); @Override Class<?> classFromFieldType(FieldType fieldType); @Override Boolean isAssignableFieldType(FieldType source, FieldType target);  }