java.lang.Object
java.lang.Record
edu.ntnu.idatt1002.k2g05.controllers.opentournament.utils.MatchPair

public record MatchPair(Match m1, Match m2) extends Record
Record for holding a match pair. The reson for heaving a match pair is because of duplicates in the program. Say when a player "A" plays against another player "B", player "B" will also have a Match against player "A"
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a MatchPair record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Method for getting a match given the one of the players in the pair, one should check if the player is in the list before doing this.
    Method for getting the other match in the match pair given a match.
    final int
    Returns a hash code value for this object.
    m1()
    Returns the value of the m1 record component.
    m2()
    Returns the value of the m2 record component.
    boolean
    Method for checking if a given match is in a pair.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MatchPair

      public MatchPair(Match m1, Match m2)
      Creates an instance of a MatchPair record class.
      Parameters:
      m1 - the value for the m1 record component
      m2 - the value for the m2 record component
  • Method Details

    • matchInPair

      public boolean matchInPair(Match match)
      Method for checking if a given match is in a pair.
      Parameters:
      match - to check with
      Returns:
      true if match is in the pair
    • getOtherMatch

      public Match getOtherMatch(Match match)
      Method for getting the other match in the match pair given a match. You should check if a match is in the pair before doing this.
      Parameters:
      match - to get th other of
      Returns:
      the other match
      Throws:
      NoSuchElementException - if the match is not in the pair.
    • getMatchByPlayer

      public Match getMatchByPlayer(Player player)
      Method for getting a match given the one of the players in the pair, one should check if the player is in the list before doing this.
      Parameters:
      player - to find match with
      Returns:
      the match
      Throws:
      NoSuchElementException - if there is no match give the player.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • m1

      public Match m1()
      Returns the value of the m1 record component.
      Returns:
      the value of the m1 record component
    • m2

      public Match m2()
      Returns the value of the m2 record component.
      Returns:
      the value of the m2 record component