StringToDataSizeConverter Class — spring-boot Architecture
Architecture documentation for the StringToDataSizeConverter class in StringToDataSizeConverter.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/main/java/org/springframework/boot/convert/StringToDataSizeConverter.java lines 38–62
final class StringToDataSizeConverter implements GenericConverter {
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(String.class, DataSize.class));
}
@Override
public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (ObjectUtils.isEmpty(source)) {
return null;
}
return convert(source.toString(), getDataUnit(targetType));
}
private @Nullable DataUnit getDataUnit(TypeDescriptor targetType) {
DataSizeUnit annotation = targetType.getAnnotation(DataSizeUnit.class);
return (annotation != null) ? annotation.value() : null;
}
private DataSize convert(String source, @Nullable DataUnit unit) {
return DataSize.parse(source, unit);
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free