fr.fezlight.eventsystem.converters.ClassConverters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-event-system-mongodb Show documentation
Show all versions of spring-boot-starter-event-system-mongodb Show documentation
This module is the MongoDB implementation for event system based on Spring Modulith MongoDB.
The newest version!
package fr.fezlight.eventsystem.converters;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.data.convert.WritingConverter;
/**
* Class used to convert {@link Class} object into MongoDB.
*
* @author FezLight
*/
public class ClassConverters {
@ReadingConverter
public static class ClassReadConverter implements Converter> {
@Override
public Class> convert(String source) {
try {
return Class.forName(source);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}
@WritingConverter
public static class ClassWriteConverter implements Converter, String> {
@Override
public String convert(Class> source) {
return source.getName();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy