类 ProtoUtils
- java.lang.Object
-
- cn.hutool.core.convert.Convert
-
- ai.yue.library.base.convert.Convert
-
- ai.yue.library.web.grpc.util.ProtoUtils
-
public class ProtoUtils extends Convert
Protobuf工具类实现Proto、Bean、Json之间的转换
- 从以下版本开始:
- 2022/5/19
- 作者:
- ylyue
-
-
构造器概要
构造器 构造器 说明 ProtoUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidmerge(Object javaBean, com.google.protobuf.Message.Builder builder)JavaBean合并到protobuf messagestatic voidmerge(String json, com.google.protobuf.Message.Builder builder)json字符串对象合并到protobuf messagestatic voidmerge(Map json, com.google.protobuf.Message.Builder builder)json对象合并到protobuf messagestatic voidregisterType(com.google.protobuf.Descriptors.Descriptor... descriptors)注册 Any 类型转换时需要的Protobuf类型描述static <T extends com.google.protobuf.GeneratedMessageV3>
voidregisterType(Class<T>... registerClasss)注册 Any 类型转换时需要的Protobuf类型描述static <T extends com.google.protobuf.Message.Builder>
TtoBuilder(Object javaBean, Class<T> builderClass)JavaBean转换为protobuf messagestatic <T extends com.google.protobuf.Message.Builder>
TtoBuilder(String json, Class<T> builderClass)json字符串对象转换为protobuf messagestatic <T extends com.google.protobuf.Message.Builder>
TtoBuilder(Map json, Class<T> builderClass)json对象转换为protobuf messagestatic com.alibaba.fastjson.JSONObjecttoJSONObject(com.google.protobuf.MessageOrBuilder message)static StringtoJsonString(com.google.protobuf.MessageOrBuilder message)转换为Json字符串static StringtoJsonStringIncludingDefaultValue(com.google.protobuf.MessageOrBuilder message)转换为Json字符串static PageIPOtoPageIPO(com.google.protobuf.MessageOrBuilder message)-
从类继承的方法 ai.yue.library.base.convert.Convert
convert, convert, convert, convert, convert, convert, convertByClassName, convertQuietly, convertQuietly, toCamelCase, toCamelCase, toCamelCaseJsonList, toCamelCaseJsonListT, toJavaBean, toJSONArray, toJsonList, toJsonList, toJsonListT, toJSONObject, toJsons, toJsons, toJsons, toJsons, toJsonsT, toJsonsTAndRemoveEmpty, toList, toList, toList, toList, toList, toListAndDistinct, toListAndDistinct, toObject, toPropertyNamingStrategy, toSnakeCase, toSnakeCaseJsonList, toSnakeCaseJsonListT, toSymbolCase, toUnderlineCase, toUnderlineCase, toUnderlineCaseJsonList, toUnderlineCaseJsonListT
-
从类继承的方法 cn.hutool.core.convert.Convert
bytesToInt, bytesToLong, bytesToShort, byteToUnsignedInt, chineseToNumber, convertCharset, convertTime, convertWithCheck, digitToChinese, hexToBytes, hexToStr, intToByte, intToBytes, longToBytes, numberToChinese, numberToSimple, numberToWord, shortToBytes, strToUnicode, toBigDecimal, toBigDecimal, toBigInteger, toBigInteger, toBool, toBool, toBooleanArray, toByte, toByte, toByteArray, toChar, toChar, toCharArray, toCollection, toDate, toDate, toDBC, toDBC, toDouble, toDouble, toDoubleArray, toEnum, toEnum, toFloat, toFloat, toFloatArray, toHex, toHex, toInstant, toInt, toInt, toIntArray, toList, toList, toLocalDateTime, toLocalDateTime, toLong, toLong, toLongArray, toMap, toNumber, toNumber, toNumberArray, toPrimitiveByteArray, toSBC, toSBC, toSet, toShort, toShort, toShortArray, toStr, toStr, toStrArray, unicodeToStr, unWrap, wrap
-
-
-
-
方法详细资料
-
registerType
public static void registerType(com.google.protobuf.Descriptors.Descriptor... descriptors)
注册 Any 类型转换时需要的Protobuf类型描述- 参数:
descriptors- Protobuf类型描述
-
registerType
public static <T extends com.google.protobuf.GeneratedMessageV3> void registerType(Class<T>... registerClasss)
注册 Any 类型转换时需要的Protobuf类型描述- 参数:
registerClasss- protobuf message class
-
toJSONObject
public static com.alibaba.fastjson.JSONObject toJSONObject(com.google.protobuf.MessageOrBuilder message)
-
toPageIPO
public static PageIPO toPageIPO(com.google.protobuf.MessageOrBuilder message)
-
toJsonString
public static String toJsonString(com.google.protobuf.MessageOrBuilder message)
转换为Json字符串- 参数:
message- protobuf message- 返回:
- Json字符串
-
toJsonStringIncludingDefaultValue
public static String toJsonStringIncludingDefaultValue(com.google.protobuf.MessageOrBuilder message)
转换为Json字符串输出null值为默认value
- 参数:
message- protobuf message- 返回:
- Json字符串
-
merge
public static void merge(String json, com.google.protobuf.Message.Builder builder)
json字符串对象合并到protobuf message- 参数:
json- json字符串builder- protobuf message
-
merge
public static void merge(Map json, com.google.protobuf.Message.Builder builder)
json对象合并到protobuf message- 参数:
json- json对象builder- protobuf message
-
merge
public static void merge(Object javaBean, com.google.protobuf.Message.Builder builder)
JavaBean合并到protobuf message- 参数:
javaBean- JavaBeanbuilder- protobuf message
-
toBuilder
public static <T extends com.google.protobuf.Message.Builder> T toBuilder(String json, Class<T> builderClass)
json字符串对象转换为protobuf message- 参数:
json- json字符串builderClass- protobuf message class- 返回:
- protobuf message builder对象
-
toBuilder
public static <T extends com.google.protobuf.Message.Builder> T toBuilder(Map json, Class<T> builderClass)
json对象转换为protobuf message- 参数:
json- json对象builderClass- protobuf message class- 返回:
- protobuf message builder对象
-
-