-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Since, apparently, we extend the RecheckOptionsBuilder by RecheckWebOptionsBuilder we need to make sure, that it can handle such. With the current implementation (as of v1.5.0) the usage of the builder is really restricted, such that one first has to set all specific Recheck*Options and then proceed to the common RecheckOptions.
Example from retest/recheck-web#349:
RecheckWebOptions.builder() //
.checkNamingStrategy( new CustomCheckNamingStrategy() ) // returns RecheckWebOptionsBuilder
.fileNamerStrategy( new CustomNamingStrategy() ) // returns RecheckOptionsBuilder
.build()
That means that the builder must use generics such that it returns a self and construct the Recheck*Options accordingly.
Generally that means to have something like an abstract builder:
public abstract class AbstractRecheckOptionsBuilder<SELF extends AbstractRecheckOptionsBuilder<SELF, OPTIONS>, OPTIONS extends RecheckOptions> {
public SELF setOptionX( /* ... */ ) {
// do stuff
return self();
}
protected abstract SELF self();
protected abstract OPTIONS construct( RecheckOptions options );
public OPTIONS build() {
return construct( new RecheckOptions( /* initialize */ ) );
}
}
For RecheckOptions:
public final class RecheckOptionsBuilder extends AbstractRecheckOptionsBuilder<RecheckOptionsBuilder, RecheckOptions> {
@Override
protected RecheckOptionsBuilder self() {
return this;
}
@Override
protected RecheckOptions construct( final RecheckOptions options ) {
return options;
}
}
For RecheckWebOptions:
public final class RecheckWebOptionsBuilder extends AbstractRecheckOptionsBuilder<RecheckWebOptionsBuilder, RecheckWebOptions> {
@Override
protected RecheckWebOptionsBuilder self() {
return this;
}
@Override
protected RecheckWebOptions construct( final RecheckOptions options ) {
return new RecheckWebOptions( options, /* initialize */ );
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request