Package fr.sandro642.github.api
Class ApiFactory
java.lang.Object
fr.sandro642.github.api.ApiFactory
- Direct Known Subclasses:
ApiClient
ApiFactory is a class that provides methods to parse raw JSON data and retrieve specific data from it.
It uses Jackson's ObjectMapper to convert JSON strings into Java objects.
This class is designed to handle API responses and allows for easy access to the parsed data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondisplay()
Method to display the raw data stored in the ApiFactory.<O> Object
getData
(O type) Method to retrieve data from the rawData map based on the provided type.<O,
K> Object getSpecData
(O type, K value) Method to retrieve nested data from the rawData map based on the provided type and value.protected void
parseFromRawJson
(String rawJson) Default constructor for ApiFactory.
-
Constructor Details
-
ApiFactory
public ApiFactory()
-
-
Method Details
-
parseFromRawJson
Default constructor for ApiFactory. Initializes the rawData and rawJson fields to null. -
getData
Method to retrieve data from the rawData map based on the provided type. The type is converted to lowercase to ensure case-insensitive matching.- Parameters:
type
- The type of data to retrieve, which is expected to be a string representation of the key.- Returns:
- The data associated with the specified type, or null if not found.
-
getSpecData
Method to retrieve nested data from the rawData map based on the provided type and value. The type and value are converted to lowercase to ensure case-insensitive matching.- Parameters:
type
- The type of data to retrieve, which is expected to be a string representation of the key.value
- The specific value within the nested map to retrieve.- Returns:
- The nested data associated with the specified type and value, or null if not found.
-
display
Method to display the raw data stored in the ApiFactory. This method returns the rawData map, which contains the parsed JSON data.- Returns:
- The rawData map containing the parsed JSON data, or null if rawData is not initialized.
-