-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDatabase.kt
More file actions
97 lines (83 loc) · 2.5 KB
/
Database.kt
File metadata and controls
97 lines (83 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* Boomega - A modern book explorer & catalog application
* Copyright (C) 2020-2022 Daniel Gyoerffy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.dansoftware.boomega.database.api
import com.dansoftware.boomega.database.api.data.Record
/**
* A Database object can communicate with a particular data source.
*
*
*
* It supports the CRUD operations with [Record]s.
*
* @author Daniel Gyorffy
*/
interface Database {
/**
* Returns a [DatabaseMeta] object that holds some meta-information
* of the database.
*/
val meta: DatabaseMeta
/**
* Gives the list of [Record]s stored in the database.
*/
val records: List<Record>
/**
* Gives the total count of records.
*/
val totalRecordCount: Int
/**
* Checks whether the db is closed.
*
* @return `true` if closed; otherwise `false`.
*/
val isClosed: Boolean
/**
* Inserts a record into the database
*/
fun insertRecord(record: Record)
/**
* Updates the record in the database
*/
fun updateRecord(record: Record)
/**
* Deletes the record from the database
*/
fun removeRecord(record: Record)
/**
* Deletes the given records from the database
*/
fun removeRecords(records: List<Record>)
/**
* Closes the database
*/
fun close()
/**
* Adds a database change listener which will be notified whenever the
* database changes.
*
* If the same listener is added more than once, then it will be ignored.
*/
fun addListener(listener: DatabaseChangeListener)
/**
* Removes the given [DatabaseChangeListener] from the list of listeners that are notified whenever the
* database changes.
*
* If the given listener has not been previously registered then this method call is a no-op.
*/
fun removeListener(listener: DatabaseChangeListener)
}