Package org.telegram.abilitybots.api.db
Interface DBContext
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
MapDBContext
This interface represents the high-level methods exposed to the user when handling an
Update
.
Example usage:
Ability.builder().action(ctx -> {db.getSet(USERS); doSomething();})
BaseAbilityBot
contains a handle on the db
that the user can use inside his declared abilities.- Author:
- Abbas Abou Daya
-
Method Summary
Modifier and TypeMethodDescriptionbackup()
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
commit()
Commits the database to its persistent layer.boolean
<T> List<T>
<K,
V> Map<K, V> <T> Set<T>
<T> Var<T>
boolean
The object passed to this method need to conform to the implementation of thebackup()
method.summary()
-
Method Details
-
getList
- Type Parameters:
T
- the type that the List holds- Parameters:
name
- the unique name of theList
- Returns:
- the List with the specified name
-
getMap
- Type Parameters:
K
- the type of the Map keysV
- the type of the Map values- Parameters:
name
- the unique name of theMap
- Returns:
- the Map with the specified name
-
getSet
- Type Parameters:
T
- the type that the Set holds- Parameters:
name
- the unique name of theSet
- Returns:
- the Set with the specified name
-
getVar
- Type Parameters:
T
- the type that the variable holds- Parameters:
name
- the unique name of theVar
- Returns:
- the variable with the specified name
-
summary
String summary()- Returns:
- a high-level summary of the database structures (Sets, Lists, Maps, ...) present.
-
backup
Object backup()Implementations of this method are free to return any object such as XML, JSON, etc...- Returns:
- a backup of the DB
-
recover
The object passed to this method need to conform to the implementation of thebackup()
method.- Parameters:
backup
- the backup of the database containing all the structures- Returns:
- true if the database successfully recovered
-
info
- Parameters:
name
- the name of the data structure- Returns:
- the high-level information of the structure
-
commit
void commit()Commits the database to its persistent layer. Implementations are free to not implement this method as it is not compulsory. -
clear
void clear()Clears the data structures present in the database.This method does not delete the data-structure themselves, but leaves them empty.
-
contains
- Parameters:
name
- the name of the data structure- Returns:
- true if this database contains the specified structure name
-