...
Four spaces, NOT a tab character, is are used for regular indentation. For code broken into multiple lines, eight spaces are used indent lines after the first:
Code Block language java if (obj instanceof DefaultDevice) { return Objects.equals(this.id, other.id) && Objects.equals(this.type, other.type) && Objects.equals(this.manufacturer, other.manufacturer);
If the line has to break at the dot separator ".", the dot symbol should be at the beginning of the next line:
Code Block language java public void describeTo(Description description) { description.appendText("status '") .appendText(status.getDescription()) .appendText("'"); }
- Trailing whitespaces should be removed in both code and comments.
There should be a space between keywords (
if
,for
,catch
,
etc.), parenthesis, and braces, as well as when casting:Code Block language java if (timer != null) { try { DeviceId did = (DeviceId) elementId; ... } catch (IOException e) { ...
There should be a space before the curly braces in method definitions. Arguments are not padded (neither in definition nor invocation):
Code Block language java public Device getDevice(DeviceId deviceId) { return store.getDevice(deviceId); }
...