Search in sources :

Example 26 with EnumElement

use of com.squareup.wire.schema.internal.parser.EnumElement in project aws-glue-schema-registry by awslabs.

the class ProtobufFile method buildIndexes.

private void buildIndexes() {
    for (TypeElement typeElement : element.getTypes()) {
        if (typeElement instanceof MessageElement) {
            MessageElement messageElement = (MessageElement) typeElement;
            processMessageElement("", messageElement);
        } else if (typeElement instanceof EnumElement) {
            EnumElement enumElement = (EnumElement) typeElement;
            processEnumElement("", enumElement);
        } else {
            throw new RuntimeException();
        }
    }
    for (ServiceElement serviceElement : element.getServices()) {
        Set<String> rpcNames = new HashSet<>();
        Map<String, String> rpcSignatures = new HashMap<>();
        for (RpcElement rpcElement : serviceElement.getRpcs()) {
            rpcNames.add(rpcElement.getName());
            String signature = rpcElement.getRequestType() + ":" + rpcElement.getRequestStreaming() + "->" + rpcElement.getResponseType() + ":" + rpcElement.getResponseStreaming();
            rpcSignatures.put(rpcElement.getName(), signature);
        }
        if (!rpcNames.isEmpty()) {
            serviceRPCnames.put(serviceElement.getName(), rpcNames);
            serviceRPCSignatures.put(serviceElement.getName(), rpcSignatures);
        }
    }
}
Also used : RpcElement(com.squareup.wire.schema.internal.parser.RpcElement) HashMap(java.util.HashMap) TypeElement(com.squareup.wire.schema.internal.parser.TypeElement) MessageElement(com.squareup.wire.schema.internal.parser.MessageElement) EnumElement(com.squareup.wire.schema.internal.parser.EnumElement) ServiceElement(com.squareup.wire.schema.internal.parser.ServiceElement) HashSet(java.util.HashSet)

Aggregations

EnumElement (com.squareup.wire.schema.internal.parser.EnumElement)26 MessageElement (com.squareup.wire.schema.internal.parser.MessageElement)23 TypeElement (com.squareup.wire.schema.internal.parser.TypeElement)22 OptionElement (com.squareup.wire.schema.internal.parser.OptionElement)18 ServiceElement (com.squareup.wire.schema.internal.parser.ServiceElement)17 HashSet (java.util.HashSet)16 ImmutableList (com.google.common.collect.ImmutableList)14 EnumValueDescriptorProto (com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto)14 ProtoFileElement (com.squareup.wire.schema.internal.parser.ProtoFileElement)14 EnumConstantElement (com.squareup.wire.schema.internal.parser.EnumConstantElement)13 FieldElement (com.squareup.wire.schema.internal.parser.FieldElement)13 OneOfElement (com.squareup.wire.schema.internal.parser.OneOfElement)13 ReservedElement (com.squareup.wire.schema.internal.parser.ReservedElement)13 Syntax (com.squareup.wire.Syntax)12 RpcElement (com.squareup.wire.schema.internal.parser.RpcElement)12 DescriptorProto (com.google.protobuf.DescriptorProtos.DescriptorProto)11 EnumDescriptorProto (com.google.protobuf.DescriptorProtos.EnumDescriptorProto)11 FieldDescriptorProto (com.google.protobuf.DescriptorProtos.FieldDescriptorProto)11 FileDescriptorProto (com.google.protobuf.DescriptorProtos.FileDescriptorProto)11 MethodDescriptorProto (com.google.protobuf.DescriptorProtos.MethodDescriptorProto)11