@Entity(name="Story") public class Story extends Object implements Serializable
| Constructor and Description |
|---|
Story() |
Story(Long id,
String title,
String content,
Genre genre,
Theme theme1,
Theme theme2,
Date date,
User author,
boolean published)
Creates a new instance of
Story with id and no views |
Story(String title,
String content,
Genre genre,
Theme theme1,
Theme theme2,
Date date,
User author)
Creates a new instance of
Story |
| Modifier and Type | Method and Description |
|---|---|
void |
addView(Date date)
Creates a new view for the story at the specified date
|
User |
getAuthor()
Returns the author of the story
|
String |
getContent()
Returns the content of the story
|
Date |
getDate()
Returns the date of the story
|
Genre |
getGenre()
Returns the genre of the story
|
Long |
getId()
Returns the id of the story
|
Theme |
getTheme1()
Returns the main theme of the story
|
Theme |
getTheme2()
Returns the secondary theme of the story
|
String |
getTitle()
Returns the title of the story
|
int |
getViewCount()
Returns the story's view count
|
protected Set<View> |
getViews()
Returns the story's views
|
boolean |
isPublished()
Returns whether the story is published or not
|
void |
setAuthor(User author)
Sets the author of the story.
|
void |
setContent(String content)
Sets the content of the story.
|
void |
setDate(Date date)
Sets the story's publication date.
|
void |
setGenre(Genre genre)
Sets the genre of the story.
|
void |
setId(Long id)
Sets the id of the story.
|
void |
setPublished(boolean published)
Sets the story's publication status
|
void |
setTheme1(Theme theme1)
Sets the main theme of the story.
|
void |
setTheme2(Theme theme2)
Sets the secondary theme of the story.
|
void |
setTitle(String title)
Sets the title of the story.
|
protected void |
setViews(List<View> views) |
public Story()
public Story(String title, String content, Genre genre, Theme theme1, Theme theme2, Date date, User author)
Storytitle - the title of the story. This parameter must be a non empty and
non null string with a maximun length of 100 charscontent - the content of the story. This parameter must be a non empty
and non null string with a maximum length that depends
on the story's genre: STORY - 1000 chars, POEM
- 500 chars, NANOSTORY - 150 charsgenre - the genre of the story. Can't be nulltheme1 - the main theme of the story. This parameter can't be
null and can't the same as the secondary themetheme2 - the secondary theme of the story. This parameter can't be the
same as the main themedate - the story's publication date. This parameter can't be
null.author - the author of the story. This parameter can't be null.NullPointerException - if a null value is passed as the
value for any parameter except theme2IllegalArgumentException - if value provided for any parameter is not
valid according to its description.public Story(Long id, String title, String content, Genre genre, Theme theme1, Theme theme2, Date date, User author, boolean published)
Story with id and no viewsid - the id of the story. This parameter must be a non empty and
non null.title - the title of the story. This parameter must be a non empty and
non null string with a maximun length of 100 charscontent - the content of the story. This parameter must be a non empty
and non null string with a maximum length that depends
on the story's genre: STORY - 1000 chars, POEM
- 500 chars, NANOSTORY - 150 charsgenre - the genre of the story. Can't be nulltheme1 - the main theme of the story. This parameter can't be
null and can't the same as the secondary themetheme2 - the secondary theme of the story. This parameter can't be the
same as the main themedate - the story's publication date. This parameter can't be
null.author - the author of the story. This parameter can't be null.NullPointerException - if a null value is passed as the
value for any parameter except theme2IllegalArgumentException - if value provided for any parameter is not
valid according to its description.public Long getId()
public void setId(Long id)
id - of the storypublic String getTitle()
public void setTitle(String title)
title - the title of the story. This parameter must be a non empty and
non null string with a maximun length of 100 charsNullPointerException - if a null value is passedIllegalArgumentException - if the length of the passed string is not
validpublic String getContent()
public void setContent(String content)
content - the content of the story. This parameter must be a non empty
and non null string with a maximum length that depends
on the story's genre: STORY - 1000 chars, POEM
- 500 chars, NANOSTORY - 150 charsNullPointerException - if a null value is passedIllegalArgumentException - if the length of the passed string is not
validpublic User getAuthor()
public void setAuthor(User author)
author - the author of the story. Can't be nullNullPointerException - if a null value is passedpublic Genre getGenre()
public void setGenre(Genre genre)
genre - the genre of the story. Can't be nullNullPointerException - if a null value is passedpublic Theme getTheme1()
public void setTheme1(Theme theme1)
theme1 - the main theme of the story. This parameter can't be
null and can't the same as the secondary themeNullPointerException - if a null value is passedIllegalArgumentException - if the passed theme is equal to the
secondary themepublic Theme getTheme2()
public void setTheme2(Theme theme2)
theme2 - the secondary theme of the story. This parameter can't be the
same as the main themeIllegalArgumentException - if the passed theme is equal to the main
themepublic Date getDate()
public void setDate(Date date)
date - the story's publication date. This parameter can't be
null.NullPointerException - if a null value is passedpublic void addView(Date date)
date - the date of the view. Can't be nullpublic int getViewCount()
public boolean isPublished()
true if it is, false if it's not;public void setPublished(boolean published)
published - the story's publication status, true if it's published, false if it's not.Copyright © 2022. All rights reserved.