My Movies 1.0.0

hirondelle.movies.edit
Class Movie

Object
  extended by Movie
All Implemented Interfaces:
Comparable<Movie>

final class Movie
extends Object
implements Comparable<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

TITLE_SORT

static Comparator<Movie> TITLE_SORT
Sort by Title.


RATING_SORT

static Comparator<Movie> RATING_SORT
Sort by Rating (descending), then Date Viewed (descending).


COMMENT_SORT

static Comparator<Movie> COMMENT_SORT
Sort by Comment.

Constructor Detail

Movie

Movie(String aId,
      String aTitle,
      Date aDateViewed,
      BigDecimal aRating,
      String aComment)
throws InvalidInputException
Constructor taking regular Java objects natural to the domain.

When the user has entered text, this constructor is called indirectly, through Movie(String, String, String, String, String).

Parameters:
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 movie
aDateViewed - optional, date the movie was screened by the user
aRating - optional, in range 0.0 to 10.0
aComment - optional, any comment on the movie
Throws:
InvalidInputException

Movie

Movie(String aId,
      String aTitle,
      String aDateViewed,
      String aRating,
      String aComment)
throws InvalidInputException
Constructor which takes all parameters as text.

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).

Throws:
InvalidInputException
Method Detail

getId

String getId()

setId

void setId(String aId)
This set method is rather artificial. It results from the toy persistence layer. It's dissatisfying to add this method since the class would otherwise be immutable. Immutability is a highly desirable characteristic.


getTitle

String getTitle()

getDateViewed

Date getDateViewed()

getRating

BigDecimal getRating()

getComment

String getComment()

equals

public boolean equals(Object aThat)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Movie aThat)
Default sort by Date Viewed, then Title. Dates have the most recent items listed first.

Specified by:
compareTo in interface Comparable<Movie>

My Movies 1.0.0

Copyright Hirondelle Systems - Generated 2008Dec30.15.53