/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.io.uri;

import java.io.IOException;
import java.util.Set;
import net.ranides.assira.collection.sets.Bitmask;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public enum URIFlags {
    
    READABLE    (0x0000_0001),
    WRITABLE    (0x0000_0002),
    EXECUTE     (0x0000_0004),
    EXISTS      (0x0000_0008),
    DIR         (0x0000_0010),
    FILE        (0x0000_0020),
    TEXT        (0x0000_0040),
    BINARY      (0x0000_0080),
    SIZE        (0x0000_0100),
    SEEK        (0x0000_0200),
    ;
    
    private static final Bitmask<URIFlags> MAP = new Bitmask<>(URIFlags.values(), a -> a.mask);
    
    private final int mask;

    private URIFlags(int mask) {
        this.mask = mask;
    }
    
    public boolean matches(URIHandle ustream) throws IOException {
        return ustream.flags().contains(this);
    }
    
    public static Set<URIFlags> collect(URIFlags... flags) {
        return MAP.collect(flags);
    }
    
    public static Set<URIFlags> constant(URIFlags... flags) {
        return MAP.constant(flags);
    }
    
    public static Set<URIFlags> clone(Set<URIFlags> flags) {
        return MAP.clone(flags);
    }
    
}
