aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/MarkOperatorFactoryChain.ts
blob: 7e6c51312d7a5787e5ab5e48190261df1251f8c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { inject, injectable } from "tsyringe";
import EnableSetMarkOperator from "./EnableSetMarkOperator";
import EnableJumpMarkOperator from "./EnableJumpMarkOperator";
import Operator from "../Operator";
import OperatorFactoryChain from "../OperatorFactoryChain";
import MarkKeyRepository from "../../repositories/MarkKeyRepository";
import * as operations from "../../../shared/operations";

@injectable()
export default class MarkOperatorFactoryChain implements OperatorFactoryChain {
  constructor(
    @inject("MarkKeyRepository")
    private readonly markKeyRepository: MarkKeyRepository
  ) {}

  create(op: operations.Operation, _repeat: number): Operator | null {
    switch (op.type) {
      case operations.MARK_SET_PREFIX:
        return new EnableSetMarkOperator(this.markKeyRepository);
      case operations.MARK_JUMP_PREFIX:
        return new EnableJumpMarkOperator(this.markKeyRepository);
    }
    return null;
  }
}