Class Post
java.lang.Object
ch.bztf.m226blb1.Database.Entities.Post
Root entity for the posts.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPost()Default constructor.Post(@Size(max=355) String description, @NotNull Instant publishedAt, @javax.validation.constraints.PositiveOrZero int likesCount, int commentsCount, Set<String> linkedUsers, @Size(max=600) String aiPrediction) Creates a newPostwith all fields set. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds amediato the post.booleaninthashCode()booleanhasMedia()Checks if the post contains amedia.voidremoveMedia(Media media) Removes amediafrom the post.voidsetAiPrediction(String aiPrediction) Sets theAI predictionto the given value.voidSets theauthorof the post.voidsetDescription(String description) Sets thedescriptionto the given value.toString()
-
Constructor Details
-
Post
protected Post()Default constructor. Used by JPA.- Implementation Requirements:
- This will initialize the
Setsto 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 newPostwith 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
mediaswill be set to an empty set. It can be modified via theaddMedia(Media)andremoveMedia(Media).
-
-
Method Details
-
setAuthor
Sets theauthorof the post. Will also remove from the old posts and add to the new one.- Parameters:
author- the new author.
-
setDescription
Sets thedescriptionto the given value.- Parameters:
description- the new description- See Also:
-
setAiPrediction
Sets theAI predictionto the given value.- Parameters:
aiPrediction- the new AI prediction- See Also:
-
addMedia
Adds amediato the post.- Parameters:
media- the media to add.- Implementation Note:
- This will set the
postto the media.
-
removeMedia
Removes amediafrom the post.- Parameters:
media- the media to remove.
-
hasMedia
public boolean hasMedia()Checks if the post contains amedia.- Returns:
- true if the post
containsa media, false otherwise.
-
equals
-
hashCode
public int hashCode() -
toString
-