Class EntityID

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, ID
    Direct Known Subclasses:
    UnitID

    public class EntityID
    extends IntegerID
    A class used to uniquely identify such objects as regions, ships or buildings by an integer. The representation of the integer depends on the system default defined in the IDBaseConverter class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int radix  
      • Fields inherited from class magellan.library.IntegerID

        id
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected EntityID​(int i, int radix)
      Constructs a new entity id based on a new Integer object created from the specified int.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EntityID clone()
      Returns a copy of this EntityID object.
      static EntityID createEntityID​(int value, int radix)
      Returns a (possibly) new EntityID object.
      static EntityID createEntityID​(java.lang.String s, int radix)
      Constructs a new entity id parsing the specified string for an integer using the specified radix.
      static EntityID createEntityID​(java.lang.String s, int inputRadix, int outputRadix)
      Constructs a new entity id parsing the specified string for an integer using the specified radix.
      int getRadix()
      Returns the radix which was used to create this ID.
      java.lang.String toString()
      Returns a string representation of this id which depends on the output of the IDBaseConverter class.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • radix

        protected final int radix
    • Constructor Detail

      • EntityID

        protected EntityID​(int i,
                           int radix)
        Constructs a new entity id based on a new Integer object created from the specified int.
        Parameters:
        i - id as integer form
        radix - the base
    • Method Detail

      • createEntityID

        public static EntityID createEntityID​(int value,
                                              int radix)
        Returns a (possibly) new EntityID object.
        Parameters:
        value - id as integer form
        radix - the base
        Returns:
        An EntityID object matching the given value and radix
      • createEntityID

        public static EntityID createEntityID​(java.lang.String s,
                                              int radix)
        Constructs a new entity id parsing the specified string for an integer using the specified radix. Effectively the same as calling createEntityID(s, radix, radix).
      • createEntityID

        public static EntityID createEntityID​(java.lang.String s,
                                              int inputRadix,
                                              int outputRadix)
        Constructs a new entity id parsing the specified string for an integer using the specified radix.
        Parameters:
        s - unit id as String
        inputRadix - base for transforming string to int
        outputRadix - base for the return value
        Returns:
        EntityID of the given string
        Throws:
        java.lang.NumberFormatException - if unit id is not parseable
      • getRadix

        public int getRadix()
        Returns the radix which was used to create this ID.
      • toString

        public java.lang.String toString()
        Returns a string representation of this id which depends on the output of the IDBaseConverter class.
        Specified by:
        toString in interface ID
        Overrides:
        toString in class IntegerID
        Returns:
        a String representation of the ID formatted in a user friendly manner.
      • clone

        public EntityID clone()
        Returns a copy of this EntityID object.
        Specified by:
        clone in interface ID
        Overrides:
        clone in class IntegerID