<commit_before>package com.ctrip.framework.apollo.biz.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;


public class ConfigChangeContentBuilder {

  private static final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();

  private List<Item> createItems = new LinkedList<>();
  private List<ItemPair> updateItems = new LinkedList<>();
  private List<Item> deleteItems = new LinkedList<>();


  public ConfigChangeContentBuilder createItem(Item item) {
    createItems.add(item);
    return this;
  }

  public ConfigChangeContentBuilder updateItem(Item oldItem, Item newItem) {
    ItemPair itemPair = new ItemPair(oldItem, newItem);
    updateItems.add(itemPair);
    return this;
  }

  public ConfigChangeContentBuilder deleteItem(Item item) {
    deleteItems.add(item);
    return this;
  }

  public ConfigChangeContentBuilder changeSet(ItemChangeSets changeSets) {
    for (ItemDTO itemDTO : changeSets.getCreateItems()) {
      createItems.add(BeanUtils.transfrom(Item.class, itemDTO));
    }

    for (ItemDTO itemDTO : changeSets.getDeleteItems()) {
      deleteItems.add(BeanUtils.transfrom(Item.class, itemDTO));
    }

    return this;
  }

  public String build() {
    //因为事务第一段提交并没有更新时间,所以build时统一更新
    for (Item item : createItems) {
      item.setDataChangeLastModifiedTime(new Date());
    }

    for (ItemPair item : updateItems) {
      item.newItem.setDataChangeLastModifiedTime(new Date());
    }

    for (Item item : deleteItems) {
      item.setDataChangeLastModifiedTime(new Date());
    }
    return gson.toJson(this);
  }

  class ItemPair {

    Item oldItem;
    Item newItem;
<commit_msg>remove abandoned interface<commit_after>package com.ctrip.framework.apollo.biz.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;


public class ConfigChangeContentBuilder {

  private static final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();

  private List<Item> createItems = new LinkedList<>();
  private List<ItemPair> updateItems = new LinkedList<>();
  private List<Item> deleteItems = new LinkedList<>();


  public ConfigChangeContentBuilder createItem(Item item) {
    createItems.add(item);
    return this;
  }

  public ConfigChangeContentBuilder updateItem(Item oldItem, Item newItem) {
    ItemPair itemPair = new ItemPair(oldItem, newItem);
    updateItems.add(itemPair);
    return this;
  }

  public ConfigChangeContentBuilder deleteItem(Item item) {
    deleteItems.add(item);
    return this;
  }

  public String build() {
    //因为事务第一段提交并没有更新时间,所以build时统一更新
    for (Item item : createItems) {
      item.setDataChangeLastModifiedTime(new Date());
    }

    for (ItemPair item : updateItems) {
      item.newItem.setDataChangeLastModifiedTime(new Date());
    }

    for (Item item : deleteItems) {
      item.setDataChangeLastModifiedTime(new Date());
    }
    return gson.toJson(this);
  }

  class ItemPair {

    Item oldItem;
    Item newItem;

{'fraction_non_alphanumeric': 0.10879243183082916, 'fraction_numerical': 0.0, 'mean_word_length': 4.150429799426934, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6022189', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1139, 'n_words': 228}