Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fbb61ff

Browse files
author
Federico Fissore
committed
Code cleanup
1 parent 88e8019 commit fbb61ff

File tree

13 files changed

+28
-39
lines changed

13 files changed

+28
-39
lines changed

‎arduino-core/src/cc/arduino/contributions/GZippedJsonDownloader.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private void decompress(File gzipTmpFile, File tmpFile) throws IOException {
6767
os = new FileOutputStream(tmpFile);
6868
gzipIs = new GzipCompressorInputStream(new FileInputStream(gzipTmpFile));
6969
final byte[] buffer = new byte[4096];
70-
int n = 0;
70+
int n;
7171
while (-1 != (n = gzipIs.read(buffer))) {
7272
os.write(buffer, 0, n);
7373
}

‎arduino-core/src/cc/arduino/contributions/JsonDownloader.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void download(File tmpFile, Progress progress, String statusText) throws
4949
downloader.download(url, tmpFile, progress, statusText);
5050
} catch (InterruptedException e) {
5151
// Download interrupted... just exit
52-
return;
5352
}
5453
}
5554
}

‎arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public boolean equals(Object obj) {
142142
String thisVersion = getParsedVersion();
143143
String otherVersion = ((ContributedLibrary) obj).getParsedVersion();
144144

145-
boolean versionEquals = thisVersion == otherVersion || (thisVersion!= null && otherVersion != null && thisVersion.equals(otherVersion));
145+
boolean versionEquals = thisVersion != null && otherVersion != null && thisVersion.equals(otherVersion);
146146

147147
String thisName = getName();
148148
String otherName = ((ContributedLibrary) obj).getName();

‎arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public void updateIndex() throws Exception {
7979
final MultiStepProgress progress = new MultiStepProgress(2);
8080

8181
// Step 1: Download index
82-
URL url = new URL(LIBRARY_INDEX_URL);
8382
File outputFile = indexer.getIndexFile();
8483
File tmpFile = new File(outputFile.getAbsolutePath() + ".tmp");
8584
try {

‎arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.
5656

5757
public NetworkDiscovery() {
5858
DNSTaskStarter.Factory.setClassDelegate(new ArduinoDNSTaskStarter());
59-
this.boardPortsDiscoveredWithJmDNS = new LinkedList<BoardPort>();
60-
this.mappedJmDNSs = new Hashtable<InetAddress, JmDNS>();
61-
this.reachableBoardPorts = new LinkedList<BoardPort>();
59+
this.boardPortsDiscoveredWithJmDNS = new LinkedList<>();
60+
this.mappedJmDNSs = new Hashtable<>();
61+
this.reachableBoardPorts = new LinkedList<>();
6262
}
6363

6464
@Override
6565
public List<BoardPort> listDiscoveredBoards() {
6666
synchronized (reachableBoardPorts) {
67-
return new LinkedList<BoardPort>(reachableBoardPorts);
67+
return new LinkedList<>(reachableBoardPorts);
6868
}
6969
}
7070

@@ -77,7 +77,7 @@ public void setReachableBoardPorts(List<BoardPort> newReachableBoardPorts) {
7777

7878
public List<BoardPort> getBoardPortsDiscoveredWithJmDNS() {
7979
synchronized (boardPortsDiscoveredWithJmDNS) {
80-
return new LinkedList<BoardPort>(boardPortsDiscoveredWithJmDNS);
80+
return new LinkedList<>(boardPortsDiscoveredWithJmDNS);
8181
}
8282
}
8383

@@ -114,11 +114,7 @@ public void serviceAdded(ServiceEvent serviceEvent) {
114114
public void serviceRemoved(ServiceEvent serviceEvent) {
115115
String name = serviceEvent.getName();
116116
synchronized (boardPortsDiscoveredWithJmDNS) {
117-
for (BoardPort port : boardPortsDiscoveredWithJmDNS) {
118-
if (port.getBoardName().equals(name)) {
119-
boardPortsDiscoveredWithJmDNS.remove(port);
120-
}
121-
}
117+
boardPortsDiscoveredWithJmDNS.stream().filter(port -> port.getBoardName().equals(name)).forEach(boardPortsDiscoveredWithJmDNS::remove);
122118
}
123119
}
124120

‎arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ public class SerialDiscovery implements Discovery {
4343
private final List<BoardPort> serialBoardPorts;
4444

4545
public SerialDiscovery() {
46-
this.serialBoardPorts = new LinkedList<BoardPort>();
46+
this.serialBoardPorts = new LinkedList<>();
4747
}
4848

4949
@Override
5050
public List<BoardPort> listDiscoveredBoards() {
5151
return getSerialBoardPorts();
5252
}
5353

54-
public List<BoardPort> getSerialBoardPorts() {
54+
private List<BoardPort> getSerialBoardPorts() {
5555
synchronized (serialBoardPorts) {
56-
return new LinkedList<BoardPort>(serialBoardPorts);
56+
return new LinkedList<>(serialBoardPorts);
5757
}
5858
}
5959

‎arduino-core/src/cc/arduino/packages/discoverers/network/BoardReachabilityFilter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void run() {
6161
InetAddress inetAddress = InetAddress.getByName(board.getAddress());
6262
int broadcastedPort = Integer.valueOf(board.getPrefs().get("port"));
6363

64-
List<Integer> ports = new LinkedList<Integer>();
64+
List<Integer> ports = new LinkedList<>();
6565
ports.add(broadcastedPort);
6666

6767
//dirty code: allows non up to date yuns to be discovered. Newer yuns will broadcast port 22

‎arduino-core/src/cc/arduino/packages/discoverers/network/NetworkChecker.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public NetworkChecker(NetworkTopologyListener topologyListener, NetworkTopologyD
4444
super();
4545
this.topologyListener = topologyListener;
4646
this.topology = topology;
47-
this.knownAddresses = Collections.synchronizedSet(new HashSet<InetAddress>());
47+
this.knownAddresses = Collections.synchronizedSet(new HashSet<>());
4848
}
4949

5050
public void start(Timer timer) {
@@ -55,18 +55,14 @@ public void start(Timer timer) {
5555
public void run() {
5656
try {
5757
InetAddress[] curentAddresses = topology.getInetAddresses();
58-
Set<InetAddress> current = new HashSet<InetAddress>(curentAddresses.length);
58+
Set<InetAddress> current = new HashSet<>(curentAddresses.length);
5959
for (InetAddress address : curentAddresses) {
6060
current.add(address);
6161
if (!knownAddresses.contains(address)) {
6262
topologyListener.inetAddressAdded(address);
6363
}
6464
}
65-
for (InetAddress address : knownAddresses) {
66-
if (!current.contains(address)) {
67-
topologyListener.inetAddressRemoved(address);
68-
}
69-
}
65+
knownAddresses.stream().filter(address -> !current.contains(address)).forEach(topologyListener::inetAddressRemoved);
7066
knownAddresses = current;
7167
} catch (Exception e) {
7268
e.printStackTrace();

‎arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void run() {
6666
return;
6767
}
6868

69-
List<BoardPort> boardPorts = new LinkedList<BoardPort>();
69+
List<BoardPort> boardPorts = new LinkedList<>();
7070

7171
List<String> ports = Serial.list();
7272

‎arduino-core/src/cc/arduino/packages/ssh/SCP.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public void open() throws IOException {
6161
}
6262
}
6363

64-
public void close() throwsIOException{
64+
public void close() {
6565
IOUtils.closeQuietly(out);
6666
IOUtils.closeQuietly(in);
6767
if (channel != null) {
6868
channel.disconnect();
6969
}
7070
}
7171

72-
protected void ensureAcknowledged() throws IOException {
72+
private void ensureAcknowledged() throws IOException {
7373
out.flush();
7474

7575
int b = in.read();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /