If the user uses an interface as a result type, use a default
concrete class.

List -> ArrayList
Collection -> ArrayList
Set -> HashSet
548679
private String determineResultClassName(ClassObjectType objType) {
        String className = objType.getClassName();
        if ( List.class.getName().equals( className ) ) {
            className = ArrayList.class.getName();
        } else if ( Set.class.getName().equals( className ) ) {
            className = HashSet.class.getName();
        } else if ( Collection.class.getName().equals( className ) ) {
            className = ArrayList.class.getName();
        }
        return className;
    }
564694
@SuppressWarnings("all")
    public static <T> List<T> toTypedList(Object data, Class<T> type) {
        List<T> listResult = new ArrayList<>();
        if (data == null) {
            return listResult;
        }
        if (data instanceof Collection) {
            Collection collection = (Collection) data;
            for (Object o : collection) {
                listResult.add(Reflection.toType(o, type));
            }
            return listResult;
        }
        if (data.getClass().isArray()) {
            for (Object o : ArrayUtil.toObjectArray(data)) {
                listResult.add(Reflection.toType(o, type));
            }
            return listResult;
        }
        listResult.add(Reflection.toType(data, type));
        return listResult;
    }
131346
public void finish() throws IOException {
        //Map<String,Set<TypeLibInfo>> byPackage = new HashMap<String,Set<TypeLibInfo>>();
        //for( TypeLibInfo tli : generatedTypeLibs ) {
        //    Set<TypeLibInfo> s = byPackage.get(tli.packageName);
        //    if(s==null)
        //        byPackage.put(tli.packageName,s=new HashSet<TypeLibInfo>());
        //    s.add(tli);
        //}

        // for( Map.Entry<String,Set<TypeLibInfo>> e : byPackage.entrySet() ) {
        for( Package pkg : packages.values() ) {
            LibBinder lib1 = pkg.typeLibs.iterator().next();

            if(referenceResolver.suppress(lib1.lib))
                continue;

            // generate ClassFactory
            IndentingWriter o = pkg.createWriter(lib1,"ClassFactory.java");
            lib1.generateHeader(o);

            o.printJavadoc("Defines methods to create COM objects");
            o.println("public abstract class ClassFactory {");
            o.in();

            o.println("private ClassFactory() {} // instanciation is not allowed");
            o.println();

            for( LibBinder lib : pkg.typeLibs ) {
                int len = lib.lib.count();
                for( int i=0; i<len; i++ ) {
                    ICoClassDecl t = lib.lib.getType(i).queryInterface(ICoClassDecl.class);
                    if(t==null)     continue;
                    if(!t.isCreatable())    continue;

                    declareFactoryMethod(o, t);
                    t.dispose();
                }
            }

            o.out();
            o.println("}");
            o.close();
        }
    }
986304
private void addType(Class<?> type, Object object)
    {
        if (!items.containsKey(type))
        {
            items.put(type, new HashSet<>());
        }
        items.get(type).add(object);
    }
67363
ITypeDecl getDefaultInterface( ICoClassDecl t ) {
        final int count = t.countImplementedInterfaces();
        // look for the default interface first.
        for( int i=0; i<count; i++ ) {
            IImplementedInterfaceDecl impl = t.getImplementedInterface(i);
            if(impl.isSource())
                continue;
            if(impl.isDefault()){
              IInterfaceDecl c = getCustom(impl);
              if(c!=null)
                return c;
              IDispInterfaceDecl d = impl.getType().queryInterface(IDispInterfaceDecl.class);
              if(d != null){
                return d;
              }
            }
        }

        // if none is found, look for any non-source interface
        Set<IInterfaceDecl> types = new HashSet<IInterfaceDecl>();
        for( int i=0; i<count; i++ ) {
            IImplementedInterfaceDecl impl = t.getImplementedInterface(i);
            if(impl.isSource())
                continue;
            IInterfaceDecl c = getCustom(impl);
            if(c !=null)
                types.add(c);
        }

        if(types.isEmpty())
            return null;

        // if T1 and T2 are in the set and T1 derives from T2, eliminate T2
        // (since returning T1 is better)
        Set<IInterfaceDecl> bases = new HashSet<IInterfaceDecl>();
        for (IInterfaceDecl ii : types) {
            for( int i=0; i<ii.countBaseInterfaces(); i++)
                bases.add(ii.getBaseInterface(i).queryInterface(IInterfaceDecl.class));
        }
        types.removeAll(bases);

        return types.iterator().next();
    }
