-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
1,986 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/it/aboutbits/springboot/toolbox/boot/type/CustomTypeScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package it.aboutbits.springboot.toolbox.boot.type; | ||
|
||
import it.aboutbits.springboot.toolbox.reflection.util.ClassScannerUtil; | ||
import it.aboutbits.springboot.toolbox.type.CustomType; | ||
import jakarta.annotation.PostConstruct; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@Slf4j | ||
public class CustomTypeScanner { | ||
public static final String LIBRARY_BASE_PACKAGE_NAME = "it.aboutbits.springboot.toolbox"; | ||
|
||
private String[] packageNamesToScan; | ||
private ClassScannerUtil.ClassScanner classScanner; | ||
|
||
public void setAdditionalTypePackages(String[] additionalTypePackages) { | ||
var tmp = new ArrayList<String>(); | ||
tmp.add(LIBRARY_BASE_PACKAGE_NAME); | ||
tmp.addAll(Arrays.stream(additionalTypePackages) | ||
.filter(item -> !item.isBlank()) | ||
.collect(Collectors.toSet())); | ||
|
||
this.packageNamesToScan = tmp.toArray(new String[0]); | ||
|
||
classScanner = ClassScannerUtil.getScannerForPackages(packageNamesToScan); | ||
} | ||
|
||
@PostConstruct | ||
public void init() { | ||
log.info("CustomTypeConfiguration enabled. Scanning: {}", Arrays.toString(packageNamesToScan)); | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
public Set<Class<? extends CustomType>> findAllCustomTypeRecords() { | ||
return classScanner.getSubTypesOf(CustomType.class).stream() | ||
.filter(Record.class::isAssignableFrom) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.