com.google.protobuf.Descriptors.FieldDescriptor.Type#MESSAGE源码实例Demo

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

源代码1 项目: rejoiner   文件: ProtoToGql.java
/** Returns a GraphQLOutputType generated from a FieldDescriptor. */
static GraphQLOutputType convertType(
    FieldDescriptor fieldDescriptor, SchemaOptions schemaOptions) {
  final GraphQLOutputType type;

  if (fieldDescriptor.getType() == Type.MESSAGE) {
    type = getReference(fieldDescriptor.getMessageType());
  } else if (fieldDescriptor.getType() == Type.GROUP) {
    type = getReference(fieldDescriptor.getMessageType());
  } else if (fieldDescriptor.getType() == Type.ENUM) {
    type = getReference(fieldDescriptor.getEnumType());
  } else if (schemaOptions.useProtoScalarTypes()) {
    type = PROTO_TYPE_MAP.get(fieldDescriptor.getType());
  } else {
    type = TYPE_MAP.get(fieldDescriptor.getType());
  }

  if (type == null) {
    throw new RuntimeException("Unknown type: " + fieldDescriptor.getType());
  }

  if (fieldDescriptor.isRepeated()) {
    return new GraphQLList(type);
  } else {
    return type;
  }
}
 
源代码2 项目: compiler   文件: Java7BaseTest.java
protected static HashMap<Integer, Declaration> collectDeclarations(FieldDescriptor field, Object value) {
	HashMap<Integer, Declaration> nodeDeclaration = new HashMap<Integer, Declaration>();
	if (field.isRepeated()) {
		// Repeated field. Print each element.
		for (Iterator<?> iter = ((List<?>) value).iterator(); iter.hasNext();)
			if (field.getType() == Type.MESSAGE)
				nodeDeclaration.putAll(collectDeclarations((Message) iter.next()));
	}
	return nodeDeclaration;
}
 
源代码3 项目: compiler   文件: ProtoMessageVisitor.java
private void visitFieldValue(FieldDescriptor field, Object value) {
	if (field.getType() == Type.MESSAGE)
		visit((Message) value);
}