|
My Movies 1.0.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectMovie
final class Movie
Data-centric class encapsulating all fields related to movies.
This class exists in order to encapsulate, validate, and sort movie information. This class is used both to validate user input, and act as a 'transfer object' when interacting with the database.
This class would greatly benefit from a JUnit test class, to test its data validation and sorting.
| Field Summary | |
|---|---|
(package private) static Comparator<Movie> |
COMMENT_SORT
Sort by Comment. |
(package private) static Comparator<Movie> |
RATING_SORT
Sort by Rating (descending), then Date Viewed (descending). |
(package private) static Comparator<Movie> |
TITLE_SORT
Sort by Title. |
| Constructor Summary | |
|---|---|
Movie(String aId,
String aTitle,
Date aDateViewed,
BigDecimal aRating,
String aComment)
Constructor taking regular Java objects natural to the domain. |
|
Movie(String aId,
String aTitle,
String aDateViewed,
String aRating,
String aComment)
Constructor which takes all parameters as text. |
|
| Method Summary | |
|---|---|
int |
compareTo(Movie aThat)
Default sort by Date Viewed, then Title. |
boolean |
equals(Object aThat)
|
(package private) String |
getComment()
|
(package private) Date |
getDateViewed()
|
(package private) String |
getId()
|
(package private) BigDecimal |
getRating()
|
(package private) String |
getTitle()
|
int |
hashCode()
|
(package private) void |
setId(String aId)
This set method is rather artificial. |
String |
toString()
|
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static Comparator<Movie> TITLE_SORT
static Comparator<Movie> RATING_SORT
static Comparator<Movie> COMMENT_SORT
| Constructor Detail |
|---|
Movie(String aId,
String aTitle,
Date aDateViewed,
BigDecimal aRating,
String aComment)
throws InvalidInputException
When the user has entered text, this constructor is called indirectly, through
Movie(String, String, String, String, String).
aId - optional, the database identifer for the movie. This item is optional since,
for 'add' operations, it has yet to be assigned by the database.aTitle - has content, name of the movieaDateViewed - optional, date the movie was screened by the useraRating - optional, in range 0.0 to 10.0aComment - optional, any comment on the movie
InvalidInputException
Movie(String aId,
String aTitle,
String aDateViewed,
String aRating,
String aComment)
throws InvalidInputException
Raw user input is usually in the form of text.
This constructor first parses such text into the required 'base objects' -
Date, BigDecimal and so on. If those parse operations fail,
then the user is shown an error message. If N such errors are present in user input,
then N separate message will be presented for each failure, one by one.
If all such parse operations succeed, then the "regular" constructor
Movie(String, String, Date, BigDecimal, String)
will then be called. It's important to note that this call to the second constructor
can in turn result in another error message being shown to the
user (just one this time).
InvalidInputException| Method Detail |
|---|
String getId()
void setId(String aId)
String getTitle()
Date getDateViewed()
BigDecimal getRating()
String getComment()
public boolean equals(Object aThat)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic int compareTo(Movie aThat)
compareTo in interface Comparable<Movie>
|
My Movies 1.0.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||