![JAR search and dependency download from the Maven repository](/logo.png)
com.github.ltsopensource.kv.DBBuilder Maven / Gradle / Ivy
package com.github.ltsopensource.kv;
import com.github.ltsopensource.core.constant.Constants;
import com.github.ltsopensource.kv.serializer.JsonStoreSerializer;
import com.github.ltsopensource.kv.serializer.StoreSerializer;
import java.io.File;
/**
* @author Robert HG ([email protected]) on 12/15/15.
*/
public class DBBuilder {
private StoreSerializer serializer;
private StoreConfig storeConfig;
public DBBuilder() {
storeConfig = new StoreConfig();
}
public DB create() {
if (serializer == null) {
this.serializer = new JsonStoreSerializer();
}
if (storeConfig.getDbPath() == null) {
storeConfig.setDbPath(new File(Constants.USER_HOME));
}
storeConfig.setDataPath(new File(storeConfig.getDbPath(), "data"));
storeConfig.setLogPath(new File(storeConfig.getDbPath(), "logs"));
storeConfig.setIndexPath(new File(storeConfig.getDbPath(), "index"));
return new DBImpl(serializer, storeConfig);
}
public DBBuilder setPath(File path) {
this.storeConfig.setDbPath(path);
return this;
}
public DBBuilder setPath(String path) {
this.storeConfig.setDbPath(new File(path));
return this;
}
public DBBuilder setSerializer(StoreSerializer serializer) {
this.serializer = serializer;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy