1111package org .springframework .ide .vscode .boot .java .commands ;
1212
1313import java .util .Map ;
14+ import java .util .Optional ;
15+ import java .util .Set ;
16+
17+ import org .jmolecules .stereotype .api .Stereotype ;
1418
1519public class StereotypeIcons {
1620
17- public static final Map <String , String > ICONS = Map .ofEntries (
21+ public static final String APPLICATION_KEY = "Application" ;
22+ public static final String PACKAGES_KEY = "Packages" ;
23+ public static final String METHOD_KEY = "Method" ;
24+ public static final String TYPE_KEY = "Type" ;
25+
26+ private static final Map <String , String > ICONS = Map .ofEntries (
27+
1828 Map .entry ("architecture.hexagonal" , "debug-breakpoint-data-unverified" ),
1929 Map .entry ("architecture.hexagonal.Port" , "symbol-interface" ),
2030 Map .entry ("architecture.hexagonal.Adapter" , "debug-disconnect" ),
2131 Map .entry ("architecture.hexagonal.Application" , "circuit-board" ),
32+
2233 Map .entry ("architecture.layered" , "layers" ),
34+
2335 Map .entry ("architecture.onion" , "target" ),
2436 Map .entry ("architecture.onion.Application" , "circuit-board" ),
2537// Map.entry("architecture.onion.Domain", "?"), // TODO
2638 Map .entry ("architecture.onion.Infrastructure" , "debug-disconnect" ),
39+
2740 Map .entry ("ddd.AggregateRoot" , "symbol-class" ),
2841 Map .entry ("ddd.Association" , "link" ),
2942 Map .entry ("ddd.Entity" , "symbol-field" ),
3043 Map .entry ("ddd.Identifier" , "lightbulb" ),
3144 Map .entry ("ddd.Repository" , "database" ),
3245// Map.entry("ddd.Service", "?"), // TODO
3346 Map .entry ("ddd.ValueObject" , "symbol-value" ),
34- Map .entry ("event.DomainEvent" , "bell" ),
35- Map .entry ("event.DomainEventHandler" , "callhierarchy-incoming" ),
3647
37- Map .entry ("org.jmolecules.architecture.hexagonal" , "debug-breakpoint-data-unverified" ),
38- Map .entry ("org.jmolecules.architecture.hexagonal.Port" , "symbol-interface" ),
39- Map .entry ("org.jmolecules.architecture.hexagonal.Adapter" , "debug-disconnect" ),
40- Map .entry ("org.jmolecules.architecture.hexagonal.Application" , "circuit-board" ),
41- Map .entry ("org.jmolecules.architecture.layered" , "layers" ),
42- Map .entry ("org.jmolecules.architecture.onion" , "target" ),
43- Map .entry ("org.jmolecules.architecture.onion.Application" , "circuit-board" ),
44- // Map.entry("org.jmolecules.architecture.onion.Domain", "?"), // TODO
45- Map .entry ("org.jmolecules.architecture.onion.Infrastructure" , "debug-disconnect" ),
46- Map .entry ("org.jmolecules.ddd.AggregateRoot" , "symbol-class" ),
47- Map .entry ("org.jmolecules.ddd.Association" , "link" ),
48- Map .entry ("org.jmolecules.ddd.Entity" , "symbol-field" ),
49- Map .entry ("org.jmolecules.ddd.Identifier" , "lightbulb" ),
50- Map .entry ("org.jmolecules.ddd.Repository" , "database" ),
51- // Map.entry("org.jmolecules.ddd.Service", "?"), // TODO
52- Map .entry ("org.jmolecules.ddd.ValueObject" , "symbol-value" ),
53- Map .entry ("org.jmolecules.event.DomainEvent" , "bell" ),
54- Map .entry ("org.jmolecules.event.DomainEventHandler" , "callhierarchy-incoming" ),
48+ Map .entry ("events.DomainEvent" , "bell" ),
49+ Map .entry ("events.DomainEventHandler" , "callhierarchy-incoming" ),
5550
5651 Map .entry ("jackson" , "bracket" ),
5752 Map .entry ("java.Exception" , "zap" ),
53+
5854 Map .entry ("jpa" , "database" ),
55+
5956 Map .entry ("spring.Configuration" , "gear" ),
57+ Map .entry ("spring.Validator" , "verified" ),
58+ Map .entry ("spring.Formatter" , "text-size" ),
6059 Map .entry ("spring.MessageListener" , "callhierarchy-incoming" ),
60+ Map .entry ("spring.aot" , "file-binary" ),
6161 Map .entry ("spring.boot" , "coffee" ),
6262 Map .entry ("spring.boot.ConfigurationProperties" , "symbol-property" ),
6363 Map .entry ("spring.data" , "database" ),
@@ -66,13 +66,56 @@ public class StereotypeIcons {
6666 Map .entry ("spring.EventListener" , "callhierarchy-incoming" ),
6767 Map .entry ("spring.web" , "globe" ),
6868 Map .entry ("spring.web.rest.hypermedia" , "link" ),
69- Map .entry ("Application" , "project" ),
69+
70+ Map .entry (APPLICATION_KEY , "project" ),
7071 Map .entry ("Module" , "library" ),
71- Map .entry ("Packages" , "package" ),
72- Map .entry ("Method" , "symbol-method" ),
73- Map .entry ("Type" , "symbol-class" ),
72+ Map .entry (PACKAGES_KEY , "package" ),
73+ Map .entry (METHOD_KEY , "symbol-method" ),
74+ Map .entry (TYPE_KEY , "symbol-class" ),
75+
7476 Map .entry ("Stereotype" , "record" )
7577 );
78+
79+ private static final Map <String , String > ICONS_ENDS_WITH = Map .ofEntries (
80+ Map .entry ("Port" , "symbol-interface" ),
81+ Map .entry ("Repository" , "database" ),
82+ Map .entry ("Adapter" , "debug-disconnect" )
83+ );
84+
85+ public static String getIcon (Stereotype stereotype ) {
86+ String stereotypeID = stereotype .getIdentifier ();
87+
88+ // exact icon
89+ String icon = StereotypeIcons .ICONS .get (stereotypeID );
90+
91+ // endsWith fallback
92+ if (icon == null ) {
93+ Set <String > keySet = ICONS_ENDS_WITH .keySet ();
94+ for (String key : keySet ) {
95+ if (stereotypeID .endsWith (key )) {
96+ icon = ICONS_ENDS_WITH .get (key );
97+ }
98+ }
99+ }
100+
101+ // group fallback
102+ if (icon == null ) {
103+ Optional <String > groupIcon = stereotype .getGroups ().stream ()
104+ .filter (group -> StereotypeIcons .ICONS .containsKey (group ))
105+ .map (group -> StereotypeIcons .ICONS .get (group ))
106+ .findFirst ();
107+
108+ if (groupIcon .isPresent ()) {
109+ icon = groupIcon .get ();
110+ }
111+ }
112+
113+ return icon != null ? icon : StereotypeIcons .ICONS .get ("Stereotype" );
114+ }
115+
116+ public static String getIcon (String key ) {
117+ return ICONS .get (key );
118+ }
76119
77120
78121}
0 commit comments