Skip to content

Commit

Permalink
Feature/java21 (#207)
Browse files Browse the repository at this point in the history
* Create maven.yml

upgrade github actions

* adding sonar analysis to action

* upgrade google formatter for java 21

* update formatting for google formatter

* [issue #197] - upgrade to java 21

* close executor

* close executor

* [issue #197] - upgrade to java 21 and cleanup
  • Loading branch information
finnyb authored Apr 20, 2024
1 parent 093fa60 commit 36721d1
Show file tree
Hide file tree
Showing 58 changed files with 232 additions and 322 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/bff/javampd/MPDException.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.bff.javampd;

import lombok.Getter;

/**
* Base class for MPD Exceptions.
*
* @author Bill
* @version 1.0
*/
@Getter
public class MPDException extends RuntimeException {
private final String command;

Expand Down Expand Up @@ -68,8 +71,4 @@ public MPDException(String message, String command, Throwable cause) {
super(message, cause);
this.command = command;
}

public String getCommand() {
return command;
}
}
6 changes: 2 additions & 4 deletions src/main/java/org/bff/javampd/admin/AdminProperties.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.bff.javampd.admin;

import lombok.Getter;
import org.bff.javampd.server.MPDProperties;

public class AdminProperties extends MPDProperties {

@Getter
private enum Command {
KILL("admin.kill"),
REFRESH("admin.update"),
Expand All @@ -17,10 +19,6 @@ private enum Command {
Command(String key) {
this.key = key;
}

public String getKey() {
return key;
}
}

public String getKill() {
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/org/bff/javampd/admin/MPDChangeEvent.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package org.bff.javampd.admin;

import lombok.Getter;

/**
* An event used to identify an administrative action.
*
* @author Bill
* @version 1.0
*/
@Getter
public class MPDChangeEvent extends java.util.EventObject {
private Event event;
/**
* -- GETTER -- Returns the specific that occurred.
*
* @return the specific {@link Event}
*/
private final Event event;

public enum Event {
KILLED,
Expand All @@ -24,13 +32,4 @@ public MPDChangeEvent(Object source, Event event) {
super(source);
this.event = event;
}

/**
* Returns the specific {@link Event} that occurred.
*
* @return the specific {@link Event}
*/
public Event getEvent() {
return this.event;
}
}
6 changes: 3 additions & 3 deletions src/main/java/org/bff/javampd/album/MPDAlbumDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public MPDAlbumDatabase(TagLister tagLister, AlbumConverter albumConverter) {
public Collection<MPDAlbum> listAlbumsByAlbumArtist(MPDArtist albumArtist) {
var p = new ArrayList<String>();
p.add(TagLister.ListType.ALBUM_ARTIST.getType());
p.add(albumArtist.getName());
p.add(albumArtist.name());

return convertResponseToAlbum(tagLister.list(TagLister.ListType.ALBUM, p, ALBUM_TAGS));
}
Expand All @@ -47,7 +47,7 @@ public Collection<MPDAlbum> listAlbumsByAlbumArtist(MPDArtist albumArtist) {
public Collection<MPDAlbum> listAlbumsByArtist(MPDArtist artist) {
List<String> list = new ArrayList<>();
list.add(TagLister.ListType.ARTIST.getType());
list.add(artist.getName());
list.add(artist.name());

return convertResponseToAlbum(tagLister.list(TagLister.ListType.ALBUM, list, ALBUM_TAGS));
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public Collection<MPDAlbum> findAlbum(String albumName) {
public Collection<MPDAlbum> listAlbumsByGenre(MPDGenre genre) {
List<String> list = new ArrayList<>();
list.add(TagLister.ListType.GENRE.getType());
list.add(genre.getName());
list.add(genre.name());

return convertResponseToAlbum(tagLister.list(TagLister.ListType.ALBUM, list, ALBUM_TAGS));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bff/javampd/art/MPDArtworkFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public List<MPDArtwork> find(MPDArtist artist, String pathPrefix) {

albumPaths.forEach(
path -> {
if (path.contains(File.separator + artist.getName() + File.separator)) {
if (path.contains(File.separator + artist.name() + File.separator)) {
paths.add(path.substring(0, path.lastIndexOf(File.separator)));
}
});
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/org/bff/javampd/artist/MPDArtist.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package org.bff.javampd.artist;

import lombok.Data;

/**
* String represents an artist.
*
* @author Bill
*/
@Data
public class MPDArtist {
private final String name;
}
public record MPDArtist(String name) {}
4 changes: 2 additions & 2 deletions src/main/java/org/bff/javampd/artist/MPDArtistDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Collection<MPDArtist> listAllAlbumArtists() {
public Collection<MPDArtist> listArtistsByGenre(MPDGenre genre) {
List<String> list = new ArrayList<>();
list.add(TagLister.ListType.GENRE.getType());
list.add(genre.getName());
list.add(genre.name());

return tagLister.list(TagLister.ListType.ARTIST, list).stream()
.map(s -> new MPDArtist(convertResponse(s)))
Expand All @@ -70,7 +70,7 @@ public MPDArtist listArtistByName(String name) {
}

if (!artists.isEmpty()) {
artist = artists.get(0);
artist = artists.getFirst();
}

return artist;
Expand Down
33 changes: 14 additions & 19 deletions src/main/java/org/bff/javampd/command/MPDCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
Expand All @@ -14,10 +15,23 @@
* @author Bill
* @version 1.0
*/
@Getter
@EqualsAndHashCode
@ToString
public class MPDCommand {
/**
* -- GETTER -- Returns the command od this object.
*
* @return the command
*/
private final String command;

/**
* -- GETTER -- Returns the parameter(s) of this command as a of s. Returns null of there is no
* parameter for the command.
*
* @return the parameters for the command
*/
private final List<String> params;

/**
Expand All @@ -35,23 +49,4 @@ public MPDCommand(String command, String... parameters) {
this.params = new ArrayList<>();
Collections.addAll(this.params, Arrays.copyOf(parameters, parameters.length));
}

/**
* Returns the command od this object.
*
* @return the command
*/
public String getCommand() {
return command;
}

/**
* Returns the parameter(s) of this command as a {@link List} of {@link String}s. Returns null of
* there is no parameter for the command.
*
* @return the parameters for the command
*/
public List<String> getParams() {
return params;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.bff.javampd.database;

import lombok.Getter;
import org.bff.javampd.server.MPDProperties;

/**
* @author bill
*/
public class DatabaseProperties extends MPDProperties {
@Getter
private enum Command {
FIND("db.find"),
LIST("db.list.tag"),
Expand All @@ -19,10 +21,6 @@ private enum Command {
Command(String key) {
this.key = key;
}

public String getKey() {
return key;
}
}

public String getFind() {
Expand Down
16 changes: 4 additions & 12 deletions src/main/java/org/bff/javampd/database/TagLister.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.bff.javampd.database;

import java.util.List;
import lombok.Getter;

/**
* Performs list operations against the MPD database.
*
* @author Bill
*/
public interface TagLister {
@Getter
enum ListType {
ALBUM("album"),
ALBUM_ARTIST("albumartist"),
Expand All @@ -20,12 +22,9 @@ enum ListType {
ListType(String type) {
this.type = type;
}

public String getType() {
return type;
}
}

@Getter
enum GroupType {
ALBUM("album"),
ALBUM_ARTIST("albumartist"),
Expand All @@ -38,12 +37,9 @@ enum GroupType {
GroupType(String type) {
this.type = type;
}

public String getType() {
return type;
}
}

@Getter
enum ListInfoType {
PLAYLIST("playlist:"),
DIRECTORY("directory:"),
Expand All @@ -55,10 +51,6 @@ enum ListInfoType {
ListInfoType(String prefix) {
this.prefix = prefix;
}

public String getPrefix() {
return prefix;
}
}

List<String> listInfo(ListInfoType... types);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/bff/javampd/file/MPDFileDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
public class MPDFileDatabase implements FileDatabase {

private DatabaseProperties databaseProperties;
private CommandExecutor commandExecutor;
private final DatabaseProperties databaseProperties;
private final CommandExecutor commandExecutor;

private static final String PREFIX_FILE = TagLister.ListInfoType.FILE.getPrefix();
private static final String PREFIX_DIRECTORY = TagLister.ListInfoType.DIRECTORY.getPrefix();
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/bff/javampd/genre/MPDGenre.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
package org.bff.javampd.genre;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

/**
* MPDGenre represents a genre
*
* @author Bill
*/
@RequiredArgsConstructor
@EqualsAndHashCode
@ToString
@Getter
public class MPDGenre {
private final String name;
}
public record MPDGenre(String name) {}
2 changes: 1 addition & 1 deletion src/main/java/org/bff/javampd/genre/MPDGenreDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public MPDGenre listGenreByName(String name) {
}

if (!genres.isEmpty()) {
genre = genres.get(0);
genre = genres.getFirst();
}

return genre;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MPDBitrateMonitor extends MPDVolumeMonitor implements BitrateMonito
private int oldBitrate;
private int newBitrate;

private List<BitrateChangeListener> bitrateListeners;
private final List<BitrateChangeListener> bitrateListeners;

MPDBitrateMonitor() {
bitrateListeners = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bff/javampd/monitor/MPDErrorMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Singleton
public class MPDErrorMonitor implements ErrorMonitor {
private String error;
private List<ErrorListener> errorListeners;
private final List<ErrorListener> errorListeners;

MPDErrorMonitor() {
this.errorListeners = new ArrayList<>();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/bff/javampd/monitor/MPDOutputMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

@Singleton
public class MPDOutputMonitor implements OutputMonitor {
private Map<Integer, MPDOutput> outputMap;
private List<OutputChangeListener> outputListeners;
private final Map<Integer, MPDOutput> outputMap;
private final List<OutputChangeListener> outputListeners;

private Admin admin;
private final Admin admin;

@Inject
MPDOutputMonitor(Admin admin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MPDPlayerMonitor extends MPDBitrateMonitor implements PlayerMonitor
private static final Logger LOGGER = LoggerFactory.getLogger(MPDPlayerMonitor.class);

private PlayerStatus status = PlayerStatus.STATUS_STOPPED;
private List<PlayerBasicChangeListener> playerListeners;
private final List<PlayerBasicChangeListener> playerListeners;
private String state;

MPDPlayerMonitor() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bff/javampd/monitor/MPDTrackMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Singleton
public class MPDTrackMonitor implements TrackMonitor {
private List<TrackPositionChangeListener> trackListeners;
private final List<TrackPositionChangeListener> trackListeners;
private long oldPos;
private long elapsedTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class MPDVolumeMonitor implements VolumeMonitor {
private int newVolume;
private int oldVolume;
private VolumeChangeDelegate volumeChangeDelegate;
private final VolumeChangeDelegate volumeChangeDelegate;

MPDVolumeMonitor() {
this.volumeChangeDelegate = new VolumeChangeDelegate();
Expand Down
Loading

0 comments on commit 36721d1

Please sign in to comment.