1515
1616import org .apache .pekko .http .impl .util .Util ;
1717import org .apache .pekko .japi .Option ;
18+ import org .apache .pekko .util .OptionConverters ;
1819
1920import java .util .HashMap ;
2021import java .util .Map ;
22+ import java .util .Optional ;
2123
2224public abstract class HttpChallenge {
2325 public abstract String scheme ();
@@ -27,31 +29,48 @@ public abstract class HttpChallenge {
2729 public abstract Map <String , String > getParams ();
2830
2931 public static HttpChallenge create (String scheme , String realm ) {
30- return create (scheme , Option . option (realm ));
32+ return create (scheme , Optional . of (realm ));
3133 }
3234
3335 public static HttpChallenge create (String scheme , String realm , Map <String , String > params ) {
34- return create (scheme , Option . option (realm ), params );
36+ return create (scheme , Optional . of (realm ), params );
3537 }
3638
39+ /** @deprecated Use {@link #create(String, Optional)} instead. */
40+ @ Deprecated // since 1.3.0
3741 public static HttpChallenge create (String scheme , Option <String > realm ) {
3842 return org .apache .pekko .http .scaladsl .model .headers .HttpChallenge .apply (
3943 scheme , realm .asScala (), Util .emptyMap );
4044 }
4145
46+ /** @since 1.3.0 */
47+ public static HttpChallenge create (String scheme , Optional <String > realm ) {
48+ return org .apache .pekko .http .scaladsl .model .headers .HttpChallenge .apply (
49+ scheme , OptionConverters .toScala (realm ), Util .emptyMap );
50+ }
51+
52+ /** @deprecated Use {@link #create(String, Optional, Map<String, String>)} instead. */
53+ @ Deprecated // since 1.3.0
4254 public static HttpChallenge create (
4355 String scheme , Option <String > realm , Map <String , String > params ) {
4456 return org .apache .pekko .http .scaladsl .model .headers .HttpChallenge .apply (
4557 scheme , realm .asScala (), Util .convertMapToScala (params ));
4658 }
4759
60+ /** @since 1.3.0 */
61+ public static HttpChallenge create (
62+ String scheme , Optional <String > realm , Map <String , String > params ) {
63+ return org .apache .pekko .http .scaladsl .model .headers .HttpChallenge .apply (
64+ scheme , OptionConverters .toScala (realm ), Util .convertMapToScala (params ));
65+ }
66+
4867 public static HttpChallenge createBasic (String realm ) {
4968 Map <String , String > params = new HashMap <String , String >();
5069 params .put ("charset" , "UTF-8" );
51- return create ("Basic" , Option . option (realm ), params );
70+ return create ("Basic" , Optional . of (realm ), params );
5271 }
5372
5473 public static HttpChallenge createOAuth2 (String realm ) {
55- return create ("Bearer" , Option . option (realm ));
74+ return create ("Bearer" , Optional . of (realm ));
5675 }
5776}
0 commit comments