diff --git a/app/src/cc/arduino/view/Event.java b/app/src/cc/arduino/view/Event.java index 5a050dfb3..86bac7504 100644 --- a/app/src/cc/arduino/view/Event.java +++ b/app/src/cc/arduino/view/Event.java @@ -39,7 +39,7 @@ public class Event extends ActionEvent { public Event(Object source, int id, String command) { super(source, id, command); - this.payload = new HashMap(); + this.payload = new HashMap<>(); } public Map getPayload() { diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 35b998c01..1e9574db6 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -85,7 +85,7 @@ public class Base { public static volatile Base INSTANCE; public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen()); - public static Map FIND_DIALOG_STATE = new HashMap(); + public static Map FIND_DIALOG_STATE = new HashMap<>(); private final ContributionInstaller contributionInstaller; private final LibraryInstaller libraryInstaller; private ContributionsSelfCheck contributionsSelfCheck; @@ -266,7 +266,7 @@ public class Base { public Base(String[] args) throws Exception { BaseNoGui.notifier = new GUIUserNotifier(this); - this.recentSketchesMenuItems = new LinkedList(); + this.recentSketchesMenuItems = new LinkedList<>(); CommandlineParser parser = new CommandlineParser(args); parser.parseArgumentsPhase1(); @@ -584,7 +584,7 @@ public class Base { return; } - Set sketches = new LinkedHashSet(); + Set sketches = new LinkedHashSet<>(); sketches.add(sketch.getSketch().getMainFilePath()); sketches.addAll(PreferencesData.getCollection("recent.sketches")); @@ -592,7 +592,7 @@ public class Base { } protected void removeRecentSketchPath(String path) { - Collection sketches = new LinkedList(PreferencesData.getCollection("recent.sketches")); + Collection sketches = new LinkedList<>(PreferencesData.getCollection("recent.sketches")); sketches.remove(path); PreferencesData.setCollection("recent.sketches", sketches); } @@ -1049,7 +1049,7 @@ public class Base { } private List getSortedLibraries() { - List installedLibraries = new LinkedList(BaseNoGui.librariesIndexer.getInstalledLibraries()); + List installedLibraries = new LinkedList<>(BaseNoGui.librariesIndexer.getInstalledLibraries()); Collections.sort(installedLibraries, new LibraryByTypeComparator()); Collections.sort(installedLibraries, new LibraryOfSameTypeComparator()); return installedLibraries; @@ -1415,7 +1415,7 @@ public class Base { boardMenu.add(new JSeparator()); // Generate custom menus for all platforms - Set customMenusTitles = new HashSet(); + Set customMenusTitles = new HashSet<>(); for (TargetPackage targetPackage : BaseNoGui.packages.values()) { for (TargetPlatform targetPlatform : targetPackage.platforms()) { customMenusTitles.addAll(targetPlatform.getCustomMenus().values()); @@ -1427,10 +1427,10 @@ public class Base { boardsCustomMenus.add(customMenu); } - List menuItemsToClickAfterStartup = new LinkedList(); + List menuItemsToClickAfterStartup = new LinkedList<>(); ButtonGroup boardsButtonGroup = new ButtonGroup(); - Map buttonGroupsMap = new HashMap(); + Map buttonGroupsMap = new HashMap<>(); // Cycle through all packages boolean first = true; @@ -2129,7 +2129,7 @@ public class Base { * that are separated by = and ignore comments with #. */ static public HashMap readSettings(File inputFile) { - HashMap outgoing = new HashMap(); + HashMap outgoing = new HashMap<>(); if (!inputFile.exists()) return outgoing; // return empty hash String lines[] = PApplet.loadStrings(inputFile); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index cf18537a3..ff245b931 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -230,7 +230,7 @@ public class Editor extends JFrame implements RunnerListener { public void windowDeactivated(WindowEvent e) { fileMenu.remove(sketchbookMenu); fileMenu.remove(examplesMenu); - List toolsMenuItemsToRemove = new LinkedList(); + List toolsMenuItemsToRemove = new LinkedList<>(); for (Component menuItem : toolsMenu.getMenuComponents()) { if (menuItem instanceof JComponent) { Object removeOnWindowDeactivation = ((JComponent) menuItem).getClientProperty("removeOnWindowDeactivation"); @@ -816,7 +816,7 @@ public class Editor extends JFrame implements RunnerListener { if (sourceFolder == null) return; - Map toolItems = new HashMap(); + Map toolItems = new HashMap<>(); File[] folders = sourceFolder.listFiles(new FileFilter() { public boolean accept(File folder) { @@ -906,7 +906,7 @@ public class Editor extends JFrame implements RunnerListener { e.printStackTrace(); } } - ArrayList toolList = new ArrayList(toolItems.keySet()); + ArrayList toolList = new ArrayList<>(toolItems.keySet()); if (toolList.size() == 0) return; menu.addSeparator(); diff --git a/app/src/processing/app/PresentMode.java b/app/src/processing/app/PresentMode.java index f9bc568de..49f888e2e 100644 --- a/app/src/processing/app/PresentMode.java +++ b/app/src/processing/app/PresentMode.java @@ -59,7 +59,7 @@ public class PresentMode { devices = environment.getScreenDevices(); GraphicsDevice defaultDevice = environment.getDefaultScreenDevice(); - Vector names = new Vector(); + Vector names = new Vector<>(); for (int i = 0; i < devices.length; i++) { String name = String.valueOf(i + 1); if (devices[i] == defaultDevice) { diff --git a/app/src/processing/app/SerialPlotter.java b/app/src/processing/app/SerialPlotter.java index decbb9694..4cfb9da49 100644 --- a/app/src/processing/app/SerialPlotter.java +++ b/app/src/processing/app/SerialPlotter.java @@ -185,7 +185,7 @@ public class SerialPlotter extends AbstractMonitor { }); messageBuffer = new StringBuffer(); - graphs = new ArrayList(); + graphs = new ArrayList<>(); } protected void onCreateWindow(Container mainPane) { diff --git a/app/src/processing/app/Theme.java b/app/src/processing/app/Theme.java index 931710342..cea6e6fe4 100644 --- a/app/src/processing/app/Theme.java +++ b/app/src/processing/app/Theme.java @@ -228,12 +228,12 @@ public class Theme { Font styledFont = new Font(font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize()); if (underlined) { - Map attr = new Hashtable(); + Map attr = new Hashtable<>(); attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); styledFont = styledFont.deriveFont(attr); } - Map result = new HashMap(); + Map result = new HashMap<>(); result.put("color", color); result.put("font", styledFont); diff --git a/arduino-core/src/cc/arduino/UploaderUtils.java b/arduino-core/src/cc/arduino/UploaderUtils.java index a80eaf506..ec27b4961 100644 --- a/arduino-core/src/cc/arduino/UploaderUtils.java +++ b/arduino-core/src/cc/arduino/UploaderUtils.java @@ -70,7 +70,7 @@ public class UploaderUtils { boolean useNewWarningsAccumulator = false; if (warningsAccumulator == null) { - warningsAccumulator = new LinkedList(); + warningsAccumulator = new LinkedList<>(); useNewWarningsAccumulator = true; } diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java index 6da9a5f46..a78b6b637 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndex.java @@ -66,7 +66,7 @@ public abstract class LibrariesIndex { } public List getCategories() { - List categories = new LinkedList(); + List categories = new LinkedList<>(); for (ContributedLibrary lib : getLibraries()) { if (lib.getCategory() != null && !categories.contains(lib.getCategory())) { categories.add(lib.getCategory()); @@ -78,14 +78,14 @@ public abstract class LibrariesIndex { } public List getTypes() { - Collection typesAccumulator = new HashSet(); + Collection typesAccumulator = new HashSet<>(); for (ContributedLibrary lib : getLibraries()) { if (lib.getTypes() != null) { typesAccumulator.addAll(lib.getTypes()); } } - List types = new LinkedList(typesAccumulator); + List types = new LinkedList<>(typesAccumulator); Collections.sort(types); return types; diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java b/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java index f00836ed8..e15e5dc78 100644 --- a/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java +++ b/arduino-core/src/cc/arduino/contributions/packages/ContributedTargetPackage.java @@ -43,7 +43,7 @@ public class ContributedTargetPackage implements TargetPackage { public ContributedTargetPackage(String _id) { id = _id; - platforms = new HashMap(); + platforms = new HashMap<>(); } void addPlatform(TargetPlatform p) { diff --git a/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java b/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java index 50cca37e9..148f4db1d 100644 --- a/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java +++ b/arduino-core/src/cc/arduino/files/DeleteFilesOnShutdown.java @@ -48,7 +48,7 @@ public class DeleteFilesOnShutdown implements Runnable { private final List files; public DeleteFilesOnShutdown() { - this.files = new LinkedList(); + this.files = new LinkedList<>(); } public synchronized void addFile(File file) { @@ -63,7 +63,7 @@ public class DeleteFilesOnShutdown implements Runnable { } List copyOfFiles; synchronized (this) { - copyOfFiles = new LinkedList(files); + copyOfFiles = new LinkedList<>(files); } Collections.reverse(copyOfFiles); for (File file : copyOfFiles) { diff --git a/arduino-core/src/cc/arduino/packages/DiscoveryManager.java b/arduino-core/src/cc/arduino/packages/DiscoveryManager.java index 2632386d4..01259e8e0 100644 --- a/arduino-core/src/cc/arduino/packages/DiscoveryManager.java +++ b/arduino-core/src/cc/arduino/packages/DiscoveryManager.java @@ -44,7 +44,7 @@ public class DiscoveryManager { private final NetworkDiscovery networkDiscoverer = new NetworkDiscovery(); public DiscoveryManager() { - discoverers = new ArrayList(); + discoverers = new ArrayList<>(); discoverers.add(serialDiscoverer); discoverers.add(networkDiscoverer); @@ -76,7 +76,7 @@ public class DiscoveryManager { } public List discovery() { - List res = new ArrayList(); + List res = new ArrayList<>(); for (Discovery d : discoverers) { res.addAll(d.listDiscoveredBoards()); } @@ -84,7 +84,7 @@ public class DiscoveryManager { } public List discovery(boolean complete) { - List res = new ArrayList(); + List res = new ArrayList<>(); for (Discovery d : discoverers) { res.addAll(d.listDiscoveredBoards(complete)); } diff --git a/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java b/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java index 1fc007997..6d1e4ba31 100644 --- a/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java +++ b/arduino-core/src/cc/arduino/utils/ArchiveExtractor.java @@ -86,7 +86,7 @@ public class ArchiveExtractor { // Folders timestamps must be set at the end of archive extraction // (because creating a file in a folder alters the folder's timestamp) - Map foldersTimestamps = new HashMap(); + Map foldersTimestamps = new HashMap<>(); ArchiveInputStream in = null; try { @@ -106,10 +106,10 @@ public class ArchiveExtractor { String pathPrefix = ""; - Map hardLinks = new HashMap(); - Map hardLinksMode = new HashMap(); - Map symLinks = new HashMap(); - Map symLinksModifiedTimes = new HashMap(); + Map hardLinks = new HashMap<>(); + Map hardLinksMode = new HashMap<>(); + Map symLinks = new HashMap<>(); + Map symLinksModifiedTimes = new HashMap<>(); // Cycle through all the archive entries while (true) { diff --git a/arduino-core/src/edazdarevic/commons/net/CIDRUtils.java b/arduino-core/src/edazdarevic/commons/net/CIDRUtils.java index d564209f2..c966ef773 100644 --- a/arduino-core/src/edazdarevic/commons/net/CIDRUtils.java +++ b/arduino-core/src/edazdarevic/commons/net/CIDRUtils.java @@ -100,7 +100,7 @@ public class CIDRUtils { private byte[] toBytes(byte[] array, int targetSize) { int counter = 0; - List newArr = new ArrayList(); + List newArr = new ArrayList<>(); while (counter < targetSize && (array.length - 1 - counter >= 0)) { newArr.add(0, array[array.length - 1 - counter]); counter++; diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index 5c010b733..f264e7376 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -500,7 +500,7 @@ public class BaseNoGui { showError(tr("Multiple files not supported"), tr("The --upload option supports only one file at a time"), null); } - List warningsAccumulator = new LinkedList(); + List warningsAccumulator = new LinkedList<>(); boolean success = false; try { // Editor constructor loads the sketch with handleOpenInternal() that @@ -619,7 +619,7 @@ public class BaseNoGui { } indexer.syncWithFilesystem(); - packages = new LinkedHashMap(); + packages = new LinkedHashMap<>(); loadHardware(getHardwareFolder()); loadContributedHardware(indexer); loadHardware(getSketchbookHardwareFolder()); @@ -794,7 +794,7 @@ public class BaseNoGui { static public void onBoardOrPortChange() { examplesFolder = getContentFile("examples"); toolsFolder = getContentFile("tools"); - librariesFolders = new ArrayList(); + librariesFolders = new ArrayList<>(); // Add IDE libraries folder librariesFolders.add(getContentFile("libraries")); @@ -874,7 +874,7 @@ public class BaseNoGui { // a list of libraries. Compiler.java will use only the first // library on each list. The others are used only to advise // user of ambiguously matched and duplicate libraries. - importToLibraryTable = new HashMap(); + importToLibraryTable = new HashMap<>(); for (UserLibrary lib : librariesIndexer.getInstalledLibraries()) { try { String headers[] = headerListFromIncludePath(lib.getSrcFolder()); diff --git a/arduino-core/src/processing/app/Platform.java b/arduino-core/src/processing/app/Platform.java index 05eab1481..f829699bd 100644 --- a/arduino-core/src/processing/app/Platform.java +++ b/arduino-core/src/processing/app/Platform.java @@ -177,7 +177,7 @@ public class Platform { } public List listSerials() { - return new ArrayList(Arrays.asList(listSerialsNative())); + return new ArrayList<>(Arrays.asList(listSerialsNative())); } public List listSerialsNames(){ @@ -233,13 +233,13 @@ public class Platform { for (TargetPackage targetPackage : packages.values()) { for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) { for (TargetBoard board : targetPlatform.getBoards().values()) { - List vids = new LinkedList(board.getPreferences().subTree("vid", 1).values()); + List vids = new LinkedList<>(board.getPreferences().subTree("vid", 1).values()); if (!vids.isEmpty()) { - List pids = new LinkedList(board.getPreferences().subTree("pid", 1).values()); + List pids = new LinkedList<>(board.getPreferences().subTree("pid", 1).values()); for (int i = 0; i < vids.size(); i++) { String vidPid = vids.get(i) + "_" + pids.get(i); if (vid_pid_iSerial.toUpperCase().contains(vidPid.toUpperCase())) { - Map boardData = new HashMap(); + Map boardData = new HashMap<>(); boardData.put("board", board); boardData.put("vid", vids.get(i)); boardData.put("pid", pids.get(i)); @@ -286,7 +286,7 @@ public class Platform { } public List filterPorts(List ports, boolean aBoolean) { - return new LinkedList(ports); + return new LinkedList<>(ports); } public void fixPrefsFilePermissions(File prefsFile) throws IOException, InterruptedException { diff --git a/arduino-core/src/processing/app/SerialPortList.java b/arduino-core/src/processing/app/SerialPortList.java index 57f833cfa..04e8c46b5 100644 --- a/arduino-core/src/processing/app/SerialPortList.java +++ b/arduino-core/src/processing/app/SerialPortList.java @@ -310,7 +310,7 @@ public class SerialPortList { if(portNames == null){ return new String[]{}; } - TreeSet ports = new TreeSet(comparator); + TreeSet ports = new TreeSet<>(comparator); for(String portName : portNames){ if(pattern.matcher(portName).find()){ ports.add(portName); @@ -329,7 +329,7 @@ public class SerialPortList { if(dir.exists() && dir.isDirectory()){ File[] files = dir.listFiles(); if(files.length > 0){ - TreeSet portsTree = new TreeSet(comparator); + TreeSet portsTree = new TreeSet<>(comparator); for(File file : files){ String fileName = file.getName(); if(!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()){ diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java index f94bae9ac..3022b9cd4 100644 --- a/arduino-core/src/processing/app/Sketch.java +++ b/arduino-core/src/processing/app/Sketch.java @@ -27,7 +27,7 @@ public class Sketch { */ private File folder; - private List files = new ArrayList(); + private List files = new ArrayList<>(); private File buildPath; diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java index fdfdf3134..5e30319dc 100644 --- a/arduino-core/src/processing/app/helpers/FileUtils.java +++ b/arduino-core/src/processing/app/helpers/FileUtils.java @@ -210,7 +210,7 @@ public class FileUtils { } public static List readFileToListOfStrings(File file) throws IOException { - List strings = new LinkedList(); + List strings = new LinkedList<>(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); @@ -343,7 +343,7 @@ public class FileUtils { public static List listFiles(File folder, boolean recursive, List extensions) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (File file : folder.listFiles()) { if (isSCCSOrHiddenFile(file)) diff --git a/arduino-core/src/processing/app/helpers/PreferencesMap.java b/arduino-core/src/processing/app/helpers/PreferencesMap.java index 2e3bf83b3..e1628b652 100644 --- a/arduino-core/src/processing/app/helpers/PreferencesMap.java +++ b/arduino-core/src/processing/app/helpers/PreferencesMap.java @@ -182,7 +182,7 @@ public class PreferencesMap extends LinkedHashMap { * @return */ public Map firstLevelMap() { - Map res = new LinkedHashMap(); + Map res = new LinkedHashMap<>(); for (String key : keySet()) { int dot = key.indexOf('.'); if (dot == -1) @@ -246,7 +246,7 @@ public class PreferencesMap extends LinkedHashMap { public String toString(String indent) { String res = indent + "{\n"; - SortedSet treeSet = new TreeSet(keySet()); + SortedSet treeSet = new TreeSet<>(keySet()); for (String k : treeSet) res += indent + k + " = " + get(k) + "\n"; return res; diff --git a/arduino-core/src/processing/app/helpers/StringReplacer.java b/arduino-core/src/processing/app/helpers/StringReplacer.java index fae77155a..159289d1d 100644 --- a/arduino-core/src/processing/app/helpers/StringReplacer.java +++ b/arduino-core/src/processing/app/helpers/StringReplacer.java @@ -49,7 +49,7 @@ public class StringReplacer { public static String[] quotedSplit(String src, String quoteChars, boolean acceptEmptyArguments) throws Exception { - List res = new ArrayList(); + List res = new ArrayList<>(); String escapedArg = null; String escapingChar = null; for (String i : src.split(" ")) { diff --git a/arduino-core/src/processing/app/legacy/PApplet.java b/arduino-core/src/processing/app/legacy/PApplet.java index 4f91ceca7..23010a42b 100644 --- a/arduino-core/src/processing/app/legacy/PApplet.java +++ b/arduino-core/src/processing/app/legacy/PApplet.java @@ -466,7 +466,7 @@ public class PApplet { static public String[][] matchAll(String what, String regexp) { Pattern p = Pattern.compile(regexp, Pattern.MULTILINE | Pattern.DOTALL); Matcher m = p.matcher(what); - ArrayList results = new ArrayList(); + ArrayList results = new ArrayList<>(); int count = m.groupCount() + 1; while (m.find()) { String[] groups = new String[count]; diff --git a/arduino-core/src/processing/app/macosx/Platform.java b/arduino-core/src/processing/app/macosx/Platform.java index 0325b5d50..e142bd18c 100644 --- a/arduino-core/src/processing/app/macosx/Platform.java +++ b/arduino-core/src/processing/app/macosx/Platform.java @@ -168,7 +168,7 @@ public class Platform extends processing.app.Platform { return super.filterPorts(ports, true); } - List filteredPorts = new LinkedList(); + List filteredPorts = new LinkedList<>(); for (BoardPort port : ports) { if (!port.getAddress().startsWith("/dev/tty.")) { filteredPorts.add(port);