Skip to content

Commit 801a7ec

Browse files
chore: remove obsolete region tags (#1122)
1 parent bcf38e2 commit 801a7ec

File tree

7 files changed

+4
-138
lines changed

7 files changed

+4
-138
lines changed

samples/snippets/src/main/java/com/example/firestore/Quickstart.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ public Quickstart(String projectId) throws Exception {
4343
// [START firestore_setup_client_create]
4444
// Option 1: Initialize a Firestore client with a specific `projectId` and
4545
// authorization credential.
46-
// [START fs_initialize_project_id]
4746
// [START firestore_setup_client_create_with_project_id]
4847
FirestoreOptions firestoreOptions =
4948
FirestoreOptions.getDefaultInstance().toBuilder()
5049
.setProjectId(projectId)
5150
.setCredentials(GoogleCredentials.getApplicationDefault())
5251
.build();
5352
Firestore db = firestoreOptions.getService();
54-
// [END fs_initialize_project_id]
5553
// [END firestore_setup_client_create_with_project_id]
5654
// [END firestore_setup_client_create]
5755
this.db = db;
@@ -65,10 +63,8 @@ public Quickstart() {
6563

6664
// Option 2: Initialize a Firestore client with default values inferred from
6765
// your environment.
68-
// [START fs_initialize]
6966
Firestore db = FirestoreOptions.getDefaultInstance().getService();
7067
// [END firestore_setup_client_create]
71-
// [END fs_initialize]
7268
this.db = db;
7369
}
7470

@@ -84,7 +80,6 @@ Firestore getDb() {
8480
void addDocument(String docName) throws Exception {
8581
switch (docName) {
8682
case "alovelace": {
87-
// [START fs_add_data_1]
8883
// [START firestore_setup_dataset_pt1]
8984
DocumentReference docRef = db.collection("users").document("alovelace");
9085
// Add document data with id "alovelace" using a hashmap
@@ -98,11 +93,9 @@ void addDocument(String docName) throws Exception {
9893
// result.get() blocks on response
9994
System.out.println("Update time : " + result.get().getUpdateTime());
10095
// [END firestore_setup_dataset_pt1]
101-
// [END fs_add_data_1]
10296
break;
10397
}
10498
case "aturing": {
105-
// [START fs_add_data_2]
10699
// [START firestore_setup_dataset_pt2]
107100
DocumentReference docRef = db.collection("users").document("aturing");
108101
// Add document data with an additional field ("middle")
@@ -115,7 +108,6 @@ void addDocument(String docName) throws Exception {
115108
ApiFuture<WriteResult> result = docRef.set(data);
116109
System.out.println("Update time : " + result.get().getUpdateTime());
117110
// [END firestore_setup_dataset_pt2]
118-
// [END fs_add_data_2]
119111
break;
120112
}
121113
case "cbabbage": {
@@ -135,7 +127,7 @@ void addDocument(String docName) throws Exception {
135127
}
136128

137129
void runQuery() throws Exception {
138-
// [START fs_add_query]
130+
// [START firestore_setup_add_query]
139131
// asynchronously query for all users born before 1900
140132
ApiFuture<QuerySnapshot> query =
141133
db.collection("users").whereLessThan("born", 1900).get();
@@ -152,11 +144,10 @@ void runQuery() throws Exception {
152144
System.out.println("Last: " + document.getString("last"));
153145
System.out.println("Born: " + document.getLong("born"));
154146
}
155-
// [END fs_add_query]
147+
// [END firestore_setup_add_query]
156148
}
157149

158150
void retrieveAllDocuments() throws Exception {
159-
// [START fs_get_all]
160151
// [START firestore_setup_dataset_read]
161152
// asynchronously retrieve all users
162153
ApiFuture<QuerySnapshot> query = db.collection("users").get();
@@ -174,7 +165,6 @@ void retrieveAllDocuments() throws Exception {
174165
System.out.println("Born: " + document.getLong("born"));
175166
}
176167
// [END firestore_setup_dataset_read]
177-
// [END fs_get_all]
178168
}
179169

180170
void run() throws Exception {

samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class ListenDataSnippets {
4949
Map<String, Object> listenToDocument() throws Exception {
5050
final SettableApiFuture<Map<String, Object>> future = SettableApiFuture.create();
5151

52-
// [START listen_to_document]
5352
// [START firestore_listen_document]
5453
DocumentReference docRef = db.collection("cities").document("SF");
5554
docRef.addSnapshotListener(
@@ -74,7 +73,6 @@ public void onEvent(@Nullable DocumentSnapshot snapshot, @Nullable FirestoreExce
7473
}
7574
});
7675
// [END firestore_listen_document]
77-
// [END listen_to_document]
7876

7977
return future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
8078
}
@@ -83,7 +81,6 @@ public void onEvent(@Nullable DocumentSnapshot snapshot, @Nullable FirestoreExce
8381
List<String> listenForMultiple() throws Exception {
8482
final SettableApiFuture<List<String>> future = SettableApiFuture.create();
8583

86-
// [START listen_to_multiple]
8784
// [START firestore_listen_query_snapshots]
8885
db.collection("cities")
8986
.whereEqualTo("state", "CA")
@@ -112,7 +109,6 @@ public void onEvent(
112109
}
113110
});
114111
// [END firestore_listen_query_snapshots]
115-
// [END listen_to_multiple]
116112

117113
return future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
118114
}
@@ -121,7 +117,6 @@ public void onEvent(
121117
List<DocumentChange> listenForChanges() throws Exception {
122118
SettableApiFuture<List<DocumentChange>> future = SettableApiFuture.create();
123119

124-
// [START listen_for_changes]
125120
// [START firestore_listen_query_changes]
126121
db.collection("cities")
127122
.whereEqualTo("state", "CA")
@@ -158,14 +153,12 @@ public void onEvent(
158153
}
159154
});
160155
// [END firestore_listen_query_changes]
161-
// [END listen_for_changes]
162156

163157
return future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
164158
}
165159

166160
/** Demonstrate how to detach an event listener. */
167161
void detachListener() {
168-
// [START detach_errors]
169162
// [START firestore_listen_detach]
170163
Query query = db.collection("cities");
171164
ListenerRegistration registration =
@@ -184,12 +177,10 @@ public void onEvent(
184177
// Stop listening to changes
185178
registration.remove();
186179
// [END firestore_listen_detach]
187-
// [END detach_errors]
188180
}
189181

190182
/** Demonstrate how to handle listening errors. */
191183
void listenErrors() {
192-
// [START listen_errors]
193184
// [START firestore_listen_handle_error]
194185
db.collection("cities")
195186
.addSnapshotListener(
@@ -210,7 +201,6 @@ public void onEvent(
210201
}
211202
});
212203
// [END firestore_listen_handle_error]
213-
// [END listen_errors]
214204
}
215205

216206
/** Closes the gRPC channels associated with this instance and frees up their resources. */

0 commit comments

Comments
 (0)