package ru.soune.nocopy.entity.file.permission;

import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public enum PermissionType {
    DOWNLOAD;

    public static Set<String> getValidPermissionNames() {
        return Arrays.stream(PermissionType.values())
                .map(Enum::name)
                .collect(Collectors.toSet());
    }

    public static Set<String> getInvalidPermissions(Map<String, Boolean> permissions) {
        Set<String> validNames = getValidPermissionNames();
        return permissions.keySet().stream()
                .filter(key -> !validNames.contains(key))
                .collect(Collectors.toSet());
    }

    public static boolean areAllValid(Map<String, Boolean> permissions) {
        return getInvalidPermissions(permissions).isEmpty();
    }
}
