Skip to content

Commit

Permalink
Minot, findbugs related, cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengtmartensson committed Mar 12, 2024
1 parent 9d45825 commit 2b9b5af
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public GirsClientBean(GuiUtils guiUtils, boolean verbose, int timeout, String in
DefaultComboBoxModel<String> model;
try {
portNames = LocalSerialPort.getSerialPortNames(true);
model = new DefaultComboBoxModel<>(portNames.toArray(new String[portNames.size()]));
model = new DefaultComboBoxModel<>(portNames.toArray(new String[0]));
} catch (IOException | LinkageError ex) {
portNames = new ArrayList<>(0);
model = new DefaultComboBoxModel<>(new String[]{ initialPort != null ? initialPort : NOT_INITIALIZED });
Expand Down Expand Up @@ -241,7 +241,7 @@ private void setupPortComboBox(boolean useCached) throws IOException {

portNames = LocalSerialPort.getSerialPortNames(useCached);
portNames.add(0, "");
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(portNames.toArray(new String[portNames.size()]));
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(portNames.toArray(new String[0]));
portComboBox.setModel(model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public boolean removeManualGlobalCache(InetAddress inetAddress) {
}

public InetAddress[] getManual() {
return manualGlobalCaches.toArray(new InetAddress[manualGlobalCaches.size()]);
return manualGlobalCaches.toArray(new InetAddress[0]);
}

public InetAddress[] getAutomatic() {
return automaticGlobalCaches.toArray(new InetAddress[automaticGlobalCaches.size()]);
return automaticGlobalCaches.toArray(new InetAddress[0]);
}

public String[] getAllNames() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private String[] irpMasterProtocols() {
if (irpDatabase == null)
return new String[]{"--"};

String[] protocolList = irpDatabase.getNames().toArray(new String[irpDatabase.getNames().size()]);
String[] protocolList = irpDatabase.getNames().toArray(new String[0]);
java.util.Arrays.sort(protocolList, String.CASE_INSENSITIVE_ORDER);
return protocolList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected static DefaultComboBoxModel<String> createModel(boolean useCached) {
portNames.add("");
}
//portNames.add(0, "");
return new DefaultComboBoxModel<>(portNames.toArray(new String[portNames.size()]));
return new DefaultComboBoxModel<>(portNames.toArray(new String[0]));
}

protected String portName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void setupPortComboBox(boolean useCached) throws IOException {

List<String> portNames = LocalSerialPort.getSerialPortNames(useCached);
portNames.add(0, null);
DefaultComboBoxModel model = new DefaultComboBoxModel(portNames.toArray(new String[portNames.size()]));
DefaultComboBoxModel model = new DefaultComboBoxModel(portNames.toArray(new String[0]));
portComboBox.setModel(model);
}

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.comm.DriverGenUnix;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
Expand Down Expand Up @@ -1022,7 +1020,7 @@ private Command.CommandTextFormat[] setupExtraTextFormats() {
formats.add(new BroadlinkHexFormatter());
if (properties.getExportGenerateBroadlinkBase64())
formats.add(new BroadlinkBase64Formatter());
return formats.toArray(new Command.CommandTextFormat[formats.size()]);
return formats.toArray(new Command.CommandTextFormat[0]);
}

private GirrExporter newGirrExporter() {
Expand Down Expand Up @@ -8738,7 +8736,7 @@ private void controlTowerManufacturerComboBoxActionPerformed(java.awt.event.Acti
if (controlTowerIrDatabase == null) {
controlTowerIrDatabase = new ControlTowerIrDatabase(properties.getVerbose());
Collection<String> manufacturers = controlTowerIrDatabase.getManufacturers();
String[] arr = manufacturers.toArray(new String[manufacturers.size()]);
String[] arr = manufacturers.toArray(new String[0]);
//resetCursor(oldCursor);
Arrays.sort(arr, String.CASE_INSENSITIVE_ORDER);
DefaultComboBoxModel dcbm = new DefaultComboBoxModel(arr);
Expand All @@ -8747,7 +8745,7 @@ private void controlTowerManufacturerComboBoxActionPerformed(java.awt.event.Acti
} else {
String manufacturer = (String) controlTowerManufacturerComboBox.getSelectedItem();
Collection<String> devTypes = controlTowerIrDatabase.getDeviceTypes(manufacturer);
String[] arr = devTypes.toArray(new String[devTypes.size()]);
String[] arr = devTypes.toArray(new String[0]);
Arrays.sort(arr, String.CASE_INSENSITIVE_ORDER);
DefaultComboBoxModel dcbm = new DefaultComboBoxModel(arr);
controlTowerDeviceTypeComboBox.setModel(dcbm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Set<String> getNames() {
public String[] toArray() {
ArrayList<String> list = new ArrayList<>(exportFormats.keySet());
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
return list.toArray(new String[list.size()]);
return list.toArray(new String[0]);
}

@SuppressWarnings("PublicInnerClass")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ protected static DocumentFragment parseToDocumentFragment(String str) {
protected Exporter() {
}

@SuppressWarnings("NoopMethodInAbstractClass")
protected void possiblyMakeExecutable(File file) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected static String[] gobbleString(String[] chunks, int column, boolean name
}
arrayList.add(chunk);
}
return arrayList.toArray(new String[arrayList.size()]);
return arrayList.toArray(new String[0]);
}
protected static String join(String[] arr) {
if (arr == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private String[] csvSplit(String line, String separator) {
}
chunks.add(chunk.trim());
}
return chunks.toArray(new String[chunks.size()]);
return chunks.toArray(new String[0]);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private String parseName(LineNumberReader reader) throws IOException, ParseExcep
String line = reader.readLine();
if (line == null)
throw new ParseException("[NAME] not found.", reader.getLineNumber());
@SuppressWarnings("SingleCharRegex")
String[] arr = line.trim().split("]");
if (!arr[0].equals("[NAME"))
throw new ParseException("[NAME] not found.", reader.getLineNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void clear() {
public String[] getManufacturers() throws IOException, SAXException {
assertDatabase();
List<String> manufacturer = remoteDatabase.getManufacturers();
return manufacturer.toArray(new String[manufacturer.size()]);
return manufacturer.toArray(new String[0]);
}

@Override
Expand All @@ -100,12 +100,12 @@ public Remote.MetaData getMetaData() {

public String[] getDeviceClasses(String manufacturer) throws NotFoundException {
List<String> deviceClasses = remoteDatabase.getDeviceTypes(manufacturer);
return deviceClasses.toArray(new String[deviceClasses.size()]);
return deviceClasses.toArray(new String[0]);
}

public String[] getRemotes(String manufacturer, String deviceType) throws NotFoundException {
List<String> remotes = remoteDatabase.getRemotes(manufacturer, deviceType);
return remotes.toArray(new String[remotes.size()]);
return remotes.toArray(new String[0]);
}

public void load(String manufacturer, String deviceType, String remoteName) throws NotFoundException {
Expand Down

0 comments on commit 2b9b5af

Please sign in to comment.