【强制】velocity 调用 POJO 类的属性时,建议直接使用属性名取值即可,模板引擎会自动按规范调用 POJO 的 getXxx(),如果是 boolean 基本数据类型变量(boolean 命名不需要加 is 前缀),会自动调用 isXxx()方法。
说明:注意如果是 Boolean 包装类对象,优先调用 getXxx()的方法。
6%的人的工资介于2500元到65000元。
Java 文件
packagetech.luxsun.interview.luxinterviewstarter.datatype; importlombok.AllArgsConstructor; importlombok.Data; importlombok.NoArgsConstructor; /*** @author Lux Sun* @date 2021/5/6*/publicclassBooleanDemo0 { privateBooleanisActive; privatebooleanisDel; }
Class 文件
//// Source code recreated from a .class file by IntelliJ IDEA// (powered by FernFlower decompiler)//packagetech.luxsun.interview.luxinterviewstarter.datatype; publicclassBooleanDemo0 { privateBooleanisActive; privatebooleanisDel; publicBooleangetIsActive() { returnthis.isActive; } publicbooleanisDel() { returnthis.isDel; } publicvoidsetIsActive(finalBooleanisActive) { this.isActive=isActive; } publicvoidsetDel(finalbooleanisDel) { this.isDel=isDel; } publicbooleanequals(finalObjecto) { if (o==this) { returntrue; } elseif (!(oinstanceofBooleanDemo0)) { returnfalse; } else { BooleanDemo0other= (BooleanDemo0)o; if (!other.canEqual(this)) { returnfalse; } elseif (this.isDel() !=other.isDel()) { returnfalse; } else { Objectthis$isActive=this.getIsActive(); Objectother$isActive=other.getIsActive(); if (this$isActive==null) { if (other$isActive!=null) { returnfalse; } } elseif (!this$isActive.equals(other$isActive)) { returnfalse; } returntrue; } } } protectedbooleancanEqual(finalObjectother) { returnotherinstanceofBooleanDemo0; } publicinthashCode() { intPRIME=true; intresult=1; intresult=result*59+ (this.isDel() ?79 : 97); Object$isActive=this.getIsActive(); result=result*59+ ($isActive==null?43 : $isActive.hashCode()); returnresult; } publicStringtoString() { return"BooleanDemo0(isActive="+this.getIsActive() +", isDel="+this.isDel() +")"; } publicBooleanDemo0() { } publicBooleanDemo0(finalBooleanisActive, finalbooleanisDel) { this.isActive=isActive; this.isDel=isDel; } }