733855
public Object initResult()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
	  SibTr.entry(tc, "initResult");  	

    Set theResults = new HashSet();
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
	  SibTr.exit(tc, "initResult");
    return theResults;
  }
1271827
public static Set<ClassNode> collectAllInterfaces(ClassNode node) {
        HashSet<ClassNode> result = new HashSet<ClassNode>();
        collectAllInterfaces(node, result);
        return result;
    }
161188
public static <T> HashSet<T> newHashSet(boolean isSorted, Collection<T> collection) {
		return isSorted ? new LinkedHashSet<T>(collection) : new HashSet<T>(collection);
	}
973692
private static Class _loadClass(ClassLoading cl, String className, Class defaultValue, Set<Throwable> exceptions) {
	className = className.trim();
	if (StringUtil.isEmpty(className)) return defaultValue;

	Class clazz = checkPrimaryTypesBytecodeDef(className, null);
	if (clazz != null) return clazz;

	// array in the format boolean[] or java.lang.String[]
	if (className.endsWith("[]")) {

	    StringBuilder pureCN = new StringBuilder(className);
	    int dimensions = 0;
	    do {
		pureCN.delete(pureCN.length() - 2, pureCN.length());
		dimensions++;
	    }
	    while (pureCN.lastIndexOf("[]") == pureCN.length() - 2);

	    clazz = __loadClass(cl, pureCN.toString(), null, exceptions);

	    if (clazz != null) {

		for (int i = 0; i < dimensions; i++)
		    clazz = toArrayClass(clazz);
		return clazz;
	    }
	}

	// array in the format [C or [Ljava.lang.String;
	else if (className.charAt(0) == '[') {

	    StringBuilder pureCN = new StringBuilder(className);
	    int dimensions = 0;

	    do {
		pureCN.delete(0, 1);
		dimensions++;
	    }
	    while (pureCN.charAt(0) == '[');

	    clazz = __loadClass(cl, pureCN.toString(), null, exceptions);
	    if (clazz != null) {
		for (int i = 0; i < dimensions; i++)
		    clazz = toArrayClass(clazz);
		return clazz;
	    }
	}
	return __loadClass(cl, className, defaultValue, exceptions);
    }
729585
public static <T> ArrayList<T> distinct(Collection<T> collection) {
		if (isEmpty(collection)) {
			return new ArrayList<>();
		} else if (collection instanceof Set) {
			return new ArrayList<>(collection);
		} else {
			return new ArrayList<>(new LinkedHashSet<>(collection));
		}
	}
997241
private void addClasses(Class<?>[] classes, HashSet<Class<?>> result){
		
		if(isNull(classes) || classes.length==0)	
			Error.globalClassesAbsent(configuredClass);
		
		for (Class<?> classe : classes)	result.add(classe);
	}
627466
private static Class<?>[] getTypes(Object... objects) {
        if (objects == null) {
            return new Class[0];
        }

        Class<?>[] result = new Class[objects.length];

        for (int i = 0; i < objects.length; i++) {
            Object value = objects[i];
            result[i] = value == null ? NULL.class : value.getClass();
        }

        return result;
    }
