-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update version * Use try with resources, improve logging (#401) * Use try with resources, improve logging * Use try with resources, improve logging * Replace concatenation with placeholders in logging (#402) * Extract object mapper, optimize user enrichment (#403) * Extract ObjectMapper to JsonHelper * Optimize users enrichment * Add Variant media field (#404) * Add Variant media field * Add assertion * Added TwitterClient.stopFilteredStream() variant with a timeout. (#406) Co-authored-by: Nick <[email protected]> Co-authored-by: takeshitakenji <[email protected]>
- Loading branch information
1 parent
14777ba
commit 23dd6c7
Showing
27 changed files
with
251 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,5 +194,5 @@ | |
|
||
<url>https://github.com/Redouane59/twittered</url> | ||
|
||
<version>2.18</version> | ||
<version>2.19</version> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 54 additions & 48 deletions
102
src/main/java/io/github/redouane59/twitter/TwitterClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/io/github/redouane59/twitter/helpers/JsonHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.github.redouane59.twitter.helpers; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.TreeNode; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.JavaType; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class JsonHelper { | ||
|
||
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
.findAndRegisterModules(); | ||
|
||
public static String toJson(Object value) throws JsonProcessingException { | ||
return OBJECT_MAPPER.writeValueAsString(value); | ||
} | ||
|
||
public static <T> T fromJson(String value, Class<T> clazz) throws JsonProcessingException { | ||
return OBJECT_MAPPER.readValue(value, clazz); | ||
} | ||
|
||
public static <T> T fromJson(TreeNode node, Class<T> clazz) throws JsonProcessingException { | ||
return OBJECT_MAPPER.treeToValue(node, clazz); | ||
} | ||
|
||
public static <T> T fromJson(TreeNode node, JavaType javaType) throws JsonProcessingException { | ||
return OBJECT_MAPPER.treeToValue(node, javaType); | ||
} | ||
|
||
public static <T> T fromJson(String value, JavaType javaType) throws JsonProcessingException { | ||
return OBJECT_MAPPER.readValue(value, javaType); | ||
} | ||
|
||
/** | ||
* Check if the string supplied is valid json | ||
*/ | ||
public static boolean isValidJSON(String json) { | ||
try { | ||
OBJECT_MAPPER.readTree(json); | ||
return true; | ||
} catch (IOException e) { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.