From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>
--- .../client/gui/panel/report/ReportRequirementsPanel.java | 2 +- src/net/sf/freecol/common/model/Building.java | 16 ++++++++-------- src/net/sf/freecol/common/model/ColonyTile.java | 10 +++++----- src/net/sf/freecol/common/model/ProductionType.java | 16 ++++++++-------- src/net/sf/freecol/common/model/WorkLocation.java | 12 ++++++------ src/net/sf/freecol/server/model/ServerBuilding.java | 4 ++-- test/src/net/sf/freecol/common/model/BuildingTest.java | 2 +- .../sf/freecol/common/model/ColonyProductionTest.java | 2 +- .../net/sf/freecol/common/model/ProductionTypeTest.java | 4 ++-- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/net/sf/freecol/client/gui/panel/report/ReportRequirementsPanel.java b/src/net/sf/freecol/client/gui/panel/report/ReportRequirementsPanel.java index b6823509b74..c95cfcfbf7a 100644 --- a/src/net/sf/freecol/client/gui/panel/report/ReportRequirementsPanel.java +++ b/src/net/sf/freecol/client/gui/panel/report/ReportRequirementsPanel.java @@ -161,7 +161,7 @@ public final class ReportRequirementsPanel extends ReportPanel { } for (Building building : colony.getBuildings()) { - for (AbstractGoods output : iterable(building.getOutputs())) { + for (AbstractGoods output : building.getOutputs()) { GoodsType goodsType = output.getType(); UnitType expert = spec.getExpertForProducing(goodsType); diff --git a/src/net/sf/freecol/common/model/Building.java b/src/net/sf/freecol/common/model/Building.java index e07c180fc93..b3774d3ffa9 100644 --- a/src/net/sf/freecol/common/model/Building.java +++ b/src/net/sf/freecol/common/model/Building.java @@ -260,8 +260,8 @@ public class Building extends WorkLocation // First, calculate the nominal production ratios. if (canAutoProduce()) { // Autoproducers are special - for (AbstractGoods output : transform(getOutputs(), - AbstractGoods::isPositive)) { + for (AbstractGoods output : getOutputs()) { + if (!output.isPositive()) continue; final GoodsType goodsType = output.getType(); int available = getColony().getGoodsCount(goodsType); if (available >= capacity) { @@ -281,7 +281,7 @@ public class Building extends WorkLocation } } } else { - for (AbstractGoods output : iterable(getOutputs())) { + for (AbstractGoods output : getOutputs()) { final GoodsType goodsType = output.getType(); float production = sum(getUnits(), u -> getUnitProduction(u, goodsType)); @@ -299,7 +299,7 @@ public class Building extends WorkLocation } // Then reduce the minimum ratio if some input is in short supply. - for (AbstractGoods input : iterable(getInputs())) { + for (AbstractGoods input : getInputs()) { long required = (long)Math.floor(input.getAmount() * minimumRatio); long available = getAvailable(input.getType(), inputs); // Do not allow auto-production to go negative. @@ -327,7 +327,7 @@ public class Building extends WorkLocation // Check whether there is space enough to store the goods // produced in order to avoid excess production. if (avoidOverflow) { - for (AbstractGoods output : iterable(getOutputs())) { + for (AbstractGoods output : getOutputs()) { double production = output.getAmount() * minimumRatio; if (production <= 0) continue; double headroom = (double)capacity @@ -346,7 +346,7 @@ public class Building extends WorkLocation } final double epsilon = 0.0001; - for (AbstractGoods input : iterable(getInputs())) { + for (AbstractGoods input : getInputs()) { GoodsType type = input.getType(); // maximize consumption int consumption = (int)Math.floor(input.getAmount() @@ -358,7 +358,7 @@ public class Building extends WorkLocation result.addMaximumConsumption(new AbstractGoods(type, maximumConsumption)); } } - for (AbstractGoods output : iterable(getOutputs())) { + for (AbstractGoods output : getOutputs()) { GoodsType type = output.getType(); // minimize production, but add a magic little something // to counter rounding errors @@ -612,7 +612,7 @@ public class Building extends WorkLocation */ @Override public List<AbstractGoods> getConsumedGoods() { - return toList(getInputs()); + return getInputs(); } /** diff --git a/src/net/sf/freecol/common/model/ColonyTile.java b/src/net/sf/freecol/common/model/ColonyTile.java index 7be9951cdff..6447fa597e3 100644 --- a/src/net/sf/freecol/common/model/ColonyTile.java +++ b/src/net/sf/freecol/common/model/ColonyTile.java @@ -160,7 +160,7 @@ public class ColonyTile extends WorkLocation { final Colony colony = getColony(); ProductionInfo pi = new ProductionInfo(); if (isColonyCenterTile()) { - forEach(getOutputs(), output -> { + for (AbstractGoods output : getOutputs()) { boolean onlyNaturalImprovements = getSpecification() .getBoolean(GameOptions.ONLY_NATURAL_IMPROVEMENTS) && !output.getType().isFoodType(); @@ -174,13 +174,13 @@ public class ColonyTile extends WorkLocation { AbstractGoods production = new AbstractGoods(output.getType(), potential); pi.addProduction(production); - }); + } } else { - forEach(map(getOutputs(), AbstractGoods::getType), - gt -> { + for (AbstractGoos ag : getOutputs()) { + GoodsType gt = ag.getType(); int n = sum(getUnits(), u -> getUnitProduction(u, gt)); if (n > 0) pi.addProduction(new AbstractGoods(gt, n)); - }); + } } return pi; } diff --git a/src/net/sf/freecol/common/model/ProductionType.java b/src/net/sf/freecol/common/model/ProductionType.java index 5cb3091e8cd..f6a769de9c0 100644 --- a/src/net/sf/freecol/common/model/ProductionType.java +++ b/src/net/sf/freecol/common/model/ProductionType.java @@ -21,10 +21,10 @@ package net.sf.freecol.common.model; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Stream; import javax.xml.stream.XMLStreamException; @@ -149,9 +149,9 @@ public class ProductionType extends FreeColSpecObject { * * @return A stream of the input {@code AbstractGoods}. */ - public final Stream<AbstractGoods> getInputs() { - return (inputs == null) ? Stream.<AbstractGoods>empty() - : inputs.stream(); + public final List<AbstractGoods> getInputs() { + return (inputs == null) ? Collections.<AbstractGoods>emptyList() + : inputs; } /** @@ -177,11 +177,11 @@ public class ProductionType extends FreeColSpecObject { /** * Get the output goods. * - * @return A stream of the output {@code AbstractGoods}. + * @return A {@code List} of the output {@code AbstractGoods}. */ - public final Stream<AbstractGoods> getOutputs() { - return (outputs == null) ? Stream.<AbstractGoods>empty() - : outputs.stream(); + public final List<AbstractGoods> getOutputs() { + return (outputs == null) ? Collections.<AbstractGoods>emptyList() + : outputs; } /** diff --git a/src/net/sf/freecol/common/model/WorkLocation.java b/src/net/sf/freecol/common/model/WorkLocation.java index 67e01daf317..c76c2f5a35c 100644 --- a/src/net/sf/freecol/common/model/WorkLocation.java +++ b/src/net/sf/freecol/common/model/WorkLocation.java @@ -410,10 +410,10 @@ public abstract class WorkLocation extends UnitLocation /** * Get the {@code AbstractGoods} consumed by this work location. * - * @return A stream of {@code AbstractGoods} consumed. + * @return A {@code List} of {@code AbstractGoods} consumed. */ - public Stream<AbstractGoods> getInputs() { - return (productionType == null) ? Stream.<AbstractGoods>empty() + public List<AbstractGoods> getInputs() { + return (productionType == null) ? Collections.<AbstractGoods>emptyList() : productionType.getInputs(); } @@ -422,8 +422,8 @@ public abstract class WorkLocation extends UnitLocation * * @return A stream of {@code AbstractGoods} produced. */ - public Stream<AbstractGoods> getOutputs() { - return (productionType == null) ? Stream.<AbstractGoods>empty() + public List<AbstractGoods> getOutputs() { + return (productionType == null) ? Collections.<AbstractGoods>emptyList() : productionType.getOutputs(); } @@ -444,7 +444,7 @@ public abstract class WorkLocation extends UnitLocation * @return True if there are any inputs. */ public boolean hasInputs() { - return any(getInputs()); + return getInputs().size() > 0; } /** diff --git a/src/net/sf/freecol/server/model/ServerBuilding.java b/src/net/sf/freecol/server/model/ServerBuilding.java index e815be6337a..7691ff96981 100644 --- a/src/net/sf/freecol/server/model/ServerBuilding.java +++ b/src/net/sf/freecol/server/model/ServerBuilding.java @@ -219,8 +219,8 @@ public class ServerBuilding extends Building implements ServerModelObject { */ public void csCheckMissingInput(ProductionInfo pi, ChangeSet cs) { if (!canAutoProduce() && pi.getProduction().isEmpty()) { - for (GoodsType gt : transform(getInputs(), alwaysTrue(), - AbstractGoods::getType)) { + for (AbstractGoods ag : getInputs()) { + GoodsType gt = ag.getType(); cs.addMessage(getOwner(), new ModelMessage(ModelMessage.MessageType.MISSING_GOODS, "model.building.notEnoughInput", diff --git a/test/src/net/sf/freecol/common/model/BuildingTest.java b/test/src/net/sf/freecol/common/model/BuildingTest.java index e76063613d7..ec8585015e5 100644 --- a/test/src/net/sf/freecol/common/model/BuildingTest.java +++ b/test/src/net/sf/freecol/common/model/BuildingTest.java @@ -990,7 +990,7 @@ public class BuildingTest extends FreeColTestCase { for (Building building : colony.getBuildings()) { clearWorkLocation(building); unit.setLocation(building); - for (AbstractGoods output : iterable(building.getOutputs())) { + for (AbstractGoods output : building.getOutputs()) { GoodsType outputType = output.getType(); for (UnitType type : transform(spec().getUnitTypeList(), ut -> (building.getType().canAdd(ut) diff --git a/test/src/net/sf/freecol/common/model/ColonyProductionTest.java b/test/src/net/sf/freecol/common/model/ColonyProductionTest.java index 0ced7597b5b..3914b710a60 100644 --- a/test/src/net/sf/freecol/common/model/ColonyProductionTest.java +++ b/test/src/net/sf/freecol/common/model/ColonyProductionTest.java @@ -221,7 +221,7 @@ public class ColonyProductionTest extends FreeColTestCase { Unit unit = colony.getFirstUnit(); unit.setLocation(colony.getWorkLocationFor(unit, bellsType)); - List<AbstractGoods> outputs = toList(pasture.getOutputs()); + List<AbstractGoods> outputs = pasture.getOutputs(); assertEquals(1, outputs.size()); assertEquals(horsesType, outputs.get(0).getType()); diff --git a/test/src/net/sf/freecol/common/model/ProductionTypeTest.java b/test/src/net/sf/freecol/common/model/ProductionTypeTest.java index 060952cc380..876fdf4220d 100644 --- a/test/src/net/sf/freecol/common/model/ProductionTypeTest.java +++ b/test/src/net/sf/freecol/common/model/ProductionTypeTest.java @@ -216,14 +216,14 @@ public class ProductionTypeTest extends FreeColTestCase { Map<GoodsType, Integer> outputs, List<ProductionType> productionTypes) { for (ProductionType productionType : productionTypes) { - for (AbstractGoods ag : toList(productionType.getInputs())) { + for (AbstractGoods ag : productionType.getInputs()) { Integer i = inputs.get(ag.getType()); assertNotNull("Input expected for " + ag.getType(), i); assertEquals("Input amount mismatch for " + ag.getType(), i.intValue(), ag.getAmount()); inputs.remove(ag.getType()); } - for (AbstractGoods ag : toList(productionType.getOutputs())) { + for (AbstractGoods ag : productionType.getOutputs()) { Integer i = outputs.get(ag.getType()); assertNotNull("Output expected for " + ag.getType(), i); assertEquals("Output amount mismatch for " + ag.getType(), -- 2.11.0.rc0.7.gbe5a750 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Freecol-developers mailing list Freecol-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freecol-developers