Skip to content

@BindType

xcesco edited this page Jan 22, 2017 · 13 revisions

This is the key annotation for Kripton. It is used to generate for annotated Java classes a BinderMapper.

Attributes

Defined attributes are:

  • value: name of the element. For XML it's the tag name. For JSON it has no use. For Property format it's the name of property. If no value is specified, the name of the element (tag or attribute for xml, name for properties just for example) will be the field name.
  • allFields: All fields are binded, for each kind of binding. Default value is true. If this attribute is false it is necessary to specify which field is needed to be persisted by @Bind annotation.

Description

When a Java class is annotated by @Bind annotation, a class mapper will be created by Kripton Annotation Processor. For the class Friend:

@BindType
public class Image {
  public String id;
  public String format;
  public String url;
  public String description;
}

The annotation processor will generate FriendBindMap:

@BindMap(Image.class)
public class ImageBindMap extends AbstractMapper<Image> {
  @Override
  public int serializeOnJackson(Image object, JsonGenerator jacksonSerializer) throws Exception {
    ...
  }

  @Override
  public int serializeOnJacksonAsString(Image object, JsonGenerator jacksonSerializer) throws Exception {
    ...
  }

  @Override
  public void serializeOnXml(Image object, XMLSerializer xmlSerializer, int currentEventType) throws Exception {
    ...
  }

  @Override
  public Image parseOnJackson(JsonParser jacksonParser) throws Exception {
    ...
  }

  @Override
  public Image parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
    ...
  }

  @Override
  public Image parseOnXml(XMLParser xmlParser, int currentEventType) throws Exception {
    ...
  }
}

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