/** * Convenience function to check if there is an output for a given goods type in a collection of * production types. * * @param goodsType The <code>GoodsType</code> to use. * @param types A list of <code>ProductionType</code>s to consider. * @return The most productive output that produces the goods type, or null if none found. */ public static boolean canProduce(GoodsType goodsType, Collection<ProductionType> types) { for (ProductionType productionType : types) { AbstractGoods output = AbstractGoods.findByType(goodsType, productionType.getOutputs()); if (output != null) return true; } return false; }
/** * Get the goods of the given goods type in this production type. * * @param goodsType The <code>GoodsType</code> to check. * @return The <code>AbstractGoods</code> output if any, otherwise null. */ public AbstractGoods getOutput(GoodsType goodsType) { if (outputs != null) { AbstractGoods output = AbstractGoods.findByType(goodsType, outputs); if (output != null) return output; } return null; }