/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package twitapp.services; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; public class User { private String name; private ArrayList followers = new ArrayList(); private ArrayList twits = new ArrayList(); public User(String name){ this.name = name; } public String getName() { return name; } public void setFollower(User follower){ followers.add(follower); } public ArrayList getFollowers(){ return followers; } public void setTwit(Twit twit){ twits.add(twit); } public ArrayList getTwits(){ return twits; } public ArrayList getTwits(Date date){ Iterator t = twits.iterator(); ArrayList newer = new ArrayList(); Twit tt; while((tt = t.next())!=null){ if(tt.getTimestamp().after(date)){ newer.add(tt); } } return newer; } }