Lombok plugin siv rau dab tsi?
Lombok plugin siv rau dab tsi?

Video: Lombok plugin siv rau dab tsi?

Video: Lombok plugin siv rau dab tsi?
Video: Java Tools: Project Lombok - пишем меньше кода 2024, Hlis ntuj nqeg
Anonim

Qhov project Lombok yog Java lub tsev qiv ntawv uas yog siv kom txo qis boilerplate code thiab txuag lub sijhawm kev txhim kho.

Dhau li ntawm no, nws puas zoo siv Lombok?

"Txij li thaum annotation processor API tsuas tso cai tsim cov ntaub ntawv tshiab thaum muab tso ua ke (thiab tsis yog hloov kho cov ntaub ntawv uas twb muaj lawm) Lombok siv qhov API ntawd los ua qhov taw qhia nkag los hloov kho java compiler. Kev siv lom tej zaum yog a zoo lub tswv yim tab sis koj yuav tsum paub tias kev txhim kho koj lub compiler tuaj yeem tsoo koj cov cai."

Ib yam li ntawd, Lombok puas tsim nyog siv Java? Tsis yog tsim nyog khi cov Java code rau Lombok annotations risking tag nrho cov hais drawbacks thaum txhua niaj hnub Java IDE muab cov cim cim rau getters, setters, constructors, sib npaug, hashCode thiab toString txoj kev. Tag nrho cov no muaj nyob rau hauv ob peb nas clicks!

Hauv qhov no, Lombok yog dab tsi?

Maven. Teeb tsa lombok nrog rau cov cuab yeej tsim, koj yuav tsum qhia meej tias qhov lombok dependency yuav tsum tau sau koj qhov chaws, tab sis tsis tas yuav muaj nyob rau thaum khiav / sim / jarring / txwv tsis pub xa koj cov cai. Feem ntau qhov no yog hu ua 'muab' kev vam khom.

Cov ntaub ntawv Lombok yog dab tsi?

@ Cov ntaub ntawv yog ib qho yooj yim shortcut annotation uas bundles cov yam ntxwv ntawm @ToString, @EqualsAndHashCode, @Getter / @Setter thiab @RequiredArgsConstructor ua ke: Hauv lwm lo lus, @ Cov ntaub ntawv generates tag nrho cov boilerplate uas ib txwm txuam nrog yooj yim POJOs (Plain Old Java Objects) thiab taum: getters rau tag nrho cov teb,

Pom zoo: