@@ -24,7 +24,7 @@ import org.immutables.value.Value
2424 * @param jsonFilePath The path to the JSON file
2525 * @param customAdapters A list of custom JSON adapters to be used during the parsing process
2626 * @param customAdaptersWithType A map of custom JSON adapters with their respective types
27- * @param typesToSkip A set of types to be skipped during the parsing process
27+ * @param skipTypes A set of types to be skipped during the parsing process
2828 * @param <PojoT> The type of the POJO to be created
2929 * @return the parsed POJO or null if the parsing fails
3030 */
@@ -34,9 +34,9 @@ fun <PojoT : Any> jsonFileToPojo(
3434 jsonFilePath : String ,
3535 customAdapters : List <Any > = emptyList(),
3636 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
37- typesToSkip : Set <Class <out Any >> = emptySet()
37+ skipTypes : Set <Class <out Any >> = emptySet()
3838): PojoT ? {
39- val jsonAdapter = initMoshi<PojoT >(customAdapters, customAdaptersWithType, typesToSkip , pojoType)
39+ val jsonAdapter = initMoshi<PojoT >(customAdapters, customAdaptersWithType, skipTypes , pojoType)
4040 return jsonAdapter.fromJson(bufferFileInResources(jsonFilePath))
4141}
4242
@@ -46,22 +46,16 @@ fun <PojoT : Any> jsonFileToPojo(jsonFile: JsonFile<PojoT>): PojoT? =
4646 jsonFile.jsonFilePath(),
4747 jsonFile.customAdapters(),
4848 jsonFile.customAdaptersWithType(),
49- jsonFile.typesToSkip ()
49+ jsonFile.skipTypes ()
5050 )
5151
5252inline fun <reified PojoT : Any > jsonFileToPojo (
5353 jsonFilePath : String ,
5454 customAdapters : List <Any > = emptyList(),
5555 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
56- typesToSkip : Set <Class <out Any >> = emptySet()
56+ skipTypes : Set <Class <out Any >> = emptySet()
5757): PojoT ? =
58- jsonFileToPojo(
59- PojoT ::class .java,
60- jsonFilePath,
61- customAdapters,
62- customAdaptersWithType,
63- typesToSkip
64- )
58+ jsonFileToPojo(PojoT ::class .java, jsonFilePath, customAdapters, customAdaptersWithType, skipTypes)
6559
6660/* *
6761 * A generic function that parses a JSON string into a POJO (Plain Old Java Object) of type PojoT.
@@ -71,7 +65,7 @@ inline fun <reified PojoT : Any> jsonFileToPojo(
7165 * @param jsonStr The JSON string to be parsed.
7266 * @param customAdapters A list of custom adapters to be used during the parsing process.
7367 * @param customAdaptersWithType A map of custom adapters with their respective types.
74- * @param typesToSkip A set of classes to be skipped during the parsing process.
68+ * @param skipTypes A set of classes to be skipped during the parsing process.
7569 * @return The parsed POJO of type PojoT.
7670 */
7771@JvmOverloads
@@ -80,9 +74,9 @@ fun <PojoT : Any> jsonToPojo(
8074 jsonStr : String ,
8175 customAdapters : List <Any > = emptyList(),
8276 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
83- typesToSkip : Set <Class <out Any >> = emptySet()
77+ skipTypes : Set <Class <out Any >> = emptySet()
8478): PojoT ? {
85- val jsonAdapter = initMoshi<PojoT >(customAdapters, customAdaptersWithType, typesToSkip , pojoType)
79+ val jsonAdapter = initMoshi<PojoT >(customAdapters, customAdaptersWithType, skipTypes , pojoType)
8680 return jsonAdapter.fromJson(jsonStr)
8781}
8882
@@ -92,16 +86,16 @@ fun <PojoT : Any> jsonToPojo(jsonString: JsonString<PojoT>): PojoT? =
9286 jsonString.jsonString(),
9387 jsonString.customAdapters(),
9488 jsonString.customAdaptersWithType(),
95- jsonString.typesToSkip ()
89+ jsonString.skipTypes ()
9690 )
9791
9892inline fun <reified PojoT : Any > jsonToPojo (
9993 jsonStr : String ,
10094 customAdapters : List <Any > = emptyList(),
10195 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
102- typesToSkip : Set <Class <out Any >> = emptySet()
96+ skipTypes : Set <Class <out Any >> = emptySet()
10397): PojoT ? =
104- jsonToPojo(PojoT ::class .java, jsonStr, customAdapters, customAdaptersWithType, typesToSkip )
98+ jsonToPojo(PojoT ::class .java, jsonStr, customAdapters, customAdaptersWithType, skipTypes )
10599
106100/* *
107101 * Generate a JSON string from a POJO object.
@@ -110,7 +104,7 @@ inline fun <reified PojoT : Any> jsonToPojo(
110104 * @param pojo The POJO object to be converted to JSON.
111105 * @param customAdapters A list of custom adapters for Moshi to use during the conversion.
112106 * @param customAdaptersWithType A map of custom adapters with their respective types.
113- * @param typesToSkip A set of classes to ignore during the conversion.
107+ * @param skipTypes A set of classes to ignore during the conversion.
114108 * @param indent An optional string for pretty-printing the JSON output.
115109 * @param <PojoT> The type of the POJO object.
116110 * @return A JSON string or null if the input is null.
@@ -121,10 +115,10 @@ fun <PojoT : Any> pojoToJson(
121115 pojo : PojoT ,
122116 customAdapters : List <Any > = emptyList(),
123117 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
124- typesToSkip : Set <Class <out Any >> = emptySet(),
118+ skipTypes : Set <Class <out Any >> = emptySet(),
125119 indent : String? = " "
126120): String? {
127- val jsonAdapter = initMoshi<PojoT >(customAdapters, customAdaptersWithType, typesToSkip , pojoType)
121+ val jsonAdapter = initMoshi<PojoT >(customAdapters, customAdaptersWithType, skipTypes , pojoType)
128122 return (indent?.let { jsonAdapter.indent(indent) } ? : jsonAdapter).toJson(pojo)
129123}
130124
@@ -134,27 +128,27 @@ fun <PojoT : Any> pojoToJson(config: Pojo<PojoT>): String? =
134128 config.pojo(),
135129 config.customAdapters(),
136130 config.customAdaptersWithType(),
137- config.typesToSkip (),
131+ config.skipTypes (),
138132 config.indent()
139133 )
140134
141135inline fun <reified PojoT : Any > pojoToJson (
142136 pojo : PojoT ,
143137 customAdapters : List <Any > = emptyList(),
144138 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
145- typesToSkip : Set <Class <out Any >> = emptySet(),
139+ skipTypes : Set <Class <out Any >> = emptySet(),
146140 indent : String? = " "
147141): String? =
148- pojoToJson(PojoT ::class .java, pojo, customAdapters, customAdaptersWithType, typesToSkip , indent)
142+ pojoToJson(PojoT ::class .java, pojo, customAdapters, customAdaptersWithType, skipTypes , indent)
149143
150144@SuppressWarnings(" kotlin:S3923" )
151145private fun <PojoT : Any > initMoshi (
152146 customAdapters : List <Any > = emptyList(),
153147 customAdaptersWithType : Map <Type , List <Either <JsonAdapter <Any >, Factory >>> = emptyMap(),
154- typesToSkip : Set <Class <out Any >> = emptySet(),
148+ skipTypes : Set <Class <out Any >> = emptySet(),
155149 pojoType : Type
156150): JsonAdapter <PojoT > {
157- val moshiBuilder = buildMoshi(customAdapters, customAdaptersWithType, typesToSkip )
151+ val moshiBuilder = buildMoshi(customAdapters, customAdaptersWithType, skipTypes )
158152 return moshiBuilder.build().adapter(pojoType)
159153}
160154
@@ -169,7 +163,7 @@ internal interface PojoDef<PojoT> {
169163
170164 fun customAdaptersWithType (): Map <Type , List <Either <JsonAdapter <Any >, Factory>>>
171165
172- fun typesToSkip (): Set <Class <out Any >>
166+ fun skipTypes (): Set <Class <out Any >>
173167
174168 @Value.Default fun indent (): String = " "
175169}
@@ -196,7 +190,7 @@ internal interface JsonConfig<PojoT> {
196190
197191 fun customAdaptersWithType (): Map <Type , List <Either <JsonAdapter <Any >, Factory>>>
198192
199- fun typesToSkip (): Set <Class <out Any >>
193+ fun skipTypes (): Set <Class <out Any >>
200194}
201195
202196@ConfigForJson
0 commit comments