Remove use of raw types
Make use of parametrised types where possible, to please the java compiler and to make it easier to find potential issues.
This commit is contained in:
@@ -88,14 +88,14 @@ public class AbstractDao {
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> List<T> query(String sql, RowMapper rowMapper, Object... args) {
|
||||
protected <T> List<T> query(String sql, RowMapper<T> rowMapper, Object... args) {
|
||||
long t = System.nanoTime();
|
||||
List<T> result = getJdbcTemplate().query(sql, args, rowMapper);
|
||||
log(sql, t);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected <T> List<T> namedQuery(String sql, RowMapper rowMapper, Map<String, Object> args) {
|
||||
protected <T> List<T> namedQuery(String sql, RowMapper<T> rowMapper, Map<String, Object> args) {
|
||||
long t = System.nanoTime();
|
||||
List<T> result = getNamedParameterJdbcTemplate().query(sql, args, rowMapper);
|
||||
log(sql, t);
|
||||
@@ -165,12 +165,12 @@ public class AbstractDao {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected <T> T queryOne(String sql, RowMapper rowMapper, Object... args) {
|
||||
protected <T> T queryOne(String sql, RowMapper<T> rowMapper, Object... args) {
|
||||
List<T> list = query(sql, rowMapper, args);
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
protected <T> T namedQueryOne(String sql, RowMapper rowMapper, Map<String, Object> args) {
|
||||
protected <T> T namedQueryOne(String sql, RowMapper<T> rowMapper, Map<String, Object> args) {
|
||||
List<T> list = namedQuery(sql, rowMapper, args);
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AlbumDao extends AbstractDao {
|
||||
|
||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||
|
||||
private final RowMapper rowMapper = new AlbumMapper();
|
||||
private final RowMapper<Album> rowMapper = new AlbumMapper();
|
||||
|
||||
public Album getAlbum(int id) {
|
||||
return queryOne("select " + QUERY_COLUMNS + " from album where id=?", rowMapper, id);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ArtistDao extends AbstractDao {
|
||||
private static final String INSERT_COLUMNS = "name, cover_art_path, album_count, last_scanned, present, folder_id";
|
||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||
|
||||
private final RowMapper rowMapper = new ArtistMapper();
|
||||
private final RowMapper<Artist> rowMapper = new ArtistMapper();
|
||||
|
||||
/**
|
||||
* Returns the artist with the given name.
|
||||
|
||||
@@ -54,8 +54,8 @@ public class MediaFileDao extends AbstractDao {
|
||||
public static final int VERSION = 4;
|
||||
|
||||
private final RowMapper<MediaFile> rowMapper = new MediaFileMapper();
|
||||
private final RowMapper musicFileInfoRowMapper = new MusicFileInfoMapper();
|
||||
private final RowMapper genreRowMapper = new GenreMapper();
|
||||
private final RowMapper<MediaFile> musicFileInfoRowMapper = new MusicFileInfoMapper();
|
||||
private final RowMapper<Genre> genreRowMapper = new GenreMapper();
|
||||
|
||||
/**
|
||||
* Returns the media file for the given path.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.airsonic.player.dao;
|
||||
|
||||
import org.airsonic.player.domain.PlayQueue;
|
||||
import org.airsonic.player.domain.SavedPlayQueue;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -37,7 +38,7 @@ public class PlayQueueDao extends AbstractDao {
|
||||
|
||||
private static final String INSERT_COLUMNS = "username, current, position_millis, changed, changed_by";
|
||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||
private final RowMapper rowMapper = new PlayQueueMapper();
|
||||
private final RowMapper<SavedPlayQueue> rowMapper = new PlayQueueMapper();
|
||||
|
||||
@Transactional
|
||||
public SavedPlayQueue getPlayQueue(String username) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PlaylistDao extends AbstractDao {
|
||||
private static final String INSERT_COLUMNS = "username, is_public, name, comment, file_count, duration_seconds, " +
|
||||
"created, changed, imported_from";
|
||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||
private final RowMapper rowMapper = new PlaylistMapper();
|
||||
private final RowMapper<Playlist> rowMapper = new PlaylistMapper();
|
||||
|
||||
public List<Playlist> getReadablePlaylistsForUser(String username) {
|
||||
|
||||
|
||||
@@ -182,8 +182,8 @@ public class PodcastDao extends AbstractDao {
|
||||
update(sql, id);
|
||||
}
|
||||
|
||||
private static class PodcastChannelRowMapper implements RowMapper {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
private static class PodcastChannelRowMapper implements RowMapper<PodcastChannel> {
|
||||
public PodcastChannel mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return new PodcastChannel(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
||||
PodcastStatus.valueOf(rs.getString(6)), rs.getString(7));
|
||||
}
|
||||
|
||||
@@ -79,14 +79,13 @@ public class ParameterDecodingFilter implements Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getParameterMap() {
|
||||
Map map = super.getParameterMap();
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
Map<String, String[]> map = super.getParameterMap();
|
||||
Map<String, String[]> result = new HashMap<String, String[]>();
|
||||
|
||||
for (Object o : map.entrySet()) {
|
||||
Map.Entry entry = (Map.Entry) o;
|
||||
String name = (String) entry.getKey();
|
||||
String[] values = (String[]) entry.getValue();
|
||||
for (Map.Entry<String, String[]> entry : map.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
String[] values = entry.getValue();
|
||||
|
||||
if (name.endsWith(PARAM_SUFFIX)) {
|
||||
result.put(name.replace(PARAM_SUFFIX, ""), decode(values));
|
||||
@@ -98,11 +97,11 @@ public class ParameterDecodingFilter implements Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration getParameterNames() {
|
||||
Enumeration e = super.getParameterNames();
|
||||
public Enumeration<String> getParameterNames() {
|
||||
Enumeration<String> e = super.getParameterNames();
|
||||
Vector<String> v = new Vector<String>();
|
||||
while (e.hasMoreElements()) {
|
||||
String name = (String) e.nextElement();
|
||||
String name = e.nextElement();
|
||||
if (name.endsWith(PARAM_SUFFIX)) {
|
||||
name = name.replace(PARAM_SUFFIX, "");
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class ResponseHeaderFilter implements Filter {
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
|
||||
// Sets the provided HTTP response parameters
|
||||
for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
|
||||
String headerName = (String) e.nextElement();
|
||||
for (Enumeration<String> e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
|
||||
String headerName = e.nextElement();
|
||||
response.setHeader(headerName, filterConfig.getInitParameter(headerName));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user