1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-13 10:29:35 +01:00

Removed redundant type specifiers for generics

This commit is contained in:
Cristian Maglie 2016-09-29 19:32:30 +02:00
parent 72a1d928b4
commit bd7e76533a
22 changed files with 52 additions and 52 deletions

View File

@ -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<String, Object>();
this.payload = new HashMap<>();
}
public Map<String, Object> getPayload() {

View File

@ -85,7 +85,7 @@ public class Base {
public static volatile Base INSTANCE;
public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
public static Map<String, Object> FIND_DIALOG_STATE = new HashMap<String, Object>();
public static Map<String, Object> 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<JMenuItem>();
this.recentSketchesMenuItems = new LinkedList<>();
CommandlineParser parser = new CommandlineParser(args);
parser.parseArgumentsPhase1();
@ -584,7 +584,7 @@ public class Base {
return;
}
Set<String> sketches = new LinkedHashSet<String>();
Set<String> 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<String> sketches = new LinkedList<String>(PreferencesData.getCollection("recent.sketches"));
Collection<String> sketches = new LinkedList<>(PreferencesData.getCollection("recent.sketches"));
sketches.remove(path);
PreferencesData.setCollection("recent.sketches", sketches);
}
@ -1049,7 +1049,7 @@ public class Base {
}
private List<ContributedLibrary> getSortedLibraries() {
List<ContributedLibrary> installedLibraries = new LinkedList<ContributedLibrary>(BaseNoGui.librariesIndexer.getInstalledLibraries());
List<ContributedLibrary> 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<String> customMenusTitles = new HashSet<String>();
Set<String> 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<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<JMenuItem>();
List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<>();
ButtonGroup boardsButtonGroup = new ButtonGroup();
Map<String, ButtonGroup> buttonGroupsMap = new HashMap<String, ButtonGroup>();
Map<String, ButtonGroup> 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<String, String> readSettings(File inputFile) {
HashMap<String, String> outgoing = new HashMap<String, String>();
HashMap<String, String> outgoing = new HashMap<>();
if (!inputFile.exists()) return outgoing; // return empty hash
String lines[] = PApplet.loadStrings(inputFile);

View File

@ -230,7 +230,7 @@ public class Editor extends JFrame implements RunnerListener {
public void windowDeactivated(WindowEvent e) {
fileMenu.remove(sketchbookMenu);
fileMenu.remove(examplesMenu);
List<Component> toolsMenuItemsToRemove = new LinkedList<Component>();
List<Component> 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<String, JMenuItem> toolItems = new HashMap<String, JMenuItem>();
Map<String, JMenuItem> 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<String> toolList = new ArrayList<String>(toolItems.keySet());
ArrayList<String> toolList = new ArrayList<>(toolItems.keySet());
if (toolList.size() == 0) return;
menu.addSeparator();

View File

@ -59,7 +59,7 @@ public class PresentMode {
devices = environment.getScreenDevices();
GraphicsDevice defaultDevice = environment.getDefaultScreenDevice();
Vector<String> names = new Vector<String>();
Vector<String> names = new Vector<>();
for (int i = 0; i < devices.length; i++) {
String name = String.valueOf(i + 1);
if (devices[i] == defaultDevice) {

View File

@ -185,7 +185,7 @@ public class SerialPlotter extends AbstractMonitor {
});
messageBuffer = new StringBuffer();
graphs = new ArrayList<Graph>();
graphs = new ArrayList<>();
}
protected void onCreateWindow(Container mainPane) {

View File

@ -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<TextAttribute, Object> attr = new Hashtable<TextAttribute, Object>();
Map<TextAttribute, Object> attr = new Hashtable<>();
attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
styledFont = styledFont.deriveFont(attr);
}
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>();
result.put("color", color);
result.put("font", styledFont);

View File

@ -70,7 +70,7 @@ public class UploaderUtils {
boolean useNewWarningsAccumulator = false;
if (warningsAccumulator == null) {
warningsAccumulator = new LinkedList<String>();
warningsAccumulator = new LinkedList<>();
useNewWarningsAccumulator = true;
}

View File

@ -66,7 +66,7 @@ public abstract class LibrariesIndex {
}
public List<String> getCategories() {
List<String> categories = new LinkedList<String>();
List<String> 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<String> getTypes() {
Collection<String> typesAccumulator = new HashSet<String>();
Collection<String> typesAccumulator = new HashSet<>();
for (ContributedLibrary lib : getLibraries()) {
if (lib.getTypes() != null) {
typesAccumulator.addAll(lib.getTypes());
}
}
List<String> types = new LinkedList<String>(typesAccumulator);
List<String> types = new LinkedList<>(typesAccumulator);
Collections.sort(types);
return types;

View File

@ -43,7 +43,7 @@ public class ContributedTargetPackage implements TargetPackage {
public ContributedTargetPackage(String _id) {
id = _id;
platforms = new HashMap<String, TargetPlatform>();
platforms = new HashMap<>();
}
void addPlatform(TargetPlatform p) {

View File

@ -48,7 +48,7 @@ public class DeleteFilesOnShutdown implements Runnable {
private final List<File> files;
public DeleteFilesOnShutdown() {
this.files = new LinkedList<File>();
this.files = new LinkedList<>();
}
public synchronized void addFile(File file) {
@ -63,7 +63,7 @@ public class DeleteFilesOnShutdown implements Runnable {
}
List<File> copyOfFiles;
synchronized (this) {
copyOfFiles = new LinkedList<File>(files);
copyOfFiles = new LinkedList<>(files);
}
Collections.reverse(copyOfFiles);
for (File file : copyOfFiles) {

View File

@ -44,7 +44,7 @@ public class DiscoveryManager {
private final NetworkDiscovery networkDiscoverer = new NetworkDiscovery();
public DiscoveryManager() {
discoverers = new ArrayList<Discovery>();
discoverers = new ArrayList<>();
discoverers.add(serialDiscoverer);
discoverers.add(networkDiscoverer);
@ -76,7 +76,7 @@ public class DiscoveryManager {
}
public List<BoardPort> discovery() {
List<BoardPort> res = new ArrayList<BoardPort>();
List<BoardPort> res = new ArrayList<>();
for (Discovery d : discoverers) {
res.addAll(d.listDiscoveredBoards());
}
@ -84,7 +84,7 @@ public class DiscoveryManager {
}
public List<BoardPort> discovery(boolean complete) {
List<BoardPort> res = new ArrayList<BoardPort>();
List<BoardPort> res = new ArrayList<>();
for (Discovery d : discoverers) {
res.addAll(d.listDiscoveredBoards(complete));
}

View File

@ -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<File, Long> foldersTimestamps = new HashMap<File, Long>();
Map<File, Long> foldersTimestamps = new HashMap<>();
ArchiveInputStream in = null;
try {
@ -106,10 +106,10 @@ public class ArchiveExtractor {
String pathPrefix = "";
Map<File, File> hardLinks = new HashMap<File, File>();
Map<File, Integer> hardLinksMode = new HashMap<File, Integer>();
Map<File, String> symLinks = new HashMap<File, String>();
Map<File, Long> symLinksModifiedTimes = new HashMap<File, Long>();
Map<File, File> hardLinks = new HashMap<>();
Map<File, Integer> hardLinksMode = new HashMap<>();
Map<File, String> symLinks = new HashMap<>();
Map<File, Long> symLinksModifiedTimes = new HashMap<>();
// Cycle through all the archive entries
while (true) {

View File

@ -100,7 +100,7 @@ public class CIDRUtils {
private byte[] toBytes(byte[] array, int targetSize) {
int counter = 0;
List<Byte> newArr = new ArrayList<Byte>();
List<Byte> newArr = new ArrayList<>();
while (counter < targetSize && (array.length - 1 - counter >= 0)) {
newArr.add(0, array[array.length - 1 - counter]);
counter++;

View File

@ -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<String> warningsAccumulator = new LinkedList<String>();
List<String> 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<String, TargetPackage>();
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<File>();
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<String, LibraryList>();
importToLibraryTable = new HashMap<>();
for (UserLibrary lib : librariesIndexer.getInstalledLibraries()) {
try {
String headers[] = headerListFromIncludePath(lib.getSrcFolder());

View File

@ -177,7 +177,7 @@ public class Platform {
}
public List<String> listSerials() {
return new ArrayList<String>(Arrays.asList(listSerialsNative()));
return new ArrayList<>(Arrays.asList(listSerialsNative()));
}
public List<String> 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<String> vids = new LinkedList<String>(board.getPreferences().subTree("vid", 1).values());
List<String> vids = new LinkedList<>(board.getPreferences().subTree("vid", 1).values());
if (!vids.isEmpty()) {
List<String> pids = new LinkedList<String>(board.getPreferences().subTree("pid", 1).values());
List<String> 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<String, Object> boardData = new HashMap<String, Object>();
Map<String, Object> 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<BoardPort> filterPorts(List<BoardPort> ports, boolean aBoolean) {
return new LinkedList<BoardPort>(ports);
return new LinkedList<>(ports);
}
public void fixPrefsFilePermissions(File prefsFile) throws IOException, InterruptedException {

View File

@ -310,7 +310,7 @@ public class SerialPortList {
if(portNames == null){
return new String[]{};
}
TreeSet<String> ports = new TreeSet<String>(comparator);
TreeSet<String> 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<String> portsTree = new TreeSet<String>(comparator);
TreeSet<String> portsTree = new TreeSet<>(comparator);
for(File file : files){
String fileName = file.getName();
if(!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()){

View File

@ -27,7 +27,7 @@ public class Sketch {
*/
private File folder;
private List<SketchFile> files = new ArrayList<SketchFile>();
private List<SketchFile> files = new ArrayList<>();
private File buildPath;

View File

@ -210,7 +210,7 @@ public class FileUtils {
}
public static List<String> readFileToListOfStrings(File file) throws IOException {
List<String> strings = new LinkedList<String>();
List<String> strings = new LinkedList<>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
@ -343,7 +343,7 @@ public class FileUtils {
public static List<File> listFiles(File folder, boolean recursive,
List<String> extensions) {
List<File> result = new ArrayList<File>();
List<File> result = new ArrayList<>();
for (File file : folder.listFiles()) {
if (isSCCSOrHiddenFile(file))

View File

@ -182,7 +182,7 @@ public class PreferencesMap extends LinkedHashMap<String, String> {
* @return
*/
public Map<String, PreferencesMap> firstLevelMap() {
Map<String, PreferencesMap> res = new LinkedHashMap<String, PreferencesMap>();
Map<String, PreferencesMap> res = new LinkedHashMap<>();
for (String key : keySet()) {
int dot = key.indexOf('.');
if (dot == -1)
@ -246,7 +246,7 @@ public class PreferencesMap extends LinkedHashMap<String, String> {
public String toString(String indent) {
String res = indent + "{\n";
SortedSet<String> treeSet = new TreeSet<String>(keySet());
SortedSet<String> treeSet = new TreeSet<>(keySet());
for (String k : treeSet)
res += indent + k + " = " + get(k) + "\n";
return res;

View File

@ -49,7 +49,7 @@ public class StringReplacer {
public static String[] quotedSplit(String src, String quoteChars,
boolean acceptEmptyArguments)
throws Exception {
List<String> res = new ArrayList<String>();
List<String> res = new ArrayList<>();
String escapedArg = null;
String escapingChar = null;
for (String i : src.split(" ")) {

View File

@ -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<String[]> results = new ArrayList<String[]>();
ArrayList<String[]> results = new ArrayList<>();
int count = m.groupCount() + 1;
while (m.find()) {
String[] groups = new String[count];

View File

@ -168,7 +168,7 @@ public class Platform extends processing.app.Platform {
return super.filterPorts(ports, true);
}
List<BoardPort> filteredPorts = new LinkedList<BoardPort>();
List<BoardPort> filteredPorts = new LinkedList<>();
for (BoardPort port : ports) {
if (!port.getAddress().startsWith("/dev/tty.")) {
filteredPorts.add(port);