From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>
--- src/net/sf/freecol/common/model/Specification.java | 29 ++++------------------ src/net/sf/freecol/common/model/Unit.java | 14 +---------- src/net/sf/freecol/common/model/UnitWas.java | 2 +- 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/src/net/sf/freecol/common/model/Specification.java b/src/net/sf/freecol/common/model/Specification.java index 950ea4d0049..0ca84faa35c 100644 --- a/src/net/sf/freecol/common/model/Specification.java +++ b/src/net/sf/freecol/common/model/Specification.java @@ -1661,28 +1661,6 @@ public final class Specification { } /** - * Gets the roles suitable for a REF unit. - * - * @param naval If true, choose roles for naval units, if not, land units. - * @return A list of {@code Role}s suitable for REF units. - */ - public List<Role> getREFRolesList(boolean naval) { - return transform(((naval) ? Stream.of(getDefaultRole()) - : getMilitaryRoles()), - r -> r.requiresAbility(Ability.REF_UNIT)); - } - - /** - * Gets the roles suitable for a REF unit as a stream. - * - * @param naval If true, choose roles for naval units, if not, land units. - * @return A stream of {@code Role}s suitable for REF units. - */ - public Stream<Role> getREFRoles(boolean naval) { - return getREFRolesList(naval).stream(); - } - - /** * Get a role with an ability. * * @param id The ability identifier to look for. @@ -1692,7 +1670,10 @@ public final class Specification { * ability, or null if none found. */ public Role getRoleWithAbility(String id, List<Role> roles) { - return find(getRoles(), r -> r.hasAbility(id)); + for (Role r : this.roles) + if (r.hasAbility(id)) + return r; + return null; } /** @@ -2030,7 +2011,7 @@ public final class Specification { } StrCat cat = new StrCat(" "); - for (Role r : getRoles()) + for (Role r : this.roles) cat.add(r.getId()); logger.info("Loading role backward compatibility fragment: " diff --git a/src/net/sf/freecol/common/model/Unit.java b/src/net/sf/freecol/common/model/Unit.java index 3f8b9b971c8..7aa3266f0fd 100644 --- a/src/net/sf/freecol/common/model/Unit.java +++ b/src/net/sf/freecol/common/model/Unit.java @@ -884,24 +884,12 @@ public class Unit extends GoodsLocation * available roles are used. * @return A list of available {@code Role}s. */ - public List<Role> getAvailableRolesList(List<Role> roles) { + public List<Role> getAvailableRoles(List<Role> roles) { if (roles == null) roles = getSpecification().getRoles(); return transform(roles, r -> roleIsAvailable(r)); } /** - * Filter a list of roles to return only those available to this unit, - * returning a stream. - * - * @param roles The list of {@code Role}s to filter, if null all - * available roles are used. - * @return A stream of available {@code Role}s. - */ - public Stream<Role> getAvailableRoles(List<Role> roles) { - return getAvailableRolesList(roles).stream(); - } - - /** * Get a military role for this unit. * * @return A military {@code Role}, or null if none found. diff --git a/src/net/sf/freecol/common/model/UnitWas.java b/src/net/sf/freecol/common/model/UnitWas.java index e6c5597a9f8..e482a6d87ca 100644 --- a/src/net/sf/freecol/common/model/UnitWas.java +++ b/src/net/sf/freecol/common/model/UnitWas.java @@ -201,7 +201,7 @@ public class UnitWas implements Comparable<UnitWas> { // we can still try our best by using the amount of equipment // the unit needs as a secondary criterion (favouring the // least equipped). - List<Role> roles = this.unit.getAvailableRolesList(null); + List<Role> roles = this.unit.getAvailableRoles(null); int cmp = ((UnitLocation)uw.loc).getUnitCapacity() - ((UnitLocation)this.loc).getUnitCapacity(); if (cmp == 0) { -- 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