Skip to content

Persist in YAML format

xcesco edited this page Sep 5, 2017 · 10 revisions

YAML format

The annotation @BindType allows to persist Java class instance. For User class

@BindType
public class User {
  public String email;
  public String name;
  public String surname;
}

When it is converted by Kripton, it will be converted in a YAML rapresentation similar to:

---
email: "[email protected]"
name: "Tonj"
surname: "Manero"
username: "1234"

As default behaviour, @BindType annotation persists all public fields and attribute with getter/setter.

It's supposed that you already include kripton-android-library or kripton-library in your dependencies.

Before serialize/deserialize java object in YAML format, you need to include kripton-dataformat-yaml in project's dependency via maven:

<dependency>
  <groupId>com.abubusoft</groupId>
  <artifactId>kripton-dataformat-yaml</artifactId>
  <version>2.0.1</version>
</dependency>

Or via gradle

compile 'com.abubusoft:kripton-dataformat-yaml:2.0.1'

Serialize from Java bean instance

Code to generate an YAML version of User instance class:

BinderContext binderContext=KriptonBinder.bind(BinderType.YAML);
String result = binderContext.serialize(bean);

Parse to Java bean instance

Code to parse YAML and create a User instance:

BinderContext binderContext=KriptonBinder.bind(BinderType.YAML);
User user=binderContext.parse(result, User.class);

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally