Skip to content

Commit

Permalink
update the jmri.display loadref xml, remove null checks in xml store
Browse files Browse the repository at this point in the history
nonnull annot overrides in several managers
  • Loading branch information
silverailscolo committed Sep 10, 2019
1 parent df74667 commit 9620aaf
Show file tree
Hide file tree
Showing 28 changed files with 237 additions and 281 deletions.
1 change: 0 additions & 1 deletion java/src/jmri/Manager.java
Expand Up @@ -319,7 +319,6 @@ public default String validateIntegerSystemNameFormat(@Nonnull String name, int
return name;
}


/**
* Convenience implementation of
* {@link #validateSystemNameFormat(java.lang.String, java.util.Locale)}
Expand Down
7 changes: 5 additions & 2 deletions java/src/jmri/NamedBeanHandleManager.java
Expand Up @@ -208,8 +208,9 @@ public char typeLetter() {
}

@Override
@Nonnull
@CheckReturnValue
public String makeSystemName(String s) {
public String makeSystemName(@Nonnull String s) {
throw new UnsupportedOperationException("Not supported yet.");
}

Expand Down Expand Up @@ -244,7 +245,7 @@ protected void firePropertyChange(String p, Object old, Object n) {
}

@Override
public void register(NamedBean n) {
public void register(@Nonnull NamedBean n) {
throw new UnsupportedOperationException("Not supported yet.");
}

Expand All @@ -260,10 +261,12 @@ public int getXMLOrder() {
}

@Override
@Nonnull
@CheckReturnValue
public String getBeanTypeHandled(boolean plural) {
return Bundle.getMessage(plural ? "BeanNames" : "BeanName");
}

private final static Logger log = LoggerFactory.getLogger(NamedBeanHandleManager.class);

}
16 changes: 4 additions & 12 deletions java/src/jmri/configurexml/BlockManagerXml.java
Expand Up @@ -85,10 +85,6 @@ public Element store(Object o) {
if (true) {
// write out first set of blocks without contents
for (Block b : blkList) {
if (b == null) {
log.error("Block null during store1, skipped");
break;
}
try {
String bName = b.getSystemName();
Element elem = new Element("block");
Expand All @@ -115,10 +111,6 @@ public Element store(Object o) {

// write out with contents
for (Block b : blkList) {
if (b == null) {
log.error("Block null during store2, skipped");
break;
}
String bName = b.getSystemName();
String uName = b.getUserName();
if (uName == null) {
Expand Down Expand Up @@ -183,7 +175,7 @@ public Element store(Object o) {
return blocks;
}

void addPath(Element e, Path p) {
private void addPath(Element e, Path p) {
// for now, persist two directions and a bean setting
Element pe = new Element("path");
pe.setAttribute("todir", "" + p.getToBlockDirection());
Expand All @@ -193,14 +185,14 @@ void addPath(Element e, Path p) {
}
List<BeanSetting> l = p.getSettings();
if (l != null) {
for (int i = 0; i < l.size(); i++) {
addBeanSetting(pe, l.get(i));
for (BeanSetting bSet : l) {
addBeanSetting(pe, bSet);
}
}
e.addContent(pe);
}

void addBeanSetting(Element e, BeanSetting bs) {
private void addBeanSetting(Element e, BeanSetting bs) {
// persist bean name, type and value
Element bse = new Element("beansetting");
// for now, assume turnout
Expand Down
5 changes: 0 additions & 5 deletions java/src/jmri/configurexml/TransitManagerXml.java
Expand Up @@ -31,7 +31,6 @@ public TransitManagerXml() {
* @return Element containing the complete info
*/
@Override
@SuppressWarnings("deprecation") // needs careful unwinding for Set operations
public Element store(Object o) {
Element transits = new Element("transits");
setStoreElementClass(transits);
Expand All @@ -45,10 +44,6 @@ public Element store(Object o) {

// store the Transit
for (Transit transit : tstList) {
if (transit == null) {
log.error("Transit null during store, skipped");
break;
}
String tstName = transit.getSystemName();
log.debug("Transit system name is {}", tstName);

Expand Down
10 changes: 7 additions & 3 deletions java/src/jmri/jmrix/dcc4pc/Dcc4PcSensorManager.java
Expand Up @@ -13,6 +13,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;

/**
* Implement SensorManager for Dcc4Pc systems. The Manager handles all the state
* changes.
Expand Down Expand Up @@ -49,7 +51,7 @@ public boolean execute() {
Dcc4PcTrafficController tc;

@Override
public Dcc4PcSensor getSensor(String name) {
public Dcc4PcSensor getSensor(@Nonnull String name) {
return (Dcc4PcSensor) super.getSensor(name);

}
Expand All @@ -58,6 +60,7 @@ public Dcc4PcSensor getSensor(String name) {
* {@inheritDoc}
*/
@Override
@Nonnull
public Dcc4PcSystemConnectionMemo getMemo() {
return (Dcc4PcSystemConnectionMemo) memo;
}
Expand Down Expand Up @@ -91,13 +94,14 @@ void extractBoardID(String systemName) {
}

@Override
public boolean allowMultipleAdditions(String systemName) {
public boolean allowMultipleAdditions(@Nonnull String systemName) {
return true;
}

//we want the system name to be in the format of board:input
@Override
public String createSystemName(String curAddress, String prefix) throws JmriException {
@Nonnull
public String createSystemName(String curAddress, @Nonnull String prefix) throws JmriException {
String iName;
if (curAddress.contains(":")) {
board = 0;
Expand Down
15 changes: 10 additions & 5 deletions java/src/jmri/jmrix/roco/z21/Z21SensorManager.java
Expand Up @@ -8,6 +8,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;

/**
* Manage the Z21Specific Sensor implementation.
* <p>
Expand Down Expand Up @@ -43,6 +45,7 @@ public Z21SensorManager(Z21SystemConnectionMemo memo) {
* {@inheritDoc}
*/
@Override
@Nonnull
public Z21SystemConnectionMemo getMemo() {
return (Z21SystemConnectionMemo) memo;
}
Expand Down Expand Up @@ -135,7 +138,8 @@ public void message(Z21Message l) {
* {@inheritDoc}
*/
@Override
public String validateSystemNameFormat(String name, Locale locale) {
@Nonnull
public String validateSystemNameFormat(@Nonnull String name, @Nonnull Locale locale) {
name = validateSystemNamePrefix(name, locale);
if (name.substring(getSystemNamePrefix().length()).contains(":")) {
return Z21CanBusAddress.validateSystemNameFormat(name, this, locale);
Expand All @@ -155,12 +159,13 @@ public NameValidity validSystemNameFormat(String systemName) {
}

@Override
public boolean allowMultipleAdditions(String systemName) {
public boolean allowMultipleAdditions(@Nonnull String systemName) {
return true;
}

@Override
public synchronized String createSystemName(String curAddress, String prefix) throws JmriException {
@Nonnull
public synchronized String createSystemName(String curAddress, @Nonnull String prefix) throws JmriException {
int encoderAddress = 0;
int input = 0;

Expand Down Expand Up @@ -200,7 +205,7 @@ public synchronized String createSystemName(String curAddress, String prefix) th
* Does not enforce any rules on the encoder or input values.
*/
@Override
public synchronized String getNextValidAddress(String curAddress, String prefix) {
public synchronized String getNextValidAddress(@Nonnull String curAddress, @Nonnull String prefix) {

String tmpSName = "";

Expand Down Expand Up @@ -234,7 +239,7 @@ public synchronized String getNextValidAddress(String curAddress, String prefix)
* {@inheritDoc}
*/
@Override
public Sensor getBySystemName(String sName){
public Sensor getBySystemName(@Nonnull String sName){
Z21SystemNameComparator comparator = new Z21SystemNameComparator(getSystemPrefix(),typeLetter());
return getBySystemName(sName,comparator);
}
Expand Down

0 comments on commit 9620aaf

Please sign in to comment.