Skip to content

Commit ca64eb8

Browse files
committed
Better inline comments
1 parent 6183c6e commit ca64eb8

5 files changed

Lines changed: 18 additions & 20 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ private static boolean isLineBreak(final char c) {
14791479
* @return true if {@code c} is a line break character (and not null).
14801480
*/
14811481
private static boolean isLineBreak(final Character c) {
1482-
return c != null && isLineBreak(c.charValue()); // Explicit (un)boxing is intentional
1482+
return c != null && isLineBreak(c.charValue()); // Explicit unboxing is intentional
14831483
}
14841484

14851485
/** Same test as in as {@link String#trim()}. */
@@ -1700,7 +1700,7 @@ public boolean equals(final Object obj) {
17001700
}
17011701

17021702
private void escape(final char c, final Appendable appendable) throws IOException {
1703-
append(escapeCharacter.charValue(), appendable); // Explicit (un)boxing is intentional
1703+
append(escapeCharacter.charValue(), appendable); // Explicit unboxing is intentional
17041704
append(c, appendable);
17051705
}
17061706

@@ -1838,7 +1838,7 @@ public DuplicateHeaderMode getDuplicateHeaderMode() {
18381838
* @return the escape character, may be {@code 0}
18391839
*/
18401840
char getEscapeChar() {
1841-
return escapeCharacter != null ? escapeCharacter.charValue() : 0; // Explicit (un)boxing is intentional
1841+
return escapeCharacter != null ? escapeCharacter.charValue() : 0; // Explicit unboxing is intentional
18421842
}
18431843

18441844
/**
@@ -2161,15 +2161,15 @@ private void print(final InputStream inputStream, final Appendable out, final bo
21612161
}
21622162
final boolean quoteCharacterSet = isQuoteCharacterSet();
21632163
if (quoteCharacterSet) {
2164-
append(getQuoteCharacter().charValue(), out); // Explicit (un)boxing is intentional
2164+
append(getQuoteCharacter().charValue(), out); // Explicit unboxing is intentional
21652165
}
21662166
// Stream the input to the output without reading or holding the whole value in memory.
21672167
// AppendableOutputStream cannot "close" an Appendable.
21682168
try (OutputStream outputStream = new Base64OutputStream(new AppendableOutputStream<>(out))) {
21692169
IOUtils.copy(inputStream, outputStream);
21702170
}
21712171
if (quoteCharacterSet) {
2172-
append(getQuoteCharacter().charValue(), out); // Explicit (un)boxing is intentional
2172+
append(getQuoteCharacter().charValue(), out); // Explicit unboxing is intentional
21732173
}
21742174
}
21752175

@@ -2418,7 +2418,7 @@ private void printWithQuotes(final Object object, final CharSequence charSeq, fi
24182418
final int len = charSeq.length();
24192419
final char[] delim = getDelimiterCharArray();
24202420
final int delimLength = delim.length;
2421-
final char quoteChar = getQuoteCharacter().charValue(); // Explicit (un)boxing is intentional
2421+
final char quoteChar = getQuoteCharacter().charValue(); // Explicit unboxing is intentional
24222422
// If escape char not specified, default to the quote char
24232423
// This avoids having to keep checking whether there is an escape character
24242424
// at the cost of checking against quote twice
@@ -2521,7 +2521,7 @@ private void printWithQuotes(final Reader reader, final Appendable appendable) t
25212521
printWithEscapes(reader, appendable);
25222522
return;
25232523
}
2524-
final char quote = getQuoteCharacter().charValue(); // Explicit (un)boxing is intentional
2524+
final char quote = getQuoteCharacter().charValue(); // Explicit unboxing is intentional
25252525
// (1) Append opening quote
25262526
append(quote, appendable);
25272527
// (2) Append Reader contents, doubling quotes
@@ -2607,13 +2607,13 @@ boolean useRow(final long rowNum) {
26072607
* @throws IllegalArgumentException Throw when any attribute is invalid or inconsistent with other attributes.
26082608
*/
26092609
private void validate() throws IllegalArgumentException {
2610-
if (quoteCharacter != null && contains(delimiter, quoteCharacter.charValue())) { // Explicit (un)boxing is intentional
2610+
if (quoteCharacter != null && contains(delimiter, quoteCharacter.charValue())) { // Explicit unboxing is intentional
26112611
throw new IllegalArgumentException("The quoteChar character and the delimiter cannot be the same ('" + quoteCharacter + "')");
26122612
}
2613-
if (escapeCharacter != null && contains(delimiter, escapeCharacter.charValue())) { // Explicit (un)boxing is intentional
2613+
if (escapeCharacter != null && contains(delimiter, escapeCharacter.charValue())) { // Explicit unboxing is intentional
26142614
throw new IllegalArgumentException("The escape character and the delimiter cannot be the same ('" + escapeCharacter + "')");
26152615
}
2616-
if (commentMarker != null && contains(delimiter, commentMarker.charValue())) { // Explicit (un)boxing is intentional
2616+
if (commentMarker != null && contains(delimiter, commentMarker.charValue())) { // Explicit unboxing is intentional
26172617
throw new IllegalArgumentException("The comment start character and the delimiter cannot be the same ('" + commentMarker + "')");
26182618
}
26192619
if (quoteCharacter != null && quoteCharacter.equals(commentMarker)) {

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ private Headers createHeaders() throws IOException {
650650
}
651651
observedMissing |= blankHeader;
652652
if (header != null) {
653-
headerMap.put(header, Integer.valueOf(i)); // Explicit (un)boxing is intentional
653+
headerMap.put(header, Integer.valueOf(i)); // Explicit boxing is intentional
654654
if (headerNames == null) {
655655
headerNames = new ArrayList<>(headerRecord.length);
656656
}

src/main/java/org/apache/commons/csv/CSVPrinter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public void printComment(final String comment) throws IOException {
235235
if (!newRecord) {
236236
println();
237237
}
238-
appendable.append(format.getCommentMarker().charValue()); // Explicit (un)boxing is intentional
238+
appendable.append(format.getCommentMarker().charValue()); // Explicit unboxing is intentional
239239
appendable.append(SP);
240240
for (int i = 0; i < comment.length(); i++) {
241241
final char c = comment.charAt(i);
@@ -247,7 +247,7 @@ public void printComment(final String comment) throws IOException {
247247
// falls-through: break intentionally excluded.
248248
case LF:
249249
println();
250-
appendable.append(format.getCommentMarker().charValue()); // Explicit (un)boxing is intentional
250+
appendable.append(format.getCommentMarker().charValue()); // Explicit unboxing is intentional
251251
appendable.append(SP);
252252
break;
253253
default:

src/main/java/org/apache/commons/csv/CSVRecord.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ public String get(final String name) {
132132
throw new IllegalArgumentException(String.format("Mapping for %s not found, expected one of %s", name, headerMap.keySet()));
133133
}
134134
try {
135-
return values[index.intValue()]; // Explicit (un)boxing is intentional
135+
return values[index.intValue()]; // Explicit unboxing is intentional
136136
} catch (final ArrayIndexOutOfBoundsException e) {
137+
// Explicit boxing is intentional
137138
throw new IllegalArgumentException(
138-
String.format("Index for header '%s' is %d but CSVRecord only has %d values!", name, index, Integer.valueOf(values.length))); // Explicit
139-
// (un)boxing
140-
// is
141-
// intentional
139+
String.format("Index for header '%s' is %d but CSVRecord only has %d values!", name, index, Integer.valueOf(values.length)));
142140
}
143141
}
144142

@@ -267,7 +265,7 @@ public boolean isSet(final int index) {
267265
* @return whether a given column is mapped and has a value.
268266
*/
269267
public boolean isSet(final String name) {
270-
return isMapped(name) && getHeaderMapRaw().get(name).intValue() < values.length; // Explicit (un)boxing is intentional
268+
return isMapped(name) && getHeaderMapRaw().get(name).intValue() < values.length; // Explicit unboxing is intentional
271269
}
272270

273271
/**

src/main/java/org/apache/commons/csv/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class Constants {
4040
/** RFC 4180 defines line breaks as CRLF. */
4141
static final String CRLF = "\r\n";
4242

43-
static final Character DOUBLE_QUOTE_CHAR = Character.valueOf('"'); // Explicit (un)boxing is intentional.
43+
static final Character DOUBLE_QUOTE_CHAR = Character.valueOf('"'); // Explicit boxing is intentional.
4444

4545
static final String EMPTY = "";
4646

0 commit comments

Comments
 (0)