Record Class MatchPair
java.lang.Object
java.lang.Record
edu.ntnu.idatt1002.k2g05.controllers.opentournament.utils.MatchPair
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 -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.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.getOtherMatch
(Match match) Method for getting the other match in the match pair given a match.final int
hashCode()
Returns a hash code value for this object.m1()
Returns the value of them1
record component.m2()
Returns the value of them2
record component.boolean
matchInPair
(Match match) Method for checking if a given match is in a pair.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
MatchPair
Creates an instance of aMatchPair
record class.- Parameters:
m1
- the value for them1
record componentm2
- the value for them2
record component
-
-
Method Details
-
matchInPair
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
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
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
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
m1
Returns the value of them1
record component.- Returns:
- the value of the
m1
record component
-
m2
Returns the value of them2
record component.- Returns:
- the value of the
m2
record component
-