cschneider commented on code in PR #22:
URL:
https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22#discussion_r1530057396
##########
src/main/java/org/apache/sling/distribution/journal/messages/PackageMessage.java:
##########
@@ -92,31 +97,36 @@ public String toString() {
out.append(pkgBinary.length);
}
out.append(", paths=");
- out.append(abbreviate(paths));
+ out.append(printList(paths, abbreviate));
out.append(", deepPaths=");
- out.append(abbreviate(deepPaths));
+ out.append(printList(deepPaths, abbreviate));
out.append(", metadata=");
out.append(metadata);
out.append(")");
return out.toString();
}
- static String abbreviate(List<String> list) {
+ static String printList(List<String> list, boolean abbreviate) {
if (list == null) {
return null;
}
- Iterator<String> iter = list.iterator();
- StringBuilder abbr = new StringBuilder();
- abbr.append("[");
- if (iter.hasNext()) {
- abbr.append(iter.next());
- }
- if (iter.hasNext()) {
- abbr.append(", ... ");
- abbr.append(list.size() - 1);
- abbr.append(" more");
+ if (abbreviate) {
+ Iterator<String> iter = list.iterator();
+ StringBuilder abbr = new StringBuilder();
+ abbr.append("[");
+ if (iter.hasNext()) {
+ abbr.append(iter.next());
+ }
+ if (iter.hasNext()) {
+ abbr.append(", ... ");
+ abbr.append(list.size() - 1);
+ abbr.append(" more");
+ }
+ abbr.append("]");
+ return abbr.toString();
+ } else {
Review Comment:
I reversed the if. Now it looks nicer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]