java.lang.Object
ch.bztf.m226blb1.Database.Entities.Post

@Entity public class Post extends Object
Root entity for the posts.
See Also:
  • Constructor Details

    • Post

      protected Post()
      Default constructor. Used by JPA.
      Implementation Requirements:
      This will initialize the Sets to empty sets.
    • Post

      public Post(@Size(max=355) @Size(max=355) String description, @NotNull @NotNull Instant publishedAt, @PositiveOrZero @javax.validation.constraints.PositiveOrZero int likesCount, int commentsCount, Set<String> linkedUsers, @Nullable @Size(max=600) @Size(max=600) String aiPrediction)
      Creates a new Post with all fields set.
      Parameters:
      description - The description of the post.
      publishedAt - The date when the post was published.
      likesCount - The amount of likes the post has.
      commentsCount - The amount of comments the post has.
      linkedUsers - The users that are linked to the post.
      aiPrediction - The AI prediction of the post.
      Implementation Note:
      The medias will be set to an empty set. It can be modified via the addMedia(Media) and removeMedia(Media).
  • Method Details

    • setAuthor

      public void setAuthor(@NonNull @NonNull User author)
      Sets the author of the post. Will also remove from the old posts and add to the new one.
      Parameters:
      author - the new author.
    • setDescription

      public void setDescription(String description)
      Sets the description to the given value.
      Parameters:
      description - the new description
      See Also:
    • setAiPrediction

      public void setAiPrediction(String aiPrediction)
      Sets the AI prediction to the given value.
      Parameters:
      aiPrediction - the new AI prediction
      See Also:
    • addMedia

      public void addMedia(@NonNull @NonNull Media media)
      Adds a media to the post.
      Parameters:
      media - the media to add.
      Implementation Note:
      This will set the post to the media.
    • removeMedia

      public void removeMedia(Media media)
      Removes a media from the post.
      Parameters:
      media - the media to remove.
    • hasMedia

      public boolean hasMedia()
      Checks if the post contains a media.
      Returns:
      true if the post contains a media, false otherwise.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object