@Override public int hashCode() { return new HashCodeBuilder() .append(lastFmUser) .append(track.getId()) .append(startTime) .toHashCode(); }
@Override public boolean equals(Object o) { if (o == null) return false; if (o == this) return true; if (o.getClass() != getClass()) return false; Scrobble s = (Scrobble) o; return new EqualsBuilder() .append(lastFmUser, s.lastFmUser) .append(track.getId(), s.track.getId()) .append(startTime, s.startTime) .isEquals(); }
public void loadMediaFiles(List<Integer> mediaFileIds) { List<Integer> missingMediaFileIds = new ArrayList<>(mediaFileIds); for (Iterator<Integer> it = missingMediaFileIds.iterator(); it.hasNext(); ) { if (mediaFileCache.isElementInMemory(it.next())) { it.remove(); } } if (missingMediaFileIds.size() > 0) { List<Track> tracks = libraryBrowserService.getTracks(missingMediaFileIds); for (Track track : tracks) { mediaFileCache.put(new Element(track.getId(), getMediaFile(track))); } } }
public static MediaFile getMediaFile(Track track) { MediaFile mediaFile = new MediaFile(track.getId()); mediaFile.setFile(new File(track.getMetaData().getPath())); mediaFile.getMetaData().setAlbum(track.getMetaData().getAlbum()); mediaFile.getMetaData().setAlbumId(track.getMetaData().getAlbumId()); mediaFile.getMetaData().setArtist(track.getMetaData().getArtist()); mediaFile.getMetaData().setArtistId(track.getMetaData().getArtistId()); mediaFile.getMetaData().setComposer(track.getMetaData().getComposer()); mediaFile.getMetaData().setBitRate((int) track.getMetaData().getBitrate()); mediaFile.getMetaData().setDiscNumber((int) track.getMetaData().getDiscNr()); mediaFile.getMetaData().setDuration((int) track.getMetaData().getDuration()); mediaFile.getMetaData().setFileSize((long) track.getMetaData().getSize()); mediaFile .getMetaData() .setFormat(track.getMetaData().getMediaType().getFilesuffix().toLowerCase()); mediaFile.getMetaData().setGenre(track.getMetaData().getGenre()); mediaFile.getMetaData().setTitle(track.getName()); mediaFile.getMetaData().setTrackNumber((int) track.getMetaData().getTrackNr()); mediaFile.getMetaData().setVariableBitRate(track.getMetaData().isVbr()); mediaFile.getMetaData().setYear(toYear(track.getMetaData().getYear())); mediaFile.getMetaData().setHasLyrics(track.getMetaData().hasLyrics()); return mediaFile; }