com.enonic.xp.dump.AbstractLoadResult Maven / Gradle / Ivy
package com.enonic.xp.dump;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
abstract class AbstractLoadResult
{
private final Long successful;
private final List errors;
@SuppressWarnings("unchecked")
AbstractLoadResult( final Builder builder )
{
this.successful = builder.successful;
this.errors = builder.errors;
}
public Long getSuccessful()
{
return successful;
}
public List getErrors()
{
return errors;
}
public static class Builder
{
private Long successful = 0L;
private final List errors = new ArrayList<>();
protected Builder()
{
}
@SuppressWarnings("unchecked")
public B successful( final Long val )
{
successful += val;
return (B) this;
}
@SuppressWarnings("unchecked")
public B errors( final Collection errors )
{
this.errors.addAll( errors );
return (B) this;
}
@SuppressWarnings("unchecked")
public B error( final LoadError error )
{
this.errors.add( error );
return (B) this;
}
@SuppressWarnings("unchecked")
protected T build()
{
return (T) this;
}
}
}