Bundlizer

Android Bundle format support for Kotlinx Serialization.

License

License

GroupId

GroupId

dev.ahmedmourad.bundlizer
ArtifactId

ArtifactId

bundlizer
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

aar
Description

Description

Bundlizer
Android Bundle format support for Kotlinx Serialization.
Project URL

Project URL

https://github.com/AhmedMourad0/bundlizer/
Source Code Management

Source Code Management

https://github.com/AhmedMourad0/bundlizer/

Download bundlizer

How to add to project

<!-- https://jarcasting.com/artifacts/dev.ahmedmourad.bundlizer/bundlizer/ -->
<dependency>
    <groupId>dev.ahmedmourad.bundlizer</groupId>
    <artifactId>bundlizer</artifactId>
    <version>0.1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/dev.ahmedmourad.bundlizer/bundlizer/
implementation 'dev.ahmedmourad.bundlizer:bundlizer:0.1.0'
// https://jarcasting.com/artifacts/dev.ahmedmourad.bundlizer/bundlizer/
implementation ("dev.ahmedmourad.bundlizer:bundlizer:0.1.0")
'dev.ahmedmourad.bundlizer:bundlizer:aar:0.1.0'
<dependency org="dev.ahmedmourad.bundlizer" name="bundlizer" rev="0.1.0">
  <artifact name="bundlizer" type="aar" />
</dependency>
@Grapes(
@Grab(group='dev.ahmedmourad.bundlizer', module='bundlizer', version='0.1.0')
)
libraryDependencies += "dev.ahmedmourad.bundlizer" % "bundlizer" % "0.1.0"
[dev.ahmedmourad.bundlizer/bundlizer "0.1.0"]

Dependencies

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk7 jar 1.3.72
org.jetbrains.kotlinx : kotlinx-serialization-runtime jar 0.20.0

Project Modules

There are no modules declared in this project.

Bundlizer CI Maven Central

Android Bundle format support for Kotlinx Serialization.

Usage

Annotate your data models with @Serializable:

import kotlinx.serialization.Serializable

enum class Type {
    HUMAN, MONKEY
}

@Serializable
data class Email(val value: String)

@Serializable
data class User(
    val id: Int,
    val name: String,
    val email: Email,
    val friends: List<String>?,
    val something: Map<String, Int>,
    val type: Type
)

To Bundle

Use Bundlizer.bundle or bundle extension function:

import dev.ahmedmourad.bundlizer.Bundlizer
import dev.ahmedmourad.bundlizer.bundle
import android.os.Bundle

val user: User = ...

val bundle: Bundle = Bundlizer.bundle(User.serializer(), user)
// or
val bundle: Bundle = user.bundle(User.serializer())

From Bundle

Use Bundlizer.unbundle or unbundle extension function:

import dev.ahmedmourad.bundlizer.Bundlizer
import dev.ahmedmourad.bundlizer.unbundle
import android.os.Bundle

val bundle: Bundle = ...

val user: User = Bundlizer.unbundle(User.serializer(), bundle)
// or
val user: User = bundle.unbundle(User.serializer())

Installation

repositories {
    mavenCentral()
}

dependencies {
    implementation "dev.ahmedmourad.bundlizer:bundlizer-core:0.6.0"
}

License

Copyright (C) 2020 Ahmed Mourad

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
0.1.0