@SuppressWarnings("unchecked") public <T> TypeInformation<? extends T> readType(S source, TypeInformation<T> basicType) { Assert.notNull(source); Class<?> documentsTargetType = getDefaultedTypeToBeUsed(source); if (documentsTargetType == null) { return basicType; } Class<T> rawType = basicType == null ? null : basicType.getType(); boolean isMoreConcreteCustomType = rawType == null ? true : rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType); return isMoreConcreteCustomType ? (TypeInformation<? extends T>) ClassTypeInformation.from(documentsTargetType) : basicType; }
/** * Returns the type discovered through {@link #readType(Object)} but defaulted to the one returned by * {@link #getFallbackTypeFor(Object)}. * * @param source * @return */ private Class<?> getDefaultedTypeToBeUsed(S source) { TypeInformation<?> documentsTargetTypeInformation = readType(source); documentsTargetTypeInformation = documentsTargetTypeInformation == null ? getFallbackTypeFor(source) : documentsTargetTypeInformation; return documentsTargetTypeInformation == null ? null : documentsTargetTypeInformation.getType(); }
public void writeType(Class<?> type, S dbObject) { writeType(ClassTypeInformation.from(type), dbObject); }
/** * Creates a new {@link MappingAerospikeConverter}. */ public MappingAerospikeConverter(AerospikeMappingContext mappingContext, CustomConversions conversions, AerospikeTypeAliasAccessor aerospikeTypeAliasAccessor) { this.conversions = conversions; this.conversionService = new DefaultConversionService(); EntityInstantiators entityInstantiators = new EntityInstantiators(); TypeMapper<Map<String, Object>> typeMapper = new DefaultTypeMapper<>(aerospikeTypeAliasAccessor, mappingContext, asList(new SimpleTypeInformationMapper())); this.writeConverter = new MappingAerospikeWriteConverter(typeMapper, mappingContext, conversions, conversionService); this.readConverter = new MappingAerospikeReadConverter(entityInstantiators, typeMapper, mappingContext, conversions, conversionService); }
@Nullable public TypeInformation<?> readType(S source) { Assert.notNull(source, "Source object must not be null!"); return getFromCacheOrCreate(accessor.readAliasFrom(source)); }
public void writeType(TypeInformation<?> info, S sink) { Assert.notNull(info, "TypeInformation must not be null!"); Alias alias = getAliasFor(info); if (alias.isPresent()) { accessor.writeTypeTo(sink, alias.getValue()); } }
public MappingTarantoolConverter(TarantoolMappingContext tarantoolMappingContext) { this.mappingContext = tarantoolMappingContext; this.conversionService = new TarantoolDefaultConversionService(); this.customConversions = new CustomConversions(); this.entityInstantiators = new EntityInstantiators(); this.typeMapper = new DefaultTypeMapper<>(new TarantoolTypeAliasAccessor(conversionService)); }
/** * Returns the type discovered through {@link #readType(Object)} but defaulted to the one returned by * {@link #getFallbackTypeFor(Object)}. * * @param source * @return */ @Nullable private Class<?> getDefaultedTypeToBeUsed(S source) { TypeInformation<?> documentsTargetTypeInformation = readType(source); documentsTargetTypeInformation = documentsTargetTypeInformation == null ? getFallbackTypeFor(source) : documentsTargetTypeInformation; return documentsTargetTypeInformation == null ? null : documentsTargetTypeInformation.getType(); }
public <T> TypeInformation<? extends T> readType(S source, TypeInformation<T> basicType) { Assert.notNull(source, "Source must not be null!"); Assert.notNull(basicType, "Basic type must not be null!"); Class<?> documentsTargetType = getDefaultedTypeToBeUsed(source); if (documentsTargetType == null) { return basicType; } Class<T> rawType = basicType.getType(); boolean isMoreConcreteCustomType = rawType == null || rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType); if (!isMoreConcreteCustomType) { return basicType; } ClassTypeInformation<?> targetType = ClassTypeInformation.from(documentsTargetType); return (TypeInformation<? extends T>) basicType.specialize(targetType); }
public void writeType(Class<?> type, S dbObject) { writeType(ClassTypeInformation.from(type), dbObject); }