package no.stelar7.api.l4j8.pojo.tournament;

import no.stelar7.api.l4j8.basic.constants.types.*;
import no.stelar7.api.l4j8.basic.exceptions.APIUnsupportedActionException;

import java.io.Serializable;

public class TournamentCodeParameters implements Serializable
{
    private static final long serialVersionUID = 6366533149651958130L;
    
    private SummonerIdParams        allowedSummonerIds;
    private TournamentMapType       mapType;
    private String                  metadata;
    private TournamentPickType      pickType;
    private TournamentSpectatorType spectatorType;
    private int                     teamSize;
    
    public TournamentCodeParameters()
    {
        // GSON needs an empty constructor to initialize..
    }
    
    public TournamentCodeParameters(final TournamentCodeUpdateParameters updateParams, final String metadata, final int teamSize)
    {
        this.allowedSummonerIds = new SummonerIdParams(updateParams.getAllowedParticipants());
        this.spectatorType = updateParams.getSpectatorType();
        this.pickType = updateParams.getPickType();
        this.mapType = updateParams.getMapType();
        this.metadata = metadata;
        this.teamSize = teamSize;
        
        
        if ((getTeamSize() > 1) && (getTeamSize() < 6) && ((getTeamSize() % 2) == 0))
        {
            throw new APIUnsupportedActionException("Cant create a match with unbalanced teams (note that teamsize / 2 must = allowedSummonerIds.size) (" + teamSize / 2 + " != " + getAllowedSummonerIds().getParticipants().size());
        }
    }
    
    /**
     * Optional list of participants in order to validate the players eligible to join the lobby.
     * NOTE: We currently do not enforce participants at the team level, but rather the aggregate of teamOne and teamTwo.
     * We may add the ability to enforce at the team level in the future.
     *
     * @return SummonerIdParams
     */
    public SummonerIdParams getAllowedSummonerIds()
    {
        return this.allowedSummonerIds;
    }
    
    public void setAllowedSummonerIds(final SummonerIdParams allowedSummonerIds)
    {
        this.allowedSummonerIds = allowedSummonerIds;
    }
    
    /**
     * The map type of the game. Valid values are SUMMONERS_RIFT, TWISTED_TREELINE, and HOWLING_ABYSS.
     *
     * @return TournamentMapType
     */
    public TournamentMapType getMapType()
    {
        return this.mapType;
    }
    
    public void setMapType(final TournamentMapType mapType)
    {
        this.mapType = mapType;
    }
    
    /**
     * Optional string that may contain any data in any format, if specified at all.
     * Used to denote any custom information about the game.
     *
     * @return string
     */
    public String getMetadata()
    {
        return this.metadata;
    }
    
    public void setMetadata(final String metadata)
    {
        this.metadata = metadata;
    }
    
    /**
     * The pick type of the game. Valid values are BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT.
     *
     * @return TournamentPickType
     */
    public TournamentPickType getPickType()
    {
        return this.pickType;
    }
    
    public void setPickType(final TournamentPickType pickType)
    {
        this.pickType = pickType;
    }
    
    /**
     * The spectator type of the game. Valid values are NONE, LOBBYONLY, ALL.
     *
     * @return TournamentSpectatorType
     */
    public TournamentSpectatorType getSpectatorType()
    {
        return this.spectatorType;
    }
    
    public void setSpectatorType(final TournamentSpectatorType spectatorType)
    {
        this.spectatorType = spectatorType;
    }
    
    /**
     * The team size of the game. Valid values are 1-5.
     *
     * @return int
     */
    public int getTeamSize()
    {
        return this.teamSize;
    }
    
    public void setTeamSize(final int teamSize)
    {
        this.teamSize = teamSize;
    }
    
    @Override
    public boolean equals(Object o)
    {
        if (this == o)
        {
            return true;
        }
        if (o == null || getClass() != o.getClass())
        {
            return false;
        }
        
        TournamentCodeParameters that = (TournamentCodeParameters) o;
        
        if (teamSize != that.teamSize)
        {
            return false;
        }
        if ((allowedSummonerIds != null) ? !allowedSummonerIds.equals(that.allowedSummonerIds) : (that.allowedSummonerIds != null))
        {
            return false;
        }
        if (mapType != that.mapType)
        {
            return false;
        }
        if ((metadata != null) ? !metadata.equals(that.metadata) : (that.metadata != null))
        {
            return false;
        }
        if (pickType != that.pickType)
        {
            return false;
        }
        return spectatorType == that.spectatorType;
    }
    
    @Override
    public int hashCode()
    {
        int result = allowedSummonerIds != null ? allowedSummonerIds.hashCode() : 0;
        result = 31 * result + (mapType != null ? mapType.hashCode() : 0);
        result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
        result = 31 * result + (pickType != null ? pickType.hashCode() : 0);
        result = 31 * result + (spectatorType != null ? spectatorType.hashCode() : 0);
        result = 31 * result + teamSize;
        return result;
    }
    
    @Override
    public String toString()
    {
        return "TournamentCodeParameters{" +
               "allowedSummonerIds=" + allowedSummonerIds +
               ", mapType=" + mapType +
               ", metadata='" + metadata + '\'' +
               ", pickType=" + pickType +
               ", spectatorType=" + spectatorType +
               ", teamSize=" + teamSize +
               '}';
    }
}

@@ -201,16 +201,39 @@
 izable;%0D
+%0Aimport java.util.Set;%0D
 %0A%0D%0Apubli
@@ -384,31 +384,31 @@
 rivate S
-ummonerIdParams
+et%3CLong%3E       
         
@@ -968,29 +968,8 @@
 s = 
-new SummonerIdParams(
 upda
@@ -1001,17 +1001,16 @@
 ipants()
-)
 ;%0D%0A     
@@ -1567,26 +1567,8 @@
 s().
-getParticipants().
 size
@@ -1965,31 +1965,24 @@
 public S
-ummonerIdParams
+et%3CLong%3E
  getAllo
@@ -2105,31 +2105,24 @@
 (final S
-ummonerIdParams
+et%3CLong%3E
  allowed

Update to match changes