@@ -61,14 +61,11 @@ public static String joinParts(@Nonnull String delimiter, @Nullable String... pa
6161 if (parts == null ) {
6262 return "" ;
6363 }
64- return Arrays .stream (parts )
65- .filter (p -> Objects .nonNull (p ) && !p .isEmpty ())
66- .collect (Collectors .joining (delimiter ));
64+ return Arrays .stream (parts ).filter (p -> Objects .nonNull (p ) && !p .isEmpty ()).collect (Collectors .joining (delimiter ));
6765 }
6866
6967 @ Nonnull
70- public static <T > String format (@ Nullable List <T > entities , @ Nonnull Function <T , String > converter ,
71- @ Nullable String tag ) {
68+ public static <T > String format (@ Nullable List <T > entities , @ Nonnull Function <T , String > converter , @ Nullable String tag ) {
7269 String prefix = tag == null ? "" : tag + LINE_DELIMITER ;
7370 if (entities == null || entities .isEmpty ()) {
7471 return "" ;
@@ -80,53 +77,42 @@ public static <T> String format(@Nullable List<T> entities, @Nonnull Function<T,
8077 }
8178
8279 @ Nonnull
83- public static String formatHeaders (@ Nullable List <Header > headers ,
84- @ Nullable Function <Header , String > headerConverter ) {
85- return format (headers ,
86- headerConverter == null ? DefaultHttpHeaderConverter .INSTANCE : headerConverter ,
87- HEADERS_TAG
88- );
80+ public static String formatHeaders (@ Nullable List <Header > headers , @ Nullable Function <Header , String > headerConverter ) {
81+ return format (headers , headerConverter == null ? DefaultHttpHeaderConverter .INSTANCE : headerConverter , HEADERS_TAG );
8982 }
9083
9184 @ Nonnull
92- public static String formatCookies (@ Nullable List <Cookie > cookies ,
93- @ Nullable Function <Cookie , String > cookieConverter ) {
94- return format (cookies ,
95- cookieConverter == null ? DefaultCookieConverter .INSTANCE : cookieConverter ,
96- COOKIES_TAG
97- );
85+ public static String formatCookies (@ Nullable List <Cookie > cookies , @ Nullable Function <Cookie , String > cookieConverter ) {
86+ return format (cookies , cookieConverter == null ? DefaultCookieConverter .INSTANCE : cookieConverter , COOKIES_TAG );
9887 }
9988
10089 @ Nonnull
10190 public static String formatText (@ Nullable String header , @ Nullable List <Param > params , @ Nullable String tag ,
102- @ Nullable Function <Param , String > paramConverter ) {
91+ @ Nullable Function <Param , String > paramConverter ) {
10392 if (params == null || params .isEmpty ()) {
10493 return header == null ? "" : header ;
10594 }
10695 String prefix = tag == null ? "" : tag + LINE_DELIMITER ;
107- String body = format (params ,
108- paramConverter == null ? DefaultFormParamConverter .INSTANCE : paramConverter ,
109- null
110- );
96+ String body = format (params , paramConverter == null ? DefaultFormParamConverter .INSTANCE : paramConverter , null );
11197 return (header == null || header .isEmpty () ? "" : header + LINE_DELIMITER + LINE_DELIMITER ) + (body .isEmpty () ?
11298 body :
11399 prefix + BODY_HIGHLIGHT + LINE_DELIMITER + body + LINE_DELIMITER + BODY_HIGHLIGHT );
114100 }
115101
116102 @ Nonnull
117103 public static String formatText (@ Nullable String header , @ Nullable String body , @ Nullable String tag ,
118- @ Nullable Map <String , Function <String , String >> contentPrettiers , String contentType ) {
119- Map <String , Function <String , String >> prettiers = contentPrettiers ;
120- if (contentPrettiers == null ) {
121- prettiers = Collections .emptyMap ();
104+ @ Nullable Map <String , Function <String , String >> contentPrettifiers , String contentType ) {
105+ Map <String , Function <String , String >> prettifiers = contentPrettifiers ;
106+ if (contentPrettifiers == null ) {
107+ prettifiers = Collections .emptyMap ();
122108 }
123109 if (body == null || body .isEmpty ()) {
124110 return header == null ? "" : header ;
125111 }
126112 return (header == null || header .isEmpty () ? "" : header + LINE_DELIMITER + LINE_DELIMITER ) + (tag == null || tag .isEmpty () ?
127113 "" :
128- tag + LINE_DELIMITER ) + BODY_HIGHLIGHT + LINE_DELIMITER + (prettiers .containsKey (contentType ) ?
129- prettiers .get (contentType ).apply (body ) :
114+ tag + LINE_DELIMITER ) + BODY_HIGHLIGHT + LINE_DELIMITER + (prettifiers .containsKey (contentType ) ?
115+ prettifiers .get (contentType ).apply (body ) :
130116 body ) + LINE_DELIMITER + BODY_HIGHLIGHT ;
131117 }
132118
@@ -162,10 +148,9 @@ public static Stream<Pair<String, String>> toKeyValue(@Nonnull String headerValu
162148 }
163149
164150 @ Nonnull
165- public static Cookie toCookie (@ Nonnull String name , @ Nullable String value , @ Nullable String comment ,
166- @ Nullable String path , @ Nullable String domain , @ Nullable Long maxAge , @ Nullable Boolean secured ,
167- @ Nullable Boolean httpOnly , @ Nullable Date expiryDate , @ Nullable Integer version ,
168- @ Nullable String sameSite ) {
151+ public static Cookie toCookie (@ Nonnull String name , @ Nullable String value , @ Nullable String comment , @ Nullable String path ,
152+ @ Nullable String domain , @ Nullable Long maxAge , @ Nullable Boolean secured , @ Nullable Boolean httpOnly ,
153+ @ Nullable Date expiryDate , @ Nullable Integer version , @ Nullable String sameSite ) {
169154 Cookie cookie = new Cookie (name );
170155 cookie .setValue (value );
171156 cookie .setComment (comment );
@@ -197,17 +182,16 @@ public static Cookie toCookie(@Nonnull String headerValue) {
197182 // Wed, 06-Sep-2023 11:22:09 GMT
198183 Date expiryDate = ofNullable (cookieMetadata .get ("expires" )).map (d -> {
199184 try {
200- return new SimpleDateFormat (DefaultCookieConverter .DEFAULT_COOKIE_DATE_FORMAT ).parse (d .replace ('-' ,
201- ' '
202- ));
185+ return new SimpleDateFormat (DefaultCookieConverter .DEFAULT_COOKIE_DATE_FORMAT ).parse (d .replace ('-' , ' ' ));
203186 } catch (ParseException e ) {
204187 return null ;
205188 }
206189 }).orElse (null );
207190 Integer version = cookieMetadata .get ("version" ) == null ? null : Integer .valueOf (cookieMetadata .get ("version" ));
208191 String sameSite = cookieMetadata .get ("samesite" );
209192
210- return toCookie (nameValue .getKey (),
193+ return toCookie (
194+ nameValue .getKey (),
211195 nameValue .getValue (),
212196 comment ,
213197 path ,
@@ -231,8 +215,10 @@ public static boolean isSetCookie(@Nullable String headerName) {
231215
232216 @ Nonnull
233217 private static Charset getCharset (@ Nullable String contentType ) {
234- return ofNullable (contentType ).flatMap (h -> toKeyValue (h ).filter (p -> "charset" .equalsIgnoreCase (p .getKey ()))
235- .findAny ()).map (Pair ::getValue ).map (Charset ::forName ).orElse (StandardCharsets .UTF_8 );
218+ return ofNullable (contentType ).flatMap (h -> toKeyValue (h ).filter (p -> "charset" .equalsIgnoreCase (p .getKey ())).findAny ())
219+ .map (Pair ::getValue )
220+ .map (Charset ::forName )
221+ .orElse (StandardCharsets .UTF_8 );
236222 }
237223
238224 @ Nonnull
0 commit comments