339612
static Set<String> getJavaDefaultTypes() {
        if (javaDefaultTypes == null) {
            javaDefaultTypes = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
                    "AbstractMethodError",
                    "Appendable",
                    "ArithmeticException",
                    "ArrayIndexOutOfBoundsException",
                    "ArrayStoreException",
                    "AssertionError",
                    "AutoCloseable",
                    "Boolean",
                    "BootstrapMethodError",
                    "Byte",
                    "Character",
                    "CharSequence",
                    "Class",
                    "ClassCastException",
                    "ClassCircularityError",
                    "ClassFormatError",
                    "ClassLoader",
                    "ClassNotFoundException",
                    "ClassValue",
                    "Cloneable",
                    "CloneNotSupportedException",
                    "Comparable",
                    "Compiler",
                    "Deprecated",
                    "Double",
                    "Enum",
                    "EnumConstantNotPresentException",
                    "Error",
                    "Exception",
                    "ExceptionInInitializerError",
                    "Float",
                    "FunctionalInterface",
                    "IllegalAccessError",
                    "IllegalAccessException",
                    "IllegalArgumentException",
                    "IllegalCallerException",
                    "IllegalMonitorStateException",
                    "IllegalStateException",
                    "IllegalThreadStateException",
                    "IncompatibleClassChangeError",
                    "IndexOutOfBoundsException",
                    "InheritableThreadLocal",
                    "InstantiationError",
                    "InstantiationException",
                    "Integer",
                    "InternalError",
                    "InterruptedException",
                    "Iterable",
                    "LayerInstantiationException",
                    "LinkageError",
                    "Long",
                    "Math",
                    "Module",
                    "ModuleLayer",
                    "NegativeArraySizeException",
                    "NoClassDefFoundError",
                    "NoSuchFieldError",
                    "NoSuchFieldException",
                    "NoSuchMethodError",
                    "NoSuchMethodException",
                    "NullPointerException",
                    "Number",
                    "NumberFormatException",
                    "Object",
                    "OutOfMemoryError",
                    "Override",
                    "Package",
                    "Process",
                    "ProcessBuilder",
                    "ProcessHandle",
                    "Readable",
                    "ReflectiveOperationException",
                    "Runnable",
                    "Runtime",
                    "RuntimeException",
                    "RuntimePermission",
                    "SafeVarargs",
                    "SecurityException",
                    "SecurityManager",
                    "Short",
                    "StackOverflowError",
                    "StackTraceElement",
                    "StackWalker",
                    "StrictMath",
                    "String",
                    "StringBuffer",
                    "StringBuilder",
                    "StringIndexOutOfBoundsException",
                    "SuppressWarnings",
                    "System",
                    "Thread",
                    "ThreadDeath",
                    "ThreadGroup",
                    "ThreadLocal",
                    "Throwable",
                    "TypeNotPresentException",
                    "UnknownError",
                    "UnsatisfiedLinkError",
                    "UnsupportedClassVersionError",
                    "UnsupportedOperationException",
                    "VerifyError",
                    "VirtualMachineError",
                    "Void",
                    "boolean",
                    "byte",
                    "char",
                    "double",
                    "float",
                    "int",
                    "long",
                    "short",
                    "void")));
        }
        return javaDefaultTypes;
    }
946303
public Datatype.Builder setInterfaceType(boolean interfaceType) {
    this.interfaceType = interfaceType;
    _unsetProperties.remove(Property.INTERFACE_TYPE);
    return (Datatype.Builder) this;
  }
1114488
@Override
    public final Class<T> returnedClass() {
        @SuppressWarnings("unchecked")Class<T> result = (Class<T>) TypeHelper.getTypeArguments(AbstractColumnMapper.class, getClass()).get(0);
        return result;
    }
743243
private void addClasses(Class<?>[] classes, HashSet<Class<?>> result, String fieldName){
		
		if(classes == null || classes.length==0)	
			Error.classesAbsent(fieldName, configuredClass);
		
		for (Class<?> classe : classes)	result.add(classe);
	}
758572
private static Class<?> getConcreteType(final Class<?> rawType, final boolean returnNullIfNotMapOrCollection) {
        // This list is not complete (e.g. EnumMap cannot be instantiated directly, you need to pass the
        // enum key type into a factory method), but this should cover a lot of the common types
        if (rawType == Map.class || rawType == AbstractMap.class || rawType == HashMap.class) {
            return HashMap.class;
        } else if (rawType == ConcurrentMap.class || rawType == ConcurrentHashMap.class) {
            return ConcurrentHashMap.class;
        } else if (rawType == SortedMap.class || rawType == NavigableMap.class || rawType == TreeMap.class) {
            return TreeMap.class;
        } else if (rawType == ConcurrentNavigableMap.class || rawType == ConcurrentSkipListMap.class) {
            return ConcurrentSkipListMap.class;
        } else if (rawType == List.class || rawType == AbstractList.class || rawType == ArrayList.class
                || rawType == Collection.class) {
            return ArrayList.class;
        } else if (rawType == AbstractSequentialList.class || rawType == LinkedList.class) {
            return LinkedList.class;
        } else if (rawType == Set.class || rawType == AbstractSet.class || rawType == HashSet.class) {
            return HashSet.class;
        } else if (rawType == SortedSet.class || rawType == TreeSet.class) {
            return TreeSet.class;
        } else if (rawType == Queue.class || rawType == AbstractQueue.class || rawType == Deque.class
                || rawType == ArrayDeque.class) {
            return ArrayDeque.class;
        } else if (rawType == BlockingQueue.class || rawType == LinkedBlockingQueue.class) {
            return LinkedBlockingQueue.class;
        } else if (rawType == BlockingDeque.class || rawType == LinkedBlockingDeque.class) {
            return LinkedBlockingDeque.class;
        } else if (rawType == TransferQueue.class || rawType == LinkedTransferQueue.class) {
            return LinkedTransferQueue.class;
        } else {
            return returnNullIfNotMapOrCollection ? null : rawType;
        }
    }