-
Notifications
You must be signed in to change notification settings - Fork 0
/
PropertyRecordsBuilder.ts
96 lines (84 loc) · 2.83 KB
/
PropertyRecordsBuilder.ts
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/**
* @packageDocumentation
* @module Properties
*/
import { PropertyRecord } from "@itwin/appui-abstract";
import {
IContentVisitor,
ProcessFieldHierarchiesProps,
ProcessMergedValueProps,
ProcessPrimitiveValueProps,
StartArrayProps,
StartCategoryProps,
StartContentProps,
StartFieldProps,
StartItemProps,
StartStructProps,
} from "@itwin/presentation-common";
import { FieldHierarchyRecord, InternalPropertyRecordsBuilder } from "./ContentBuilder";
/**
* A `Content` visitor that traverses all content, creates a `PropertyRecord` for each property
* and streams them into the given callback function.
*
* @public
*/
export class PropertyRecordsBuilder implements IContentVisitor {
private _internal: InternalPropertyRecordsBuilder;
public constructor(visitPropertyRecord: (record: PropertyRecord) => void) {
this._internal = new InternalPropertyRecordsBuilder((item) => ({
item,
append(entry: FieldHierarchyRecord) {
visitPropertyRecord(entry.record);
},
}));
}
public startContent(props: StartContentProps): boolean {
return this._internal.startContent(props);
}
public finishContent(): void {
return this._internal.finishContent();
}
public startItem(props: StartItemProps): boolean {
return this._internal.startItem(props);
}
public finishItem(): void {
return this._internal.finishItem();
}
public processFieldHierarchies(props: ProcessFieldHierarchiesProps): void {
return this._internal.processFieldHierarchies(props);
}
public startCategory(props: StartCategoryProps): boolean {
return this._internal.startCategory(props);
}
public finishCategory(): void {
return this._internal.finishCategory();
}
public startField(props: StartFieldProps): boolean {
return this._internal.startField(props);
}
public finishField(): void {
return this._internal.finishField();
}
public startStruct(props: StartStructProps): boolean {
return this._internal.startStruct(props);
}
public finishStruct(): void {
return this._internal.finishStruct();
}
public startArray(props: StartArrayProps): boolean {
return this._internal.startArray(props);
}
public finishArray(): void {
return this._internal.finishArray();
}
public processMergedValue(props: ProcessMergedValueProps): void {
return this._internal.processMergedValue(props);
}
public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {
return this._internal.processPrimitiveValue(props);
}
}