Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit ae537a9

Browse files
committed
refactor(Index): rename variable to avoid easy mistake
1 parent b5a8ab7 commit ae537a9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/Index.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public class Index {
5353
/** The client to which this index belongs. */
5454
private Client client;
5555

56-
/** This index's name. */
57-
private String indexName;
56+
/** This index's name, <b>not URL-encoded</b>. */
57+
private String rawIndexName;
5858

5959
/** This index's name, URL-encoded. Cached for optimization. */
6060
private String encodedIndexName;
@@ -72,11 +72,11 @@ public class Index {
7272
// Initialization
7373
// ----------------------------------------------------------------------
7474

75-
protected Index(@NonNull Client client, @NonNull String indexName) {
75+
protected Index(@NonNull Client client, @NonNull String rawIndexName) {
7676
try {
7777
this.client = client;
78-
this.encodedIndexName = URLEncoder.encode(indexName, "UTF-8");
79-
this.indexName = indexName;
78+
this.encodedIndexName = URLEncoder.encode(rawIndexName, "UTF-8");
79+
this.rawIndexName = rawIndexName;
8080
} catch (UnsupportedEncodingException e) {
8181
throw new RuntimeException(e); // should never happen, as UTF-8 is always supported
8282
}
@@ -87,11 +87,11 @@ protected Index(@NonNull Client client, @NonNull String indexName) {
8787
// ----------------------------------------------------------------------
8888

8989
@Override public String toString() {
90-
return String.format("%s{%s}", this.getClass().getSimpleName(), getIndexName());
90+
return String.format("%s{%s}", this.getClass().getSimpleName(), getRawIndexName());
9191
}
9292

93-
public String getIndexName() {
94-
return indexName;
93+
public String getRawIndexName() {
94+
return rawIndexName;
9595
}
9696

9797
public Client getClient() {
@@ -1111,7 +1111,7 @@ protected JSONObject getObjects(@NonNull List<String> objectIDs, @Nullable List<
11111111
JSONArray requests = new JSONArray();
11121112
for (String id : objectIDs) {
11131113
JSONObject request = new JSONObject();
1114-
request.put("indexName", this.indexName);
1114+
request.put("indexName", this.rawIndexName);
11151115
request.put("objectID", id);
11161116
if (attributesToRetrieve != null) {
11171117
request.put("attributesToRetrieve", new JSONArray(attributesToRetrieve));

algoliasearch/src/main/java/com/algolia/search/saas/IndexQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public IndexQuery(@NonNull String indexName, @NonNull Query query) {
3838
}
3939

4040
public IndexQuery(@NonNull Index index, @NonNull Query query) {
41-
this.indexName = index.getIndexName();
41+
this.indexName = index.getRawIndexName();
4242
this.query = query;
4343
}
4444

0 commit comments

Comments
 (0)