All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fizzed.bigmap.impl.AbstractBigObjectCloser Maven / Gradle / Ivy

There is a newer version: 1.0.16
Show newest version
package com.fizzed.bigmap.impl;

import com.fizzed.bigmap.BigObjectCloser;

import java.io.IOException;
import java.nio.file.Path;
import java.util.UUID;

abstract public class AbstractBigObjectCloser implements BigObjectCloser {

    private final UUID id;
    private final boolean persistent;
    private final Path directory;
    private boolean closed;

    public AbstractBigObjectCloser(UUID id, boolean persistent, Path directory) {
        this.id = id;
        this.persistent = persistent;
        this.directory = directory;
    }

    @Override
    public UUID getId() {
        return this.id;
    }

    @Override
    public boolean isPersistent() {
        return persistent;
    }

    @Override
    public Path getDirectory() {
        return directory;
    }

    @Override
    public boolean isClosed() {
        return this.closed;
    }

    @Override
    public void close() throws IOException {
        this.doClose();

        if (!this.persistent) {
            // remove the scratch directory
            BigMapHelper.recursivelyDelete(this.directory);
        }

        this.closed = true;
    }

    abstract public void doClose() throws IOException;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy