@@ -215,8 +215,15 @@ public static TextContent ofGYearList(List<OffsetDateTime> content) {
215215 return ofOffsetDateTimeList (content , CalendarField .GYEAR_FIELDS , WITH_DATE_OFFSET );
216216 }
217217
218+ public boolean isAbsent () {
219+ return this == ABSENT ;
220+ }
221+
218222 public TextContent trim () {
219- content = trimContent ();
223+ if (isPresent ()) {
224+ content = trimContent ();
225+ }
226+
220227 return this ;
221228 }
222229
@@ -236,16 +243,6 @@ public TextContent collapse() {
236243 return this ;
237244 }
238245
239- public boolean isPresent () {
240- return this != ABSENT ;
241- }
242-
243- public void ifPresent (Consumer <String > action ) {
244- if (isPresent ()) {
245- action .accept (content );
246- }
247- }
248-
249246 public String get () {
250247 return isPresent () ? content : null ;
251248 }
@@ -258,6 +255,16 @@ public String getOrElseGet(Supplier<String> defaultValue) {
258255 return getOrElseGet (get (), defaultValue );
259256 }
260257
258+ public boolean isPresent () {
259+ return this != ABSENT ;
260+ }
261+
262+ public void ifPresent (Consumer <String > action ) {
263+ if (isPresent ()) {
264+ action .accept (content );
265+ }
266+ }
267+
261268 public List <String > getAsList () {
262269 List <String > list = getAsList (String .class );
263270 if (list != null ) {
@@ -953,7 +960,7 @@ private static TextContent ofObject(Object value) {
953960 }
954961
955962 private static TextContent ofObjectList (List <?> values ) {
956- return values != null ? new TextContent (TextHelper .toContent (values )) : ABSENT ;
963+ return values != null && ! values . isEmpty () ? new TextContent (TextHelper .toContent (values )) : ABSENT ;
957964 }
958965
959966 private static TextContent ofOffsetDateTime (OffsetDateTime dateTime , EnumSet <CalendarField > fields , boolean withOffset ) {
@@ -962,7 +969,9 @@ private static TextContent ofOffsetDateTime(OffsetDateTime dateTime, EnumSet<Cal
962969 }
963970
964971 private static TextContent ofOffsetDateTimeList (List <OffsetDateTime > dateTimes , EnumSet <CalendarField > fields , boolean withOffset ) {
965- return dateTimes != null ? new TextContent (TextHelper .toContent (dateTimes , fields , withOffset )) : ABSENT ;
972+ return dateTimes != null && !dateTimes .isEmpty () ?
973+ new TextContent (TextHelper .toContent (dateTimes , fields , withOffset )) :
974+ ABSENT ;
966975 }
967976
968977 public static void setZoneOffsetProvider (Function <LocalDateTime , ZoneOffset > zoneOffsetProvider ) {
0 commit comments