    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;
    021
    022/**
    023 * Appends all data to the famous <strong>/dev/null</strong>.
    024 * <p>
    025 * This Appendable has no destination (file/socket etc.) and all characters written to it are ignored and lost.
    026 * </p>
    027 *
    028 * @since 2.8.0
    029 */
    030public class NullAppendable implements Appendable { // NOPMD Class will be final in 3.0.
    031
    032    /**
    033     * A singleton.
    034     */
    035    public static final NullAppendable INSTANCE = new NullAppendable();
    036
    037    /** Use the singleton. */
    038    private NullAppendable() {
    039        // no instances.
    040    }
    041
    042    @Override
    043    public Appendable append(final char c) throws IOException {
    044        return this;
    045    }
    046
    047    @Override
    048    public Appendable append(final CharSequence csq) throws IOException {
    049        return this;
    050    }
    051
    052    @Override
    053    public Appendable append(final CharSequence csq, final int start, final int end) throws IOException {
    054        return this;
    055    }
    056
    057}