
com.bazaarvoice.ostrich.healthcheck.DefaultHealthCheckResults Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ostrich-core Show documentation
Show all versions of ostrich-core Show documentation
Core classes that form Ostrich
package com.bazaarvoice.ostrich.healthcheck;
import com.bazaarvoice.ostrich.HealthCheckResult;
import com.bazaarvoice.ostrich.HealthCheckResults;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
public final class DefaultHealthCheckResults implements HealthCheckResults {
private final List _results = Lists.newArrayList();
@Override
public boolean hasHealthyResult() {
return getHealthyResult() != null;
}
@Override
public Iterable getAllResults() {
return Iterables.unmodifiableIterable(_results);
}
@Override
public HealthCheckResult getHealthyResult() {
return Iterables.tryFind(_results, new Predicate() {
@Override
public boolean apply(HealthCheckResult result) {
return result.isHealthy();
}
}).orNull();
}
@Override
public Iterable getUnhealthyResults() {
return Iterables.filter(_results, new Predicate() {
@Override
public boolean apply(HealthCheckResult result) {
return !result.isHealthy();
}
});
}
public void addHealthCheckResult(HealthCheckResult result) {
checkNotNull(result);
_results.add(result);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy