package com.njcn.gather.user.user.pojo.constant;

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 通用文件扩展名常量。
 */
public final class SysFileExtensionConst {

    private SysFileExtensionConst() {
    }

    /**
     * 图片文件扩展名，适用于签名、图片附件等场景。
     */
    public static final Set<String> IMAGE_EXTENSIONS = unmodifiableSet(
            "png", "jpg", "jpeg", "bmp", "webp");

    /**
     * 常见文档文件扩展名，适用于文档、台账、说明文件等场景。
     */
    public static final Set<String> DOCUMENT_EXTENSIONS = unmodifiableSet(
            "doc", "docx", "xls", "xlsx", "txt", "pdf");

    /**
     * 通用上传扩展名，供后续文件业务按需复用。
     */
    public static final Set<String> COMMON_UPLOAD_EXTENSIONS = merge(IMAGE_EXTENSIONS, DOCUMENT_EXTENSIONS);

    private static Set<String> merge(Set<String> left, Set<String> right) {
        LinkedHashSet<String> merged = new LinkedHashSet<String>();
        merged.addAll(left);
        merged.addAll(right);
        return Collections.unmodifiableSet(merged);
    }

    private static Set<String> unmodifiableSet(String... values) {
        return Collections.unmodifiableSet(new LinkedHashSet<String>(Arrays.asList(values)));
    }
}
