All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zhibaocloud.carbon.intg.jackson.desensitization.CarbonObjectDesensitizeSerializer Maven / Gradle / Ivy

The newest version!
package com.zhibaocloud.carbon.intg.jackson.desensitization;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.zhibaocloud.carbon.intg.desensitization.CarbonDesensitization;
import java.io.IOException;

/**
 * @author yangtuo
 */
public class CarbonObjectDesensitizeSerializer extends StdSerializer {

  private final CarbonDesensitization desensitization;

  public CarbonDesensitization getDesensitization() {
    return desensitization;
  }

  public CarbonObjectDesensitizeSerializer(CarbonDesensitization desensitization) {
    super(Object.class);
    this.desensitization = desensitization;
  }


  @Override
  public void serialize(Object value, JsonGenerator gen, SerializerProvider provider)
      throws IOException {
    CarbonDesensitization objectDesensitization = getDesensitization();
    gen.writeObject(objectDesensitization.desensitize(value));
  }
}