org.javers.core.metamodel.scanner.ScannerModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-core Show documentation
Show all versions of javers-core Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.core.metamodel.scanner;
import org.javers.common.collections.Lists;
import org.javers.core.JaversBuilder;
import org.javers.core.JaversCoreConfiguration;
import org.javers.core.MappingStyle;
import org.javers.core.pico.LateInstantiatingModule;
import org.picocontainer.MutablePicoContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
/**
* @author bartosz.walacik
*/
public class ScannerModule extends LateInstantiatingModule {
private static final Logger logger = JaversBuilder.logger;
public ScannerModule(JaversCoreConfiguration configuration, MutablePicoContainer container) {
super(configuration, container);
}
@Override
protected Collection getImplementations() {
MappingStyle mappingStyle = getConfiguration().getMappingStyle();
logger.info("mappingStyle: "+mappingStyle.name());
Class usedPropertyScanner;
if (mappingStyle == MappingStyle.BEAN){
usedPropertyScanner = BeanBasedPropertyScanner.class;
} else if (mappingStyle == MappingStyle.FIELD){
usedPropertyScanner = FieldBasedPropertyScanner.class;
} else{
throw new RuntimeException("not implementation for "+mappingStyle);
}
return (Collection) Lists.asList(
ClassScanner.class,
ClassAnnotationsScanner.class,
AnnotationNamesProvider.class,
usedPropertyScanner
);
}
}