Class PlayerNodes

java.lang.Object
org.xxdc.oss.example.PlayerNodes
All Implemented Interfaces:
Serializable

public class PlayerNodes extends Object implements Serializable
Represents a collection of PlayerNode instances, providing methods to manage and render the players.

The PlayerNodes class maintains a SequencedMap of PlayerNode instances, indexed by their unique player marker. It also maintains a list of the player markers in the order they were added.

The class provides methods to retrieve players by index, get the next player index, render the player information, and close any AutoCloseable players.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new PlayerNodes instance with an initial capacity of 2 for both the player map and the player marker list.
  • Method Summary

    Modifier and Type
    Method
    Description
    byIndex(int index)
    Returns the PlayerNode instance at the specified index in the ordered list of players.
    void
     
    int
    nextPlayerIndex(int index)
    Returns the index of the next player in the ordered list of players.
    of(PlayerNode... players)
    Creates a new PlayerNodes instance and adds the provided PlayerNode instances to it.
    Returns a list of all the player markers in the PlayerNodes instance.
    Returns a comma-separated string of all the player markers in the PlayerNodes instance.
    void
    Renders a list of players, logging their player identifiers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlayerNodes

      public PlayerNodes()
      Constructs a new PlayerNodes instance with an initial capacity of 2 for both the player map and the player marker list.
  • Method Details

    • of

      public static PlayerNodes of(PlayerNode... players)
      Creates a new PlayerNodes instance and adds the provided PlayerNode instances to it.
      Parameters:
      players - the PlayerNode instances to add to the new PlayerNodes instance
      Returns:
      a new PlayerNodes instance containing the provided PlayerNode instances
    • byIndex

      public PlayerNode byIndex(int index)
      Returns the PlayerNode instance at the specified index in the ordered list of players.
      Parameters:
      index - the index of the player to retrieve
      Returns:
      the PlayerNode instance at the specified index
    • nextPlayerIndex

      public int nextPlayerIndex(int index)
      Returns the index of the next player in the ordered list of players. If the current index is the last player, it returns 0 to wrap around to the first player.
      Parameters:
      index - the current index of the player
      Returns:
      the index of the next player in the ordered list
    • render

      public void render()
      Renders a list of players, logging their player identifiers. This method is used to display information about the players in the PlayerNodes instance.
    • playerMarkers

      public String playerMarkers()
      Returns a comma-separated string of all the player markers in the PlayerNodes instance.
      Returns:
      a string containing all the player markers
    • playerMarkerList

      public List<String> playerMarkerList()
      Returns a list of all the player markers in the PlayerNodes instance.
      Returns:
      a list of player markers
    • close

      public void close()