Class NationType

    • Constructor Detail

      • NationType

        public NationType​(java.lang.String id,
                          Specification specification)
        Default nation type constructor.
        Parameters:
        id - The object identifier.
        specification - The Specification to refer to.
    • Method Detail

      • getSettlementTypes

        public final java.util.List<SettlementType> getSettlementTypes()
        Get the settlement types.
        Returns:
        A list of SettlementTypes.
      • setSettlementTypes

        public final void setSettlementTypes​(java.util.List<SettlementType> settlementTypes)
        Set the settlement types.
        Parameters:
        settlementTypes - A new list of SettlementTypes.
      • addSettlementType

        private void addSettlementType​(SettlementType settlementType)
        Add a settlement type.
        Parameters:
        settlementType - The SettlementType to add.
      • addSettlementTypes

        private void addSettlementTypes​(java.util.List<SettlementType> types)
        Add settlement types.
        Parameters:
        types - A list of SettlementTypes to add.
      • getCapitalType

        public SettlementType getCapitalType()
        Gets the settlement type for the national capital.
        Returns:
        The capital SettlementType.
      • getSettlementType

        public SettlementType getSettlementType​(boolean isCapital)
        Gets the settlement type for a settlement of this nation.
        Parameters:
        isCapital - If true, get the capital type.
        Returns:
        The settlement type.
      • getSettlementType

        public SettlementType getSettlementType​(java.lang.String id)
        Get a settlement type by identifier.
        Parameters:
        id - The object identifier.
        Returns:
        The settlement type.
      • getNumberOfSettlements

        public final NationType.SettlementNumber getNumberOfSettlements()
        Get the national number of settlements.
        Returns:
        The SettlementNumber.
      • getAggression

        public final NationType.AggressionLevel getAggression()
        Get the national aggression.
        Returns:
        The national AggressionLevel.
      • isEuropean

        public abstract boolean isEuropean()
        Whether this is a EuropeanNation, i.e. a player or a REF.
        Returns:
        True if this is an European nation.
      • isIndian

        public abstract boolean isIndian()
        Whether this is a IndianNation.
        Returns:
        True if this is a native nation.
      • isREF

        public abstract boolean isREF()
        Whether this is a EuropeanREFNation.
        Returns:
        True if this is a REF nation.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class FreeColSpecObjectType
        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 FreeColObject
        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 FreeColSpecObjectType
        Parameters:
        xw - The FreeColXMLWriter to 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:
        readAttributes in class FreeColSpecObjectType
        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 FreeColSpecObjectType
        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 FreeColSpecObjectType
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.