com.enonic.xp.cluster.ClusterValidatorResult Maven / Gradle / Ivy
The newest version!
package com.enonic.xp.cluster;
import java.util.ArrayList;
import java.util.List;
public class ClusterValidatorResult
{
private final List errors;
private final List warnings;
private ClusterValidatorResult( final Builder builder )
{
errors = builder.errors;
warnings = builder.warnings;
}
public ClusterValidationStatus getStatus()
{
if (!errors.isEmpty()) {
return ClusterValidationStatus.RED;
}
if (!warnings.isEmpty()) {
return ClusterValidationStatus.YELLOW;
}
return ClusterValidationStatus.GREEN;
}
public List getErrors()
{
return errors;
}
public List getWarnings()
{
return warnings;
}
public static Builder create()
{
return new Builder();
}
public static ClusterValidatorResult ok()
{
return create().build();
}
public static final class Builder
{
private List errors = new ArrayList<>();
private List warnings = new ArrayList<>();
private Builder()
{
}
public Builder errors( final List errors )
{
this.errors = errors;
return this;
}
public Builder error( final ClusterValidationError error )
{
this.errors.add( error );
return this;
}
public Builder warnings( final List warnings )
{
this.warnings = warnings;
return this;
}
public Builder warning( final ClusterValidationWarning warning )
{
this.warnings.add( warning );
return this;
}
public ClusterValidatorResult build()
{
return new ClusterValidatorResult( this );
}
}
}