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

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.time.Instant;

/**
 *
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 */
public enum URITime {

    /**
     * Time of creation
     */
    CREATED,
    /**
     * Time of last modification of content
     */
    MODIFIED,
    /**
     * Time of last access
     */
    ACCESSED,
    /**
     * Time of last modification of meta-data
     */
    META_MODIFIED,
    ;

    /**
     * Returns timestamp for provided resource.
     *
     * This method makes a call to {@link URIHandle#time(URITime)}.
     *
     * @param ustream ustream
     * @return Instant
     * @throws IOException on error
     */
    public Instant resolve(URIHandle ustream) throws IOException {
        return ustream.time(this);
    }

    /**
     * Returns timestamp for provided resource.
     *
     * This method uses default resolver to create handle.
     * This method makes a call to {@link URIHandle#time(URITime)}.
     *
     * @param file file
     * @return Instant
     * @throws IOException on error
     */
    public Instant resolve(File file) throws IOException {
        return resolve(URIHandle.resolve(file));
    }

    /**
     * Returns timestamp for provided resource.
     *
     * This method uses default resolver to create handle.
     * This method makes a call to {@link URIHandle#time(URITime)}.
     *
     * @param uri uri
     * @return Instant
     * @throws IOException on error
     */
    public Instant resolve(URI uri) throws IOException {
        return resolve(URIHandle.resolve(uri));
    }
    
}
