001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.io.output;
019
020import java.io.IOException;
021import java.io.UncheckedIOException;
022
023/**
024 * An {@link Appendable} that throws {@link UncheckedIOException} instead of {@link IOException}.
025 *
026 * @see Appendable
027 * @see IOException
028 * @see UncheckedIOException
029 * @since 2.12.0
030 */
031public interface UncheckedAppendable extends Appendable {
032
033    /**
034     * Constructs a new instance on the given Appendable.
035     *
036     * @param appendable The Appendable to uncheck.
037     * @return a new instance.
038     */
039    static UncheckedAppendable on(final Appendable appendable) {
040        return new UncheckedAppendableImpl(appendable);
041    }
042
043    /**
044     * Appends per {@link Appendable#append(char)} but rethrows {@link IOException} as {@link UncheckedIOException}.
045     */
046    @Override
047    UncheckedAppendable append(char c);
048
049    /**
050     * Appends per {@link Appendable#append(CharSequence)} but rethrows {@link IOException} as {@link UncheckedIOException}.
051     */
052    @Override
053    UncheckedAppendable append(CharSequence csq);
054
055    /**
056     * Appends per {@link Appendable#append(CharSequence, int, int)} but rethrows {@link IOException} as
057     * {@link UncheckedIOException}.
058     */
059    @Override
060    UncheckedAppendable append(CharSequence csq, int start, int end);
061}