com.google.protobuf.Descriptors.Descriptor#getFullName ( )源码实例Demo

下面列出了com.google.protobuf.Descriptors.Descriptor#getFullName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: grpc-nebula-java   文件: ProtoReflectionService.java
private void processType(Descriptor type, FileDescriptor fd) {
  String typeName = type.getFullName();
  checkState(
      !fileDescriptorsBySymbol.containsKey(typeName), "Type already defined: %s", typeName);
  fileDescriptorsBySymbol.put(typeName, fd);
  for (FieldDescriptor extension : type.getExtensions()) {
    processExtension(extension, fd);
  }
  for (Descriptor nestedType : type.getNestedTypes()) {
    processType(nestedType, fd);
  }
}
 
源代码2 项目: grpc-swagger   文件: OpenApiDefinitionHandler.java
@Nullable
private String findRefByType(Descriptor typeDescriptor) {
    String fullName = typeDescriptor.getFullName();
    DefinitionType definitionType = typeLookupTable.get(fullName);
    if (definitionType != null) {
        return DEFINITION_REF_PREFIX + fullName;
    }
    return null;
}
 
源代码3 项目: grpc-swagger   文件: OpenApiDefinitionHandler.java
@Nullable
private String findRefByType(Descriptor typeDescriptor) {
    String fullName = typeDescriptor.getFullName();
    DefinitionType definitionType = typeLookupTable.get(fullName);
    if (definitionType != null) {
        return DEFINITION_REF_PREFIX + fullName;
    }
    return null;
}
 
源代码4 项目: protobuf-dynamic   文件: DynamicSchema.java
private void addMessageType(Descriptor msgType, String scope, Set<String> msgDupes, Set<String> enumDupes) {
	String msgTypeNameFull = msgType.getFullName();
	String msgTypeNameShort = (scope == null ? msgType.getName() : scope + "." + msgType.getName());
	
	if (mMsgDescriptorMapFull.containsKey(msgTypeNameFull)) throw new IllegalArgumentException("duplicate name: " + msgTypeNameFull);
	if (mMsgDescriptorMapShort.containsKey(msgTypeNameShort)) msgDupes.add(msgTypeNameShort);
	
	mMsgDescriptorMapFull.put(msgTypeNameFull, msgType);
	mMsgDescriptorMapShort.put(msgTypeNameShort, msgType);
	
	for (Descriptor nestedType : msgType.getNestedTypes()) addMessageType(nestedType, msgTypeNameShort, msgDupes, enumDupes);
	for (EnumDescriptor enumType : msgType.getEnumTypes()) addEnumType(enumType, msgTypeNameShort, enumDupes);
}
 
源代码5 项目: armeria   文件: GrpcDocServicePlugin.java
@VisibleForTesting
StructInfo newStructInfo(Descriptor descriptor) {
    return new StructInfo(
            descriptor.getFullName(),
            descriptor.getFields().stream()
                      .map(GrpcDocServicePlugin::newFieldInfo)
                      .collect(toImmutableList()));
}
 
源代码6 项目: grpc-java   文件: ProtoReflectionService.java
private void processType(Descriptor type, FileDescriptor fd) {
  String typeName = type.getFullName();
  checkState(
      !fileDescriptorsBySymbol.containsKey(typeName), "Type already defined: %s", typeName);
  fileDescriptorsBySymbol.put(typeName, fd);
  for (FieldDescriptor extension : type.getExtensions()) {
    processExtension(extension, fd);
  }
  for (Descriptor nestedType : type.getNestedTypes()) {
    processType(nestedType, fd);
  }
}
 
源代码7 项目: jigsaw-payment   文件: JsonJacksonFormat.java
/**
 * Parse a single field from {@code parser} and merge it into {@code builder}. If a ',' is
 * detected after the field ends, the next field will be parsed automatically
 * @throws IOException
 * @throws JsonParseException
 */
protected void mergeField(JsonParser parser,
                               ExtensionRegistry extensionRegistry,
                               Message.Builder builder) throws JsonParseException, IOException {
    FieldDescriptor field = null;
    Descriptor type = builder.getDescriptorForType();
    boolean unknown = false;
    ExtensionRegistry.ExtensionInfo extension = null;
    JsonToken token = parser.getCurrentToken();

    if (token != null) {
        String name = parser.getCurrentName();

        if (name.contains(".")) {
        	// should be an extension
        	extension = extensionRegistry.findExtensionByName(name);
            if (extension == null) {
                throw new RuntimeException("Extension \""
                		+ name + "\" not found in the ExtensionRegistry.");
            } else if (extension.descriptor.getContainingType() != type) {
                throw new RuntimeException("Extension \"" + name
                		+ "\" does not extend message type \""
                		+ type.getFullName() + "\".");
            }

        	field = extension.descriptor;
        } else {
        	field = type.findFieldByName(name);
        }

        // Group names are expected to be capitalized as they appear in the
        // .proto file, which actually matches their type names, not their field
        // names.
        if (field == null) {
            // Explicitly specify US locale so that this code does not break when
            // executing in Turkey.
            String lowerName = name.toLowerCase(Locale.US);
            field = type.findFieldByName(lowerName);
            // If the case-insensitive match worked but the field is NOT a group,
            if ((field != null) && (field.getType() != FieldDescriptor.Type.GROUP)) {
                field = null;
            }
        }
        // Again, special-case group names as described above.
        if ((field != null) && (field.getType() == FieldDescriptor.Type.GROUP)
            && !field.getMessageType().getName().equals(name)
            && !field.getMessageType().getFullName().equalsIgnoreCase(name) /* extension */) {
            field = null;
        }

        // Last try to lookup by field-index if 'name' is numeric,
        // which indicates a possible unknown field
        if (field == null && TextUtils.isDigits(name)) {
            field = type.findFieldByNumber(Integer.parseInt(name));
            unknown = true;
        }

        // no throwing exceptions if field not found, since it could be a different version.
        if (field == null) {
        	UnknownFieldSet.Builder unknownsBuilder = UnknownFieldSet.newBuilder();
        	handleMissingField(name, parser, extensionRegistry, unknownsBuilder);
        	builder.setUnknownFields(unknownsBuilder.build());
        }
    }

    if (field != null) {
    	token = parser.nextToken();

        boolean array = token.equals(JsonToken.START_ARRAY);

        if (array) {
        	token = parser.nextToken();
            while (!token.equals(JsonToken.END_ARRAY)) {
                handleValue(parser, extensionRegistry, builder, field, extension, unknown);
                token = parser.nextToken();
            }
        } else {
            handleValue(parser, extensionRegistry, builder, field, extension, unknown);
        }
    }
}