2025-12-29 16:06:48 +08:00
|
|
|
package com.senmesh.common.annotation;
|
2025-06-11 09:42:13 +08:00
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonGenerator;
|
|
|
|
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
|
|
|
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author sr on 2021-11-25
|
|
|
|
|
*/
|
|
|
|
|
public class MaskSerializer extends StdSerializer<Object> {
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
private String mask = "***";
|
|
|
|
|
|
|
|
|
|
public MaskSerializer() {
|
|
|
|
|
super(Object.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MaskSerializer(String mask, int count) {
|
|
|
|
|
this();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MaskSerializer(MaskSerializer src) {
|
|
|
|
|
super(src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void serialize(Object s, JsonGenerator jsonGenerator,
|
|
|
|
|
SerializerProvider serializerProvider) throws IOException {
|
|
|
|
|
jsonGenerator.writeString(mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|