File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
tests/pyreverse/functional/class_diagrams/associations Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1
1
classDiagram
2
+ class AggregationContainer {
3
+ component_dict : dict[str, Component]
4
+ components : list[Component]
5
+ components_set : set[Component]
6
+ lazy_components : Generator[Component]
7
+ }
2
8
class AssociationContainer {
3
9
component_dict : dict[int, Component]
4
10
components : list[Component]
@@ -22,3 +28,7 @@ classDiagram
22
28
Component --* CompositionContainer : component_dict
23
29
Component --* CompositionContainer : components_set
24
30
Component --* CompositionContainer : lazy_components
31
+ Component --o AggregationContainer : components
32
+ Component --o AggregationContainer : component_dict
33
+ Component --o AggregationContainer : components_set
34
+ Component --o AggregationContainer : lazy_components
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ def __init__(self):
17
17
self .components_set : set [Component ]
18
18
self .lazy_components : Generator [Component ]
19
19
20
+ class AggregationContainer :
21
+ """Comprehensions using existing objects - aggregation."""
22
+ def __init__ (self , existing_components : list [Component ]):
23
+ # Aggregation: comprehensions using existing objects (not creating)
24
+ self .components : list [Component ] = [comp for comp in existing_components ]
25
+ self .component_dict : dict [str , Component ] = {f"key_{ i } " : comp for i , comp in enumerate (existing_components )}
26
+ self .components_set : set [Component ] = {comp for comp in existing_components }
27
+ self .lazy_components : Generator [Component ] = (comp for comp in existing_components )
28
+
20
29
class CompositionContainer :
21
30
"""Comprehensions creating new objects - composition."""
22
31
def __init__ (self ):
You can’t perform that action at this time.
0 commit comments