OGNL投影查询

四、附:测试类代码

1.Department类

public class Department {

private String departName;

private List<Employee> empList;

public Department() {

}

 

public Department(String departName, List<Employee> empList) {

super();

this.departName = departName;

this.empList = empList;

}

 

@Override

public String toString() {

return “Department [departName=” + departName + “, empList=” + empList

+ “]”;

}

 

public String getDepartName() {

return departName;

}

 

public void setDepartName(String departName) {

this.departName = departName;

}

 

public List<Employee> getEmpList() {

return empList;

}

 

public void setEmpList(List<Employee> empList) {

this.empList = empList;

}

 

}

2.Employee类

public class Employee {

private String empName;

private Address address;

private double salary;

 

public Employee() {

}

 

public Employee(String empName, Address address, double salary) {

super();

this.empName = empName;

this.address = address;

this.salary = salary;

}

 

public double getSalary() {

return salary;

}

 

public void setSalary(double salary) {

this.salary = salary;

}

 

public String getEmpName() {

return empName;

}

 

public void setEmpName(String empName) {

this.empName = empName;

}

 

public Address getAddress() {

return address;

}

 

public void setAddress(Address address) {

this.address = address;

}

 

@Override

public String toString() {

return “Employee [empName=” + empName + “, address=” + address + “]”;

}

}

3.Address类

public class Address {

private String country;

private String province;

private String city;

private String street;

public Address() {

}

 

public Address(String country, String province, String city, String street) {

super();

this.country = country;

this.province = province;

this.city = city;

this.street = street;

}

 

public String getCountry() {

return country;

}

 

public void setCountry(String country) {

this.country = country;

}

 

public String getProvince() {

return province;

}

 

public void setProvince(String province) {

this.province = province;

}

 

public String getCity() {

return city;

}

 

public void setCity(String city) {

this.city = city;

}

 

public String getStreet() {

return street;

}

 

public void setStreet(String street) {

this.street = street;

}

 

@Override

public String toString() {

return “Address [country=” + country + “, province=” + province

+ “, city=” + city + “, street=” + street + “]”;

}

}

4.GetData类

public class GetData {

public static List<Department> getDepartList() {

List<Department> departList = new ArrayList<>();

List<Employee> empList = new ArrayList<>();

for(int i = 1; i <= 20; i++) {

Employee employee = new Employee(“emp”+String.format(“%02d”, i), new Address(“country”+String.format(“%02d”, i), “prov”+String.format(“%02d”, i), “city”+String.format(“%02d”, i), “street”+String.format(“%02d”, i)),i*100.00);

empList.add(employee);

}

Department department01 = new Department(“depart01”, empList.subList(0, 4));

Department department02 = new Department(“depart02”, empList.subList(4, 8));

Department department03 = new Department(“depart03”, empList.subList(8, 12));

Department department04 = new Department(“depart04”, empList.subList(12, 16));

Department department05 = new Department(“depart05”, empList.subList(16, 20));

departList.add(department01);

departList.add(department02);

departList.add(department03);

departList.add(department04);

departList.add(department05);

return departList;

}

 

}

 

 


上一篇:
下一篇:
关于尚硅谷
教育理念
名师团队
学员心声
资源下载
视频下载
资料下载
工具下载
加入我们
招聘岗位
岗位介绍
招贤纳师
联系我们
电话:010-56253825
邮箱:info@atguigu.com
地址:北京市昌平区宏福科技园综合楼6层(北京校区)

 深圳市宝安区西部硅谷大厦B座C区一层(深圳校区)

上海市松江区谷阳北路166号大江商厦6层(上海校区)