// Path: library/src/main/java/com/wangjie/rapidrouter/core/config/RapidRouterConfiguration.java
// public interface RapidRouterConfiguration {
//     /**
//      * 配置路由策略
//      */
//     @NonNull
//     RapidRouterStrategy[] configRapidRouterStrategies();
// 
//     /**
//      * 配置路由映射
//      */
//     @Nullable
//     RapidRouterMapping[] configRapidRouterMappings();
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/exception/RapidRouterIllegalException.java
// public class RapidRouterIllegalException extends RapidRouterException {
// 
//     public RapidRouterIllegalException(String message) {
//         super(message);
//     }
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/exception/RapidRouterNotInitializedException.java
// public class RapidRouterNotInitializedException extends RapidRouterException {
// 
//     public RapidRouterNotInitializedException(String message) {
//         super(message);
//     }
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/OnRapidRouterListener.java
// public interface OnRapidRouterListener {
// 
//     void onRouterError(RouterStuff routerStuff, Throwable throwable);
// 
//     void onRouterGoAfter(RouterStuff routerStuff);
// 
//     boolean onRouterGoAround(RouterStuff routerStuff);
// 
//     void onRouterGoBefore(RouterStuff routerStuff);
// 
//     void onRouterTargetNotFound(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/RouterGoAroundCallback.java
// public interface RouterGoAroundCallback {
//     void onRouterGoAround(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/RouterGoBeforeCallback.java
// public interface RouterGoBeforeCallback {
//     boolean onRouterGoBefore(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/RouterTargetNotFoundCallback.java
// public interface RouterTargetNotFoundCallback {
//     boolean onRouterTargetNotFound(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategy.java
// public interface RapidRouterStrategy {
//     
//     void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings);
// 
//     @Nullable
//     RouterTarget findRouterTarget(@NonNull Uri uri);
// 
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
//     private Class targetClass;
//     private HashMap<String, Class> params;
// 
//     public RouterTarget(Class targetClass, HashMap<String, Class> params) {
//         this.targetClass = targetClass;
//         this.params = params;
//     }
// 
//     public Class getTargetClass() {
//         return targetClass;
//     }
// 
//     public void setTargetClass(Class targetClass) {
//         this.targetClass = targetClass;
//     }
// 
//     public HashMap<String, Class> getParams() {
//         return params;
//     }
// 
//     public void setParams(HashMap<String, Class> params) {
//         this.params = params;
//     }
// }


