/*
 * Copyright 2015-2022 Danilo Reinert
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.reinert.requestor.gwt;

import io.reinert.requestor.core.Requestor;
import io.reinert.requestor.core.auth.BasicAuth;
import io.reinert.requestor.core.auth.DigestAuth;

/**
 * This class provides a static initializer for Requestor's deferred bindings for GWT environment.
 *
 * @author Danilo Reinert
 */
public class RequestorGwt {

    /**
     * Initializes static lazy bindings to enable the proper usage of Requestor in GWT environment.
     * <p></p>
     * Call this method in a static block in the app's EntryPoint.
     */
    public static void init() {
        Requestor.init(
                new BasicAuth.Base64() {
                    @Override
                    public native String encode(String text) /*-{
                        return $wnd.btoa(text);
                    }-*/;
                },
                new GwtUriCodec()
        );

        DigestAuth.setHashFunction("md5", new DigestAuth.HashFunction() {
            public String hash(String input) {
                return MD5.hash(input);
            }
        });
    }

    public static boolean isInitialized() {
        return Requestor.isInitialized();
    }
}

@@ -1178,16 +1178,21 @@
         
+if (!
 Requesto
@@ -1198,15 +1198,54 @@
 or.i
+sI
 nit
+ialized()) %7B%0A            Requestor.init
 (%0A
-  
     
@@ -1250,24 +1250,30 @@
             
+      
 new BasicAut
@@ -1305,16 +1305,20 @@
         
+    
 @Overrid
@@ -1335,24 +1335,28 @@
             
+ 
+   
 public nativ
@@ -1409,24 +1409,28 @@
             
+    
 return $wnd.
@@ -1437,24 +1437,28 @@
 btoa(text);%0A
+    
             
@@ -1491,11 +1491,19 @@
     
-%7D,%0A
+    %7D,%0A    
     
@@ -1544,12 +1544,20 @@
     
+   
+ 
 );%0A%0A
+    
     
@@ -1634,24 +1634,28 @@
             
+    
 public Strin
@@ -1689,24 +1689,28 @@
             
+ 
+   
 return MD5.h
@@ -1737,114 +1737,39 @@
     
-%7D%0A        %7D);
+    %7D
 %0A    
-%7D%0A%0A
     
-public static boolean isInitialized() %7B%0A        return Requestor.isInitialized();
+    %7D);%0A        %7D
 %0A   

Check Requestor is not initialized in RequestorGwt.init