java.lang.Object
fr.utc.miage.sporttrack.entity.user.communication.Friendship

@Entity public class Friendship extends Object
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 Details

    • Friendship

      public Friendship()
      No-argument constructor required by JPA.
    • Friendship

      public Friendship(Athlete initiator, Athlete recipient)
      Constructs a new friendship with the specified initiator and recipient. The status is set to FriendshipStatus.PENDING and the creation timestamp is set to the current time.
      Parameters:
      initiator - the athlete who sent the friendship request
      recipient - the athlete who received the friendship request
    • Friendship

      public Friendship(Athlete initiator, Athlete recipient, FriendshipStatus status)
      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 request
      recipient - the athlete who received the friendship request
      status - the initial FriendshipStatus of the relationship
  • Method Details

    • getId

      public Integer getId()
      Returns the unique identifier of this friendship.
      Returns:
      the friendship's database identifier
    • getInitiator

      public Athlete getInitiator()
      Returns the athlete who initiated the friendship request.
      Returns:
      the initiator Athlete
    • getRecipient

      public Athlete getRecipient()
      Returns the athlete who received the friendship request.
      Returns:
      the recipient Athlete
    • getStatus

      public FriendshipStatus getStatus()
      Returns the current status of this friendship.
      Returns:
      the FriendshipStatus
    • getCreatedAt

      public LocalDateTime getCreatedAt()
      Returns the creation timestamp of this friendship record.
      Returns:
      the creation timestamp
    • setStatus

      public void setStatus(FriendshipStatus status)
      Sets the status of this friendship.
      Parameters:
      status - the FriendshipStatus to assign
    • setCreatedAt

      public void setCreatedAt(LocalDateTime createdAt)
      Sets the creation timestamp of this friendship record.
      Parameters:
      createdAt - the creation timestamp to assign
    • setInitiator

      public void setInitiator(Athlete initiator)
      Sets the athlete who initiated the friendship request.
      Parameters:
      initiator - the initiator Athlete to assign
    • setRecipient

      public void setRecipient(Athlete recipient)
      Sets the athlete who received the friendship request.
      Parameters:
      recipient - the recipient Athlete to assign
    • equals

      public boolean equals(Object o)
      Compares this friendship to another object for equality based on the database identifier.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if the objects are considered equal, false otherwise
    • hashCode

      public int hashCode()
      Returns the hash code for this friendship, computed from the identifier.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value
    • toString

      public String toString()
      Returns a string representation of this friendship, including the identifier, initiator, recipient, status, and creation timestamp.
      Overrides:
      toString in class Object
      Returns:
      a descriptive string representation