Package org.telegram.abilitybots.api.db
Class MapDBContext
- java.lang.Object
-
- org.telegram.abilitybots.api.db.MapDBContext
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,DBContext
public class MapDBContext extends Object implements DBContext
An implementation ofDBContext
that relies on aDB
.- Author:
- Abbas Abou Daya
- See Also:
- MapDB project
-
-
Constructor Summary
Constructors Constructor Description MapDBContext(org.mapdb.DB db)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
backup()
Implementations of this method are free to return any object such as XML, JSON, etc...void
clear()
Clears the data structures present in the database.void
close()
void
commit()
Commits the database to its persistent layer.boolean
contains(String name)
<T> List<T>
getList(String name)
<K,V>
Map<K,V>getMap(String name)
<T> Set<T>
getSet(String name)
<T> Var<T>
getVar(String name)
String
info(String name)
static DBContext
offlineInstance(String name)
This DB returned by this method gets deleted on JVM shutdown.static DBContext
onlineInstance(String name)
This DB returned by this method does not trigger deletion on JVM shutdown.boolean
recover(Object backup)
The object passed to this method need to conform to the implementation of theDBContext.backup()
method.String
summary()
-
-
-
Method Detail
-
onlineInstance
public static DBContext onlineInstance(String name)
This DB returned by this method does not trigger deletion on JVM shutdown.- Parameters:
name
- name of the DB file- Returns:
- an online instance of
MapDBContext
-
offlineInstance
public static DBContext offlineInstance(String name)
This DB returned by this method gets deleted on JVM shutdown.- Parameters:
name
- name of the DB file- Returns:
- an offline instance of
MapDBContext
-
summary
public String summary()
-
backup
public Object backup()
Description copied from interface:DBContext
Implementations of this method are free to return any object such as XML, JSON, etc...
-
recover
public boolean recover(Object backup)
Description copied from interface:DBContext
The object passed to this method need to conform to the implementation of theDBContext.backup()
method.
-
commit
public void commit()
Description copied from interface:DBContext
Commits the database to its persistent layer. Implementations are free to not implement this method as it is not compulsory.
-
clear
public void clear()
Description copied from interface:DBContext
Clears the data structures present in the database.This method does not delete the data-structure themselves, but leaves them empty.
-
contains
public boolean contains(String name)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-