public class SourceComparator extends java.lang.Object implements java.util.Comparator<NewsStory>
The SourceComparator compares the sources of two news stories.
Note that the constructor has nothing to do, so it is omitted.
Modifier and Type | Field and Description |
---|---|
static SourceComparator |
SOURCE_COMPARATOR
We create a single comparator object for the class and make a public
final field that references that object.
|
Constructor and Description |
---|
SourceComparator() |
Modifier and Type | Method and Description |
---|---|
int |
compare(NewsStory newsStory1,
NewsStory newsStory2)
The required
compare method for implementing
Comparator . |
public static final SourceComparator SOURCE_COMPARATOR
public int compare(NewsStory newsStory1, NewsStory newsStory2)
compare
method for implementing
Comparator
.compare
in interface java.util.Comparator<NewsStory>
newsStory1
- The first news story to compare based on source.newsStory2
- The second news story to compare based on source.