Rabbit-R1/switch port/java/sources/com/alibaba/fastjson/serializer/EnumSerializer.java
2024-05-21 17:08:36 -04:00

24 lines
1 KiB
Java

package com.alibaba.fastjson.serializer;
import java.io.IOException;
import java.lang.reflect.Type;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class EnumSerializer implements ObjectSerializer {
@Override // com.alibaba.fastjson.serializer.ObjectSerializer
public void write(JSONSerializer jSONSerializer, Object obj, Object obj2, Type type) throws IOException {
SerializeWriter serializeWriter = jSONSerializer.out;
if ((serializeWriter.features & SerializerFeature.WriteEnumUsingToString.mask) != 0) {
String str = ((Enum) obj).toString();
if ((serializeWriter.features & SerializerFeature.UseSingleQuotes.mask) != 0) {
serializeWriter.writeStringWithSingleQuote(str);
return;
} else {
serializeWriter.writeStringWithDoubleQuote(str, (char) 0, false);
return;
}
}
serializeWriter.writeInt(((Enum) obj).ordinal());
}
}