/**
* Compute map size.
*
* @param <K> the key type
* @param <V> the value type
* @param order the order
* @param map the map
* @param keyType the key type
* @param defaultKey the default key
* @param valueType the value type
* @param defalutValue the defalut value
* @return the int
*/
public static <K, V> int computeMapSize(int order, Map<K, V> map, com.google.protobuf.WireFormat.FieldType keyType,
K defaultKey, com.google.protobuf.WireFormat.FieldType valueType, V defalutValue) {
int size = 0;
for (java.util.Map.Entry<K, V> entry : map.entrySet()) {
com.baidu.bjf.remoting.protobuf.MapEntry<K, V> valuesDefaultEntry = com.baidu.bjf.remoting.protobuf.MapEntry
.<K, V> newDefaultInstance(null, keyType, defaultKey, valueType, defalutValue);
com.baidu.bjf.remoting.protobuf.MapEntry<K, V> values =
valuesDefaultEntry.newBuilderForType().setKey(entry.getKey()).setValue(entry.getValue()).build();
size += com.google.protobuf.CodedOutputStream.computeMessageSize(order, values);
}
return size;
}
CodedConstant.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:jprotobuf
作者:
评论列表
文章目录