style: 全项目统一 Tab 缩进并补全尾随逗号
This commit is contained in:
@@ -40,71 +40,71 @@ import com.mingliqiye.utils.uuid.UUIDFormatType
|
||||
*/
|
||||
class UUIDJsonConverter private constructor() : BaseJsonStringConverter<UUID> {
|
||||
|
||||
companion object {
|
||||
private val uuidJsonConverter by lazy {
|
||||
UUIDJsonConverter()
|
||||
}
|
||||
companion object {
|
||||
private val uuidJsonConverter by lazy {
|
||||
UUIDJsonConverter()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getJsonConverter(): UUIDJsonConverter = uuidJsonConverter
|
||||
}
|
||||
@JvmStatic
|
||||
fun getJsonConverter(): UUIDJsonConverter = uuidJsonConverter
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 UUID 对象转换为字符串形式。
|
||||
*
|
||||
* @param obj 需要转换的 UUID 对象,可能为 null。
|
||||
* @param annotationGetter 用于获取注解信息的对象。
|
||||
* @return 转换后的字符串,如果输入为 null 则返回 null。
|
||||
*/
|
||||
override fun convert(
|
||||
obj: UUID?,
|
||||
annotationGetter: AnnotationGetter
|
||||
): String? {
|
||||
// 如果输入对象为 null,直接返回 null
|
||||
if (obj.isNull()) return null
|
||||
/**
|
||||
* 将 UUID 对象转换为字符串形式。
|
||||
*
|
||||
* @param obj 需要转换的 UUID 对象,可能为 null。
|
||||
* @param annotationGetter 用于获取注解信息的对象。
|
||||
* @return 转换后的字符串,如果输入为 null 则返回 null。
|
||||
*/
|
||||
override fun convert(
|
||||
obj: UUID?,
|
||||
annotationGetter: AnnotationGetter,
|
||||
): String? {
|
||||
// 如果输入对象为 null,直接返回 null
|
||||
if (obj.isNull()) return null
|
||||
|
||||
// 获取 UUIDJsonFormat 注解信息,若未找到则使用默认格式
|
||||
val dateTimeJsonFormat: UUIDJsonFormat = annotationGetter.get<UUIDJsonFormat>() ?: return obj.getString()
|
||||
// 获取 UUIDJsonFormat 注解信息,若未找到则使用默认格式
|
||||
val dateTimeJsonFormat: UUIDJsonFormat = annotationGetter.get<UUIDJsonFormat>() ?: return obj.getString()
|
||||
|
||||
// 根据注解中的 base 和 value 属性选择合适的字符串表示方式
|
||||
return if (BaseType.BASE16 != dateTimeJsonFormat.base) {
|
||||
obj.getString(dateTimeJsonFormat.base)
|
||||
} else if (UUIDFormatType.NO_UPPER_SPACE != dateTimeJsonFormat.value) {
|
||||
obj.getString(dateTimeJsonFormat.value)
|
||||
} else {
|
||||
obj.getString()
|
||||
}
|
||||
}
|
||||
// 根据注解中的 base 和 value 属性选择合适的字符串表示方式
|
||||
return if (BaseType.BASE16 != dateTimeJsonFormat.base) {
|
||||
obj.getString(dateTimeJsonFormat.base)
|
||||
} else if (UUIDFormatType.NO_UPPER_SPACE != dateTimeJsonFormat.value) {
|
||||
obj.getString(dateTimeJsonFormat.value)
|
||||
} else {
|
||||
obj.getString()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串反序列化为 UUID 对象。
|
||||
*
|
||||
* @param obj 需要反序列化的字符串,可能为 null 或空。
|
||||
* @param annotationGetter 用于获取注解信息的对象。
|
||||
* @return 反序列化后的 UUID 对象,如果输入无效则返回 null。
|
||||
*/
|
||||
override fun deConvert(
|
||||
obj: String?,
|
||||
annotationGetter: AnnotationGetter
|
||||
): UUID? {
|
||||
// 如果输入字符串为 null 或空,直接返回 null
|
||||
if (obj.isNullish()) return null
|
||||
/**
|
||||
* 将字符串反序列化为 UUID 对象。
|
||||
*
|
||||
* @param obj 需要反序列化的字符串,可能为 null 或空。
|
||||
* @param annotationGetter 用于获取注解信息的对象。
|
||||
* @return 反序列化后的 UUID 对象,如果输入无效则返回 null。
|
||||
*/
|
||||
override fun deConvert(
|
||||
obj: String?,
|
||||
annotationGetter: AnnotationGetter,
|
||||
): UUID? {
|
||||
// 如果输入字符串为 null 或空,直接返回 null
|
||||
if (obj.isNullish()) return null
|
||||
|
||||
// 获取 UUIDJsonFormat 注解信息,若未找到则使用默认解析方式
|
||||
val dateTimeJsonFormat: UUIDJsonFormat = annotationGetter.get<UUIDJsonFormat>() ?: return UUID.of(obj)
|
||||
// 获取 UUIDJsonFormat 注解信息,若未找到则使用默认解析方式
|
||||
val dateTimeJsonFormat: UUIDJsonFormat = annotationGetter.get<UUIDJsonFormat>() ?: return UUID.of(obj)
|
||||
|
||||
// 根据注解中的 base 属性选择合适的解析方式
|
||||
return if (BaseType.BASE16 != dateTimeJsonFormat.base) {
|
||||
UUID.of(obj, dateTimeJsonFormat.base)
|
||||
} else {
|
||||
UUID.of(obj)
|
||||
}
|
||||
}
|
||||
// 根据注解中的 base 属性选择合适的解析方式
|
||||
return if (BaseType.BASE16 != dateTimeJsonFormat.base) {
|
||||
UUID.of(obj, dateTimeJsonFormat.base)
|
||||
} else {
|
||||
UUID.of(obj)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前转换器支持的目标类型引用。
|
||||
*
|
||||
* @return 表示 UUID 类型的 JsonTypeReference 对象。
|
||||
*/
|
||||
override fun getFromType() = JsonTypeReference.of<UUID>()
|
||||
/**
|
||||
* 返回当前转换器支持的目标类型引用。
|
||||
*
|
||||
* @return 表示 UUID 类型的 JsonTypeReference 对象。
|
||||
*/
|
||||
override fun getFromType() = JsonTypeReference.of<UUID>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user