mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 07:59:21 +08:00
Fix code cleanups (#1441)
* Fix immutable properties It was intentionally designed the previous way * Restore limit in for loop * Another ImmutableProperties
This commit is contained in:
@@ -436,7 +436,10 @@ class GeneratedAdaptersTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
class ImmutableProperties(val a: Int, val b: Int)
|
class ImmutableProperties(a: Int, b: Int) {
|
||||||
|
val a = a
|
||||||
|
val b = b
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun constructorDefaults() {
|
@Test fun constructorDefaults() {
|
||||||
val moshi = Moshi.Builder().build()
|
val moshi = Moshi.Builder().build()
|
||||||
|
@@ -115,7 +115,10 @@ class KotlinJsonAdapterTest {
|
|||||||
assertThat(decoded.b).isEqualTo(5)
|
assertThat(decoded.b).isEqualTo(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImmutableProperties(val a: Int, val b: Int)
|
class ImmutableProperties(a: Int, b: Int) {
|
||||||
|
val a = a
|
||||||
|
val b = b
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun constructorDefaults() {
|
@Test fun constructorDefaults() {
|
||||||
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
||||||
|
@@ -185,7 +185,7 @@ public final class Moshi {
|
|||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public Moshi.Builder newBuilder() {
|
public Moshi.Builder newBuilder() {
|
||||||
Builder result = new Builder();
|
Builder result = new Builder();
|
||||||
for (int i = 0; i < lastOffset; i++) {
|
for (int i = 0, limit = lastOffset; i < limit; i++) {
|
||||||
result.add(factories.get(i));
|
result.add(factories.get(i));
|
||||||
}
|
}
|
||||||
for (int i = lastOffset, limit = factories.size() - BUILT_IN_FACTORIES.size(); i < limit; i++) {
|
for (int i = lastOffset, limit = factories.size() - BUILT_IN_FACTORIES.size(); i < limit; i++) {
|
||||||
|
Reference in New Issue
Block a user