Skip to content

Commit db84cc2

Browse files
committed
Reformat
1 parent 9060a62 commit db84cc2

File tree

84 files changed

+3456
-3492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3456
-3492
lines changed

build.gradle.kts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import com.diffplug.gradle.spotless.JavaExtension
22
import com.vanniktech.maven.publish.MavenPublishBaseExtension
3+
import java.net.URI
34
import org.jetbrains.dokka.gradle.DokkaExtension
45
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
56
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
67
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7-
import java.net.URI
88

99
buildscript {
1010
dependencies {
11-
val kotlinVersion =
12-
System.getenv("MOSHI_KOTLIN_VERSION")
13-
?: libs.versions.kotlin.get()
14-
val kspVersion =
15-
System.getenv("MOSHI_KSP_VERSION")
16-
?: libs.versions.ksp.get()
11+
val kotlinVersion = System.getenv("MOSHI_KOTLIN_VERSION") ?: libs.versions.kotlin.get()
12+
val kspVersion = System.getenv("MOSHI_KSP_VERSION") ?: libs.versions.ksp.get()
1713
classpath(kotlin("gradle-plugin", version = kotlinVersion))
1814
classpath("com.google.devtools.ksp:symbol-processing-gradle-plugin:$kspVersion")
1915
}
@@ -31,9 +27,7 @@ allprojects {
3127
group = "com.squareup.moshi"
3228
version = "2.0.0-SNAPSHOT"
3329

34-
repositories {
35-
mavenCentral()
36-
}
30+
repositories { mavenCentral() }
3731
}
3832

3933
spotless {
@@ -70,14 +64,10 @@ subprojects {
7064
// Apply with "java" instead of just "java-library" so kotlin projects get it too
7165
pluginManager.withPlugin("java") {
7266
configure<JavaPluginExtension> {
73-
toolchain {
74-
languageVersion.set(libs.versions.jdk.map(JavaLanguageVersion::of))
75-
}
67+
toolchain { languageVersion.set(libs.versions.jdk.map(JavaLanguageVersion::of)) }
7668
}
7769
if (project.name != "records-tests") {
78-
tasks.withType<JavaCompile>().configureEach {
79-
options.release.set(8)
80-
}
70+
tasks.withType<JavaCompile>().configureEach { options.release.set(8) }
8171
}
8272
}
8373

@@ -104,11 +94,7 @@ dependencies {
10494
dokka(project(":moshi-kotlin-codegen"))
10595
}
10696

107-
dokka {
108-
dokkaPublications.html {
109-
outputDirectory.set(layout.projectDirectory.dir("docs/2.x"))
110-
}
111-
}
97+
dokka { dokkaPublications.html { outputDirectory.set(layout.projectDirectory.dir("docs/2.x")) } }
11298

11399
subprojects {
114100
plugins.withId("org.jetbrains.dokka") {
@@ -129,9 +115,7 @@ subprojects {
129115
sourceLink {
130116
localDirectory.set(layout.projectDirectory.dir("src"))
131117
val relPath =
132-
rootProject.isolated.projectDirectory.asFile
133-
.toPath()
134-
.relativize(projectDir.toPath())
118+
rootProject.isolated.projectDirectory.asFile.toPath().relativize(projectDir.toPath())
135119
remoteUrl("https://github.com/square/moshi/tree/main/$relPath/src")
136120
remoteLineSuffix.set("#L")
137121
}

examples/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ dependencies {
1313
}
1414

1515
tasks.withType<KotlinCompile>().configureEach {
16-
compilerOptions {
17-
freeCompilerArgs.add(
18-
"-opt-in=kotlin.ExperimentalStdlibApi",
19-
)
20-
}
16+
compilerOptions { freeCompilerArgs.add("-opt-in=kotlin.ExperimentalStdlibApi") }
2117
}

examples/src/main/java/com/squareup/moshi/recipes/JsonString.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ import com.squareup.moshi.JsonWriter
2323
import com.squareup.moshi.Moshi
2424
import com.squareup.moshi.Moshi.Builder
2525
import com.squareup.moshi.Types
26-
import okio.BufferedSource
2726
import java.lang.reflect.Type
2827
import kotlin.annotation.AnnotationRetention.RUNTIME
28+
import okio.BufferedSource
2929

3030
@JsonClass(generateAdapter = true)
3131
data class ExampleClass(val type: Int, @JsonString val rawJson: String)
3232

33-
@Retention(RUNTIME)
34-
@JsonQualifier
35-
annotation class JsonString
33+
@Retention(RUNTIME) @JsonQualifier annotation class JsonString
3634

3735
class JsonStringJsonAdapterFactory : JsonAdapter.Factory {
3836
override fun create(type: Type, annotations: Set<Annotation>, moshi: Moshi): JsonAdapter<*>? {
@@ -52,17 +50,15 @@ class JsonStringJsonAdapterFactory : JsonAdapter.Factory {
5250
}
5351

5452
fun main() {
55-
//language=JSON
53+
// language=JSON
5654
val json = "{\"type\":1,\"rawJson\":{\"a\":2,\"b\":3,\"c\":[1,2,3]}}"
5755

58-
val moshi = Builder()
59-
.add(JsonStringJsonAdapterFactory())
60-
.build()
56+
val moshi = Builder().add(JsonStringJsonAdapterFactory()).build()
6157

6258
val example: ExampleClass = moshi.adapter<ExampleClass>().fromJson(json)
6359

6460
check(example.type == 1)
6561

66-
//language=JSON
62+
// language=JSON
6763
check(example.rawJson == "{\"a\":2,\"b\":3,\"c\":[1,2,3]}")
6864
}

examples/src/main/java/com/squareup/moshi/recipes/ReadJsonListKt.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import com.squareup.moshi.recipes.models.Card
2121

2222
class ReadJsonListKt {
2323

24-
//language=JSON
25-
private val jsonString = """
24+
// language=JSON
25+
private val jsonString =
26+
"""
2627
[{"rank": "4",
2728
"suit": "CLUBS"
2829
},
@@ -32,7 +33,8 @@ class ReadJsonListKt {
3233
{"rank": "J",
3334
"suit": "SPADES"
3435
}]
35-
""".trimIndent()
36+
"""
37+
.trimIndent()
3638

3739
fun readJsonList() {
3840
val jsonAdapter = Moshi.Builder().build().adapter<List<Card>>()

moshi-adapters/build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ dependencies {
1919
}
2020

2121
tasks.withType<Jar>().configureEach {
22-
manifest {
23-
attributes("Automatic-Module-Name" to "com.squareup.moshi.adapters")
24-
}
22+
manifest { attributes("Automatic-Module-Name" to "com.squareup.moshi.adapters") }
2523
}
2624

27-
configure<MavenPublishBaseExtension> {
28-
configure(KotlinJvm(javadocJar = None()))
29-
}
25+
configure<MavenPublishBaseExtension> { configure(KotlinJvm(javadocJar = None())) }

moshi-adapters/japicmp/build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ val latest = configurations.create("latest")
1111
dependencies {
1212
baseline("com.squareup.moshi:moshi-adapters:1.15.2") {
1313
isTransitive = false
14-
version {
15-
strictly("1.14.0")
16-
}
14+
version { strictly("1.14.0") }
1715
}
1816
latest(project(":moshi-adapters"))
1917
}
@@ -30,6 +28,4 @@ val japicmp =
3028
includeSynthetic.set(true)
3129
}
3230

33-
tasks.named("check").configure {
34-
dependsOn(japicmp)
35-
}
31+
tasks.named("check").configure { dependsOn(japicmp) }

moshi-adapters/src/main/java/com/squareup/moshi/Rfc3339DateJsonAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package com.squareup.moshi
1717

1818
import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter
19-
import okio.IOException
2019
import java.util.Date
20+
import okio.IOException
2121

2222
@Deprecated(
2323
"""This class moved to avoid a package name conflict in the Java Platform Module System.

moshi-adapters/src/main/java/com/squareup/moshi/adapters/EnumJsonAdapter.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,26 @@ import okio.IOException
2828
* A JsonAdapter for enums that allows having a fallback enum value when a deserialized string does
2929
* not match any enum value. To use, add this as an adapter for your enum type on your
3030
* [Moshi.Builder][com.squareup.moshi.Moshi.Builder]:
31-
*
3231
* ```
3332
* Moshi moshi = new Moshi.Builder()
3433
* .add(CurrencyCode.class, EnumJsonAdapter.create(CurrencyCode.class)
3534
* .withUnknownFallback(CurrencyCode.USD))
3635
* .build();
3736
* ```
3837
*/
39-
public class EnumJsonAdapter<T : Enum<T>> internal constructor(
38+
public class EnumJsonAdapter<T : Enum<T>>
39+
internal constructor(
4040
private val enumType: Class<T>,
4141
private val fallbackValue: T?,
4242
private val useFallbackValue: Boolean,
4343
) : JsonAdapter<T?>() {
4444

4545
private val constants = enumType.enumConstants
46-
private val nameStrings = Array(constants.size) { i ->
47-
val constantName = constants[i].name
48-
enumType.getField(constantName).jsonName(constantName)
49-
}
46+
private val nameStrings =
47+
Array(constants.size) { i ->
48+
val constantName = constants[i].name
49+
enumType.getField(constantName).jsonName(constantName)
50+
}
5051
private val options = Options.of(*nameStrings)
5152

5253
/**
@@ -66,13 +67,11 @@ public class EnumJsonAdapter<T : Enum<T>> internal constructor(
6667
if (!useFallbackValue) {
6768
val name = reader.nextString()
6869
throw JsonDataException(
69-
"Expected one of ${nameStrings.toList()} but was $name at path ${reader.path}",
70+
"Expected one of ${nameStrings.toList()} but was $name at path ${reader.path}"
7071
)
7172
}
7273
if (reader.peek() != STRING) {
73-
throw JsonDataException(
74-
"Expected a string but was ${reader.peek()} at path ${reader.path}",
75-
)
74+
throw JsonDataException("Expected a string but was ${reader.peek()} at path ${reader.path}")
7675
}
7776
reader.skipValue()
7877
return fallbackValue
@@ -81,9 +80,7 @@ public class EnumJsonAdapter<T : Enum<T>> internal constructor(
8180
@Throws(IOException::class)
8281
override fun toJson(writer: JsonWriter, value: T?) {
8382
if (value == null) {
84-
throw NullPointerException(
85-
"value was null! Wrap in .nullSafe() to write nullable values.",
86-
)
83+
throw NullPointerException("value was null! Wrap in .nullSafe() to write nullable values.")
8784
}
8885
writer.value(nameStrings[value.ordinal])
8986
}

0 commit comments

Comments
 (0)