打字猴:1.700483729e+09
1700483729
1700483730 }
1700483731
1700483732 //检验用户是否满足条件
1700483733
1700483734 public boolean isSatisfiedBy(User user){
1700483735
1700483736 return user.getAge()>age;
1700483737
1700483738 }
1700483739
1700483740 }
1700483741
1700483742 规格书都已经定义完毕了,那我们再来看用户操作类,先看用户操作的接口,如代码清单37-9所示。
1700483743
1700483744 代码清单37-9 用户操作接口
1700483745
1700483746 public interface IUserProvider{
1700483747
1700483748 //根据条件查找用户
1700483749
1700483750 public ArrayList<User>findUser(IUserSpecification userSpec);
1700483751
1700483752 }
1700483753
1700483754 只有一个方法——根据指定的规格书查找用户。再来看其实现类,如代码清单37-10所示。
1700483755
1700483756 代码清单37-10 用户操作
1700483757
1700483758 public class UserProvider implements IUserProvider{
1700483759
1700483760 //用户列表
1700483761
1700483762 private ArrayList<User>userList;
1700483763
1700483764 //传递用户列表
1700483765
1700483766 public UserProvider(ArrayList<User>_userList){
1700483767
1700483768 this.userList=_userList;
1700483769
1700483770 }
1700483771
1700483772 //根据指定的规格书查找用户
1700483773
1700483774 public ArrayList<User>findUser(IUserSpecification userSpec){
1700483775
1700483776 ArrayList<User>result=new ArrayList<User>();
1700483777
1700483778 for(User u:userList){
[ 上一页 ]  [ :1.700483729e+09 ]  [ 下一页 ]