1- package it .aboutbits .springboot .toolbox .boot . type ;
1+ package it .aboutbits .springboot .toolbox .autoconfiguration . web ;
22
33import it .aboutbits .springboot .toolbox .reflection .util .ClassScannerUtil ;
44import it .aboutbits .springboot .toolbox .type .CustomType ;
5- import jakarta . annotation . PostConstruct ;
5+ import lombok . Getter ;
66import lombok .extern .slf4j .Slf4j ;
77
88import java .util .ArrayList ;
99import java .util .Arrays ;
10+ import java .util .HashSet ;
1011import java .util .Set ;
1112import java .util .stream .Collectors ;
1213
1314@ Slf4j
15+ @ Getter
1416public class CustomTypeScanner {
15- public static final String LIBRARY_BASE_PACKAGE_NAME = "it.aboutbits.springboot.toolbox" ;
17+ private static final String LIBRARY_BASE_PACKAGE_NAME = "it.aboutbits.springboot.toolbox" ;
1618
17- private String [] packageNamesToScan ;
18- private ClassScannerUtil . ClassScanner classScanner ;
19+ @ SuppressWarnings ( "rawtypes" )
20+ private Set < Class <? extends CustomType >> relevantTypes = new HashSet <>() ;
1921
2022 public void setAdditionalTypePackages (String [] additionalTypePackages ) {
2123 var tmp = new ArrayList <String >();
@@ -24,20 +26,18 @@ public void setAdditionalTypePackages(String[] additionalTypePackages) {
2426 .filter (item -> !item .isBlank ())
2527 .collect (Collectors .toSet ()));
2628
27- this .packageNamesToScan = tmp .toArray (new String [0 ]);
28-
29- classScanner = ClassScannerUtil .getScannerForPackages (packageNamesToScan );
30- }
29+ var packageNamesToScan = tmp .toArray (new String [0 ]);
3130
32- @ PostConstruct
33- public void init () {
3431 log .info ("CustomTypeConfiguration enabled. Scanning: {}" , Arrays .toString (packageNamesToScan ));
32+ var classScanner = ClassScannerUtil .getScannerForPackages (packageNamesToScan );
33+
34+ this .relevantTypes = findAllCustomTypeRecords (classScanner );
3535 }
3636
3737 @ SuppressWarnings ("rawtypes" )
38- public Set <Class <? extends CustomType >> findAllCustomTypeRecords () {
38+ public static Set <Class <? extends CustomType >> findAllCustomTypeRecords (ClassScannerUtil . ClassScanner classScanner ) {
3939 return classScanner .getSubTypesOf (CustomType .class ).stream ()
4040 .filter (Record .class ::isAssignableFrom )
41- .collect (Collectors .toSet ());
41+ .collect (Collectors .toSet ()); //TODO: ttp://
4242 }
4343}
0 commit comments