This file contains hidden or 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
| val vehicleAdapterFactory: RuntimeTypeAdapterFactory = | |
| RuntimeTypeAdapterFactory.of(Vehicle::class.java, "type") | |
| .registerSubtype(Vehicle::class.java, "car") | |
| .registerSubtype(Vehicle::class.java, "truck") | |
| val Gson = GsonBuilder().registerTypeAdapterFactory(vehicleAdapterFactory) | |
| .create() |
This file contains hidden or 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
| try { | |
| val vehicleContainer = moshi.adapter(VehicleContainer::class.java) | |
| .fromJson(jsonStr, VehicleContainer.class) | |
| } catch(error: JsonDataException) { | |
| } |
This file contains hidden or 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
| val vehicleContainer = Gson.fromJson(jsonStr, VehicleContainer.class) |
This file contains hidden or 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
| val vehicleAdapterFactory = PolymorphicJsonAdapterFactory.of(Vehicle::class.java, "type") | |
| .withSubtype(Car::class.java, "car") | |
| .withSubtype(Truck::class.java, "truck") | |
| val moshi = Moshi.Builder().add(vehicleAdapterFactory).build() |
This file contains hidden or 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
| data class VehicleContainer(val vehicles: List) | |
| abstract class Vehicle { | |
| abstract val model: String | |
| abstract val type : String | |
| abstract val tyres: List? | |
| } | |
| data class Car(override val model: String, | |
| override val type: String, |
This file contains hidden or 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
| @JsonClass(generateAdapter = true) | |
| data class Car(override val model: String, | |
| override val type: String, | |
| override val tyres: List?): Vehicle() |
This file contains hidden or 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
| on: | |
| issue_comment: | |
| types: [created] |
This file contains hidden or 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
| jobs: | |
| build-head: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: khan/pull-request-comment-trigger@master | |
| id: check | |
| with: | |
| trigger: 'benchmark-build' |
This file contains hidden or 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
| - uses: xt0rted/pull-request-comment-branch@v1 | |
| id: comment-branch | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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
| # Clone head commit | |
| - name: Clone Repo | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive | |
| ref: ${{ steps.comment-branch.outputs.head_ref }} |
OlderNewer