Package net.sf.freecol.common.model
Class TileTypeChange
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.model.FreeColSpecObjectType
-
- net.sf.freecol.common.model.TileTypeChange
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Named,ObjectWithId
public class TileTypeChange extends FreeColSpecObjectType
A change in a tile type, including some bonus production when this occurs.
-
-
Field Summary
Fields Modifier and Type Field Description private TileTypefromThe original tile type.private static java.lang.StringFROM_TAGprivate static java.lang.StringGOODS_TYPE_TAGprivate AbstractGoodsproductionThe goods produced by the tile type change, e.g.private static java.lang.StringPRODUCTION_TAGstatic java.lang.StringTAGprivate TileTypetoThe destination tile type.private static java.lang.StringTO_TAGprivate static java.lang.StringVALUE_TAG-
Fields inherited from class net.sf.freecol.common.model.FreeColSpecObjectType
DELETE_TAG, EXTENDS_TAG, PRESERVE_TAG
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, logger, PARTIAL_ATTRIBUTE_TAG
-
-
Constructor Summary
Constructors Constructor Description TileTypeChange(FreeColXMLReader xr, Specification specification)Creates a newTileTypeChangeinstance.TileTypeChange(Specification specification)Create a new tile type change.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.booleanequals(java.lang.Object other)TileTypegetFrom()Gets the original tile type.AbstractGoodsgetProduction()Gets the production consequent to the type change.TileTypegetTo()Gets the destination tile type.java.lang.StringgetXMLTagName()Get the serialization tag for this object.inthashCode()protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.protected voidreadChildren(FreeColXMLReader xr)Reads the children of this object from an XML stream.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.protected voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObjectType
addScope, appliesTo, copyScopes, getDescriptionKey, getFeatureContainer, getIndex, getNameKey, getScopeList, getScopes, isAbstractType, readChild, removeScope, setIndex, toString
-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObject
getSpecification, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
from
private TileType from
The original tile type.
-
to
private TileType to
The destination tile type.
-
production
private AbstractGoods production
The goods produced by the tile type change, e.g. lumber when clearing a forest.
-
FROM_TAG
private static final java.lang.String FROM_TAG
- See Also:
- Constant Field Values
-
GOODS_TYPE_TAG
private static final java.lang.String GOODS_TYPE_TAG
- See Also:
- Constant Field Values
-
PRODUCTION_TAG
private static final java.lang.String PRODUCTION_TAG
- See Also:
- Constant Field Values
-
TO_TAG
private static final java.lang.String TO_TAG
- See Also:
- Constant Field Values
-
VALUE_TAG
private static final java.lang.String VALUE_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TileTypeChange
public TileTypeChange(Specification specification)
Create a new tile type change.- Parameters:
specification- TheSpecificationto refer to.
-
TileTypeChange
public TileTypeChange(FreeColXMLReader xr, Specification specification) throws javax.xml.stream.XMLStreamException
Creates a newTileTypeChangeinstance.- Parameters:
xr- TheFreeColXMLReaderto read from.specification- TheSpecificationto refer to.- Throws:
javax.xml.stream.XMLStreamException- if an error occurs
-
-
Method Detail
-
getFrom
public final TileType getFrom()
Gets the original tile type.- Returns:
- The original tile type.
-
getTo
public final TileType getTo()
Gets the destination tile type.- Returns:
- The destination tile type.
-
getProduction
public final AbstractGoods getProduction()
Gets the production consequent to the type change.- Returns:
- The consequent production.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyInin classFreeColSpecObjectType- Type Parameters:
T- TheFreeColObjectsubclass of the object to copy in.- Parameters:
other- The other object.- Returns:
- True if the copy in is succesful.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributesin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
writeChildren
protected void writeChildren(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream. To be overridden if required by any object that has children and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeChildrenin classFreeColSpecObjectType- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributesin classFreeColSpecObjectType- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChildren
protected void readChildren(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.- Overrides:
readChildrenin classFreeColSpecObjectType- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classFreeColObject
-
hashCode
public int hashCode()
- Overrides:
hashCodein classFreeColObject
-
-