Skip to content

Persist in (Java) Properties

xcesco edited this page Jan 20, 2017 · 2 revisions

(Java) Properties 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 (Java) Property representation similar to:

email=dummy@test.org
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-properties</artifactId>
  <version>1.5.0</version>
</dependency>

Or via gradle

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

Moreover, you need to registry the YAML context:

KriptonBinder.registryBinder(new KriptonPropertiesContext());

Serialize from Java bean instance

Code to generate an (Java) properties version of User instance class:

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

Parse to Java bean instance

Code to parse (Java) Properties and create a User instance:

BinderContext binderContext=KriptonBinder.bind(BinderType.PROPERTIES);
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