Class Friendship
java.lang.Object
fr.utc.miage.sporttrack.entity.user.communication.Friendship
JPA entity representing a friendship relationship between two athletes
within the SportTrack application.
A friendship has an initiator (the athlete who sent the request) and a
recipient (the athlete who received it). The relationship progresses through
statuses defined by FriendshipStatus, from PENDING to
ACCEPTED, REJECTED, or BLOCKED.
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionNo-argument constructor required by JPA.Friendship(Athlete initiator, Athlete recipient) Constructs a new friendship with the specified initiator and recipient.Friendship(Athlete initiator, Athlete recipient, FriendshipStatus status) Constructs a new friendship with the specified initiator, recipient, and initial status. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this friendship to another object for equality based on the database identifier.Returns the creation timestamp of this friendship record.getId()Returns the unique identifier of this friendship.Returns the athlete who initiated the friendship request.Returns the athlete who received the friendship request.Returns the current status of this friendship.inthashCode()Returns the hash code for this friendship, computed from the identifier.voidsetCreatedAt(LocalDateTime createdAt) Sets the creation timestamp of this friendship record.voidsetInitiator(Athlete initiator) Sets the athlete who initiated the friendship request.voidsetRecipient(Athlete recipient) Sets the athlete who received the friendship request.voidsetStatus(FriendshipStatus status) Sets the status of this friendship.toString()Returns a string representation of this friendship, including the identifier, initiator, recipient, status, and creation timestamp.
-
Constructor Details
-
Friendship
public Friendship()No-argument constructor required by JPA. -
Friendship
Constructs a new friendship with the specified initiator and recipient. The status is set toFriendshipStatus.PENDINGand the creation timestamp is set to the current time.- Parameters:
initiator- the athlete who sent the friendship requestrecipient- the athlete who received the friendship request
-
Friendship
Constructs a new friendship with the specified initiator, recipient, and initial status. The creation timestamp is set to the current time.- Parameters:
initiator- the athlete who sent the friendship requestrecipient- the athlete who received the friendship requeststatus- the initialFriendshipStatusof the relationship
-
-
Method Details
-
getId
Returns the unique identifier of this friendship.- Returns:
- the friendship's database identifier
-
getInitiator
Returns the athlete who initiated the friendship request.- Returns:
- the initiator
Athlete
-
getRecipient
Returns the athlete who received the friendship request.- Returns:
- the recipient
Athlete
-
getStatus
Returns the current status of this friendship.- Returns:
- the
FriendshipStatus
-
getCreatedAt
Returns the creation timestamp of this friendship record.- Returns:
- the creation timestamp
-
setStatus
Sets the status of this friendship.- Parameters:
status- theFriendshipStatusto assign
-
setCreatedAt
Sets the creation timestamp of this friendship record.- Parameters:
createdAt- the creation timestamp to assign
-
setInitiator
Sets the athlete who initiated the friendship request.- Parameters:
initiator- the initiatorAthleteto assign
-
setRecipient
Sets the athlete who received the friendship request.- Parameters:
recipient- the recipientAthleteto assign
-
equals
Compares this friendship to another object for equality based on the database identifier. -
hashCode
public int hashCode()Returns the hash code for this friendship, computed from the identifier. -
toString
Returns a string representation of this friendship, including the identifier, initiator, recipient, status, and creation timestamp.
-