File tree 1 file changed +9
-8
lines changed
1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
- import java.util.*
1
+ class ComplexSystemStore ( private val filePath : String ) {
2
2
3
- class ComplexSystemStore ( val filePath : String ) {
3
+ private val cache : HashMap < String , String >
4
4
5
5
init {
6
6
println (" Reading data from file: $filePath " )
7
+ cache = HashMap ()
8
+ // read properties from file and put to store cache
7
9
}
8
10
9
- val store = HashMap <String , String >()
10
-
11
11
fun store (key : String , payload : String ) {
12
- store.put( key, payload)
12
+ cache[ key] = payload
13
13
}
14
14
15
- fun read (key : String ): String = store [key] ? : " "
15
+ fun read (key : String ): String = cache [key] ? : " "
16
16
17
- fun commit () = println (" Storing cached data: $store to file: $filePath " )
17
+ fun commit () = println (" Storing cached data: $cache to file: $filePath " )
18
18
}
19
19
20
20
data class User (val login : String )
21
21
22
22
// Facade:
23
23
class UserRepository {
24
- val systemPreferences = ComplexSystemStore (" /data/default.prefs" )
24
+
25
+ private val systemPreferences = ComplexSystemStore (" /data/default.prefs" )
25
26
26
27
fun save (user : User ) {
27
28
systemPreferences.store(" USER_KEY" , user.login)
You can’t perform that action at this time.
0 commit comments