class DefaultCustomPhase<Solution_> extends AbstractPhase<Solution_> implements CustomPhase<Solution_> {

    private final List<CustomPhaseCommand<Solution_>> customPhaseCommandList;

    private DefaultCustomPhase(Builder<Solution_> builder) {
        super(builder);
        customPhaseCommandList = builder.customPhaseCommandList;
    }

    @Override
    public String getPhaseTypeString() {
        return "Custom";
    }

    // ************************************************************************
    // Worker methods
    // ************************************************************************

    @Override
    public void solve(SolverScope<Solution_> solverScope) {
        CustomPhaseScope<Solution_> phaseScope = new CustomPhaseScope<>(solverScope);
        phaseStarted(phaseScope);
        for (CustomPhaseCommand<Solution_> customPhaseCommand : customPhaseCommandList) {
            solverScope.checkYielding();
            if (phaseTermination.isPhaseTerminated(phaseScope)) {
                break;
            }
            CustomStepScope<Solution_> stepScope = new CustomStepScope<>(phaseScope);
            stepStarted(stepScope);
            doStep(stepScope, customPhaseCommand);
            stepEnded(stepScope);
            phaseScope.setLastCompletedStepScope(stepScope);
        }
        phaseEnded(phaseScope);
    }

    private void doStep(CustomStepScope<Solution_> stepScope, CustomPhaseCommand<Solution_> customPhaseCommand) {
        InnerScoreDirector<Solution_, ?> scoreDirector = stepScope.getScoreDirector();
        customPhaseCommand.changeWorkingSolution(scoreDirector);
        calculateWorkingStepScore(stepScope, customPhaseCommand);
        solver.getBestSolutionRecaller().processWorkingSolutionDuringStep(stepScope);
    }

    public void stepEnded(CustomStepScope<Solution_> stepScope) {
        super.stepEnded(stepScope);
        CustomPhaseScope<Solution_> phaseScope = stepScope.getPhaseScope();
        if (logger.isDebugEnabled()) {
            logger.debug("{}    Custom step ({}), time spent ({}), score ({}), {} best score ({}).",
                    logIndentation,
                    stepScope.getStepIndex(),
                    phaseScope.calculateSolverTimeMillisSpentUpToNow(),
                    stepScope.getScore(),
                    stepScope.getBestScoreImproved() ? "new" : "   ",
                    phaseScope.getBestScore());
        }
    }

    public void phaseEnded(CustomPhaseScope<Solution_> phaseScope) {<FILL_FUNCTION_BODY>}

    public static final class Builder<Solution_> extends AbstractPhase.Builder<Solution_> {

        private final List<CustomPhaseCommand<Solution_>> customPhaseCommandList;

        public Builder(int phaseIndex, String logIndentation, Termination<Solution_> phaseTermination,
                List<CustomPhaseCommand<Solution_>> customPhaseCommandList) {
            super(phaseIndex, logIndentation, phaseTermination);
            this.customPhaseCommandList = List.copyOf(customPhaseCommandList);
        }

        @Override
        public DefaultCustomPhase<Solution_> build() {
            return new DefaultCustomPhase<>(this);
        }
    }
}

        super.phaseEnded(phaseScope);
        phaseScope.endingNow();
        logger.info("{}Custom phase ({}) ended: time spent ({}), best score ({}),"
                + " score calculation speed ({}/sec), step total ({}).",
                logIndentation,
                phaseIndex,
                phaseScope.calculateSolverTimeMillisSpentUpToNow(),
                phaseScope.getBestScore(),
                phaseScope.getPhaseScoreCalculationSpeed(),
                phaseScope.getNextStepIndex());
    
<methods>public void addPhaseLifecycleListener(PhaseLifecycleListener<Solution_>) ,public int getPhaseIndex() ,public Termination<Solution_> getPhaseTermination() ,public abstract java.lang.String getPhaseTypeString() ,public AbstractSolver<Solution_> getSolver() ,public boolean isAssertExpectedStepScore() ,public boolean isAssertShadowVariablesAreNotStaleAfterStep() ,public boolean isAssertStepScoreFromScratch() ,public void phaseEnded(AbstractPhaseScope<Solution_>) ,public void phaseStarted(AbstractPhaseScope<Solution_>) ,public void removePhaseLifecycleListener(PhaseLifecycleListener<Solution_>) ,public void setSolver(AbstractSolver<Solution_>) ,public void solvingEnded(SolverScope<Solution_>) ,public void solvingStarted(SolverScope<Solution_>) ,public void stepEnded(AbstractStepScope<Solution_>) ,public void stepStarted(AbstractStepScope<Solution_>) <variables>protected final non-sealed boolean assertExpectedStepScore,protected final non-sealed boolean assertShadowVariablesAreNotStaleAfterStep,protected final non-sealed boolean assertStepScoreFromScratch,protected final non-sealed java.lang.String logIndentation,protected final transient Logger logger,protected final non-sealed int phaseIndex,protected PhaseLifecycleSupport<Solution_> phaseLifecycleSupport,protected final non-sealed Termination<Solution_> phaseTermination,protected AbstractSolver<Solution_> solver