// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
// 
//     public static final String STORAGE_FOLDER = "prevayler";
// 
//     PersistenceDiskHelper() {
//         throw new UnsupportedOperationException("do not create util classes");
//     }
// 
//     public static String calcFolderName(final Path path) {
//         return path.toString();
//     }
// 
//     /**
//      * Check if save of given name exists.
//      */
//     public static boolean exists(Path path) {
//         return Files.exists(path);
//     }
// 
//     public static void delete(Path path) {
//         if (exists(path)) {
//             Politician.beatAroundTheBush(() -> {
//                 FileUtils.deleteDirectory(path.toFile());
//             });
//         }
//     }
// 
// 
//     public static Path calcUserPath(String folderName) {
//         final String userFolder = System.getProperty("user.home");
//         return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
//     }
// 
// }


import com.thoughtworks.xstream.XStream;
import org.prevayler.Prevayler;
import pl.setblack.airomem.core.*;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path;
     */
    @Override
    public <R> R executeAndQuery(Command<ROOT, R> cmd) {
        return this.executeAndQuery((ContextCommand<ROOT, R>) cmd);
    }

    @Override
    public void execute(VoidCommand<ROOT> cmd) {
        this.executeAndQuery((Command<ROOT, Void>) cmd);
    }

    @Override
    public void execute(VoidContextCommand<ROOT> cmd) {
        this.executeAndQuery((ContextCommand<ROOT, Void>) cmd);
    }

    private ROOT getObject() {
        return this.prevayler.prevalentSystem().getWorkObject();
    }

    private ROOT getImmutable() {
        return this.getObject();
    }

    @Override
    public boolean isOpen() {
        return this.prevayler != null;
    }

    public void deleteFolder() {
// Path: airomem-core/src/main/java/pl/setblack/airomem/core/disk/PersistenceDiskHelper.java
// public final class PersistenceDiskHelper {
// 
//     public static final String STORAGE_FOLDER = "prevayler";
// 
//     PersistenceDiskHelper() {
//         throw new UnsupportedOperationException("do not create util classes");
//     }
// 
//     public static String calcFolderName(final Path path) {
//         return path.toString();
//     }
// 
//     /**
//      * Check if save of given name exists.
//      */
//     public static boolean exists(Path path) {
//         return Files.exists(path);
//     }
// 
//     public static void delete(Path path) {
//         if (exists(path)) {
//             Politician.beatAroundTheBush(() -> {
//                 FileUtils.deleteDirectory(path.toFile());
//             });
//         }
//     }
// 
// 
//     public static Path calcUserPath(String folderName) {
//         final String userFolder = System.getProperty("user.home");
//         return Paths.get(userFolder, STORAGE_FOLDER, folderName).toAbsolutePath();
//     }
// 
// }


// Path: airomem-core/src/main/java/pl/setblack/airomem/core/impl/PersistenceControllerImpl.java
import com.thoughtworks.xstream.XStream;
import org.prevayler.Prevayler;
import pl.setblack.airomem.core.*;
import pl.setblack.airomem.core.disk.PersistenceDiskHelper;
import pl.setblack.badass.Politician;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path;

     */
    @Override
    public <R> R executeAndQuery(Command<ROOT, R> cmd) {
        return this.executeAndQuery((ContextCommand<ROOT, R>) cmd);
    }

    @Override
    public void execute(VoidCommand<ROOT> cmd) {
        this.executeAndQuery((Command<ROOT, Void>) cmd);
    }

    @Override
    public void execute(VoidContextCommand<ROOT> cmd) {
        this.executeAndQuery((ContextCommand<ROOT, Void>) cmd);
    }

    private ROOT getObject() {
        return this.prevayler.prevalentSystem().getWorkObject();
    }

    private ROOT getImmutable() {
        return this.getObject();
    }

    @Override
    public boolean isOpen() {
        return this.prevayler != null;
    }

    public void deleteFolder() {
        PersistenceDiskHelper.delete(this.path);