From: Stefan F. <ste...@us...> - 2011-09-30 18:53:34
|
rails/algorithms/NetworkGraphBuilder.java | 21 - rails/algorithms/NetworkTrain.java | 2 rails/algorithms/NetworkVertex.java | 10 rails/algorithms/RevenueManager.java | 6 rails/algorithms/RevenueTrainRun.java | 2 rails/common/GuiHints.java | 2 rails/game/Bank.java | 9 rails/game/BaseToken.java | 6 rails/game/Bonus.java | 2 rails/game/BonusToken.java | 6 rails/game/CashHolder.java | 9 rails/game/Certificate.java | 2 rails/game/Company.java | 14 rails/game/CompanyI.java | 7 rails/game/GameManager.java | 80 +-- rails/game/GameManagerI.java | 12 rails/game/MapHex.java | 98 ++-- rails/game/MapManager.java | 5 rails/game/OperatingRound.java | 287 ++++++-------- rails/game/Player.java | 32 - rails/game/PlayerManager.java | 2 rails/game/Portfolio.java | 278 ++++--------- rails/game/PrivateCompany.java | 4 rails/game/PrivateCompanyI.java | 4 rails/game/PublicCertificate.java | 18 rails/game/PublicCompany.java | 185 ++++----- rails/game/PublicCompanyI.java | 22 - rails/game/ReportBuffer.java | 12 rails/game/Round.java | 38 - rails/game/ShareSellingRound.java | 13 rails/game/StartItem.java | 29 - rails/game/StartRound.java | 32 - rails/game/StartRoundI.java | 10 rails/game/StartRound_1830.java | 16 rails/game/StartRound_1835.java | 20 rails/game/Station.java | 4 rails/game/StationHolder.java | 2 rails/game/StockMarket.java | 6 rails/game/StockRound.java | 119 ++--- rails/game/StockSpace.java | 29 - rails/game/StockSpaceI.java | 4 rails/game/Stop.java | 44 -- rails/game/Tile.java | 43 +- rails/game/TileI.java | 7 rails/game/TileManager.java | 2 rails/game/Token.java | 6 rails/game/TokenHolder.java | 13 rails/game/TokenI.java | 5 rails/game/Train.java | 12 rails/game/TrainI.java | 5 rails/game/TrainManager.java | 2 rails/game/TreasuryShareRound.java | 36 - rails/game/action/BuyBonusToken.java | 6 rails/game/action/BuyCertificate.java | 6 rails/game/action/BuyPrivate.java | 6 rails/game/action/BuyStartItem.java | 2 rails/game/action/BuyTrain.java | 10 rails/game/action/DiscardTrain.java | 8 rails/game/action/LayBaseToken.java | 2 rails/game/action/LayBonusToken.java | 2 rails/game/action/LayTile.java | 12 rails/game/action/LayToken.java | 4 rails/game/action/MergeCompanies.java | 6 rails/game/action/PossibleAction.java | 2 rails/game/action/PossibleORAction.java | 6 rails/game/action/ReachDestinations.java | 4 rails/game/action/RepayLoans.java | 4 rails/game/action/RequestTurn.java | 2 rails/game/action/SetDividend.java | 2 rails/game/action/StartCompany.java | 2 rails/game/action/TakeLoans.java | 4 rails/game/correct/CashCorrectionAction.java | 4 rails/game/correct/CashCorrectionManager.java | 16 rails/game/correct/ClosePrivate.java | 2 rails/game/correct/CorrectionManager.java | 6 rails/game/correct/MapCorrectionAction.java | 6 rails/game/correct/MapCorrectionManager.java | 6 rails/game/model/AbstractModel.java | 42 ++ rails/game/model/BaseTokensModel.java | 14 rails/game/model/BonusModel.java | 32 - rails/game/model/CalculatedMoneyModel.java | 42 +- rails/game/model/CashModel.java | 51 +- rails/game/model/CertCountModel.java | 18 rails/game/model/CertificateCountModel.java | 22 + rails/game/model/CertificatesModel.java | 48 ++ rails/game/model/HolderModel.java | 48 ++ rails/game/model/Model.java | 20 rails/game/model/ModelObject.java | 96 ---- rails/game/model/MoneyModel.java | 82 ++-- rails/game/model/PresidentModel.java | 19 rails/game/model/PriceModel.java | 18 rails/game/model/PrivatesModel.java | 27 - rails/game/model/ShareModel.java | 48 -- rails/game/model/TrainsModel.java | 95 ++++ rails/game/model/View.java | 12 rails/game/model/ViewUpdate.java | 2 rails/game/round/RoundContext.java | 6 rails/game/special/ExchangeForShare.java | 6 rails/game/special/LocatedBonus.java | 4 rails/game/special/SellBonusToken.java | 4 rails/game/special/SpecialProperty.java | 14 rails/game/special/SpecialPropertyI.java | 10 rails/game/special/SpecialRight.java | 2 rails/game/special/SpecialTileLay.java | 4 rails/game/special/SpecialTokenLay.java | 6 rails/game/special/SpecialTrainBuy.java | 8 rails/game/specific/_1825/PublicCompany_1825.java | 2 rails/game/specific/_1825/StartRound_1825.java | 2 rails/game/specific/_1825/StockRound_1825.java | 2 rails/game/specific/_1835/OperatingRound_1835.java | 31 - rails/game/specific/_1835/PrussianFormationRound.java | 64 +-- rails/game/specific/_1835/StockRound_1835.java | 4 rails/game/specific/_1851/StartRound_1851.java | 2 rails/game/specific/_1856/CGRFormationRound.java | 97 ++-- rails/game/specific/_1856/OperatingRound_1856.java | 48 +- rails/game/specific/_1856/PublicCompany_1856.java | 2 rails/game/specific/_1856/PublicCompany_CGR.java | 8 rails/game/specific/_1856/StockRound_1856.java | 14 rails/game/specific/_1880/StartRound_1880.java | 19 rails/game/specific/_1880/StockRound_1880.java | 2 rails/game/specific/_1889/OperatingRound_1889.java | 6 rails/game/specific/_18AL/NameTrains.java | 2 rails/game/specific/_18AL/NameableTrain.java | 14 rails/game/specific/_18AL/NamedTrainRevenueModifier.java | 2 rails/game/specific/_18AL/NamedTrainToken.java | 2 rails/game/specific/_18AL/OperatingRound_18AL.java | 16 rails/game/specific/_18EU/FinalMinorExchangeRound.java | 4 rails/game/specific/_18EU/GameManager_18EU.java | 9 rails/game/specific/_18EU/OperatingRound_18EU.java | 16 rails/game/specific/_18EU/StartCompany_18EU.java | 8 rails/game/specific/_18EU/StartRound_18EU.java | 10 rails/game/specific/_18EU/StockRound_18EU.java | 112 ++--- rails/game/specific/_18GA/OperatingRound_18GA.java | 6 rails/game/specific/_18TN/PublicCompany_18TN.java | 5 rails/game/state/AbstractState.java | 50 ++ rails/game/state/ArrayListMultimapState.java | 50 ++ rails/game/state/ArrayListState.java | 19 rails/game/state/CashMove.java | 63 --- rails/game/state/ChangeSet.java | 32 - rails/game/state/ChangeStack.java | 39 + rails/game/state/DoubleMapChange.java | 4 rails/game/state/Formatter.java | 10 rails/game/state/HashMapChange.java | 2 rails/game/state/HashMapState.java | 7 rails/game/state/HashMultimapState.java | 61 ++ rails/game/state/Holder.java | 16 rails/game/state/MapChange.java | 73 --- rails/game/state/Move.java | 47 -- rails/game/state/MoveUtils.java | 50 ++ rails/game/state/Moveable.java | 10 rails/game/state/MoveableHolder.java | 19 rails/game/state/MultimapChange.java | 39 + rails/game/state/MultimapState.java | 11 rails/game/state/NewMove.java | 32 - rails/game/state/Notifiable.java | 5 rails/game/state/ObjectMove.java | 97 ---- rails/game/state/Observable.java | 7 rails/game/state/Observer.java | 7 rails/game/state/PriceMove.java | 4 rails/game/state/PriceTokenMove.java | 8 rails/game/state/RemoveFromMap.java | 74 --- rails/game/state/State.java | 9 rails/game/state/StateManager.java | 11 rails/game/state/TileMove.java | 15 rails/game/state/Triggerable.java | 7 rails/ui/swing/GameStatus.java | 16 rails/ui/swing/GameUIManager.java | 26 - rails/ui/swing/GridPanel.java | 32 - rails/ui/swing/ORPanel.java | 10 rails/ui/swing/ORUIManager.java | 52 +- rails/ui/swing/RemainingTilesWindow.java | 4 rails/ui/swing/ReportWindowDynamic.java | 7 rails/ui/swing/StartRoundWindow.java | 10 rails/ui/swing/StatusWindow.java | 4 rails/ui/swing/UpgradesPanel.java | 20 rails/ui/swing/elements/Field.java | 37 - rails/ui/swing/elements/GUIStockSpace.java | 17 rails/ui/swing/elements/ViewObject.java | 9 rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java | 10 rails/ui/swing/gamespecific/_18AL/NameTrainsDialog.java | 4 rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java | 6 rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java | 6 rails/ui/swing/gamespecific/_18EU/StatusWindow_18EU.java | 4 rails/ui/swing/hexmap/GUIHex.java | 41 -- rails/ui/swing/hexmap/HexMap.java | 2 rails/util/Util.java | 7 tools/MakeGameTileSets.java | 2 187 files changed, 2144 insertions(+), 2133 deletions(-) New commits: commit cb6b30794ca00d6fa13c7b43a69afbd676ca6a26 Author: Stefan Frey <ste...@we...> Date: Fri Sep 30 16:58:56 2011 +0200 renamed PortfolioModel to Portfolio again diff --git a/rails/game/Bank.java b/rails/game/Bank.java index 04d4226..22b0a4c 100644 --- a/rails/game/Bank.java +++ b/rails/game/Bank.java @@ -26,13 +26,13 @@ public class Bank extends AbstractItem implements CashHolder, ConfigurableCompon private CashModel money; /** The IPO */ - private PortfolioModel ipo = null; + private Portfolio ipo = null; /** The Bank Pool */ - private PortfolioModel pool = null; + private Portfolio pool = null; /** Collection of items that will (may) become available in the future */ - private PortfolioModel unavailable = null; + private Portfolio unavailable = null; /** Collection of items that have been discarded (but are kept to allow Undo) */ - private PortfolioModel scrapHeap = null; + private Portfolio scrapHeap = null; private static Bank instance = null; @@ -54,10 +54,10 @@ public class Bank extends AbstractItem implements CashHolder, ConfigurableCompon money = new CashModel(this); // Create the IPO and the Bank Pool. - ipo = new PortfolioModel(PortfolioModel.IPO_NAME, this); - pool = new PortfolioModel(PortfolioModel.POOL_NAME, this); - unavailable = new PortfolioModel(PortfolioModel.UNAVAILABLE_NAME, this); - scrapHeap = new PortfolioModel(PortfolioModel.SCRAPHEAP_NAME, this); + ipo = new Portfolio(Portfolio.IPO_NAME, this); + pool = new Portfolio(Portfolio.POOL_NAME, this); + unavailable = new Portfolio(Portfolio.UNAVAILABLE_NAME, this); + scrapHeap = new Portfolio(Portfolio.SCRAPHEAP_NAME, this); String configFormat = Config.get("money_format"); if (Util.hasValue(configFormat) && configFormat.matches(".*@.*")) { @@ -123,11 +123,11 @@ public class Bank extends AbstractItem implements CashHolder, ConfigurableCompon /** * @return IPO Portfolio */ - public PortfolioModel getIpo() { + public Portfolio getIpo() { return ipo; } - public PortfolioModel getScrapHeap() { + public Portfolio getScrapHeap() { return scrapHeap; } @@ -159,14 +159,14 @@ public class Bank extends AbstractItem implements CashHolder, ConfigurableCompon /** * @return Portfolio of stock in Bank Pool */ - public PortfolioModel getPool() { + public Portfolio getPool() { return pool; } /** * @return Portfolio of unavailable shares */ - public PortfolioModel getUnavailable() { + public Portfolio getUnavailable() { return unavailable; } diff --git a/rails/game/Certificate.java b/rails/game/Certificate.java index 662926c..c802fbe 100644 --- a/rails/game/Certificate.java +++ b/rails/game/Certificate.java @@ -12,7 +12,7 @@ public interface Certificate extends Moveable { /** * @return Portfolio */ - public PortfolioModel getPortfolio(); + public Portfolio getPortfolio(); public String getId(); diff --git a/rails/game/Company.java b/rails/game/Company.java index dd99c33..474c717 100644 --- a/rails/game/Company.java +++ b/rails/game/Company.java @@ -28,7 +28,7 @@ Cloneable, Comparable<Company> { * In private companies, it is primarily the portfolio that holds this private. * In public companies, it is the portfolio of this company. * This contradictory use needs to be disentangled. */ - protected PortfolioModel portfolio = null; + protected Portfolio portfolio = null; protected String infoText = ""; protected String parentInfoText = ""; @@ -114,7 +114,7 @@ Cloneable, Comparable<Company> { * * @return The Portfolio of this company. */ - public PortfolioModel getPortfolio() { + public Portfolio getPortfolio() { return portfolio; } diff --git a/rails/game/CompanyI.java b/rails/game/CompanyI.java index 271c1d7..0e3eb6e 100644 --- a/rails/game/CompanyI.java +++ b/rails/game/CompanyI.java @@ -42,7 +42,7 @@ public interface CompanyI extends Item, ConfigurableComponentI, Holder { * * @return The Portfolio of this company. */ - public PortfolioModel getPortfolio(); + public Portfolio getPortfolio(); /** * Returns the name of the Company diff --git a/rails/game/GameManager.java b/rails/game/GameManager.java index 6a22c51..b822121 100644 --- a/rails/game/GameManager.java +++ b/rails/game/GameManager.java @@ -73,11 +73,11 @@ public class GameManager extends AbstractItem implements ConfigurableComponentI, /** Map relating portfolio names and objects, to enable deserialization. * OBSOLETE since Rails 1.3.1, but still required to enable reading old saved files */ - protected Map<String, PortfolioModel> portfolioMap = - new HashMap<String, PortfolioModel> (); + protected Map<String, Portfolio> portfolioMap = + new HashMap<String, Portfolio> (); /** Map relating portfolio unique names and objects, to enable deserialization */ - protected Map<String, PortfolioModel> portfolioUniqueNameMap = - new HashMap<String, PortfolioModel> (); + protected Map<String, Portfolio> portfolioUniqueNameMap = + new HashMap<String, Portfolio> (); protected IntegerState playerCertificateLimit = new IntegerState (this, "PlayerCertificateLimit", 0); @@ -1528,17 +1528,17 @@ public class GameManager extends AbstractItem implements ConfigurableComponentI, setCurrentPlayerIndex(currentPlayerIndex); } - public void addPortfolio (PortfolioModel portfolio) { + public void addPortfolio (Portfolio portfolio) { portfolioMap.put(portfolio.getId(), portfolio); portfolioUniqueNameMap.put(portfolio.getUniqueName(), portfolio); } /* since Rails 1.3.1, but still required to enable loading old saved files */ - public PortfolioModel getPortfolioByName (String name) { + public Portfolio getPortfolioByName (String name) { return portfolioMap.get(name); } - public PortfolioModel getPortfolioByUniqueName (String name) { + public Portfolio getPortfolioByUniqueName (String name) { return portfolioUniqueNameMap.get(name); } diff --git a/rails/game/GameManagerI.java b/rails/game/GameManagerI.java index b179b82..a307edb 100644 --- a/rails/game/GameManagerI.java +++ b/rails/game/GameManagerI.java @@ -155,9 +155,9 @@ public interface GameManagerI extends Item, Holder, ConfigurableComponentI { public abstract void setNextPlayer(); - public void addPortfolio (PortfolioModel portfolio); - public PortfolioModel getPortfolioByName (String name); - public PortfolioModel getPortfolioByUniqueName (String name); + public void addPortfolio (Portfolio portfolio); + public Portfolio getPortfolioByName (String name); + public Portfolio getPortfolioByUniqueName (String name); /** * @return the StartPacket diff --git a/rails/game/OperatingRound.java b/rails/game/OperatingRound.java index 174ee77..8dec061 100644 --- a/rails/game/OperatingRound.java +++ b/rails/game/OperatingRound.java @@ -143,8 +143,8 @@ public class OperatingRound extends Round implements View<String> { int count = 0; for (PrivateCompanyI priv : companyManager.getAllPrivateCompanies()) { if (!priv.isClosed()) { - if (((PortfolioModel)priv.getHolder()).getOwner().getClass() != Bank.class) { - CashHolder recipient = ((PortfolioModel)priv.getHolder()).getOwner(); + if (((Portfolio)priv.getHolder()).getOwner().getClass() != Bank.class) { + CashHolder recipient = ((Portfolio)priv.getHolder()).getOwner(); int revenue = priv.getRevenueByPhase(getCurrentPhase()); // sfy 1889: revenue by phase if (count++ == 0) ReportBuffer.add(""); ReportBuffer.add(LocalText.getText("ReceivesFor", @@ -2328,7 +2328,7 @@ public class OperatingRound extends Round implements View<String> { /** Who gets the per-share revenue? */ protected CashHolder getBeneficiary(PublicCertificateI cert) { - PortfolioModel holder = cert.getPortfolio(); + Portfolio holder = cert.getPortfolio(); CashHolder beneficiary = holder.getOwner(); // Special cases apply if the holder is the IPO or the Pool if (operatingCompany.get().paysOutToTreasury(cert)) { @@ -2687,7 +2687,7 @@ public class OperatingRound extends Round implements View<String> { Bank.format(actualPresidentCash))); } - PortfolioModel oldHolder = train.getHolder(); + Portfolio oldHolder = train.getHolder(); if (exchangedTrain != null) { TrainI oldTrain = @@ -2939,7 +2939,7 @@ public class OperatingRound extends Round implements View<String> { if (getCurrentPhase().isTrainTradingAllowed()) { BuyTrain bt; Player p; - PortfolioModel pf; + Portfolio pf; int index; int numberOfPlayers = getNumberOfPlayers(); int presidentCash = operatingCompany.get().getPresident().getCash(); diff --git a/rails/game/Phase.java b/rails/game/Phase.java index a23d664..e509507 100644 --- a/rails/game/Phase.java +++ b/rails/game/Phase.java @@ -69,7 +69,7 @@ public class Phase implements PhaseI { protected Map<String, String> actions; private GameManagerI gameManager; - private PortfolioModel lastTrainBuyer; + private Portfolio lastTrainBuyer; protected String extraInfo = ""; @@ -264,7 +264,7 @@ public class Phase implements PhaseI { } } - public void setLastTrainBuyer(PortfolioModel lastTrainBuyer) { + public void setLastTrainBuyer(Portfolio lastTrainBuyer) { this.lastTrainBuyer = lastTrainBuyer; } diff --git a/rails/game/PhaseI.java b/rails/game/PhaseI.java index 62f611c..a598e12 100644 --- a/rails/game/PhaseI.java +++ b/rails/game/PhaseI.java @@ -41,5 +41,5 @@ public interface PhaseI extends ConfigurableComponentI { public String getParameterAsString (String key); public int getParameterAsInteger (String key); - public void setLastTrainBuyer(PortfolioModel lastTrainBuyer); + public void setLastTrainBuyer(Portfolio lastTrainBuyer); } diff --git a/rails/game/PhaseManager.java b/rails/game/PhaseManager.java index 188650c..061c71e 100644 --- a/rails/game/PhaseManager.java +++ b/rails/game/PhaseManager.java @@ -76,11 +76,11 @@ public class PhaseManager extends AbstractItem implements ConfigurableComponentI return getCurrentPhase().getIndex(); } - public void setPhase(String name, PortfolioModel lastTrainBuyer) { + public void setPhase(String name, Portfolio lastTrainBuyer) { setPhase(phaseMap.get(name), lastTrainBuyer); } - protected void setPhase(PhaseI phase, PortfolioModel lastTrainBuyer) { + protected void setPhase(PhaseI phase, Portfolio lastTrainBuyer) { if (phase != null) { phase.setLastTrainBuyer (lastTrainBuyer); currentPhase.set(phase); diff --git a/rails/game/Player.java b/rails/game/Player.java index 3336196..dafdd24 100644 --- a/rails/game/Player.java +++ b/rails/game/Player.java @@ -33,12 +33,12 @@ public class Player extends AbstractItem implements CashHolder, Comparable<Playe private boolean hasBoughtStockThisTurn = false; - private PortfolioModel portfolio = null; + private Portfolio portfolio = null; public Player(String name, int index) { this.name = name; this.index = index; - portfolio = new PortfolioModel(name, this); + portfolio = new Portfolio(name, this); freeCash = new CalculatedMoneyModel(this, "getFreeCash"); wallet.addView(freeCash); blockedCash = new MoneyModel(this, "blockedCash"); @@ -54,7 +54,7 @@ public class Player extends AbstractItem implements CashHolder, Comparable<Playe /** * @return Returns the player's portfolio. */ - public PortfolioModel getPortfolio() { + public Portfolio getPortfolio() { return portfolio; } diff --git a/rails/game/Portfolio.java b/rails/game/Portfolio.java new file mode 100644 index 0000000..89136a1 --- /dev/null +++ b/rails/game/Portfolio.java @@ -0,0 +1,733 @@ +package rails.game; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import com.google.common.collect.Maps; + +import rails.common.LocalText; +import rails.game.model.AbstractModel; +import rails.game.model.CertificateCountModel; +import rails.game.model.HolderModel; +import rails.game.model.PrivatesModel; +import rails.game.model.CertificatesModel; +import rails.game.model.TrainsModel; +import rails.game.special.LocatedBonus; +import rails.game.special.SpecialPropertyI; +import rails.game.state.AbstractItem; +import rails.game.state.ArrayListState; +import rails.game.state.MoveUtils; +import rails.game.state.Moveable; +import rails.game.state.Holder; +import rails.util.Util; + +/** + * A Portfolio(Model) stores several HolderModels + * + * For the important MoveAble objects own methods are implemented + * + * All other HolderModels can be added by the general methods + * + * @author evos, freystef (2.0) + */ +public final class Portfolio extends AbstractItem { + + protected static Logger log = + Logger.getLogger(Portfolio.class.getPackage().getName()); + + /** Specific portfolio names */ + public static final String IPO_NAME = "IPO"; + public static final String POOL_NAME = "Pool"; + public static final String SCRAPHEAP_NAME = "ScrapHeap"; + public static final String UNAVAILABLE_NAME = "Unavailable"; + + /** Owner */ + private final CashHolder owner; + + /** Owned private companies */ + private final PrivatesModel privates = new PrivatesModel(this); + + /** Owned public company certificates */ + private final Map<PublicCompanyI, CertificatesModel> certificates = Maps.newHashMap(); + + /** Owned trains */ + private final TrainsModel trains = new TrainsModel(this); + + /** Owned tokens */ + // TODO Currently only used to discard expired Bonus tokens. + private final HolderModel<TokenI> tokens = new HolderModel<TokenI> (this, "tokens"); + + /** + * Private-independent special properties. When moved here, a special + * property no longer depends on the private company being alive. Example: + * 18AL named train tokens. + */ + private final HolderModel<SpecialPropertyI> specialProperties = + new HolderModel<SpecialPropertyI>(this, "specialProperties"); + + private final GameManagerI gameManager; + + public Portfolio(CashHolder holder, String id) { + super(holder, id); + this.owner = holder; + + gameManager = GameManager.getInstance(); + gameManager.addPortfolio(this); + + // change display style dependent on owner + if (owner instanceof PublicCompanyI) { + trains.setAbbrList(false); + privates.setLineBreak(false); + } else if (owner instanceof Bank) { + trains.setAbbrList(true); + } else if (owner instanceof Player) { + privates.setLineBreak(true); + } + } + + public void transferAssetsFrom(Portfolio otherPortfolio) { + + // Move trains + MoveUtils.objectMoveAll(otherPortfolio.getTrainList(), this.getTrainList()); + + // Move treasury certificates + MoveUtils.objectMoveAll(otherPortfolio.getCertificates(), this.getCertificates()); + } + + /** Low-level method, only to be called by the local addObject() method and by initialisation code. */ + public void addPrivate(PrivateCompanyI privateCompany, int position) { + + // add to private Model + privates.addObject(privateCompany, position); + + // change the holder inside the private Company + privateCompany.setHolder(this); + + + log.debug("Adding " + privateCompany.getId() + " to portfolio of " + + name); + if (privateCompany.getSpecialProperties() != null) { + log.debug(privateCompany.getId() + " has special properties!"); + } else { + log.debug(privateCompany.getId() + " has no special properties"); + } + privates.notifyModel(); + updatePlayerWorth (); + } + + /** Low-level method, only to be called by the local addObject() method and by initialisation code. */ + public void addCertificate(PublicCertificateI certificate){ + addCertificate (certificate, new int[] {-1,-1,-1}); + } + + /** Low-level method, only to be called by the local addObject() method. */ + private void addCertificate(PublicCertificateI certificate, int[] position) { + // When undoing a company start, put the President back at the top. + if (certificate.isPresidentShare()) position = new int[] {0,0,0}; + + certificates.add(position[0], certificate); + + String companyName = certificate.getCompany().getId(); + if (!certPerCompany.containsKey(companyName)) { + certPerCompany.put(companyName, new ArrayList<PublicCertificateI>()); + } + + Util.addToList(certPerCompany.get(companyName), certificate, position[1]); + + String certTypeId = certificate.getTypeId(); + if (!certsPerType.containsKey(certTypeId)) { + certsPerType.put(certTypeId, new ArrayList<PublicCertificateI>()); + } + Util.addToList(certsPerType.get(certTypeId), certificate, position[2]); + + certificate.setPortfolio(this); + + getShareModel(certificate.getCompany()).addShare(certificate.getShare()); + updatePlayerWorth (); + } + + /** Low-level method, only to be called by the local addObject() method. */ + private boolean removePrivate(PrivateCompanyI privateCompany) { + boolean removed = privateCompanies.remove(privateCompany); + if (removed) { + privates.notifyModel(); + updatePlayerWorth (); + } + return removed; + } + + /** Low-level method, only to be called by the local addObject() method. */ + private void removeCertificate(PublicCertificateI certificate) { + certificates.remove(certificate); + + String companyName = certificate.getCompany().getId(); + + List<PublicCertificateI> certs = getCertificatesPerCompany(companyName); + certs.remove(certificate); + + String certTypeId = certificate.getTypeId(); + if (certsPerType.containsKey(certTypeId)) { + certsPerType.get(certTypeId).remove(0); + if (certsPerType.get(certTypeId).isEmpty()) { + certsPerType.remove(certTypeId); + } + } + + getShareModel(certificate.getCompany()).addShare( + -certificate.getShare()); + updatePlayerWorth (); + } + + protected void updatePlayerWorth () { + if (owner instanceof Player) { + ((Player)owner).updateWorth(); + } + } + + public CertificatesModel getShareModel(PublicCompanyI company) { + + if (!shareModelPerCompany.containsKey(company)) { + shareModelPerCompany.put(company, new CertificatesModel(this, company)); + } + return shareModelPerCompany.get(company); + } + + public ArrayListState<PrivateCompanyI> getPrivateCompanies() { + return privateCompanies; + } + + public ArrayListState<PublicCertificateI> getCertificates() { + return certificates; + } + + /** Get the number of certificates that count against the certificate limit */ + public float getCertificateCount() { + + float number = privateCompanies.size(); // May not hold for all games + PublicCompanyI comp; + + for (PublicCertificateI cert : certificates) { + comp = cert.getCompany(); + if (!comp.hasFloated() || !comp.hasStockPrice() + || !cert.getCompany().getCurrentSpace().isNoCertLimit()) + number += cert.getCertificateCount(); + } + return number; + } + + public Map<String, List<PublicCertificateI>> getCertsPerCompanyMap() { + return certPerCompany; + } + + public List<PublicCertificateI> getCertificatesPerCompany(String compName) { + if (certPerCompany.containsKey(compName)) { + return certPerCompany.get(compName); + } else { + // TODO: This is bad. If we don't find the company name + // we should check to see if certPerCompany has been loaded + // or possibly throw a config error. + return new ArrayList<PublicCertificateI>(); + } + } + + /** + * Find a certificate for a given company. + * + * @param company The public company for which a certificate is found. + * @param president Whether we look for a president or non-president + * certificate. If there is only one certificate, this parameter has no + * meaning. + * @return The certificate, or null if not found./ + */ + public PublicCertificateI findCertificate(PublicCompanyI company, + boolean president) { + return findCertificate(company, 1, president); + } + + /** Find a certificate for a given company. */ + public PublicCertificateI findCertificate(PublicCompanyI company, + int shares, boolean president) { + String companyName = company.getId(); + if (!certPerCompany.containsKey(companyName)) { + return null; + } + for (PublicCertificateI cert : certPerCompany.get(companyName)) { + if (cert.getCompany() == company) { + if (company.getShareUnit() == 100 || president + && cert.isPresidentShare() || !president + && !cert.isPresidentShare() && cert.getShares() == shares) { + return cert; + } + } + } + return null; + } + + public Map<String, List<PublicCertificateI>> getCertsPerType() { + return certsPerType; + } + + public List<PublicCertificateI> getCertsOfType(String certTypeId) { + if (certsPerType.containsKey(certTypeId)) { + return certsPerType.get(certTypeId); + } else { + return null; + } + } + + public PublicCertificateI getCertOfType(String certTypeId) { + if (certsPerType.containsKey(certTypeId)) { + return certsPerType.get(certTypeId).get(0); + } else { + return null; + } + } + + /** + * @return + */ + public CashHolder getOwner() { + return owner; + } + + /** + * @param object + */ + public void setOwner(CashHolder owner) { + this.owner = owner; + } + + /** + * @return + */ + public String getId() { + return name; + } + + /** Get unique name (prefixed by the owners class type, to avoid Bank, Player and Company + * namespace clashes). + * @return + */ + public String getUniqueName () { + return uniqueName; + } + + /** + * Returns percentage that a portfolio contains of one company. + * + * @param company + * @return + */ + public int getShare(PublicCompanyI company) { + return certificates.get(company).getShare(); + } + + public int ownsCertificates(PublicCompanyI company, int unit, + boolean president) { + int certs = 0; + String name = company.getId(); + if (certPerCompany.containsKey(name)) { + for (PublicCertificateI cert : certPerCompany.get(name)) { + if (president) { + if (cert.isPresidentShare()) return 1; + } else if (cert.getShares() == unit) { + certs++; + } + } + } + return certs; + } + + /** + * Swap this Portfolio's President certificate for common shares in another + * Portfolio. + * + * @param company The company whose Presidency is handed over. + * @param other The new President's portfolio. + * @return The common certificates returned. + */ + public List<PublicCertificateI> swapPresidentCertificate( + PublicCompanyI company, Portfolio other) { + + List<PublicCertificateI> swapped = new ArrayList<PublicCertificateI>(); + PublicCertificateI swapCert; + + // Find the President's certificate + PublicCertificateI cert = this.findCertificate(company, true); + if (cert == null) return null; + int shares = cert.getShares(); + + // Check if counterparty has enough single certificates + if (other.ownsCertificates(company, 1, false) >= shares) { + for (int i = 0; i < shares; i++) { + swapCert = other.findCertificate(company, 1, false); + swapCert.moveTo(this); + swapped.add(swapCert); + + } + } else if (other.ownsCertificates(company, shares, false) >= 1) { + swapCert = other.findCertificate(company, 2, false); + swapCert.moveTo(this); + swapped.add(swapCert); + } else { + return null; + } + cert.moveTo(other); + + // Make sure the old President is no longer marked as such + getShareModel(company).setShare(); + + return swapped; + } + + /** Low-level method, only to be called by initialisation code and by the local addObject() method. */ + public void addTrain (TrainI train) { + addTrain (train, new int[] {-1,-1,-1}); + } + + /** Low-level method, only to be called by the local addObject() method. */ + private void addTrain(TrainI train, int[] position) { + + trains.add(position[0], train); + + TrainType type = train.getType(); + if (!trainsPerType.containsKey(type)) { + trainsPerType.put(type, new ArrayList<TrainI>()); + } + Util.addToList(trainsPerType.get(type), train, position[1]); + + TrainCertificateType certType = train.getCertType(); + if (!trainsPerCertType.containsKey(certType)) { + trainsPerCertType.put(certType, new ArrayList<TrainI>()); + } + Util.addToList(trainsPerCertType.get(certType), train, position[2]); + + train.setHolder(this); + trainsModel.notifyModel(); + } + + /** Low-level method, only to be called by Move objects */ + private void removeTrain(TrainI train) { + trains.remove(train); + trainsPerType.get(train.getPreviousType()).remove(train); + trainsPerCertType.get(train.getCertType()).remove(train); + train.setHolder(null); + trainsModel.notifyModel(); + } + + public void buyTrain(TrainI train, int price) { + CashHolder oldOwner = train.getOwner(); + train.moveTo(this); + if (price > 0) MoveUtils.cashMove(owner, oldOwner, price); + } + + public void discardTrain(TrainI train) { + train.moveTo(GameManager.getInstance().getBank().getPool()); + ReportBuffer.add(LocalText.getText("CompanyDiscardsTrain", + name, train.getId() )); + } + + public void updateTrainsModel() { + trainsModel.notifyModel(); + } + + public int getNumberOfTrains() { + return trains.size(); + } + + public ArrayListState<TrainI> getTrainList() { + return trains; + } + + public TrainI[] getTrainsPerType(TrainType type) { + + List<TrainI> trainsFound = new ArrayList<TrainI>(); + for (TrainI train : trains) { + if (train.getType() == type) trainsFound.add(train); + } + + return trainsFound.toArray(new TrainI[0]); + } + + public AbstractModel<String> getTrainsModel() { + return trainsModel; + } + + /** Returns one train of any type held */ + public List<TrainI> getUniqueTrains() { + + List<TrainI> trainsFound = new ArrayList<TrainI>(); + Map<TrainType, Object> trainTypesFound = + new HashMap<TrainType, Object>(); + for (TrainI train : trains) { + if (!trainTypesFound.containsKey(train.getType())) { + trainsFound.add(train); + trainTypesFound.put(train.getType(), null); + } + } + return trainsFound; + + } + + public TrainI getTrainOfType(TrainCertificateType type) { + return trains.getTrainOfType(type); + } + + + /** + * Add a special property. Used to make special properties independent of + * the private company that originally held it. + * Low-level method, only to be called by Move objects. + * + * @param property The special property object to add. + * @return True if successful. + */ + private boolean addSpecialProperty(SpecialPropertyI property, int position) { + + + if (specialProperties == null) { + specialProperties = new ArrayList<SpecialPropertyI>(2); + } + + boolean result = Util.addToList(specialProperties, property, position); + if (!result) return false; + + property.setHolder(this); + + // Special case for bonuses with predefined locations + // TODO Does this belong here? + if (owner instanceof PublicCompanyI && property instanceof LocatedBonus) { + PublicCompanyI company = (PublicCompanyI)owner; + LocatedBonus locBonus = (LocatedBonus)property; + Bonus bonus = new Bonus(company, locBonus.getId(), locBonus.getValue(), + locBonus.getLocations()); + company.addBonus(bonus); + ReportBuffer.add(LocalText.getText("AcquiresBonus", + owner.getId(), + locBonus.getId(), + Bank.format(locBonus.getValue()), + locBonus.getLocationNameString())); + } + + return result; + } + + /** + * Remove a special property. + * Low-level method, only to be called by Move objects. + * @param property The special property object to remove. + * @return True if successful. + */ + private boolean removeSpecialProperty(SpecialPropertyI property) { + + boolean result = false; + + if (specialProperties != null) { + result = specialProperties.remove(property); + + // Special case for bonuses with predefined locations + // TODO Does this belong here? + if (owner instanceof PublicCompanyI && property instanceof LocatedBonus) { + PublicCompanyI company = (PublicCompanyI)owner; + LocatedBonus locBonus = (LocatedBonus)property; + company.removeBonus(locBonus.getId()); + } + } + + return result; + } + + /** + * Add an object. + * Low-level method, only to be called by Move objects. + * @param object The object to add. + * @return True if successful. + */ + public boolean addObject(Moveable object, int position) { + if (object instanceof PublicCertificateI) { + if (position == null) position = new int[] {-1, -1, -1}; + addCertificate((PublicCertificateI) object, position); + return true; + } else if (object instanceof PrivateCompanyI) { + addPrivate((PrivateCompanyI) object, position == null ? -1 : position[0]); + return true; + } else if (object instanceof TrainI) { + if (position == null) position = new int[] {-1, -1, -1}; + addTrain((TrainI) object, position); + return true; + } else if (object instanceof SpecialPropertyI) { + return addSpecialProperty((SpecialPropertyI) object, position == null ? -1 : position[0]); + } else if (object instanceof TokenI) { + return addToken((TokenI) object, position == null ? -1 : position[0]); + } else { + return false; + } + } + + /** + * Remove an object. + * Low-level method, only to be called by Move objects. + * + * @param object The object to remove. + * @return True if successful. + */ + public boolean removeObject(Moveable object) { + if (object instanceof PublicCertificateI) { + removeCertificate((PublicCertificateI) object); + return true; + } else if (object instanceof PrivateCompanyI) { + removePrivate((PrivateCompanyI) object); + return true; + } else if (object instanceof TrainI) { + removeTrain((TrainI) object); + return true; + } else if (object instanceof SpecialPropertyI) { + return removeSpecialProperty((SpecialPropertyI) object); + } else if (object instanceof TokenI) { + return removeToken((TokenI) object); + } else { + return false; + } + } + + public int[] getListIndex (Moveable object) { + if (object instanceof PublicCertificateI) { + PublicCertificateI cert = (PublicCertificateI) object; + return new int[] { + certificates.indexOf(object), + certPerCompany.get(cert.getCompany().getId()).indexOf(cert), + certsPerType.get(cert.getTypeId()).indexOf(cert) + }; + } else if (object instanceof PrivateCompanyI) { + return new int[] {privateCompanies.indexOf(object)}; + } else if (object instanceof TrainI) { + TrainI train = (TrainI) object; + return new int[] { + trains.indexOf(train), + train.getPreviousType() != null ? trainsPerType.get(train.getPreviousType()).indexOf(train) : -1, + trainsPerCertType.get(train.getCertType()).indexOf(train) + }; + } else if (object instanceof SpecialPropertyI) { + return new int[] {specialProperties.indexOf(object)}; + } else if (object instanceof TokenI) { + return new int[] {tokens.indexOf(object)}; + } else { + return Moveable.AT_END; + } + } + + /** + * @return ArrayList of all special properties we have. + */ + public List<SpecialPropertyI> getPersistentSpecialProperties() { + return specialProperties; + } + + public List<SpecialPropertyI> getAllSpecialProperties() { + List<SpecialPropertyI> sps = new ArrayList<SpecialPropertyI>(); + if (specialProperties != null) sps.addAll(specialProperties); + for (PrivateCompanyI priv : privateCompanies.view()) { + if (priv.getSpecialProperties() != null) { + sps.addAll(priv.getSpecialProperties()); + } + } + return sps; + } + + /** + * Do we have any special properties? + * + * @return Boolean + */ + public boolean hasSpecialProperties() { + return specialProperties != null && !specialProperties.isEmpty(); + } + + @SuppressWarnings("unchecked") + public <T extends SpecialPropertyI> List<T> getSpecialProperties( + Class<T> clazz, boolean includeExercised) { + List<T> result = new ArrayList<T>(); + List<SpecialPropertyI> sps; + + if (owner instanceof Player || owner instanceof PublicCompanyI) { + + for (PrivateCompanyI priv : privateCompanies.view()) { + + sps = priv.getSpecialProperties(); + if (sps == null) continue; + + for (SpecialPropertyI sp : sps) { + if ((clazz == null || clazz.isAssignableFrom(sp.getClass())) + && sp.isExecutionable() + && (!sp.isExercised() || includeExercised) + && (owner instanceof Company && sp.isUsableIfOwnedByCompany() + || owner instanceof Player && sp.isUsableIfOwnedByPlayer())) { + log.debug("Portfolio "+name+" has SP " + sp); + result.add((T) sp); + } + } + } + + // Private-independent special properties + if (specialProperties != null) { + for (SpecialPropertyI sp : specialProperties) { + if ((clazz == null || clazz.isAssignableFrom(sp.getClass())) + && sp.isExecutionable() + && (!sp.isExercised() || includeExercised) + && (owner instanceof Company && sp.isUsableIfOwnedByCompany() + || owner instanceof Player && sp.isUsableIfOwnedByPlayer())) { + log.debug("Portfolio "+name+" has persistent SP " + sp); + result.add((T) sp); + } + } + } + + } + + return result; + } + + public PrivatesModel getPrivatesOwnedModel() { + return privates; + } + + /** Low-level method, only to be called by the local addObject() method. */ + public boolean addToken(TokenI token, int position) { + tokens.add(position, token); + return true; + } + + /** Low-level method, only to be called by the local addObject() method. */ + public boolean removeToken(TokenI token) { + return tokens.remove(token); + } + + public boolean hasTokens() { + return tokens != null && !tokens.isEmpty(); + } + + public void rustObsoleteTrains() { + + List<TrainI> trainsToRust = new ArrayList<TrainI>(); + for (TrainI train : trains) { + if (train.isObsolete()) { + trainsToRust.add(train); + } + } + // Need to separate selection and execution, + // otherwise we get a ConcurrentModificationException on trains. + for (TrainI train : trainsToRust) { + ReportBuffer.add(LocalText.getText("TrainsObsoleteRusted", + train.getId(), name)); + log.debug("Obsolete train " + train.getUniqueId() + " (owned by " + + name + ") rusted"); + train.setRusted(); + } + trainsModel.notifyModel(); + } + +} diff --git a/rails/game/PortfolioModel.java b/rails/game/PortfolioModel.java deleted file mode 100644 index 1048c36..0000000 --- a/rails/game/PortfolioModel.java +++ /dev/null @@ -1,787 +0,0 @@ -package rails.game; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -import com.google.common.collect.Maps; - -import rails.common.LocalText; -import rails.game.model.AbstractModel; -import rails.game.model.CertificateCountModel; -import rails.game.model.HolderModel; -import rails.game.model.PrivatesModel; -import rails.game.model.CertificatesModel; -import rails.game.model.TrainsModel; -import rails.game.special.LocatedBonus; -import rails.game.special.SpecialPropertyI; -import rails.game.state.AbstractItem; -import rails.game.state.ArrayListState; -import rails.game.state.MoveUtils; -import rails.game.state.Moveable; -import rails.game.state.Holder; -import rails.util.Util; - -/** - * A Portfolio(Model) stores several HolderModels - * - * For the important MoveAble objects own methods are implemented - * - * All other HolderModels can be added by the general methods - * - * @author evos, freystef (2.0) - */ -public final class PortfolioModel extends AbstractItem { - - protected static Logger log = - Logger.getLogger(PortfolioModel.class.getPackage().getName()); - - /** Specific portfolio names */ - public static final String IPO_NAME = "IPO"; - public static final String POOL_NAME = "Pool"; - public static final String SCRAPHEAP_NAME = "ScrapHeap"; - public static final String UNAVAILABLE_NAME = "Unavailable"; - - /** Owner */ - private final CashHolder owner; - - /** Owned private companies */ - private final PrivatesModel privates = new PrivatesModel(this); - - /** Owned public company certificates */ - private final Map<PublicCompanyI, CertificatesModel> certificates = Maps.newHashMap(); - - /** Owned trains */ - private final TrainsModel trains = new TrainsModel(this); - - /** Owned tokens */ - // TODO Currently only used to discard expired Bonus tokens. - private final HolderModel<TokenI> tokens = new HolderModel<TokenI> (this, "tokens"); - - /** - * Private-independent special properties. When moved here, a special - * property no longer depends on the private company being alive. Example: - * 18AL named train tokens. - */ - private final HolderModel<SpecialPropertyI> specialProperties = - new HolderModel<SpecialPropertyI>(this, "specialProperties"); - - private final GameManagerI gameManager; - - public PortfolioModel(CashHolder holder, String id) { - super(holder, id); - this.owner = holder; - - gameManager = GameManager.getInstance(); - gameManager.addPortfolio(this); - - // change display style dependent on owner - if (owner instanceof PublicCompanyI) { - trainsModel.setAbbrList(false); - privates.setLineBreak(false); - } else if (owner instanceof Bank) { - trainsModel.setAbbrList(true); - } else if (owner instanceof Player) { - privates.setLineBreak(true); - } - } - - public void transferAssetsFrom(PortfolioModel otherPortfolio) { - - // Move trains - MoveUtils.objectMoveAll(otherPortfolio.getTrainList(), this.getTrainList()); - - // Move treasury certificates - MoveUtils.objectMoveAll(otherPortfolio.getCertificates(), this.getCertificates()); - } - - /** Low-level method, only to be called by the local addObject() method and by initialisation code. */ - public void addPrivate(PrivateCompanyI privateCompany, int position) { - - // FIXME: has to be rewritten - if (!Util.addToList(privateCompanies.view(), privateCompany, position)) return; - - privateCompany.setHolder(this); - log.debug("Adding " + privateCompany.getId() + " to portfolio of " - + name); - if (privateCompany.getSpecialProperties() != null) { - log.debug(privateCompany.getId() + " has special properties!"); - } else { - log.debug(privateCompany.getId() + " has no special properties"); - } - privates.notifyModel(); - updatePlayerWorth (); - } - - /** Low-level method, only to be called by the local addObject() method and by initialisation code. */ - public void addCertificate(PublicCertificateI certificate){ - addCertificate (certificate, new int[] {-1,-1,-1}); - } - - /** Low-level method, only to be called by the local addObject() method. */ - private void addCertificate(PublicCertificateI certificate, int[] position) { - // When undoing a company start, put the President back at the top. - if (certificate.isPresidentShare()) position = new int[] {0,0,0}; - - certificates.add(position[0], certificate); - - String companyName = certificate.getCompany().getId(); - if (!certPerCompany.containsKey(companyName)) { - certPerCompany.put(companyName, new ArrayList<PublicCertificateI>()); - } - - Util.addToList(certPerCompany.get(companyName), certificate, position[1]); - - String certTypeId = certificate.getTypeId(); - if (!certsPerType.containsKey(certTypeId)) { - certsPerType.put(certTypeId, new ArrayList<PublicCertificateI>()); - } - Util.addToList(certsPerType.get(certTypeId), certificate, position[2]); - - certificate.setPortfolio(this); - - getShareModel(certificate.getCompany()).addShare(certificate.getShare()); - updatePlayerWorth (); - } - - /** Low-level method, only to be called by the local addObject() method. */ - private boolean removePrivate(PrivateCompanyI privateCompany) { - boolean removed = privateCompanies.remove(privateCompany); - if (removed) { - privates.notifyModel(); - updatePlayerWorth (); - } - return removed; - } - - /** Low-level method, only to be called by the local addObject() method. */ - private void removeCertificate(PublicCertificateI certificate) { - certificates.remove(certificate); - - String companyName = certificate.getCompany().getId(); - - List<PublicCertificateI> certs = getCertificatesPerCompany(companyName); - certs.remove(certificate); - - String certTypeId = certificate.getTypeId(); - if (certsPerType.containsKey(certTypeId)) { - certsPerType.get(certTypeId).remove(0); - if (certsPerType.get(certTypeId).isEmpty()) { - certsPerType.remove(certTypeId); - } - } - - getShareModel(certificate.getCompany()).addShare( - -certificate.getShare()); - updatePlayerWorth (); - } - - protected void updatePlayerWorth () { - if (owner instanceof Player) { - ((Player)owner).updateWorth(); - } - } - - public CertificatesModel getShareModel(PublicCompanyI company) { - - if (!shareModelPerCompany.containsKey(company)) { - shareModelPerCompany.put(company, new CertificatesModel(this, company)); - } - return shareModelPerCompany.get(company); - } - - public ArrayListState<PrivateCompanyI> getPrivateCompanies() { - return privateCompanies; - } - - public ArrayListState<PublicCertificateI> getCertificates() { - return certificates; - } - - /** Get the number of certificates that count against the certificate limit */ - public float getCertificateCount() { - - float number = privateCompanies.size(); // May not hold for all games - PublicCompanyI comp; - - for (PublicCertificateI cert : certificates) { - comp = cert.getCompany(); - if (!comp.hasFloated() || !comp.hasStockPrice() - || !cert.getCompany().getCurrentSpace().isNoCertLimit()) - number += cert.getCertificateCount(); - } - return number; - } - - public Map<String, List<PublicCertificateI>> getCertsPerCompanyMap() { - return certPerCompany; - } - - public List<PublicCertificateI> getCertificatesPerCompany(String compName) { - if (certPerCompany.containsKey(compName)) { - return certPerCompany.get(compName); - } else { - // TODO: This is bad. If we don't find the company name - // we should check to see if certPerCompany has been loaded - // or possibly throw a config error. - return new ArrayList<PublicCertificateI>(); - } - } - - /** - * Find a certificate for a given company. - * - * @param company The public company for which a certificate is found. - * @param president Whether we look for a president or non-president - * certificate. If there is only one certificate, this parameter has no - * meaning. - * @return The certificate, or null if not found./ - */ - public PublicCertificateI findCertificate(PublicCompanyI company, - boolean president) { - return findCertificate(company, 1, president); - } - - /** Find a certificate for a given company. */ - public PublicCertificateI findCer... [truncated message content] |