Skip to content
Permalink
Browse files

LocoNet connection spotbugs fixes

  • Loading branch information...
devel-bobm committed Mar 4, 2019
1 parent 756cf65 commit 18713c835ee2ad0d0cd072f3c3f90b498403a212
@@ -13,6 +13,8 @@
/**
* Ctor for an object being created during load process; Swing init is
* deferred.
*
* @param p - Serial port adapter for the connection
*/
public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
super(p);
@@ -25,11 +27,19 @@ public ConnectionConfig() {
super();
}

/**
* Get the connection type name
* @return Connection type name
*/
@Override
public String name() {
return "LocoNet PR3"; // NOI18N
}

/**
* Is Option List 2 Advanced?
* @return boolean, always false
*/
public boolean isOptList2Advanced() {
return false;
}
@@ -1,6 +1,7 @@
package jmri.jmrix.loconet.pr3;

import jmri.jmrix.loconet.LnCommandStationType;
import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
import jmri.jmrix.loconet.LnPacketizer;
import jmri.jmrix.loconet.LocoNetMessage;
import jmri.jmrix.loconet.locobuffer.LocoBufferAdapter;
@@ -176,16 +177,16 @@ public void configure() {
return retval;
}


@Override
public PR3SystemConnectionMemo getSystemConnectionMemo() {
if (super.getSystemConnectionMemo() instanceof PR3SystemConnectionMemo) {
return (PR3SystemConnectionMemo) super.getSystemConnectionMemo();
} else {
log.error("Cannot cast the system connection memo to a PR3SystemConnection Memo.");
return null;
LocoNetSystemConnectionMemo m = super.getSystemConnectionMemo();
if (m instanceof PR3SystemConnectionMemo) {
return (PR3SystemConnectionMemo) m;
}
log.error("Cannot cast the system connection memo to a PR3SystemConnection Memo.");
return null;
}


private final static Logger log = LoggerFactory.getLogger(PR3Adapter.class);
}
@@ -12,11 +12,13 @@
* @author B. Milhaupt Copyright (C) 2019
*/

public class ConnectionConfig extends jmri.jmrix.loconet.pr3.ConnectionConfig {
public class ConnectionConfig extends jmri.jmrix.AbstractSerialConnectionConfig {

/**
* Ctor for an object being created during load process; Swing init is
* deferred.
*
* @param p - Serial port adapter for the connection
*/
public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
super(p);
@@ -29,11 +31,31 @@ public ConnectionConfig() {
super();
}

/**
* Get the connection type name
* @return Connection type name
*/
@Override
public String name() {
return "LocoNet PR4"; // NOI18N
}

/**
* Is Option List 2 Advanced?
* @return boolean, always false
*/
public boolean isOptList2Advanced() {
return false;
}

@Override
protected String[] getPortFriendlyNames() {
if (SystemType.isWindows()) {
return new String[]{"Communications Port"}; // NOI18N
}
return new String[]{};
}

@Override
protected void setInstance() {
if (adapter == null) {
@@ -3,6 +3,7 @@
import jmri.jmrix.loconet.LnCommandStationType;
import jmri.jmrix.loconet.LnPacketizer;
import jmri.jmrix.loconet.LocoNetMessage;
import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
import jmri.jmrix.loconet.locobuffer.LocoBufferAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -177,14 +178,13 @@ public void configure() {

@Override
public PR4SystemConnectionMemo getSystemConnectionMemo() {
if (super.getSystemConnectionMemo() instanceof PR4SystemConnectionMemo) {
return (PR4SystemConnectionMemo) super.getSystemConnectionMemo();
} else {
log.error("Cannot cast the system connection memo to a PR4SystemConnection Memo.");
return null;
LocoNetSystemConnectionMemo m = super.getSystemConnectionMemo();
if (m instanceof PR4SystemConnectionMemo) {
return (PR4SystemConnectionMemo) m;
}
log.error("Cannot cast the system connection memo to a PR4SystemConnection Memo.");
return null;
}


private final static Logger log = LoggerFactory.getLogger(PR4Adapter.class);
}
@@ -3,6 +3,7 @@
import jmri.jmrix.loconet.LnCommandStationType;
import jmri.jmrix.loconet.LnPacketizer;
import jmri.jmrix.loconet.LocoNetMessage;
import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
import jmri.jmrix.loconet.locobuffer.LocoBufferAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -180,14 +181,13 @@ public void configure() {

@Override
public UsbDcs240SystemConnectionMemo getSystemConnectionMemo() {
if (super.getSystemConnectionMemo() instanceof UsbDcs240SystemConnectionMemo) {
return (UsbDcs240SystemConnectionMemo) super.getSystemConnectionMemo();
} else {
log.error("Cannot cast the system connection memo to a UsbDcs240SystemConnection Memo.");
return null;
LocoNetSystemConnectionMemo m = super.getSystemConnectionMemo();
if (m instanceof UsbDcs240SystemConnectionMemo) {
return (UsbDcs240SystemConnectionMemo) m;
}
log.error("Cannot cast the system connection memo to a UsbDcs240SystemConnection Memo.");
return null;
}


private final static Logger log = LoggerFactory.getLogger(UsbDcs240Adapter.class);
}
@@ -36,7 +36,7 @@ protected void getInstance(Object object) {

@Override
protected void register() {
this.register(new ConnectionConfig(adapter));
super.register(new ConnectionConfig(adapter));
}

}
@@ -3,6 +3,7 @@
import jmri.jmrix.loconet.LnCommandStationType;
import jmri.jmrix.loconet.LnPacketizer;
import jmri.jmrix.loconet.LocoNetMessage;
import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
import jmri.jmrix.loconet.locobuffer.LocoBufferAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -180,14 +181,13 @@ public void configure() {

@Override
public UsbDcs52SystemConnectionMemo getSystemConnectionMemo() {
if (super.getSystemConnectionMemo() instanceof UsbDcs52SystemConnectionMemo) {
return (UsbDcs52SystemConnectionMemo) super.getSystemConnectionMemo();
} else {
log.error("Cannot cast the system connection memo to a UsbDcs52SystemConnection Memo.");
return null;
LocoNetSystemConnectionMemo m = super.getSystemConnectionMemo();
if (m instanceof UsbDcs52SystemConnectionMemo) {
return (UsbDcs52SystemConnectionMemo) m;
}
log.error("Cannot cast the system connection memo to a UsbDcs52SystemConnection Memo.");
return null;
}


private final static Logger log = LoggerFactory.getLogger(UsbDcs52Adapter.class);
}
@@ -18,7 +18,7 @@
* @author Bob Jacobsen Copyright: Copyright (c) 2003, 2005, 2006, 2008
* @author B. Milhaupt Copyright (C) 2019
*/
public class ConnectionConfigXml extends jmri.jmrix.loconet.pr3.configurexml.ConnectionConfigXml {
public class ConnectionConfigXml extends AbstractSerialConnectionConfigXml {

@Override
protected void getInstance() {
@@ -32,7 +32,7 @@ protected void getInstance(Object object) {

@Override
protected void register() {
this.register(new ConnectionConfig(adapter));
super.register(new ConnectionConfig(adapter));
}

}

0 comments on commit 18713c8

Please sign in to comment.
You can’t perform that action at this time.