public int compare(Viewer viewer, Object e1, Object e2) {
if (!(e1 instanceof AudioFile) || !(e2 instanceof AudioFile)) {
return 0;
}
AudioTag a1 = ((AudioFileInfo) ((AudioFile) e1).getAudioModelInfo())
.getAudioTag();
AudioTag a2 = ((AudioFileInfo) ((AudioFile) e2).getAudioModelInfo())
.getAudioTag();
switch (sortType) {
case TITLE: {
return a1.getTitle().compareTo(a2.getTitle());
}
case -TITLE: {
return a2.getTitle().compareTo(a1.getTitle());
}
case ARTIST: {
return a1.getArtist().compareTo(a2.getArtist());
}
case -ARTIST: {
return a2.getArtist().compareTo(a1.getArtist());
}
case ALBUM: {
return a1.getAlbum().compareTo(a2.getAlbum());
}
case -ALBUM: {
return a2.getAlbum().compareTo(a1.getAlbum());
}
case YEAR: {
return a1.getYear().compareTo(a2.getYear());
}
case -YEAR: {
return a2.getYear().compareTo(a1.getYear());
}
case TRACK: {
return a1.getTrack().compareTo(a2.getTrack());
}
case -TRACK: {
return a2.getTrack().compareTo(a1.getTrack());
}
case COMMENT: {
return a1.getComment().compareTo(a2.getComment());
}
case -COMMENT: {
return a2.getComment().compareTo(a1.getComment());
}
case ALBUM_ARTIST: {
return a1.getAlbumArtist().compareTo(a2.getAlbumArtist());
}
case -ALBUM_ARTIST: {
return a2.getAlbumArtist().compareTo(a1.getAlbumArtist());
}
}
return 0;
}