Package net.sf.freecol.common.model
Interface Location
-
- All Superinterfaces:
ObjectWithId
- All Known Implementing Classes:
Building
,Colony
,ColonyTile
,Europe
,GoodsLocation
,HighSeas
,IndianSettlement
,Map
,ServerBuilding
,ServerColony
,ServerColonyTile
,ServerEurope
,ServerIndianSettlement
,ServerUnit
,Settlement
,Tile
,Unit
,UnitLocation
,WorkLocation
public interface Location extends ObjectWithId
A place where aLocatable
can be put.- See Also:
Locatable
-
-
Field Summary
Fields Modifier and Type Field Description static int
LOCATION_RANK_EUROPE
static int
LOCATION_RANK_HIGHSEAS
static int
LOCATION_RANK_NOWHERE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
add(Locatable locatable)
Adds aLocatable
to this Location.boolean
canAdd(Locatable locatable)
Checks whether or not the specified locatable may be added to thisLocation
.boolean
contains(Locatable locatable)
Checks if thisLocation
contains the specifiedLocatable
.Colony
getColony()
Get the colony at this location.GoodsContainer
getGoodsContainer()
Gets theGoodsContainer
thisLocation
use for storing it's goods.java.lang.String
getId()
Gets the identifier of thisLocation
.IndianSettlement
getIndianSettlement()
Gets the native settlement at this location.default java.lang.String
getLocationImageKey()
Get an image key for this location.StringTemplate
getLocationLabel()
Get a label for this location.StringTemplate
getLocationLabelFor(Player player)
Get a label for this location for a particular player.int
getRank()
Get a integer for this location, for the benefit of location comparators.Settlement
getSettlement()
Gets theSettlement
thisLocation
is located in.Tile
getTile()
Gets the Tile associated with this Location.int
getUnitCount()
Gets the number of units at this Location.java.util.List<Unit>
getUnitList()
Gets a list of all the units present at this location.java.util.stream.Stream<Unit>
getUnits()
Gets a stream of all the units present at this location.static int
rankOf(Location loc)
Static front end to getRank.boolean
remove(Locatable locatable)
Removes aLocatable
from this Location.java.lang.String
toShortString()
Get a short description of this location.Location
up()
Promote this location to a more meaningful one if possible.static Location
upLoc(Location loc)
Static frontend to up().
-
-
-
Field Detail
-
LOCATION_RANK_NOWHERE
static final int LOCATION_RANK_NOWHERE
- See Also:
- Constant Field Values
-
LOCATION_RANK_EUROPE
static final int LOCATION_RANK_EUROPE
- See Also:
- Constant Field Values
-
LOCATION_RANK_HIGHSEAS
static final int LOCATION_RANK_HIGHSEAS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
java.lang.String getId()
Gets the identifier of thisLocation
.- Specified by:
getId
in interfaceObjectWithId
- Returns:
- The object identifier.
- See Also:
FreeColObject.getId()
-
getTile
Tile getTile()
Gets the Tile associated with this Location.- Returns:
- The Tile associated with this Location, or null if none found.
-
getLocationLabel
StringTemplate getLocationLabel()
Get a label for this location.- Returns:
- A label for this location.
-
getLocationLabelFor
StringTemplate getLocationLabelFor(Player player)
Get a label for this location for a particular player.- Parameters:
player
- ThePlayer
to return the name for.- Returns:
- A label for this location.
-
add
boolean add(Locatable locatable)
Adds aLocatable
to this Location.- Parameters:
locatable
- TheLocatable
to add to this Location.- Returns:
- True if the locatable was added.
-
remove
boolean remove(Locatable locatable)
Removes aLocatable
from this Location.- Parameters:
locatable
- TheLocatable
to remove from this Location.- Returns:
- True if the locatable was removed.
-
contains
boolean contains(Locatable locatable)
Checks if thisLocation
contains the specifiedLocatable
.- Parameters:
locatable
- TheLocatable
to test the presence of.- Returns:
- True if the locatable is present at this location.
-
canAdd
boolean canAdd(Locatable locatable)
Checks whether or not the specified locatable may be added to thisLocation
.- Parameters:
locatable
- TheLocatable
to add.- Returns:
- True if the locatable can be added to this location.
-
getUnitCount
int getUnitCount()
Gets the number of units at this Location.- Returns:
- The number of units at this Location.
-
getUnits
java.util.stream.Stream<Unit> getUnits()
Gets a stream of all the units present at this location.- Returns:
- A stream of all the units at this location.
-
getUnitList
java.util.List<Unit> getUnitList()
Gets a list of all the units present at this location.- Returns:
- A list of all the units at this location.
-
getGoodsContainer
GoodsContainer getGoodsContainer()
Gets theGoodsContainer
thisLocation
use for storing it's goods.- Returns:
- The
GoodsContainer
ornull
if theLocation
cannot store any goods.
-
getSettlement
Settlement getSettlement()
Gets theSettlement
thisLocation
is located in.- Returns:
- The associated
Settlement
, or null if none.
-
getColony
Colony getColony()
Get the colony at this location.- Returns:
- A
Colony
at this location if any, or null if none found.
-
getIndianSettlement
IndianSettlement getIndianSettlement()
Gets the native settlement at this location.- Returns:
- The
IndianSettlement
at this location if any, or null if none found.
-
up
Location up()
Promote this location to a more meaningful one if possible. For example: a settlement is more meaningful than the tile it occupies.- Returns:
- A more meaningful
Location
, or this one.
-
getRank
int getRank()
Get a integer for this location, for the benefit of location comparators.- Returns:
- A suitable integer.
-
toShortString
java.lang.String toShortString()
Get a short description of this location.- Returns:
- A short description.
-
upLoc
static Location upLoc(Location loc)
Static frontend to up().- Parameters:
loc
- TheLocation
to improve.- Returns:
- The improved
Location
.
-
rankOf
static int rankOf(Location loc)
Static front end to getRank.- Parameters:
loc
- ALocation
to check.- Returns:
- The integer rank of the given location.
-
getLocationImageKey
default java.lang.String getLocationImageKey()
Get an image key for this location.- Returns:
- A key for image lookup, null by default.
-
-