dev.youshallnotpass.inspection.InspectionFailures Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-inspections Show documentation
Show all versions of java-inspections Show documentation
Java inspections library for youshallnotpass
The newest version!
package dev.youshallnotpass.inspection;
import dev.youshallnotpass.inspection.badge.Badge;
import dev.youshallnotpass.plugin.Failures;
import dev.youshallnotpass.plugin.YsnpException;
import dev.youshallnotpass.plugin.Ui;
import java.net.URL;
public final class InspectionFailures implements Failures {
private final Violations nulls;
private final Badge badge;
public InspectionFailures(
final Violations nulls,
final Badge badge
) {
this.nulls = nulls;
this.badge = badge;
}
@Override
public void failIfRed() throws YsnpException {
try {
badge.failIfRed();
} catch (final InspectionException e) {
throw new YsnpException("Inspection failed. ", e);
}
}
@Override
public void show(final Ui ui) throws YsnpException {
try {
for (final T violation : nulls.asList()) {
ui.println(violation.description());
}
} catch (final InspectionException e) {
throw new YsnpException("Could not show the violations.", e);
}
}
@Override
public void publish(final URL url) throws YsnpException {
try {
badge.send(url);
} catch (final InspectionException e) {
throw new YsnpException(
"Could not publish the violations.",
e
);
}
}
}