Skip to content

Commit 34750ed

Browse files
committed
Add ApiAtomicReactor and CustomFactory classes; update version to 0.4.3-STABLE
1 parent 97dcbd9 commit 34750ed

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'fr.sandro642.github'
8-
version = '0.4.2.1-STABLE'
8+
version = '0.4.3-STABLE'
99

1010
// Générer une classe de version automatiquement
1111
task generateVersionClass {

src/main/java/fr/sandro642/github/api/ApiFactory.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected void parseFromRawJson(String rawJson) {
4949
this.rawJson = rawJson;
5050
try {
5151
ObjectMapper mapper = new ObjectMapper();
52-
this.rawData = mapper.readValue(rawJson, new TypeReference<Map<String, Object>>() {});
52+
this.rawData = mapper.readValue(rawJson, new TypeReference<>() {});
5353
} catch (Exception e) {
5454
connectLib.Logger().ERROR(connectLib.LangManager().getMessage(CategoriesType.APIFACTORY_CLASS, "parsefromrawjson.error", Map.of("json", rawJson, "exception", e.getMessage())));
5555
}
@@ -62,6 +62,15 @@ protected void setStatusCode(int statusCode) {
6262
this.statusCode = statusCode;
6363
}
6464

65+
/**
66+
* Method to retrieve the rawData map containing the parsed JSON data.
67+
*
68+
* @return The rawData map containing the parsed JSON data.
69+
*/
70+
public Map <String, Object> getRawData() {
71+
return rawData;
72+
}
73+
6574
/**
6675
* Method to retrieve data from the rawData map based on the provided type.
6776
* The type is converted to lowercase to ensure case-insensitive matching.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package fr.sandro642.github.provider;
2+
3+
import fr.sandro642.github.ConnectLib;
4+
import fr.sandro642.github.api.ApiFactory;
5+
import fr.sandro642.github.enums.lang.CategoriesType;
6+
7+
import java.util.Map;
8+
9+
public abstract class ApiAtomicReactor {
10+
11+
private final ApiFactory apiFactory;
12+
13+
private static final ConnectLib connectLib = new ConnectLib();
14+
15+
protected ApiAtomicReactor() {
16+
this.apiFactory = new ApiFactory();
17+
}
18+
19+
protected Map<?, ?> rawPhysx() {
20+
return apiFactory.getRawData();
21+
}
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package fr.sandro642.github.test;
2+
3+
import fr.sandro642.github.provider.ApiAtomicReactor;
4+
5+
6+
public class CustomFactory extends ApiAtomicReactor {
7+
8+
public Object getToken() {
9+
return rawPhysx().get("token");
10+
}
11+
12+
}

0 commit comments

Comments
 (0)