Search in sources :

Example 16 with MessageType

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;
}
Also used : Field(com.google.api.tools.framework.model.Field) ProtoFile(com.google.api.tools.framework.model.ProtoFile) MessageType(com.google.api.tools.framework.model.MessageType)

Aggregations

MessageType (com.google.api.tools.framework.model.MessageType)16 ProtoFile (com.google.api.tools.framework.model.ProtoFile)7 Field (com.google.api.tools.framework.model.Field)6 ImmutableList (com.google.common.collect.ImmutableList)5 GrpcElementDocView (com.google.api.codegen.viewmodel.GrpcElementDocView)3 GrpcMessageDocView (com.google.api.codegen.viewmodel.GrpcMessageDocView)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ResourceDescriptor (com.google.api.ResourceDescriptor)2 GapicCodeGeneratorAnnotationsTest (com.google.api.codegen.protoannotations.GapicCodeGeneratorAnnotationsTest)2 HeaderRequestParamView (com.google.api.codegen.viewmodel.HeaderRequestParamView)2 ProtoElement (com.google.api.tools.framework.model.ProtoElement)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 ResourceNameMessageConfigProto (com.google.api.codegen.ResourceNameMessageConfigProto)1 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)1 ProtoField (com.google.api.codegen.config.ProtoField)1 ResourceDescriptorConfig (com.google.api.codegen.config.ResourceDescriptorConfig)1 TypeName (com.google.api.codegen.util.TypeName)1 EnumType (com.google.api.tools.framework.model.EnumType)1 Method (com.google.api.tools.framework.model.Method)1