for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
package com.hltech.pact.gen.domain.client.annotation;
import com.google.common.collect.Lists;
import com.hltech.pact.gen.domain.client.annotation.handlers.AnnotatedMethodHandler;
import io.github.classgraph.ClassGraph;
import java.util.List;
public class MappingHandlerFactory {
private static final String PACKAGE = "com.hltech.pact.gen";
public List<AnnotatedMethodHandler> createAll() {
try {
return createHandlers(findClasses());
} catch (IllegalAccessException | InstantiationException exception) {
throw new MappingMethodCreationException("Cannot create mapping handler", exception);
}
private List<Class<?>> findClasses() {
return new ClassGraph()
.whitelistPackages(PACKAGE)
.enableAnnotationInfo()
.scan()
.getClassesWithAnnotation(MappingMethodHandler.class.getName())
.loadClasses();
private List<AnnotatedMethodHandler> createHandlers(List<Class<?>> classes)
throws IllegalAccessException, InstantiationException {
List<AnnotatedMethodHandler> result = Lists.newArrayList();
for (Class<?> handlerClass : classes) {
result.add((AnnotatedMethodHandler) handlerClass.newInstance());
return result;