In Registry.getConnectedServices(IConnection), return empty collection instead of null. Use isEmpty() instead of == null for caller conditionals
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Wed Feb 17 08:25:29 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Wed Feb 17 12:51:20 2010 -0800
@@ -433,7 +433,7 @@
if (connectedServices != null)
return new ArrayList<IConnectedService>(connectedServices);
- return null;
+ return Collections.emptyList();
}
private File getConnectionStorageFile() {
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Wed Feb 17 08:25:29 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Wed Feb 17 12:51:20 2010 -0800
@@ -144,7 +144,7 @@
Collection<IConnectedService> connectedServices =
Registry.instance().getConnectedServices(connection);
// if any service is in-use, then connection is in-use
- if (connectedServices == null)
+ if (connectedServices.isEmpty())
return null;
for (IConnectedService connectedService : connectedServices) {
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java Wed Feb 17 08:25:29 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/SettingsWizard.java Wed Feb 17 12:51:20 2010 -0800
@@ -139,7 +139,7 @@
private void saveConnectedServicesEnabledState() {
Collection<IConnectedService> connectedServices = Registry.instance().getConnectedServices(connectionToEdit);
- if (connectedServices == null)
+ if (connectedServices.isEmpty())
return;
if (savedEnabledStates == null)
savedEnabledStates = new HashMap<IConnectedService, Boolean>();
@@ -150,7 +150,7 @@
private void enableConnectedServices(boolean enabled) {
Collection<IConnectedService> connectedServices = Registry.instance().getConnectedServices(connectionToEdit);
- if (connectedServices == null || savedEnabledStates == null)
+ if (connectedServices.isEmpty() || savedEnabledStates == null)
return;
for (IConnectedService connectedService : connectedServices) {
if (!enabled) // disable when asked
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Wed Feb 17 08:25:29 2010 -0600
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Wed Feb 17 12:51:20 2010 -0800
@@ -196,11 +196,9 @@
if (connection != null) {
IConnectedService connectedService = null;
Collection<IConnectedService> services = manager.getConnectedServices(connection);
- if (services != null) {
- for (IConnectedService service : services) {
- if (service != null && service.getService().getIdentifier().equals(data.getService().getIdentifier())) {
- connectedService = service;
- }
+ for (IConnectedService service : services) {
+ if (service != null && service.getService().getIdentifier().equals(data.getService().getIdentifier())) {
+ connectedService = service;
}
}