1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | class AbstractObjectDefinitionInspector {
|
4 | constructor() {
|
5 | this.relevantClasses = [];
|
6 | this.namePatterns = [];
|
7 | this.inspectAll = false;
|
8 | }
|
9 | addInterestedClass(clazz) {
|
10 | this.relevantClasses.push(clazz);
|
11 | }
|
12 | addNamePattern(nameOrRegex) {
|
13 | this.namePatterns.push(nameOrRegex);
|
14 | }
|
15 | inspect(objectDefinition) {
|
16 | if (this.interestedIn(objectDefinition)) {
|
17 | return this.doInspect(objectDefinition);
|
18 | }
|
19 | return null;
|
20 | }
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 | interestedIn(objectDefinition) {
|
27 | if (this.inspectAll) {
|
28 | return true;
|
29 | }
|
30 | const relevantClass = this.relevantClasses.find((clazz) => objectDefinition.getProducedClass() === clazz);
|
31 | if (relevantClass) {
|
32 | return true;
|
33 | }
|
34 | const relevantPattern = this.namePatterns.find((nameOrPattern) => {
|
35 | if (nameOrPattern instanceof RegExp) {
|
36 | if (nameOrPattern.test(objectDefinition.getName())) {
|
37 | return true;
|
38 | }
|
39 | }
|
40 | else if (nameOrPattern === objectDefinition.getName()) {
|
41 | return true;
|
42 | }
|
43 | return false;
|
44 | });
|
45 | if (relevantPattern) {
|
46 | return true;
|
47 | }
|
48 | return false;
|
49 | }
|
50 | setInspectAll(inspectAll) {
|
51 | this.inspectAll = inspectAll;
|
52 | }
|
53 | }
|
54 | exports.AbstractObjectDefinitionInspector = AbstractObjectDefinitionInspector;
|
55 |
|
\ | No newline at end of file |