package com.niomongo.processing;

import com.niomongo.RequestProcessor;

/**
 * Created with IntelliJ IDEA.
 * User: Yevgen Bushuyev
 * Date: 18.02.15.
 */
public class SimpleStep implements Step {
  private Action action;
  private Step nextStep;
  private boolean last;

  public SimpleStep(Action action, Step nextStep) {
    this.action = action;
    this.nextStep = nextStep;
  }

  public SimpleStep(Action action) {
    this.action = action;
  }

  @Override
  public void execute(RequestProcessor requestProcessor) {
    action.execute(requestProcessor);
  }

  @Override
  public Step provideNextStep(RequestProcessor requestProcessor) {
    return nextStep;
  }

  @Override
  public boolean isLast() {
    return nextStep == null;
  }
}
