Refactoring towards Java language evolution.

- use the diamond operator in a few places
- use of multi-catch in a few places
This commit is contained in:
Rodrigo Bonifacio
2017-06-15 11:48:49 -03:00
parent 18a64d1b30
commit 325070d711
9 changed files with 17 additions and 32 deletions
+6 -11
View File
@@ -28,7 +28,7 @@ public class Library extends LocalContribution {
StringList packageList;
/** Per-platform exports for this library. */
HashMap<String, String[]> exportList;
HashMap<String, String[]> exportList;
/** Applet exports (cross-platform by definition). */
String[] appletExportList;
@@ -282,7 +282,7 @@ public class Library extends LocalContribution {
}
static protected HashMap<String, Object> packageWarningMap = new HashMap<String, Object>();
static protected HashMap<String, Object> packageWarningMap = new HashMap<>();
/**
* Add the packages provided by this library to the master list that maps
@@ -461,12 +461,7 @@ public class Library extends LocalContribution {
static public boolean hasMultipleArch(int platform, List<Library> libraries) {
for (Library library : libraries) {
if (library.hasMultipleArch(platform)) {
return true;
}
}
return false;
return libraries.stream().anyMatch(library -> library.hasMultipleArch(platform));
}
@@ -484,7 +479,7 @@ public class Library extends LocalContribution {
static public List<File> discover(File folder) {
List<File> libraries = new ArrayList<File>();
List<File> libraries = new ArrayList<>();
String[] folderNames = folder.list(junkFolderFilter);
// if a bad folder or something like that, this might come back null
@@ -529,8 +524,8 @@ public class Library extends LocalContribution {
static public List<Library> list(File folder) {
List<Library> libraries = new ArrayList<Library>();
List<File> librariesFolders = new ArrayList<File>();
List<Library> libraries = new ArrayList<>();
List<File> librariesFolders = new ArrayList<>();
librariesFolders.addAll(discover(folder));
for (File baseFolder : librariesFolders) {
+1 -1
View File
@@ -60,7 +60,7 @@ public class MarkerColumn extends JPanel {
private Color warningColor;
// Stores error markers displayed PER TAB along the error bar.
private List<LineMarker> errorPoints = new ArrayList<LineMarker>();
private List<LineMarker> errorPoints = new ArrayList<>();
public MarkerColumn(Editor editor, int height) {
@@ -109,9 +109,7 @@ public class FileTextFieldTransferHandler extends TransferHandler {
c.setText(file.getPath());
}
imported = true;
} catch (UnsupportedFlavorException ex) {
// ex.printStackTrace();
} catch (IOException ex) {
} catch (UnsupportedFlavorException | IOException ex) {
// ex.printStackTrace();
}
}
@@ -129,11 +127,7 @@ public class FileTextFieldTransferHandler extends TransferHandler {
boolean useRead = false;
handleReaderImport(r, c, useRead);
imported = true;
} catch (UnsupportedFlavorException ex) {
// ex.printStackTrace();
} catch (BadLocationException ex) {
// ex.printStackTrace();
} catch (IOException ex) {
} catch (UnsupportedFlavorException | BadLocationException | IOException ex) {
// ex.printStackTrace();
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ public class FloatDict {
protected float[] values;
/** Internal implementation for faster lookups */
private HashMap<String, Integer> indices = new HashMap<String, Integer>();
private HashMap<String, Integer> indices = new HashMap<>();
public FloatDict() {
+1 -1
View File
@@ -161,7 +161,7 @@ public class LED {
return new String[]{ "led0", "led1" };
}
ArrayList<String> devs = new ArrayList<String>();
ArrayList<String> devs = new ArrayList<>();
File dir = new File("/sys/class/leds");
File[] files = dir.listFiles();
if (files != null) {
@@ -81,7 +81,7 @@ public class VariableInspector extends JDialog {
// protected Debugger dbg;
/// list of expanded tree paths. (using list to maintain the order of expansion)
protected List<TreePath> expandedNodes = new ArrayList<TreePath>();
protected List<TreePath> expandedNodes = new ArrayList<>();
public VariableInspector(final JavaEditor editor) {
@@ -696,7 +696,7 @@ public class VariableInspector extends JDialog {
// first remove all children of collapsed path
// this makes sure children do not appear before parents in the list.
// (children can't be expanded before their parents)
List<TreePath> removalList = new ArrayList<TreePath>();
List<TreePath> removalList = new ArrayList<>();
for (TreePath path : expandedNodes) {
if (path.getParentPath().equals(tee.getPath())) {
removalList.add(path);
@@ -911,7 +911,7 @@ public class VariableInspector extends JDialog {
* @return the filtered list.
*/
protected List<VariableNode> filterNodes(List<VariableNode> nodes, VariableNodeFilter filter) {
List<VariableNode> filtered = new ArrayList<VariableNode>();
List<VariableNode> filtered = new ArrayList<>();
for (VariableNode node : nodes) {
if (filter.accept(node)) {
filtered.add(node);
@@ -52,9 +52,7 @@ public class ArrayFieldNode extends VariableNode {
public void setValue(Value value) {
try {
array.setValue(index, value);
} catch (InvalidTypeException ex) {
Messages.loge(null, ex);
} catch (ClassNotLoadedException ex) {
} catch (InvalidTypeException | ClassNotLoadedException ex) {
Messages.loge(null, ex);
}
this.value = value;
@@ -51,9 +51,7 @@ public class LocalVariableNode extends VariableNode {
public void setValue(Value value) {
try {
frame.setValue(var, value);
} catch (InvalidTypeException ex) {
Messages.loge(null, ex);
} catch (ClassNotLoadedException ex) {
} catch (InvalidTypeException | ClassNotLoadedException ex) {
Messages.loge(null, ex);
}
this.value = value;
@@ -55,7 +55,7 @@ public class VariableNode implements MutableTreeNode {
protected String type;
protected String name;
protected Value value;
protected List<MutableTreeNode> children = new ArrayList<MutableTreeNode>();
protected List<MutableTreeNode> children = new ArrayList<>();
protected MutableTreeNode parent;