@Override
  public void addModel(M model, XContentBuilder builder) throws IOException {
    builder.startObject();

    for (FieldMapper<M> field : mapping) {
      field.addToDocument(model, builder);
    }

    builder.endObject();
  }
  @Override
  public M createModel(Map<String, Object> map) {
    M model = ReflectionUtil.newInstance(clazz);

    for (FieldMapper<M> field : mapping) {
      field.inflate(model, map);
    }

    return model;
  }
  @Override
  public void addMapping(XContentBuilder builder) throws IOException {
    builder.startObject(getTypeName());
    if (clazz.isAnnotationPresent(ElasticSearchTtl.class)) {
      String ttlValue = clazz.getAnnotation(ElasticSearchTtl.class).value();
      builder.startObject("_ttl");
      builder.field("enabled", true);
      builder.field("default", ttlValue);
      builder.endObject();
    }
    builder.startObject("properties");

    for (FieldMapper<M> field : mapping) {
      field.addToMapping(builder);
    }

    builder.endObject();
    builder.endObject();
  }