-
Notifications
You must be signed in to change notification settings - Fork 24
/
Pkg.Json.Lists.pas
53 lines (41 loc) · 1.01 KB
/
Pkg.Json.Lists.pas
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
unit Pkg.Json.Lists;
interface
uses
System.SysUtils, System.Generics.Defaults, System.Generics.Collections,
Pkg.Json.JSONName;
type
TJsonNameList<T: TJsonName> = class abstract(TObjectList<T>)
strict protected
constructor Create(AOwnsObjects: Boolean); reintroduce; overload;
public
constructor Create; reintroduce; overload;
function ItemByName(aJsonName: string): T;
end;
TJsonNameObjectList<T: TJsonName> = class abstract(TJsonNameList<T>)
public
constructor Create; reintroduce;
end;
implementation
constructor TJsonNameList<T>.Create;
begin
inherited Create(false);
end;
constructor TJsonNameList<T>.Create(AOwnsObjects: Boolean);
begin
inherited;
end;
function TJsonNameList<T>.ItemByName(aJsonName: string): T;
var
JSONName: TJsonName;
begin
for JSONName in Self do
if SameText(JSONName.JSONName, aJsonName) then
exit(JSONName as T);
Result := nil;
end;
{ TJsonNameObjectList<T> }
constructor TJsonNameObjectList<T>.Create;
begin
inherited Create(True);
end;
end.