<commit_before>/*
 *    Copyright 2009-2010 The Rocoto Team
 *
 *    Licensed 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.
 */
package com.rocoto.simpleconfig;

import java.io.File;
import java.io.FileFilter;
import java.util.regex.Pattern;

import lombok.Data;

/**
 * 
 *
 * @author <NAME>
 * @version $Id$
 */
@Data
public abstract class AbstractPropertiesFileFilter implements FileFilter {

    private final Pattern propertiesPattern;

    private final Pattern xmlPropertiesPattern;

    /**
     * {@inheritDoc}
     */
    public boolean accept(File pathname) {
        return pathname.isDirectory()
                || this.isXMLProperties(pathname)
                || this.isProperties(pathname);
    }

    protected final boolean isXMLProperties(File pathname) {
        return matches(pathname, this.xmlPropertiesPattern);
    }

    protected final boolean isProperties(File pathname) {
        return matches(pathname, this.propertiesPattern);
    }

    /**
     * Check if a file name matches with the Pattern.
     *
     * @param pathname
     * @param pattern
     * @return
     */
    private static boolean matches(File pathname, Pattern pattern) {
        return pattern.matcher(pathname.getName()).matches();
    }

}<commit_msg>checked potential NPEs<commit_after>/*
 *    Copyright 2009-2010 The Rocoto Team
 *
 *    Licensed 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.
 */
package com.rocoto.simpleconfig;

import java.io.File;
import java.io.FileFilter;
import java.util.regex.Pattern;

import lombok.Data;

/**
 * 
 *
 * @author <NAME>
 * @version $Id$
 */
@Data
public abstract class AbstractPropertiesFileFilter implements FileFilter {

    private final Pattern propertiesPattern;

    private final Pattern xmlPropertiesPattern;

    /**
     * {@inheritDoc}
     */
    public boolean accept(File pathname) {
        return pathname.isDirectory()
                || this.isXMLProperties(pathname)
                || this.isProperties(pathname);
    }

    protected final boolean isXMLProperties(File pathname) {
        return matches(pathname, this.xmlPropertiesPattern);
    }

    protected final boolean isProperties(File pathname) {
        return matches(pathname, this.propertiesPattern);
    }

    /**
     * Check if a file name matches with the Pattern.
     *
     * @param pathname
     * @param pattern
     * @return
     */
    private static boolean matches(File pathname, Pattern pattern) {
        return pattern != null
                && pathname != null
                && pattern.matcher(pathname.getName()).matches();
    }

}
{'fraction_non_alphanumeric': 0.08710033076074973, 'fraction_numerical': 0.006615214994487321, 'mean_word_length': 2.7920585161964473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6965896', 'n_tokens_mistral': 970, 'n_tokens_neox': 938, 'n_words': 328}