com.hltech.pact.gen.domain.client.jaxrs.JaxRsClientsFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pact-gen Show documentation
Show all versions of pact-gen Show documentation
Automated generation of pact files
The newest version!
package com.hltech.pact.gen.domain.client.jaxrs;
import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
import javax.ws.rs.Path;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
public class JaxRsClientsFinder {
public Set> findJaxRsClients(String packageRoot) {
Set> jaxRsClients = new HashSet<>();
jaxRsClients.addAll(classAnnotatedClients(packageRoot));
jaxRsClients.addAll(methodAnnotatedClients(packageRoot));
return jaxRsClients;
}
private Set> classAnnotatedClients(String packageRoot) {
return new Reflections(packageRoot)
.getTypesAnnotatedWith(Path.class);
}
private Set> methodAnnotatedClients(String packageRoot) {
return new Reflections(packageRoot, new MethodAnnotationsScanner())
.getMethodsAnnotatedWith(Path.class).stream()
.map(Method::getDeclaringClass)
.collect(Collectors.toSet());
}
}