use of com.google.api.tools.framework.model.MessageType in project toolkit by googleapis.
the class ResourceNameMessageConfigs method createFieldsByMessage.
private static ListMultimap<String, FieldModel> createFieldsByMessage(List<ProtoFile> protoFiles, Map<String, ResourceNameMessageConfig> messageResourceTypeConfigMap) {
ListMultimap<String, FieldModel> fieldsByMessage = ArrayListMultimap.create();
Set<String> seenProtoFiles = new HashSet<>();
for (ProtoFile protoFile : protoFiles) {
if (!seenProtoFiles.contains(protoFile.getSimpleName())) {
seenProtoFiles.add(protoFile.getSimpleName());
for (MessageType msg : protoFile.getMessages()) {
ResourceNameMessageConfig messageConfig = messageResourceTypeConfigMap.get(msg.getFullName());
if (messageConfig == null) {
continue;
}
for (Field field : msg.getFields()) {
if (!messageConfig.getEntityNamesForField(field.getSimpleName()).isEmpty()) {
fieldsByMessage.put(msg.getFullName(), new ProtoField(field));
}
}
}
}
}
return fieldsByMessage;
}
Aggregations