Java 17 features (A-G) (#15516)
- 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:
@@ -47,6 +47,7 @@ public class AuthorizationController implements AuthorizationProvider {
|
||||
this.oAuthClientService = oAuthClientService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorizationHeader() throws IndegoAuthenticationException {
|
||||
final AccessTokenResponse accessTokenResponse;
|
||||
try {
|
||||
|
||||
@@ -158,8 +158,8 @@ public class IndegoController {
|
||||
throw new IndegoException(e);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause != null && cause instanceof HttpResponseException) {
|
||||
Response response = ((HttpResponseException) cause).getResponse();
|
||||
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
|
||||
Response response = httpResponseException.getResponse();
|
||||
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
|
||||
/*
|
||||
* The service may respond with HTTP code 401 without any "WWW-Authenticate"
|
||||
@@ -218,8 +218,8 @@ public class IndegoController {
|
||||
throw new IndegoException(e);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause != null && cause instanceof HttpResponseException) {
|
||||
Response response = ((HttpResponseException) cause).getResponse();
|
||||
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
|
||||
Response response = httpResponseException.getResponse();
|
||||
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
|
||||
/*
|
||||
* When contextId is not valid, the service will respond with HTTP code 401 without
|
||||
@@ -316,8 +316,8 @@ public class IndegoController {
|
||||
throw new IndegoException(e);
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause != null && cause instanceof HttpResponseException) {
|
||||
Response response = ((HttpResponseException) cause).getResponse();
|
||||
if (cause != null && cause instanceof HttpResponseException httpResponseException) {
|
||||
Response response = httpResponseException.getResponse();
|
||||
if (response.getStatus() == HttpStatus.UNAUTHORIZED_401) {
|
||||
/*
|
||||
* When contextId is not valid, the service will respond with HTTP code 401 without
|
||||
|
||||
@@ -141,9 +141,7 @@ public class IndegoDeviceController extends IndegoController {
|
||||
* @throws IndegoException if any communication or parsing error occurred
|
||||
*/
|
||||
public DeviceCalendarResponse getCalendar() throws IndegoAuthenticationException, IndegoException {
|
||||
DeviceCalendarResponse calendar = getRequest(SERIAL_NUMBER_SUBPATH + serialNumber + "/calendar",
|
||||
DeviceCalendarResponse.class);
|
||||
return calendar;
|
||||
return getRequest(SERIAL_NUMBER_SUBPATH + serialNumber + "/calendar", DeviceCalendarResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,10 +130,12 @@ public class BoschAccountHandler extends BaseBridgeHandler implements Authorizat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccessfulAuthorization() {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailedAuthorization(Throwable throwable) {
|
||||
logger.debug("Authorization failure", throwable);
|
||||
if (throwable instanceof IndegoAuthenticationException) {
|
||||
@@ -144,6 +146,7 @@ public class BoschAccountHandler extends BaseBridgeHandler implements Authorizat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthorizationFlowCompleted() {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@@ -161,14 +161,17 @@ public class BoschIndegoHandler extends BaseThingHandler implements Authorizatio
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccessfulAuthorization() {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailedAuthorization(Throwable throwable) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthorizationFlowCompleted() {
|
||||
// Trigger immediate state refresh upon authorization success.
|
||||
rescheduleStatePoll(0, stateInactiveRefreshIntervalSeconds, true);
|
||||
@@ -226,8 +229,8 @@ public class BoschIndegoHandler extends BaseThingHandler implements Authorizatio
|
||||
handleRefreshCommand(channelUID.getId());
|
||||
return;
|
||||
}
|
||||
if (command instanceof DecimalType && channelUID.getId().equals(STATE)) {
|
||||
sendCommand(((DecimalType) command).intValue());
|
||||
if (command instanceof DecimalType decimalCommand && channelUID.getId().equals(STATE)) {
|
||||
sendCommand(decimalCommand.intValue());
|
||||
}
|
||||
} catch (IndegoAuthenticationException e) {
|
||||
// Ignore, will be handled by bridge
|
||||
|
||||
Reference in New Issue
Block a user