/** Tick action */ public void tick() { if (this.subscribers.size() > 0) { for (Subscriber sub : this.subscribers) { // Check subscription date Date now = new Date(); if (sub.getDate().after(now)) { this.notify(sub); } else { this.subscribers.remove(sub); break; } } } }
/** Delete subscriber */ public boolean deregister(Subscription sub) throws FailureException { for (Subscriber subs : subscribers) { if (subs.getSub().equals(sub)) { subscribers.remove(new Subscriber(subs.getSub(), subs.getType(), subs.getDate())); } } // System.out.println( "Agent " + buildingcs.getAID().getName() + " deregistered the agent " + sub.getMessage().getSender().getName()); return false; }