// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java
// public static <T> T notNull(T object) {
//     if (object == null) {
//         throw new NullPointerException();
//     }
// 
//     return object;
// }


import java.util.HashMap;
import java.util.Map;
import static xdroid.core.ObjectUtils.notNull;
package xdroid.core;



public final class Singletons {
    private static final Map<Class<?>, Object> MAP = new HashMap<>();

    public static <T> void putSingleton(Class<T> clazz, T instance) {
        if (!clazz.isInstance(instance)) {
            throw new IllegalArgumentException();
        }

        Object old = MAP.get(clazz);
        if (old != null) {
            throw new IllegalStateException();
        }

// Path: lib-core/src/main/java/xdroid/core/ObjectUtils.java
// public static <T> T notNull(T object) {
//     if (object == null) {
//         throw new NullPointerException();
//     }
// 
//     return object;
// }


// Path: lib-core/src/main/java/xdroid/core/Singletons.java
import java.util.HashMap;
import java.util.Map;
import static xdroid.core.ObjectUtils.notNull;

package xdroid.core;



public final class Singletons {
    private static final Map<Class<?>, Object> MAP = new HashMap<>();

    public static <T> void putSingleton(Class<T> clazz, T instance) {
        if (!clazz.isInstance(instance)) {
            throw new IllegalArgumentException();
        }

        Object old = MAP.get(clazz);
        if (old != null) {
            throw new IllegalStateException();
        }

        MAP.put(clazz, notNull(instance));