io.redskap.swagger.brake.maven.jar.JarScanner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-brake Show documentation
Show all versions of swagger-brake Show documentation
Swagger contract checker for breaking API changes
package io.redskap.swagger.brake.maven.jar;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.apache.commons.collections4.EnumerationUtils;
import org.springframework.stereotype.Component;
@Component
public class JarScanner {
public Optional find(File jarFile, Predicate criteria) throws IOException {
Optional result = Optional.empty();
try (JarFile jar = new JarFile(jarFile)) {
List jarEntries = EnumerationUtils.toList(jar.entries());
for (JarEntry entry : jarEntries) {
if (criteria.test(entry)) {
result = Optional.of(entry);
}
}
}
return result;
}
}