public DataStreamSource <TOut> FromCollection <TOut>(IEnumerable <TOut> data, TypeInformation <TOut> typeInfo)
        {
            Preconditions.CheckNotNull(data, "Collection must not be null");

            // must not have null elements and mixed elements
            FromElementsFunction <TOut> .CheckCollection(data, typeInfo.TypeClass);

            ISourceFunction <TOut> function;

            try
            {
                function = new FromElementsFunction <TOut>(typeInfo.CreateSerializer(_config), data);
            }
            catch (Exception e)
            {
                throw new RuntimeException(e.Message, e);
            }

            return(AddSource(function, "Collection Source", typeInfo)
                   .SetParallelism(1));
        }