/* 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

using ParquetSharp.External;
using ParquetSharp.IO.Api;

namespace ParquetSharp.Hadoop.Api
{
    /**
     *
     * Helps composing write supports
     *
     * @author Julien Le Dem
     *
     * @param <T>
     */
    public class DelegatingWriteSupport<T> : WriteSupport<T>
    {
        private readonly WriteSupport<T> @delegate;

        public DelegatingWriteSupport(WriteSupport<T> @delegate)
        {
            this.@delegate = @delegate;
        }

        public override WriteSupport<T>.WriteContext init(Configuration configuration)
        {
            return @delegate.init(configuration);
        }

        public override void prepareForWrite(RecordConsumer recordConsumer)
        {
            @delegate.prepareForWrite(recordConsumer);
        }

        public override void write(T record)
        {
            @delegate.write(record);
        }

        public override string getName()
        {
            return @delegate.getName();
        }

        public override WriteSupport<T>.FinalizedWriteContext finalizeWrite()
        {
            return @delegate.finalizeWrite();
        }

        public override string ToString()
        {
            return GetType().Name + "(" + @delegate.ToString() + ")";
        }
    }
}
