Java 17 features (N-S) (#15565)
- add missing @override - Java style array syntax - remove redundant modifiers - always move String constants to left side in comparisons - simplify lambda expressions and return statements - use replace instead of replaceAll w/o regex - instanceof matching and multiline strings Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -133,11 +133,9 @@ public class PlexApiConnector {
|
||||
*/
|
||||
public @Nullable MediaContainer getSessionData() {
|
||||
try {
|
||||
String url = "https://" + host + ":" + String.valueOf(port) + "/status/sessions" + "?X-Plex-Token=" + token;
|
||||
String url = "https://" + host + ":" + port + "/status/sessions" + "?X-Plex-Token=" + token;
|
||||
logger.debug("Getting session data '{}'", url);
|
||||
MediaContainer mediaContainer = getFromXml(doHttpRequest("GET", url, getClientHeaders(), false),
|
||||
MediaContainer.class);
|
||||
return mediaContainer;
|
||||
return getFromXml(doHttpRequest("GET", url, getClientHeaders(), false), MediaContainer.class);
|
||||
} catch (IOException | InterruptedException | TimeoutException | ExecutionException e) {
|
||||
logger.debug("An exception occurred while polling the PLEX Server: '{}'", e.getMessage());
|
||||
return null;
|
||||
@@ -151,8 +149,7 @@ public class PlexApiConnector {
|
||||
* @return the completed url that will be usable
|
||||
*/
|
||||
public String getURL(String url) {
|
||||
String artURL = scheme + "://" + host + ":" + String.valueOf(port + url + "?X-Plex-Token=" + token);
|
||||
return artURL;
|
||||
return scheme + "://" + host + ":" + port + url + "?X-Plex-Token=" + token;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,7 +352,7 @@ public class PlexApiConnector {
|
||||
NotificationContainer notification = gson.fromJson(msg, NotificationContainer.class);
|
||||
if (notification != null) {
|
||||
PlexUpdateListener listenerLocal = listener;
|
||||
if (listenerLocal != null && notification.getNotificationContainer().getType().equals("playing")) {
|
||||
if (listenerLocal != null && "playing".equals(notification.getNotificationContainer().getType())) {
|
||||
listenerLocal.onItemStatusUpdate(
|
||||
notification.getNotificationContainer().getPlaySessionStateNotification().get(0)
|
||||
.getSessionKey(),
|
||||
@@ -413,7 +410,7 @@ public class PlexApiConnector {
|
||||
|
||||
if (commandPath != null) {
|
||||
try {
|
||||
String url = "https://" + host + ":" + String.valueOf(port) + commandPath;
|
||||
String url = "https://" + host + ":" + port + commandPath;
|
||||
Properties headers = getClientHeaders();
|
||||
headers.put("X-Plex-Target-Client-Identifier", playerID);
|
||||
doHttpRequest("GET", url, headers, false);
|
||||
|
||||
@@ -245,10 +245,10 @@ public class PlexServerHandler extends BaseBridgeHandler implements PlexUpdateLi
|
||||
// configured, update
|
||||
// it
|
||||
tmpMeta.setArt(plexAPIConnector.getURL(tmpMeta.getArt()));
|
||||
if (tmpMeta.getType().equals("episode")) {
|
||||
if ("episode".equals(tmpMeta.getType())) {
|
||||
tmpMeta.setThumb(plexAPIConnector.getURL(tmpMeta.getGrandparentThumb()));
|
||||
tmpMeta.setTitle(tmpMeta.getGrandparentTitle() + " : " + tmpMeta.getTitle());
|
||||
} else if (tmpMeta.getType().equals("track")) {
|
||||
} else if ("track".equals(tmpMeta.getType())) {
|
||||
tmpMeta.setThumb(plexAPIConnector.getURL(tmpMeta.getThumb()));
|
||||
tmpMeta.setTitle(tmpMeta.getGrandparentTitle() + " - " + tmpMeta.getParentTitle() + " - "
|
||||
+ tmpMeta.getTitle());
|
||||
@@ -304,8 +304,8 @@ public class PlexServerHandler extends BaseBridgeHandler implements PlexUpdateLi
|
||||
}
|
||||
refreshAllPlayers();
|
||||
} catch (Exception e) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, String
|
||||
.format("An exception occurred while polling the PLEX Server: '%s'", e.getMessage()).toString());
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||
String.format("An exception occurred while polling the PLEX Server: '%s'", e.getMessage()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user