Handler Generator
สร้างหรือปรับปรุงโครงสร้างของคลาสและเมธอด handler ตามการอ้างอิง handler ของ RouterFunction
วิเคราะห์เป้าหมาย
โดยพื้นฐานแล้วจะสแกนแหล่งที่อยู่ภายใต้ routerPackage หากใช้ scanWholeProject(true) จะค้นหา RouterFunction จาก rootPath ทั้งหมด วิเคราะห์พารามิเตอร์ bean ของ router และการอ้างอิง handler::method เพื่อจับคู่คลาสและวิธีการ handler ที่จำเป็น
ตัวเลือกการกำหนดค่า
rootPath
root source เริ่มต้น
routerPackage
แพ็คเกจ router ที่จะสแกน
scanWholeProject
สแกนทั้ง root แทนแพ็คเกจ router
handlerPackage
แพ็คเกจของคลาสที่สร้างขึ้น
handlerOutputDir
เส้นทางเอาต์พุตไฟล์ Java ที่แท้จริง
addAutoImport / autoImports
เพิ่มการนำเข้าทั่วไปหรือแทนที่ทั้งหมด
addStaticAutoImport / staticAutoImports
เพิ่มการนำเข้าคงที่หรือแทนที่ทั้งหมด
การฉีด import ทั่วไปในโปรเจกต์
java
var handlerConfig = HandlerGenerator.Config.builder()
.addAutoImport(ReactiveMongoDsl.class)
.addAutoImport(ResponseWrapper.class)
.addAutoImport(Result.class)
.addStaticAutoImport(
HandlerGenerator.StaticImportSpec.of(ResponseWrapper.class, "response")
)
.addStaticAutoImport(
HandlerGenerator.StaticImportSpec.of(FieldsPair.class, "pair")
)
.build();