Class AIObject

    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • aiMain

        private final AIMain aiMain
        The AI this object exists within.
      • initialized

        protected boolean initialized
        Whether the object is initialized.
    • Constructor Detail

      • AIObject

        protected AIObject​(AIMain aiMain)
        Creates a new uninitialized AIObject.
        Parameters:
        aiMain - The main AI-object.
      • AIObject

        protected AIObject​(AIMain aiMain,
                           java.lang.String id)
        Creates a new uninitialized AIObject with a registerable AI identifier.
        Parameters:
        aiMain - The main AI-object.
        id - The object identifier.
        See Also:
        AIMain.addAIObject(String, AIObject)
    • Method Detail

      • isInitialized

        private final boolean isInitialized()
        Is this AI object initialized? That is: it has been fully initialized by a detailed constructor, or built with a simple constructor due to being referenced by another object, but then updated with FreeColObject.readFromXML(net.sf.freecol.common.io.FreeColXMLReader).
        Returns:
        True if this AIObject is initialized.
      • setInitialized

        public abstract void setInitialized()
        Set the initialized flag in this object. To be implemented by leaf classes, and called in their constructors plus the special case in readChild below where we resolve forward references.
      • getAIMain

        public final AIMain getAIMain()
        Convenience accessor for the main AI-object.
        Returns:
        The AIMain.
      • dispose

        public void dispose()
        Disposes this AIObject by removing the reference to this object from the enclosing AIMain.
      • isDisposed

        public final boolean isDisposed()
        Has this AIObject been disposed?
        Returns:
        True if this AIObject was disposed.
      • addAIObjectWithId

        protected final void addAIObjectWithId()
        Adds this object to the AI main if it has a non-null identifier.
      • checkIntegrity

        public Constants.IntegrityType checkIntegrity​(boolean fix,
                                                      LogBuilder lb)
        AIObjects need integrity checking too.
        Parameters:
        fix - If true, fix problems if possible.
        lb - A LogBuilder to log to.
        Returns:
        -1 if there are problems remaining, zero if problems were fixed, +1 if no problems found at all.
      • checkIntegrity

        public Constants.IntegrityType checkIntegrity​(boolean fix)
        Just do the check, short cut the logging.
        Parameters:
        fix - Fix problems if possible.
        Returns:
        Negative if there are problems remaining, zero if problems were fixed, positive if no problems found at all.
      • setSpecification

        public final void setSpecification​(Specification specification)
        Sets the specification for this object.
        Overrides:
        setSpecification in class FreeColObject
        Parameters:
        specification - The Specification to use.
      • getGame

        public final Game getGame()
        Gets the game this object belongs to.
        Overrides:
        getGame in class FreeColObject
        Returns:
        The Game this object belongs to.
      • setGame

        public final void setGame​(Game game)
        Sets the game object this object belongs to.
        Overrides:
        setGame in class FreeColObject
        Parameters:
        game - The Game to set.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class FreeColObject
        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.