// Path: EventBus/src/org/greenrobot/eventbus/Logger.java
// public interface Logger {
// 
//     void log(Level level, String msg);
// 
//     void log(Level level, String msg, Throwable th);
// 
//     class JavaLogger implements Logger {
//         protected final java.util.logging.Logger logger;
// 
//         public JavaLogger(String tag) {
//             logger = java.util.logging.Logger.getLogger(tag);
//         }
// 
//         @Override
//         public void log(Level level, String msg) {
//             // TODO Replace logged method with caller method
//             logger.log(level, msg);
//         }
// 
//         @Override
//         public void log(Level level, String msg, Throwable th) {
//             // TODO Replace logged method with caller method
//             logger.log(level, msg, th);
//         }
// 
//     }
// 
//     class SystemOutLogger implements Logger {
// 
//         @Override
//         public void log(Level level, String msg) {
//             System.out.println("[" + level + "] " + msg);
//         }
// 
//         @Override
//         public void log(Level level, String msg, Throwable th) {
//             System.out.println("[" + level + "] " + msg);
//             th.printStackTrace(System.out);
//         }
// 
//     }
// 
//     class Default {
//         public static Logger get() {
//             if (AndroidComponents.areAvailable()) {
//                 return AndroidComponents.get().logger;
//             }
// 
//             return new SystemOutLogger();
//         }
//     }
// 
// }


import org.greenrobot.eventbus.Logger;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
/*
 * Copyright (C) 2012-2020 Markus Junginger, greenrobot (http://greenrobot.org)
 *
 * 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 org.greenrobot.eventbus.util;




/**
 * Maps throwables to texts for error dialogs. Use Config to configure the mapping.
 * 
 * @author Markus
 */
public class ExceptionToResourceMapping {

    public final Map<Class<? extends Throwable>, Integer> throwableToMsgIdMap;

    public ExceptionToResourceMapping() {
        throwableToMsgIdMap = new HashMap<>();
    }

    /** Looks at the exception and its causes trying to find an ID. */
    public Integer mapThrowable(final Throwable throwable) {
        Throwable throwableToCheck = throwable;
        int depthToGo = 20;

        while (true) {
            Integer resId = mapThrowableFlat(throwableToCheck);
            if (resId != null) {
                return resId;
            } else {
                throwableToCheck = throwableToCheck.getCause();
                depthToGo--;
                if (depthToGo <= 0 || throwableToCheck == throwable || throwableToCheck == null) {
// Path: EventBus/src/org/greenrobot/eventbus/Logger.java
// public interface Logger {
// 
//     void log(Level level, String msg);
// 
//     void log(Level level, String msg, Throwable th);
// 
//     class JavaLogger implements Logger {
//         protected final java.util.logging.Logger logger;
// 
//         public JavaLogger(String tag) {
//             logger = java.util.logging.Logger.getLogger(tag);
//         }
// 
//         @Override
//         public void log(Level level, String msg) {
//             // TODO Replace logged method with caller method
//             logger.log(level, msg);
//         }
// 
//         @Override
//         public void log(Level level, String msg, Throwable th) {
//             // TODO Replace logged method with caller method
//             logger.log(level, msg, th);
//         }
// 
//     }
// 
//     class SystemOutLogger implements Logger {
// 
//         @Override
//         public void log(Level level, String msg) {
//             System.out.println("[" + level + "] " + msg);
//         }
// 
//         @Override
//         public void log(Level level, String msg, Throwable th) {
//             System.out.println("[" + level + "] " + msg);
//             th.printStackTrace(System.out);
//         }
// 
//     }
// 
//     class Default {
//         public static Logger get() {
//             if (AndroidComponents.areAvailable()) {
//                 return AndroidComponents.get().logger;
//             }
// 
//             return new SystemOutLogger();
//         }
//     }
// 
// }


// Path: EventBus/src/org/greenrobot/eventbus/util/ExceptionToResourceMapping.java
import org.greenrobot.eventbus.Logger;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;

/*
 * Copyright (C) 2012-2020 Markus Junginger, greenrobot (http://greenrobot.org)
 *
 * 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 org.greenrobot.eventbus.util;




/**
 * Maps throwables to texts for error dialogs. Use Config to configure the mapping.
 * 
 * @author Markus
 */
public class ExceptionToResourceMapping {

    public final Map<Class<? extends Throwable>, Integer> throwableToMsgIdMap;

    public ExceptionToResourceMapping() {
        throwableToMsgIdMap = new HashMap<>();
    }

    /** Looks at the exception and its causes trying to find an ID. */
    public Integer mapThrowable(final Throwable throwable) {
        Throwable throwableToCheck = throwable;
        int depthToGo = 20;

        while (true) {
            Integer resId = mapThrowableFlat(throwableToCheck);
            if (resId != null) {
                return resId;
            } else {
                throwableToCheck = throwableToCheck.getCause();
                depthToGo--;
                if (depthToGo <= 0 || throwableToCheck == throwable || throwableToCheck == null) {
                    Logger logger = Logger.Default.get();  // No EventBus instance here