Class EuropeanNationType

  • All Implemented Interfaces:
    java.lang.Comparable<FreeColObject>, Named, ObjectWithId

    public class EuropeanNationType
    extends NationType
    Represents one of the European nations present in the game, i.e. both REFs and possible human players.
    • Field Detail

      • ref

        private boolean ref
        Whether this is an REF Nation.
      • startingUnitMap

        private final java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​AbstractUnit>> startingUnitMap
        Stores the starting units of this Nation at various difficulties.
      • EXPERT_STARTING_UNITS_TAG

        private static final java.lang.String EXPERT_STARTING_UNITS_TAG
        See Also:
        Constant Field Values
    • Constructor Detail

      • EuropeanNationType

        public EuropeanNationType​(java.lang.String id,
                                  Specification specification)
        Create a new European nation type.
        Parameters:
        id - The object identifier.
        specification - The Specification to refer to.
    • Method Detail

      • getStartingUnitMap

        protected java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​AbstractUnit>> getStartingUnitMap()
        Get the starting unit map.
        Returns:
        The map of national starting units by difficulty.
      • setStartingUnitMap

        protected void setStartingUnitMap​(java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​AbstractUnit>> startingUnitMap)
        Set the starting unit map.
        Parameters:
        startingUnitMap - The new map of national starting units.
      • getMapKey

        private java.lang.String getMapKey​(boolean b)
        Get the map key, either expert or default, according to a boolean.
        Parameters:
        b - The boolean to test.
        Returns:
        The map key.
      • getStartingUnits

        public java.util.List<AbstractUnit> getStartingUnits()
        Gets the starting units for this nation type.
        Returns:
        A list of AbstractUnits to start with.
      • getStartingUnits

        public java.util.List<AbstractUnit> getStartingUnits​(java.lang.String key)
        Gets a list of this Nation's starting units at the given difficulty.
        Parameters:
        key - The value of the expert-starting-units field.
        Returns:
        A list of AbstractUnits to start with.
      • addStartingUnit

        private void addStartingUnit​(java.lang.String id,
                                     AbstractUnit unit,
                                     boolean expert)
        Add a starting unit.
        Parameters:
        id - The unit identifier.
        unit - The AbstractUnit to add.
        expert - Is this an expert unit?
      • isREF

        public final boolean isREF()
        Is this a REF nation type?
        Specified by:
        isREF in class NationType
        Returns:
        True if this is a REF nation type.
      • isEuropean

        public boolean isEuropean()
        Is this a European nation type?
        Specified by:
        isEuropean in class NationType
        Returns:
        True.
      • isIndian

        public boolean isIndian()
        Is this a native nation type?
        Specified by:
        isIndian in class NationType
        Returns:
        False.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class NationType
        Type Parameters:
        T - The FreeColObject subclass 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:
        writeAttributes in class NationType
        Parameters:
        xw - The FreeColXMLWriter to 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:
        writeChildren in class NationType
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • writeUnit

        private void writeUnit​(FreeColXMLWriter xw,
                               java.lang.String id,
                               AbstractUnit au,
                               boolean expert)
                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • readAttributes

        protected void readAttributes​(FreeColXMLReader xr)
                               throws javax.xml.stream.XMLStreamException
        Reads the attributes of this object from an XML stream.
        Overrides:
        readAttributes in class NationType
        Parameters:
        xr - The FreeColXMLReader to 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:
        readChildren in class NationType
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • readChild

        protected void readChild​(FreeColXMLReader xr)
                          throws javax.xml.stream.XMLStreamException
        Reads a single child object. Subclasses must override to read their enclosed elements. This particular instance of the routine always throws XMLStreamException because we should never arrive here. However it is very useful to always call super.readChild() when an unexpected tag is encountered, as the exception thrown here provides some useful debugging context.
        Overrides:
        readChild in class NationType
        Parameters:
        xr - The FreeColXMLReader to 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:
        getXMLTagName in class FreeColObject
        Returns:
        The tag.