src/main/java/org/organicdesign/fp/type/RuntimeTypes.java
public static ImList<Class> registerClasses(Class... cs) {
        if (cs == null) {
            throw new IllegalArgumentException("Can't register a null type array");
        }
        if (cs.length == 0) {
            throw new IllegalArgumentException("Can't register a zero-length type array");
        }
        for (Class c : cs) {
            if (c == null) {
                throw new IllegalArgumentException("There shouldn't be any null types in this array!");
            }
        }

        ArrayHolder<Class> ah = new ArrayHolder<>(cs);
        ImList<Class> registeredTypes;
        synchronized (Lock.INSTANCE) {
            registeredTypes = typeMap.get(ah);
            if (registeredTypes == null) {
                ImList<Class> vecCs = vec(cs);
                typeMap.put(ah, vecCs);
                registeredTypes = vecCs;
            }
        }
        // We are returning the original array.  If we returned our safe copy, it could be modified!
        return registeredTypes;
    }
public static ImList<Class> registerClasses(Class... cs) {
        if (cs == null) {
            throw new IllegalArgumentException("Can't register a null type array");
        }
        if (cs.length == 0) {
            throw new IllegalArgumentException("Can't register a zero-length type array");
        }
        for (Class c : cs) {
            if (c == null) {
                throw new IllegalArgumentException("There shouldn't be any null types in this array!");
            }
        }

        ArrayHolder<Class> ah = new ArrayHolder<>(cs);
        ImList<Class> registeredTypes;
        synchronized (Lock.INSTANCE) {
            registeredTypes = typeMap.get(ah);
            if (registeredTypes == null) {
                ImList<Class> vecCs = vec(cs);
                typeMap.put(ah, vecCs);
                registeredTypes = vecCs;
            }
        }
        // We are returning the original array.  If we returned our safe copy, it could be modified!
        return registeredTypes;
    }
public static ImList < Class > registerClasses ( Class ... cs ) { if ( cs == null ) { throw new IllegalArgumentException ( "Can't register a null type array" ) ; } if ( cs . length == 0 ) { throw new IllegalArgumentException ( "Can't register a zero-length type array" ) ; } for ( Class c : cs ) { if ( c == null ) { throw new IllegalArgumentException ( "There shouldn't be any null types in this array!" ) ; } } ArrayHolder < Class > ah = new ArrayHolder <> ( cs ) ; ImList < Class > registeredTypes ; synchronized ( Lock . INSTANCE ) { registeredTypes = typeMap . get ( ah ) ; if ( registeredTypes == null ) { ImList < Class > vecCs = vec ( cs ) ; typeMap . put ( ah , vecCs ) ; registeredTypes = vecCs ; } } // We are returning the original array.  If we returned our safe copy, it could be modified! return registeredTypes ; }
Use this to prevent duplicate runtime types.
@param cs an immutable vector of classes to register
Use this to prevent duplicate runtime types .