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;

   }

  

 

}

 

 

 

本教程由尚硅谷教育大数据研究院出品,如需转载请注明来源。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值