yangys
2024-03-31 2969df3e404db3cd116f27db1495e523ce05bf86
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.qianwen.core.tool.utils;
 
import java.io.File;
import java.io.FileFilter;
import java.io.Serializable;
import org.springframework.util.Assert;
 
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/utils/SuffixFileFilter.class */
public class SuffixFileFilter implements FileFilter, Serializable {
    private static final long serialVersionUID = -3389157631240246157L;
    private final String[] suffixes;
 
    public SuffixFileFilter(final String suffix) {
        Assert.notNull(suffix, "The suffix must not be null");
        this.suffixes = new String[]{suffix};
    }
 
    public SuffixFileFilter(final String[] suffixes) {
        Assert.notNull(suffixes, "The suffix must not be null");
        this.suffixes = new String[suffixes.length];
        System.arraycopy(suffixes, 0, this.suffixes, 0, suffixes.length);
    }
 
    @Override // java.io.FileFilter
    public boolean accept(File pathname) {
        String[] strArr;
        String name = pathname.getName();
        for (String suffix : this.suffixes) {
            if (checkEndsWith(name, suffix)) {
                return true;
            }
        }
        return false;
    }
 
    private boolean checkEndsWith(final String str, final String end) {
        int endLen = end.length();
        return str.regionMatches(true, str.length() - endLen, end, 0, endLen);
    }
}