final class VideoObj extends java.lang.Object implements java.lang.Comparable<VideoObj>
Class Type: Immutable Data Class
Object Invariant:
Title is non-null, no leading or final spaces, not empty string.Object Invariant:
Year is greater than 1800, less than 5000.Object Invariant:
Director is non-null, no leading or final spaces, not empty string.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
director
Invariant: non-null, no leading or final spaces, not empty string
|
private java.lang.String |
title
Invariant: non-null, no leading or final spaces, not empty string
|
private int |
year
Invariant: greater than 1800, less than 5000
|
Constructor and Description |
---|
VideoObj(java.lang.String title,
int year,
java.lang.String director)
Initialize all object attributes.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(VideoObj that)
Compares the attributes of this object with those of thatObject, in
the following order: title, year, director.
|
java.lang.String |
director()
Return the value of the attribute.
|
boolean |
equals(java.lang.Object thatObject)
Compare the attributes of this object with those of thatObject.
|
int |
hashCode()
Return a hash code value for this object using the algorithm from Bloch:
fields are added in the following order: title, year, director.
|
java.lang.String |
title()
Return the value of the attribute.
|
java.lang.String |
toString()
Return a string representation of the object in the following format:
"title (year) : director" . |
int |
year()
Return the value of the attribute.
|
private final java.lang.String title
Invariant: non-null, no leading or final spaces, not empty string
private final int year
Invariant: greater than 1800, less than 5000
private final java.lang.String director
Invariant: non-null, no leading or final spaces, not empty string
VideoObj(java.lang.String title, int year, java.lang.String director)
java.lang.IllegalArgumentException
- if any object invariant is violated.public java.lang.String director()
public java.lang.String title()
public int year()
public boolean equals(java.lang.Object thatObject)
equals
in class java.lang.Object
thatObject
- the Object to be compared.public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(VideoObj that)
compareTo
in interface java.lang.Comparable<VideoObj>
that
- the VideoObj to be compared.public java.lang.String toString()
"title (year) : director"
.toString
in class java.lang.Object