refactor: Optimsed comments.

This commit is contained in:
Zihlu Wang
2024-03-31 18:38:12 +08:00
parent 5895557368
commit 65287d0b24
@@ -267,24 +267,24 @@ public final class WebCalendarEvent extends WebCalendarNode {
DURATION:PT{6}S DURATION:PT{6}S
{4}{5}{7}{8}{9}{10}{11}{12} {4}{5}{7}{8}{9}{10}{11}{12}
END:{0}""", END:{0}""",
TAG, // 0 - tag /* 0 - tag */TAG,
Optional.ofNullable(uid).orElse(UUID.randomUUID().toString()) + "@" + domainName, // 1 - uid /* 1 - uid */ Optional.ofNullable(uid).orElse(UUID.randomUUID().toString()) + "@" + domainName,
now.format(DateAndTimeFormatter.getUtcDatetimeFormatter()), // 2 - dtstamp /* 2 - dtstamp */ now.format(DateAndTimeFormatter.getUtcDatetimeFormatter()),
start.atZone(ZoneId.systemDefault()).format(DateAndTimeFormatter.getUtcDatetimeFormatter()), // 3 - start time /* 3 - start time */ start.atZone(ZoneId.systemDefault()).format(DateAndTimeFormatter.getUtcDatetimeFormatter()),
Optional.ofNullable(summary).map((item) -> "\nSUMMARY:" + item).orElse(""), // 4 - summary /* 4 - summary */ Optional.ofNullable(summary).map((item) -> "\nSUMMARY:" + item).orElse(""),
Optional.ofNullable(categories) /* 5 - categories */ Optional.ofNullable(categories)
.map((item) -> !item.isEmpty() ? "\nCATEGORIES:" + resolveCategories() : null).orElse(""), // 5 - categories .map((item) -> !item.isEmpty() ? "\nCATEGORIES:" + resolveCategories() : null).orElse(""),
Optional.ofNullable(duration) /* 6 - duration */ Optional.ofNullable(duration)
.map((_duration) -> String.valueOf(_duration.getSeconds())) .map((_duration) -> String.valueOf(_duration.getSeconds()))
.orElse(Optional.ofNullable(end) .orElse(Optional.ofNullable(end)
.map((_end) -> String.valueOf(Duration.between(_end, start).getSeconds())) .map((_end) -> String.valueOf(Duration.between(_end, start).getSeconds()))
.orElse("0")), // 6 - duration .orElse("0")),
Optional.ofNullable(classification).map((_classification) -> "\nCLASS:" + _classification + "\n").orElse(""), /* 7 - classification */ /* 7 - classification */ Optional.ofNullable(classification).map((_classification) -> "\nCLASS:" + _classification + "\n").orElse(""),
Optional.ofNullable(comment).map((_comment) -> "\nCOMMENT:" + _comment + "\n").orElse(""), /* 8 - comment */ /* 8 - comment */ Optional.ofNullable(comment).map((_comment) -> "\nCOMMENT:" + _comment + "\n").orElse(""),
Optional.ofNullable(location).map((_location) -> "\nLOCATION:" + _location).orElse("") /* 9 - location */, /* 9 - location */ Optional.ofNullable(location).map((_location) -> "\nLOCATION:" + _location).orElse(""),
Optional.ofNullable(percentComplete).map((_percentComplete) -> "\nPERCENT-COMPLETE:" + _percentComplete).orElse("") /* 10 = percentComplete */, /* 10 = percentComplete */ Optional.ofNullable(percentComplete).map((_percentComplete) -> "\nPERCENT-COMPLETE:" + _percentComplete).orElse(""),
Optional.ofNullable(description).map((_description) -> "\nDESCRIPTION:" + _description).orElse("") /* 11 - description */, /* 11 - description */ Optional.ofNullable(description).map((_description) -> "\nDESCRIPTION:" + _description).orElse(""),
Optional.ofNullable(priority).map((_priority) -> "\nPRIORITY:" + _priority).orElse("") /* 12 - priority */ /* 12 - priority */ Optional.ofNullable(priority).map((_priority) -> "\nPRIORITY:" + _priority).orElse("")
); );
} }