-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd3d450
commit 886c8d6
Showing
3 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
12 changes: 11 additions & 1 deletion
12
docpuree/src/main/java/jp/co/tokubai/docpuree/serializer/DocPureeGsonSerializer.kt
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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
package jp.co.tokubai.docpuree.serializer | ||
|
||
import com.cookpad.puree.PureeFilter | ||
import com.cookpad.puree.PureeSerializer | ||
import com.google.gson.Gson | ||
import jp.co.tokubai.docpuree.model.SerializedClassInfo | ||
import jp.co.tokubai.docpuree.source.LogHistorySource | ||
|
||
class DocPureeGsonSerializer(private val gson: Gson) : PureeSerializer { | ||
class DocPureeGsonSerializer( | ||
private val gson: Gson, | ||
private val filters: List<PureeFilter>, | ||
) : PureeSerializer { | ||
|
||
override fun serialize(log: Any): String { | ||
val json = gson.toJson(log) | ||
LogHistorySource.serializedClassHistory.add(SerializedClassInfo(log.javaClass, json)) | ||
|
||
var filteredJson = json | ||
filters.forEach { filter -> | ||
filteredJson = filter.apply(filteredJson) | ||
} | ||
LogHistorySource.serializedClassHistory.add(SerializedClassInfo(log.javaClass, filteredJson)) | ||
|
||
return json | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
docpuree/src/main/java/jp/co/tokubai/docpuree/serializer/DocPureeMoshiSerializer.kt
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