import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;
import com.wangjie.rapidrouter.core.config.RapidRouterConfiguration;
import com.wangjie.rapidrouter.core.exception.RapidRouterIllegalException;
import com.wangjie.rapidrouter.core.exception.RapidRouterNotInitializedException;
import com.wangjie.rapidrouter.core.listener.OnRapidRouterListener;
import com.wangjie.rapidrouter.core.listener.RouterGoAroundCallback;
import com.wangjie.rapidrouter.core.listener.RouterGoBeforeCallback;
import com.wangjie.rapidrouter.core.listener.RouterTargetNotFoundCallback;
import com.wangjie.rapidrouter.core.strategy.RapidRouterStrategy;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
                    if (null != onRapidRouterListener) {
                        onRapidRouterListener.onRouterGoAfter(routerStuff);
                    }
                }
            }

            return true;
        } catch (Throwable throwable) {
            Log.e(TAG, "", throwable);
            if (null != onRapidRouterListener) {
                onRapidRouterListener.onRouterError(routerStuff, throwable);
            }
            return false;
        }
    }

    /**
     * 根据策略 查询RouterTarget
     */
    private static RouterTarget findRouterTarget(RouterStuff routerStuff, Uri uri) {
        RouterTarget routerTarget = null;
        List<Class<? extends RapidRouterStrategy>> supportStrategies = routerStuff.strategies();
        if (null == supportStrategies || supportStrategies.isEmpty()) {
            for (Map.Entry<String, RapidRouterStrategy> entry : routerStrategyTreeMap.entrySet()) {
                if (null != (routerTarget = entry.getValue().findRouterTarget(uri))) {
                    break;
                }
            }
        } else {
            for (Class<? extends RapidRouterStrategy> routerStrategyClass : supportStrategies) {
// Path: library/src/main/java/com/wangjie/rapidrouter/core/config/RapidRouterConfiguration.java
// public interface RapidRouterConfiguration {
//     /**
//      * 配置路由策略
//      */
//     @NonNull
//     RapidRouterStrategy[] configRapidRouterStrategies();
// 
//     /**
//      * 配置路由映射
//      */
//     @Nullable
//     RapidRouterMapping[] configRapidRouterMappings();
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/exception/RapidRouterIllegalException.java
// public class RapidRouterIllegalException extends RapidRouterException {
// 
//     public RapidRouterIllegalException(String message) {
//         super(message);
//     }
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/exception/RapidRouterNotInitializedException.java
// public class RapidRouterNotInitializedException extends RapidRouterException {
// 
//     public RapidRouterNotInitializedException(String message) {
//         super(message);
//     }
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/OnRapidRouterListener.java
// public interface OnRapidRouterListener {
// 
//     void onRouterError(RouterStuff routerStuff, Throwable throwable);
// 
//     void onRouterGoAfter(RouterStuff routerStuff);
// 
//     boolean onRouterGoAround(RouterStuff routerStuff);
// 
//     void onRouterGoBefore(RouterStuff routerStuff);
// 
//     void onRouterTargetNotFound(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/RouterGoAroundCallback.java
// public interface RouterGoAroundCallback {
//     void onRouterGoAround(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/RouterGoBeforeCallback.java
// public interface RouterGoBeforeCallback {
//     boolean onRouterGoBefore(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/RouterTargetNotFoundCallback.java
// public interface RouterTargetNotFoundCallback {
//     boolean onRouterTargetNotFound(RouterStuff routerStuff);
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategy.java
// public interface RapidRouterStrategy {
//     
//     void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings);
// 
//     @Nullable
//     RouterTarget findRouterTarget(@NonNull Uri uri);
// 
// }
// 
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
//     private Class targetClass;
//     private HashMap<String, Class> params;
// 
//     public RouterTarget(Class targetClass, HashMap<String, Class> params) {
//         this.targetClass = targetClass;
//         this.params = params;
//     }
// 
//     public Class getTargetClass() {
//         return targetClass;
//     }
// 
//     public void setTargetClass(Class targetClass) {
//         this.targetClass = targetClass;
//     }
// 
//     public HashMap<String, Class> getParams() {
//         return params;
//     }
// 
//     public void setParams(HashMap<String, Class> params) {
//         this.params = params;
//     }
// }


// Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouter.java
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;
import com.wangjie.rapidrouter.core.config.RapidRouterConfiguration;
import com.wangjie.rapidrouter.core.exception.RapidRouterIllegalException;
import com.wangjie.rapidrouter.core.exception.RapidRouterNotInitializedException;
import com.wangjie.rapidrouter.core.listener.OnRapidRouterListener;
import com.wangjie.rapidrouter.core.listener.RouterGoAroundCallback;
import com.wangjie.rapidrouter.core.listener.RouterGoBeforeCallback;
import com.wangjie.rapidrouter.core.listener.RouterTargetNotFoundCallback;
import com.wangjie.rapidrouter.core.strategy.RapidRouterStrategy;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

                    if (null != onRapidRouterListener) {
                        onRapidRouterListener.onRouterGoAfter(routerStuff);
                    }
                }
            }

            return true;
        } catch (Throwable throwable) {
            Log.e(TAG, "", throwable);
            if (null != onRapidRouterListener) {
                onRapidRouterListener.onRouterError(routerStuff, throwable);
            }
            return false;
        }
    }

    /**
     * 根据策略 查询RouterTarget
     */
    private static RouterTarget findRouterTarget(RouterStuff routerStuff, Uri uri) {
        RouterTarget routerTarget = null;
        List<Class<? extends RapidRouterStrategy>> supportStrategies = routerStuff.strategies();
        if (null == supportStrategies || supportStrategies.isEmpty()) {
            for (Map.Entry<String, RapidRouterStrategy> entry : routerStrategyTreeMap.entrySet()) {
                if (null != (routerTarget = entry.getValue().findRouterTarget(uri))) {
                    break;
                }
            }
        } else {
            for (Class<? extends RapidRouterStrategy> routerStrategyClass : supportStrategies) {
                RapidRouterStrategy routerStrategy = routerStrategyTreeMap.get(routerStrategyClass.getCanonicalName());