/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * JavaWorld Library, Copyright 2011 Bryan Chadwick * * * * FILE: ./universe/Bundle.java * * * * This file is part of JavaWorld. * * * * JavaWorld is free software: you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version * * 3 of the License, or (at your option) any later version. * * * * JavaWorld is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with JavaWorld. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package universe; import java.io.Serializable; /** Represents the result of a Universe function where the universe is updated, * messages are sent to registered Worlds, and Worlds are marked for removal * from the universe. */ public class Bundle{ /** The current Universe state */ private Universe univ; /** A list of mail messages to be sent to worlds */ private List> mails; /** A list of worlds to remove on the next tick */ private List worlds; /** Create a Bundle without any Mail/Worlds to remove */ public Bundle(Universe univ){ this(univ, new Empty>(), new Empty()); } /** Create a Bundle with Mail messages but no Worlds to remove */ public Bundle(Universe univ, Mail mail){ this(univ, List.>create(mail), new Empty()); } /** Create a Bundle with Mail messages but no Worlds to remove */ public Bundle(Universe univ, Mail ... mails){ this(univ, List.>create(mails), new Empty()); } /** Create a Bundle with a list of Mail messages but no Worlds to remove */ public Bundle(Universe univ, List> mails){ this(univ, mails, new Empty()); } /** Create a Bundle with a list of Mail messages and ask that the given * Worlds be removed */ public Bundle(Universe univ, List> mails, List worlds){ // Current Universe this.univ = univ; // Messages to send... this.mails = mails; // Worlds to remove from the list... this.worlds = worlds; } /** Get the Universe state */ public Universe getUniverse(){ return this.univ; } /** Get the list of Mail messages */ public List> getMails(){ return this.mails; } /** Get the worlds to be removed */ public List getWorlds(){ return this.worlds; } }