UserProvider.java
上传用户:hensond
上传日期:2021-12-27
资源大小:817k
文件大小:1k
- package com.company.section4;
- import java.util.ArrayList;
- /**
- * @author cbf4Life cbf4life@126.com
- * I'm glad to share my knowledge with you all.
- */
- public class UserProvider implements IUserProvider {
- //用户列表
- private ArrayList<User> userList;
- //传递用户列表
- public UserProvider(ArrayList<User> _userList){
- this.userList = _userList;
- }
- //根据指定的规格查找用户
- public ArrayList<User> findUser(IUserSpecification userSpec) {
- ArrayList<User> result = new ArrayList<User>();
- for(User u:userList){
- if(userSpec.IsSatisfiedBy(u)){//符合指定规格
- result.add(u);
- }
- }
- return result;
- }
- }