Skip to content

Commit c08d4fd

Browse files
committed
Using static import to reduce code bloat in Serial.java
1 parent 1f175e9 commit c08d4fd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arduino-core/src/processing/app/Serial.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.util.List;
3333

3434
import static processing.app.I18n._;
35-
35+
import static processing.app.I18n.format;
3636

3737
public class Serial implements SerialPortEventListener {
3838

@@ -84,7 +84,7 @@ public static boolean touchForCDCReset(String iname) throws SerialException {
8484
serialPort.closePort();
8585
return true;
8686
} catch (SerialPortException e) {
87-
throw new SerialException(I18n.format(_("Error touching serial port ''{0}''."), iname), e);
87+
throw new SerialException(format(_("Error touching serial port ''{0}''."), iname), e);
8888
} finally {
8989
if (serialPort.isOpened()) {
9090
try {
@@ -116,13 +116,13 @@ private Serial(String iname, int irate, char iparity, int idatabits, float istop
116116
port.addEventListener(this);
117117
} catch (SerialPortException e) {
118118
if (e.getPortName().startsWith("/dev") && SerialPortException.TYPE_PERMISSION_DENIED.equals(e.getExceptionType())) {
119-
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission"), iname));
119+
throw new SerialException(format(_("Error opening serial port ''{0}''. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission"), iname));
120120
}
121-
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e);
121+
throw new SerialException(format(_("Error opening serial port ''{0}''."), iname), e);
122122
}
123123

124124
if (port == null) {
125-
throw new SerialNotFoundException(I18n.format(_("Serial port ''{0}'' not found. Did you select the right one from the Tools > Serial Port menu?"), iname));
125+
throw new SerialNotFoundException(format(_("Serial port ''{0}'' not found. Did you select the right one from the Tools > Serial Port menu?"), iname));
126126
}
127127
}
128128

@@ -231,7 +231,7 @@ static public List<String> list() {
231231
* I think of something slightly more intelligent to do.
232232
*/
233233
private static void errorMessage(String where, Throwable e) {
234-
System.err.println(I18n.format(_("Error inside Serial.{0}()"), where));
234+
System.err.println(format(_("Error inside Serial.{0}()"), where));
235235
e.printStackTrace();
236236
}
237237
}

0 commit comments

Comments
 (0)