use of org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor in project hbase by apache.
the class AbstractMessage method convertMapEntryListToMap.
/**
* Converts a list of MapEntry messages into a Map used for equals() and
* hashCode().
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private static Map convertMapEntryListToMap(List list) {
if (list.isEmpty()) {
return Collections.emptyMap();
}
Map result = new HashMap();
Iterator iterator = list.iterator();
Message entry = (Message) iterator.next();
Descriptors.Descriptor descriptor = entry.getDescriptorForType();
Descriptors.FieldDescriptor key = descriptor.findFieldByName("key");
Descriptors.FieldDescriptor value = descriptor.findFieldByName("value");
Object fieldValue = entry.getField(value);
if (fieldValue instanceof EnumValueDescriptor) {
fieldValue = ((EnumValueDescriptor) fieldValue).getNumber();
}
result.put(entry.getField(key), fieldValue);
while (iterator.hasNext()) {
entry = (Message) iterator.next();
fieldValue = entry.getField(value);
if (fieldValue instanceof EnumValueDescriptor) {
fieldValue = ((EnumValueDescriptor) fieldValue).getNumber();
}
result.put(entry.getField(key), fieldValue);
}
return result;
}
Aggregations