Coverage Summary for Class: LobbyServerAccept (it.polimi.ingsw.Server.Messages.ServerResponses)

Class Class, % Method, % Line, %
LobbyServerAccept 0% (0/1) 0% (0/4) 0% (0/5)


1 package it.polimi.ingsw.Server.Messages.ServerResponses; 2  3 import it.polimi.ingsw.Server.Messages.ServerResponses.SupportStructures.LobbyInfo; 4 import it.polimi.ingsw.Server.Messages.ServerResponses.SupportStructures.StatusCode; 5  6 import java.io.Serial; 7 import java.util.List; 8  9 /** 10  * A {@link Response} to represent the output the controller gave on a previous 11  * {@link it.polimi.ingsw.Server.Messages.Events.Requests.DeclarePlayerRequest} 12  */ 13 public class LobbyServerAccept extends Response { 14  @Serial 15  private static final long serialVersionUID = 308L; 16  17  private final List<LobbyInfo> publicLobbies; 18  19  /** 20  * Construct the response 21  * 22  * @param statusCode the status code of the response 23  * @param openLobbies a {@link List} of open lobbies the client may join or null if the response is negative 24  */ 25  private LobbyServerAccept(StatusCode statusCode, List<LobbyInfo> openLobbies) { 26  super(statusCode); 27  this.publicLobbies = openLobbies; 28  } 29  30  /** 31  * Returns a failed status code response 32  * 33  * @return a failed status code response 34  */ 35  public static LobbyServerAccept fail() { 36  return new LobbyServerAccept(StatusCode.Fail, null); 37  } 38  39  /** 40  * Returns a successful status code response 41  * 42  * @param openLobbies a {@link List} of open lobbies the client may join 43  * @return a successful status code response 44  */ 45  public static LobbyServerAccept success(List<LobbyInfo> openLobbies) { 46  return new LobbyServerAccept(StatusCode.Success, openLobbies); 47  } 48  49  /** 50  * Get a list of the open lobbies the client may join 51  * 52  * @return a {@link List} of open lobbies the client may join or null if {@link #getStatusCode()} is {@link StatusCode#Fail} 53  */ 54  public List<LobbyInfo> getPublicLobbies() { 55  return publicLobbies; 56  } 57  58 }