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 */
017package org.apache.commons.io.filefilter;
018
019import java.io.File;
020import java.io.Serializable;
021
022/**
023 * A file filter that always returns true.
024 *
025 * @since 1.0
026 *
027 * @see FileFilterUtils#trueFileFilter()
028 */
029public class TrueFileFilter implements IOFileFilter, Serializable {
030
031    private static final long serialVersionUID = 8782512160909720199L;
032    /**
033     * Singleton instance of true filter.
034     * @since 1.3
035     */
036    public static final IOFileFilter TRUE = new TrueFileFilter();
037    /**
038     * Singleton instance of true filter.
039     * Please use the identical TrueFileFilter.TRUE constant.
040     * The new name is more JDK 1.5 friendly as it doesn't clash with other
041     * values when using static imports.
042     */
043    public static final IOFileFilter INSTANCE = TRUE;
044
045    /**
046     * Restrictive constructor.
047     */
048    protected TrueFileFilter() {
049    }
050
051    /**
052     * Returns true.
053     *
054     * @param file  the file to check (ignored)
055     * @return true
056     */
057    @Override
058    public boolean accept(final File file) {
059        return true;
060    }
061
062    /**
063     * Returns true.
064     *
065     * @param dir  the directory to check (ignored)
066     * @param name  the file name (ignored)
067     * @return true
068     */
069    @Override
070    public boolean accept(final File dir, final String name) {
071        return true;
072    }
073
074}