Skip to content

Commit

Permalink
Prepare for release 0.8.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Jan 27, 2021
1 parent ef46973 commit 2f7368c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
Changelog
=========

Version 0.8.0-alpha
-------------------

_2021-01-27_

* **New:** Experimental support for Java `record` classes via new `moshi-records-reflect` artifact. See
`RecordsJsonAdapterFactory`. Requires JDK 15 + `--enable-preview`.
```java
Moshi moshi = new Moshi.Builder()
.add(new RecordsJsonAdapterFactory())
.build();

final record Message(String value) {
}
```

* **New:** Experimental support for Java `sealed` classes and interfaces in moshi-sealed via new
`moshi-sealed-java-sealed-reflect` artifact. See `JavaSealedJsonAdapterFactory`. Requires JDK 15 + `--enable-preview`.
```java
Moshi moshi = new Moshi.Builder()
.add(new JavaSealedJsonAdapterFactory())
.add(new RecordsJsonAdapterFactory())
.build();

@JsonClass(generateAdapter = true, generator = "sealed:type")
sealed interface MessageInterface
permits MessageInterface.Success, MessageInterface.Error {

@TypeLabel(label = "success", alternateLabels = {"successful"})
final record Success(String value) implements MessageInterface {
}

@TypeLabel(label = "error")
final record Error(Map<String, Object> error_logs) implements MessageInterface {
}
}
```

* **New:** `@AdaptedBy` annotation support in `moshi-adapters`. This is analogous to Gson's `@JsonAdapter` annotation,
allowing you to annotate a class or a property with it to indicate which `JsonAdapter` or `JsonAdapter.Factory`
should be used to encode it.
```Kotlin
val moshi = Moshi.Builder()
.add(AdaptedBy.Factory())
.build()

@AdaptedBy(StringAliasAdapter::class)
data class StringAlias(val value: String)

class StringAliasAdapter : JsonAdapter<StringAlias>() {
override fun fromJson(reader: JsonReader): StringAlias? {
return StringAlias(reader.nextString())
}

override fun toJson(writer: JsonWriter, value: StringAlias?) {
if (value == null) {
writer.nullValue()
return
}
writer.value(value.value)
}
}
```

Version 0.7.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
org.gradle.jvmargs=-Xmx2048m

GROUP=dev.zacsweers.moshix
VERSION_NAME=0.8.0-SNAPSHOT
VERSION_NAME=0.8.0
POM_DESCRIPTION=Moshi Extensions
POM_URL=https://github.com/ZacSweers/MoshiX
POM_SCM_URL=https://github.com/ZacSweers/MoshiX
Expand Down

0 comments on commit 2f7368c

Please sign in to comment.