Skip to content

Commit

Permalink
Replace ConcurrentHashMap by Map (#43)
Browse files Browse the repository at this point in the history
Use the Map interface instead of ConcurrentHashMap to let the developer choose what kind of Map to use.
  • Loading branch information
jenow authored Feb 5, 2021
1 parent dda398b commit 50b1a40
Show file tree
Hide file tree
Showing 198 changed files with 934 additions and 960 deletions.
2 changes: 1 addition & 1 deletion .ci/doc/templates/catch.tpl.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import io.kuzzle.sdk.Kuzzle;
import java.util.ArrayList;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.concurrent.ConcurrentHashMap;
import io.kuzzle.sdk.coreClasses.responses.Response;
import java.util.*;

public class SnippetTest {
private static Kuzzle kuzzle;
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/catch.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response

Expand Down
3 changes: 1 addition & 2 deletions .ci/doc/templates/default.tpl.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import io.kuzzle.sdk.Kuzzle;
import java.util.ArrayList;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.concurrent.ConcurrentHashMap;
import io.kuzzle.sdk.coreClasses.responses.Response;
import io.kuzzle.sdk.coreClasses.SearchResult;
import java.util.*;

public class SnippetTest {
private static Kuzzle kuzzle;
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/default.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response
import io.kuzzle.sdk.coreClasses.SearchResult
Expand Down
4 changes: 1 addition & 3 deletions .ci/doc/templates/print-result-array.tpl.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import io.kuzzle.sdk.Kuzzle;
import io.kuzzle.sdk.protocol.WebSocket;
import io.kuzzle.sdk.coreClasses.responses.Response;

import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
import java.util.*;

public class SnippetTest {
private static Kuzzle kuzzle;
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/print-result-array.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response
import io.kuzzle.sdk.coreClasses.maps.KuzzleMap
Expand Down
4 changes: 1 addition & 3 deletions .ci/doc/templates/print-result-arraylist.tpl.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import io.kuzzle.sdk.Kuzzle;
import io.kuzzle.sdk.protocol.WebSocket;
import io.kuzzle.sdk.coreClasses.responses.Response;

import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
import java.util.*;

public class SnippetTest {
private static Kuzzle kuzzle;
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/print-result-arraylist.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response

Expand Down
5 changes: 1 addition & 4 deletions .ci/doc/templates/print-result.tpl.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import io.kuzzle.sdk.Kuzzle;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.Date;
import io.kuzzle.sdk.coreClasses.responses.Response;

import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
import java.util.*;

public class SnippetTest {
private static Kuzzle kuzzle;
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/print-result.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.Date
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response

Expand Down
3 changes: 1 addition & 2 deletions .ci/doc/templates/print-search-result.tpl.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import io.kuzzle.sdk.Kuzzle;
import java.util.ArrayList;
import java.util.*;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.concurrent.ConcurrentHashMap;
import io.kuzzle.sdk.coreClasses.responses.Response;
import io.kuzzle.sdk.coreClasses.SearchResult;

Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/print-search-result.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException
import io.kuzzle.sdk.coreClasses.responses.Response
import io.kuzzle.sdk.coreClasses.SearchResult
Expand Down
1 change: 1 addition & 0 deletions .ci/doc/templates/without-connect.tpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io.kuzzle.sdk.Kuzzle;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.*;

public class SnippetTest {
private static Kuzzle kuzzle;
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/without-connect.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException

fun main() {
Expand Down
1 change: 1 addition & 0 deletions .ci/doc/templates/without-ctor.tpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io.kuzzle.sdk.Kuzzle;
import io.kuzzle.sdk.protocol.WebSocket;
import java.util.*;

public class SnippetTest {
public static void main(String[] argv) {
Expand Down
2 changes: 1 addition & 1 deletion .ci/doc/templates/without-ctor.tpl.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import io.kuzzle.sdk.Kuzzle
import io.kuzzle.sdk.protocol.WebSocket
import java.util.concurrent.ConcurrentHashMap

import java.util.concurrent.ExecutionException

fun main() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugins {

val artifactName = "sdk-jvm"
val artifactGroup = "io.kuzzle"
val artifactVersion = "1.0.2"
val artifactVersion = "1.0.3-"

val pomUrl = "https://github.com/kuzzleio/sdk-jvm"
val pomScmUrl = "https://github.com/kuzzleio/sdk-jvm"
Expand Down
8 changes: 4 additions & 4 deletions doc/1/controllers/auth/check-token/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Checks an authentication token's validity.
## Arguments

```java
public CompletableFuture<ConcurrentHashMap<String, Object>> checkToken(String token)
public CompletableFuture<Map<String, Object>> checkToken(String token)
throws NotConnectedException, InternalException
```

Expand All @@ -25,7 +25,7 @@ public CompletableFuture<ConcurrentHashMap<String, Object>> checkToken(String to

## Return

A ConcurrentHashMap which has the following properties:
A Map which has the following properties:

| Property | Type | Description |
|--------------|-------------------|----------------------------------|
Expand All @@ -43,7 +43,7 @@ A ConcurrentHashMap which has the following properties:
## Arguments

```kotlin
fun checkToken(token: String): CompletableFuture<ConcurrentHashMap<String, Any?>>
fun checkToken(token: String): CompletableFuture<Map<String, Any?>>
```

| Argument | Type | Description |
Expand All @@ -52,7 +52,7 @@ fun checkToken(token: String): CompletableFuture<ConcurrentHashMap<String, Any?>

## Return

A ConcurrentHashMap which has the following properties:
A Map which has the following properties:

| Property | Type | Description |
|--------------|-------------------|----------------------------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ConcurrentHashMap<String, Object> credentials = new ConcurrentHashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", "foo");
credentials.put("password", "bar");

ConcurrentHashMap<String, Object> response =
Map<String, Object> response =
kuzzle.getAuthController().login("local", credentials).get();
ConcurrentHashMap<String, Object> responseToken =
Map<String, Object> responseToken =
kuzzle.getAuthController().checkToken(response.get("jwt").toString()).get();
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
val response = kuzzle.authController.login("local", ConcurrentHashMap<String, Any?>().apply {
val response = kuzzle.authController.login("local", HashMap<String, Any?>().apply {
put("username", "foo")
put("password", "bar")
}).get()

val responseToken: ConcurrentHashMap<String, Any?> =
val responseToken: Map<String, Any?> =
kuzzle.authController.checkToken(response["jwt"].toString()).get()
14 changes: 7 additions & 7 deletions doc/1/controllers/auth/create-my-credentials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ Creates the current user's credentials for the specified strategy.
## Arguments

```java
public CompletableFuture<ConcurrentHashMap<String, Object>> createMyCredentials(final String strategy,
final ConcurrentHashMap<String, Object> credentials)
public CompletableFuture<Map<String, Object>> createMyCredentials(final String strategy,
final Map<String, Object> credentials)
throws NotConnectedException, InternalException
```

| Argument | Type | Description |
|---------------|--------------------|--------------------------------------|
| `strategy` | <pre>String</pre> | Strategy to use |
| `credentials` | <pre>ConcurrentHashMap<String, Object></pre> | ConcurrentHashMap representing the credentials |
| `credentials` | <pre>Map<String, Object></pre> | Map representing the credentials |

## Return

A ConcurrentHashMap representing the new credentials.
A Map representing the new credentials.

## Usage

Expand All @@ -41,17 +41,17 @@ A ConcurrentHashMap representing the new credentials.
```kotlin
fun createMyCredentials(
strategy: String,
credentials: ConcurrentHashMap<String, Any>): CompletableFuture<ConcurrentHashMap<String, Any?>>
credentials: Map<String, Any>): CompletableFuture<Map<String, Any?>>
```

| Argument | Type | Description |
|---------------|--------------------|--------------------------------------|
| `strategy` | <pre>String</pre> | Strategy to use |
| `credentials` | <pre>ConcurrentHashMap<String, Any?></pre> | ConcurrentHashMap representing the credentials |
| `credentials` | <pre>Map<String, Any?></pre> | Map representing the credentials |

## Return

A ConcurrentHashMap representing the new credentials.
A Map representing the new credentials.

## Usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ConcurrentHashMap<String, Object> credentials = new ConcurrentHashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", "foo");
credentials.put("password", "bar");

ConcurrentHashMap<String, Object> newCredentials = new ConcurrentHashMap<>();
Map<String, Object> newCredentials = new HashMap<>();
newCredentials.put("username", "foo2");
newCredentials.put("password", "bar2");

ConcurrentHashMap<String, Object> response =
Map<String, Object> response =
kuzzle.getAuthController().login("local", credentials).get();
kuzzle.getAuthController().createMyCredentials("other", newCredentials).get();
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
kuzzle.authController.login("local", ConcurrentHashMap<String, Any?>().apply {
kuzzle.authController.login("local", HashMap<String, Any?>().apply {
put("username", "foo")
put("password", "bar")
}).get()

kuzzle.authController.createMyCredentials("other", ConcurrentHashMap<String, Any?>().apply {
kuzzle.authController.createMyCredentials("other", HashMap<String, Any?>().apply {
put("username", "foo2")
put("password", "bar2")
}).get()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ConcurrentHashMap<String, Object> credentials = new ConcurrentHashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", "foo");
credentials.put("password", "bar");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kuzzle.authController.login("local", ConcurrentHashMap<String, Any?>().apply {
kuzzle.authController.login("local", HashMap<String, Any?>().apply {
put("username", "foo")
put("password", "bar")
}).get()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ConcurrentHashMap<String, Object> credentials = new ConcurrentHashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", "foo");
credentials.put("password", "bar");

ConcurrentHashMap<String, Object> response = kuzzle.getAuthController().login("local", credentials).get();
Map<String, Object> response = kuzzle.getAuthController().login("local", credentials).get();
kuzzle.getAuthController().deleteMyCredentials("local").get();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kuzzle.authController.login("local", ConcurrentHashMap<String, Any?>().apply {
kuzzle.authController.login("local", HashMap<String, Any?>().apply {
put("username", "foo")
put("password", "bar")
}).get()
Expand Down
12 changes: 6 additions & 6 deletions doc/1/controllers/auth/get-current-user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ Returns informations about the user currently loggued with the SDK instance.
## Arguments

```java
public CompletableFuture<ConcurrentHashMap<String, Object>> getCurrentUser()
public CompletableFuture<Map<String, Object>> getCurrentUser()
throws NotConnectedException, InternalException
```

## Return

A ConcurrentHashMap representing the User.
A Map representing the User.

| Property | Type | Description |
|--------------|--------------------|---------------------------------------------------|
| `_id` | <pre>String</pre> | Representing the current user `kuid` |
| `strategies` | <pre>Array</pre> | Available authentication strategies for that user |
| `_source` | <pre>ConcurrentHashMap</pre> | User information |
| `_source` | <pre>Map</pre> | User information |

## Usage

Expand All @@ -39,18 +39,18 @@ A ConcurrentHashMap representing the User.
## Arguments

```kotlin
fun getCurrentUser(): CompletableFuture<ConcurrentHashMap<String, Any?>>
fun getCurrentUser(): CompletableFuture<Map<String, Any?>>
```

## Return

A ConcurrentHashMap representing the User.
A Map representing the User.

| Property | Type | Description |
|--------------|--------------------|---------------------------------------------------|
| `_id` | <pre>String</pre> | Representing the current user `kuid` |
| `strategies` | <pre>Array</pre> | Available authentication strategies for that user |
| `_source` | <pre>ConcurrentHashMap</pre> | User information |
| `_source` | <pre>Map</pre> | User information |

## Usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ConcurrentHashMap<String, Object> credentials = new ConcurrentHashMap<>();
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", "foo");
credentials.put("password", "bar");

kuzzle.getAuthController().login("local", credentials).get();
ConcurrentHashMap<String, Object> result = kuzzle.getAuthController().getCurrentUser().get();
Map<String, Object> result = kuzzle.getAuthController().getCurrentUser().get();
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kuzzle.authController.login("local", ConcurrentHashMap<String, Any?>().apply {
kuzzle.authController.login("local", HashMap<String, Any?>().apply {
put("username", "foo")
put("password", "bar")
}).get()

val result: ConcurrentHashMap<String, Any?> =
val result: Map<String, Any?> =
kuzzle.authController.getCurrentUser().get()
Loading

0 comments on commit 50b1a40

Please sign in to comment.