@@ -13,168 +13,127 @@ public class ConfigurationStore {
13
13
private final KeyValueStore keyValueStore ;
14
14
private final RecipientStore recipientStore ;
15
15
16
- private final KeyValueEntry <Boolean > readReceipts = new KeyValueEntry <>("config-read-receipts" , Boolean .class );
17
- private final KeyValueEntry <Boolean > unidentifiedDeliveryIndicators = new KeyValueEntry <>(
16
+ private final static KeyValueEntry <Boolean > readReceipts = new KeyValueEntry <>("config-read-receipts" , Boolean .class );
17
+ private final static KeyValueEntry <Boolean > unidentifiedDeliveryIndicators = new KeyValueEntry <>(
18
18
"config-unidentified-delivery-indicators" ,
19
19
Boolean .class );
20
- private final KeyValueEntry <Boolean > typingIndicators = new KeyValueEntry <>("config-typing-indicators" ,
20
+ private final static KeyValueEntry <Boolean > typingIndicators = new KeyValueEntry <>("config-typing-indicators" ,
21
21
Boolean .class );
22
- private final KeyValueEntry <Boolean > linkPreviews = new KeyValueEntry <>("config-link-previews" , Boolean .class );
23
- private final KeyValueEntry <Boolean > phoneNumberUnlisted = new KeyValueEntry <>("config-phone-number-unlisted" ,
22
+ private final static KeyValueEntry <Boolean > linkPreviews = new KeyValueEntry <>("config-link-previews" , Boolean .class );
23
+ private final static KeyValueEntry <Boolean > phoneNumberUnlisted = new KeyValueEntry <>("config-phone-number-unlisted" ,
24
24
Boolean .class );
25
- private final KeyValueEntry <PhoneNumberSharingMode > phoneNumberSharingMode = new KeyValueEntry <>(
25
+ private final static KeyValueEntry <PhoneNumberSharingMode > phoneNumberSharingMode = new KeyValueEntry <>(
26
26
"config-phone-number-sharing-mode" ,
27
27
PhoneNumberSharingMode .class );
28
- private final KeyValueEntry <String > usernameLinkColor = new KeyValueEntry <>("username-link-color" , String .class );
28
+ private final static KeyValueEntry <String > usernameLinkColor = new KeyValueEntry <>("username-link-color" , String .class );
29
29
30
30
public ConfigurationStore (final KeyValueStore keyValueStore , RecipientStore recipientStore ) {
31
31
this .keyValueStore = keyValueStore ;
32
32
this .recipientStore = recipientStore ;
33
33
}
34
34
35
+ public ConnectedConfigurationStore withConnection (final Connection connection ) throws SQLException {
36
+ return new ConnectedConfigurationStore (keyValueStore , recipientStore , connection );
37
+ }
38
+
35
39
public Boolean getReadReceipts () {
36
40
return keyValueStore .getEntry (readReceipts );
37
41
}
38
42
39
- public Boolean getReadReceipts (final Connection connection ) throws SQLException {
40
- return keyValueStore .getEntry (connection , readReceipts );
41
- }
43
+ // DS: thanks to `withConnection()` method we don't need these versions.
44
+ // Commenting them out for now, to simplify merge. Will try to refactor connection management to use context object pattern.
45
+
46
+ // public Boolean getReadReceipts(final Connection connection) throws SQLException {
47
+ // return keyValueStore.getEntry(connection, readReceipts);
48
+ // }
42
49
43
50
public void setReadReceipts (final boolean value ) {
44
51
if (keyValueStore .storeEntry (readReceipts , value )) {
45
52
recipientStore .rotateSelfStorageId ();
46
53
}
47
54
}
48
55
49
- public void setReadReceipts (final Connection connection , final boolean value ) throws SQLException {
50
- if (keyValueStore .storeEntry (connection , readReceipts , value )) {
51
- recipientStore .rotateSelfStorageId (connection );
52
- }
53
- }
54
-
55
56
public Boolean getUnidentifiedDeliveryIndicators () {
56
57
return keyValueStore .getEntry (unidentifiedDeliveryIndicators );
57
58
}
58
59
59
- public Boolean getUnidentifiedDeliveryIndicators (final Connection connection ) throws SQLException {
60
- return keyValueStore .getEntry (connection , unidentifiedDeliveryIndicators );
61
- }
60
+ // public Boolean getUnidentifiedDeliveryIndicators(final Connection connection) throws SQLException {
61
+ // return keyValueStore.getEntry(connection, unidentifiedDeliveryIndicators);
62
+ // }
62
63
63
64
public void setUnidentifiedDeliveryIndicators (final boolean value ) {
64
65
if (keyValueStore .storeEntry (unidentifiedDeliveryIndicators , value )) {
65
66
recipientStore .rotateSelfStorageId ();
66
67
}
67
68
}
68
69
69
- public void setUnidentifiedDeliveryIndicators (
70
- final Connection connection ,
71
- final boolean value
72
- ) throws SQLException {
73
- if (keyValueStore .storeEntry (connection , unidentifiedDeliveryIndicators , value )) {
74
- recipientStore .rotateSelfStorageId (connection );
75
- }
76
- }
77
-
78
70
public Boolean getTypingIndicators () {
79
71
return keyValueStore .getEntry (typingIndicators );
80
72
}
81
73
82
- public Boolean getTypingIndicators (final Connection connection ) throws SQLException {
83
- return keyValueStore .getEntry (connection , typingIndicators );
84
- }
74
+ // public Boolean getTypingIndicators(final Connection connection) throws SQLException {
75
+ // return keyValueStore.getEntry(connection, typingIndicators);
76
+ // }
85
77
86
78
public void setTypingIndicators (final boolean value ) {
87
79
if (keyValueStore .storeEntry (typingIndicators , value )) {
88
80
recipientStore .rotateSelfStorageId ();
89
81
}
90
82
}
91
83
92
- public void setTypingIndicators (final Connection connection , final boolean value ) throws SQLException {
93
- if (keyValueStore .storeEntry (connection , typingIndicators , value )) {
94
- recipientStore .rotateSelfStorageId (connection );
95
- }
96
- }
97
-
98
84
public Boolean getLinkPreviews () {
99
85
return keyValueStore .getEntry (linkPreviews );
100
86
}
101
87
102
- public Boolean getLinkPreviews (final Connection connection ) throws SQLException {
103
- return keyValueStore .getEntry (connection , linkPreviews );
104
- }
88
+ // public Boolean getLinkPreviews(final Connection connection) throws SQLException {
89
+ // return keyValueStore.getEntry(connection, linkPreviews);
90
+ // }
105
91
106
92
public void setLinkPreviews (final boolean value ) {
107
93
if (keyValueStore .storeEntry (linkPreviews , value )) {
108
94
recipientStore .rotateSelfStorageId ();
109
95
}
110
96
}
111
97
112
- public void setLinkPreviews (final Connection connection , final boolean value ) throws SQLException {
113
- if (keyValueStore .storeEntry (connection , linkPreviews , value )) {
114
- recipientStore .rotateSelfStorageId (connection );
115
- }
116
- }
117
-
118
98
public Boolean getPhoneNumberUnlisted () {
119
99
return keyValueStore .getEntry (phoneNumberUnlisted );
120
100
}
121
101
122
- public Boolean getPhoneNumberUnlisted (final Connection connection ) throws SQLException {
123
- return keyValueStore .getEntry (connection , phoneNumberUnlisted );
124
- }
102
+ // public Boolean getPhoneNumberUnlisted(final Connection connection) throws SQLException {
103
+ // return keyValueStore.getEntry(connection, phoneNumberUnlisted);
104
+ // }
125
105
126
106
public void setPhoneNumberUnlisted (final boolean value ) {
127
107
if (keyValueStore .storeEntry (phoneNumberUnlisted , value )) {
128
108
recipientStore .rotateSelfStorageId ();
129
109
}
130
110
}
131
111
132
- public void setPhoneNumberUnlisted (final Connection connection , final boolean value ) throws SQLException {
133
- if (keyValueStore .storeEntry (connection , phoneNumberUnlisted , value )) {
134
- recipientStore .rotateSelfStorageId (connection );
135
- }
136
- }
137
-
138
112
public PhoneNumberSharingMode getPhoneNumberSharingMode () {
139
113
return keyValueStore .getEntry (phoneNumberSharingMode );
140
114
}
141
115
142
- public PhoneNumberSharingMode getPhoneNumberSharingMode (final Connection connection ) throws SQLException {
143
- return keyValueStore .getEntry (connection , phoneNumberSharingMode );
144
- }
116
+ // public PhoneNumberSharingMode getPhoneNumberSharingMode(final Connection connection) throws SQLException {
117
+ // return keyValueStore.getEntry(connection, phoneNumberSharingMode);
118
+ // }
145
119
146
120
public void setPhoneNumberSharingMode (final PhoneNumberSharingMode value ) {
147
121
if (keyValueStore .storeEntry (phoneNumberSharingMode , value )) {
148
122
recipientStore .rotateSelfStorageId ();
149
123
}
150
124
}
151
125
152
- public void setPhoneNumberSharingMode (
153
- final Connection connection ,
154
- final PhoneNumberSharingMode value
155
- ) throws SQLException {
156
- if (keyValueStore .storeEntry (connection , phoneNumberSharingMode , value )) {
157
- recipientStore .rotateSelfStorageId (connection );
158
- }
159
- }
160
-
161
126
public String getUsernameLinkColor () {
162
127
return keyValueStore .getEntry (usernameLinkColor );
163
128
}
164
129
165
- public String getUsernameLinkColor (final Connection connection ) throws SQLException {
166
- return keyValueStore .getEntry (connection , usernameLinkColor );
167
- }
130
+ // public String getUsernameLinkColor(final Connection connection) throws SQLException {
131
+ // return keyValueStore.getEntry(connection, usernameLinkColor);
132
+ // }
168
133
169
134
public void setUsernameLinkColor (final String color ) {
170
135
if (keyValueStore .storeEntry (usernameLinkColor , color )) {
171
136
recipientStore .rotateSelfStorageId ();
172
137
}
173
138
}
174
-
175
- public void setUsernameLinkColor (final Connection connection , final String color ) throws SQLException {
176
- if (keyValueStore .storeEntry (connection , usernameLinkColor , color )) {
177
- recipientStore .rotateSelfStorageId (connection );
178
- }
179
- }
180
139
}
0 commit comments