Class Post
java.lang.Object
ch.bztf.m226blb1.Database.Entities.Post
Root entity for the posts.
-
Constructor Summary
ModifierConstructorDescriptionprotected
Post()
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 newPost
with all fields set. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds amedia
to the post.boolean
int
hashCode()
boolean
hasMedia()
Checks if the post contains amedia
.void
removeMedia
(Media media) Removes amedia
from the post.void
setAiPrediction
(String aiPrediction) Sets theAI prediction
to the given value.void
Sets theauthor
of the post.void
setDescription
(String description) Sets thedescription
to the given value.toString()
-
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 newPost
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 theaddMedia(Media)
andremoveMedia(Media)
.
-
-
Method Details
-
setAuthor
Sets theauthor
of the post. Will also remove from the old posts and add to the new one.- Parameters:
author
- the new author.
-
setDescription
Sets thedescription
to the given value.- Parameters:
description
- the new description- See Also:
-
setAiPrediction
Sets theAI prediction
to the given value.- Parameters:
aiPrediction
- the new AI prediction- See Also:
-
addMedia
Adds amedia
to the post.- Parameters:
media
- the media to add.- Implementation Note:
- This will set the
post
to the media.
-
removeMedia
Removes amedia
from the post.- Parameters:
media
- the media to remove.
-
hasMedia
public boolean hasMedia()Checks if the post contains amedia
.- Returns:
- true if the post
contains
a media, false otherwise.
-
equals
-
hashCode
public int hashCode() -
toString
-