aboutsummaryrefslogtreecommitdiff
path: root/src/content/operators/impls/FindOperatorFactoryChain.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/operators/impls/FindOperatorFactoryChain.ts')
-rw-r--r--src/content/operators/impls/FindOperatorFactoryChain.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/content/operators/impls/FindOperatorFactoryChain.ts b/src/content/operators/impls/FindOperatorFactoryChain.ts
new file mode 100644
index 0000000..ef1c754
--- /dev/null
+++ b/src/content/operators/impls/FindOperatorFactoryChain.ts
@@ -0,0 +1,32 @@
+import { inject, injectable } from "tsyringe";
+import Operator from "../Operator";
+import OperatorFactoryChain from "../OperatorFactoryChain";
+import RepeatOperator from "./RepeatOperator";
+import FindNextOperator from "./FindNextOperator";
+import FindPrevOperator from "./FindPrevOperator";
+import FindMasterClient from "../../client/FindMasterClient";
+import * as operations from "../../../shared/operations";
+
+@injectable()
+export default class FindOperatorFactoryChain implements OperatorFactoryChain {
+ constructor(
+ @inject("FindMasterClient")
+ private readonly findMasterClient: FindMasterClient
+ ) {}
+
+ create(op: operations.Operation, repeat: number): Operator | null {
+ switch (op.type) {
+ case operations.FIND_NEXT:
+ return new RepeatOperator(
+ new FindNextOperator(this.findMasterClient),
+ repeat
+ );
+ case operations.FIND_PREV:
+ return new RepeatOperator(
+ new FindPrevOperator(this.findMasterClient),
+ repeat
+ );
+ }
+ return null;
+ }
+}