Java 类com.google.protobuf.Descriptors.FileDescriptor.Syntax 实例源码

项目:cfapi    文件:Descriptors.java   
/** Get the syntax of the .proto file. */
public Syntax getSyntax() {
  if (Syntax.PROTO3.name.equals(proto.getSyntax())) {
    return Syntax.PROTO3;
  }
  return Syntax.PROTO2;
}
项目:cfapi    文件:Descriptors.java   
/** For internal use only. */
public boolean needsUtf8Check() {
  if (type != Type.STRING) {
    return false;
  }
  if (getContainingType().getOptions().getMapEntry()) {
    // Always enforce strict UTF-8 checking for map fields.
    return true;
  }
  if (getFile().getSyntax() == Syntax.PROTO3) {
    return true;
  }
  return getFile().getOptions().getJavaStringCheckUtf8();
}
项目:cfapi    文件:Descriptors.java   
/** Does this field have the {@code [packed = true]} option or is this field
 *  packable in proto3 and not explicitly setted to unpacked?
 */
public boolean isPacked() {
  if (!isPackable()) {
    return false;
  }
  if (getFile().getSyntax() == FileDescriptor.Syntax.PROTO2) {
    return getOptions().getPacked();
  } else {
    return !getOptions().hasPacked() || getOptions().getPacked();
  }
}
项目:play-store-api    文件:Descriptors.java   
/** Get the syntax of the .proto file. */
public Syntax getSyntax() {
  if (Syntax.PROTO3.name.equals(proto.getSyntax())) {
    return Syntax.PROTO3;
  }
  return Syntax.PROTO2;
}
项目:play-store-api    文件:Descriptors.java   
/** For internal use only. */
public boolean needsUtf8Check() {
  if (type != Type.STRING) {
    return false;
  }
  if (getContainingType().getOptions().getMapEntry()) {
    // Always enforce strict UTF-8 checking for map fields.
    return true;
  }
  if (getFile().getSyntax() == Syntax.PROTO3) {
    return true;
  }
  return getFile().getOptions().getJavaStringCheckUtf8();
}
项目:play-store-api    文件:Descriptors.java   
/** Does this field have the {@code [packed = true]} option or is this field
 *  packable in proto3 and not explicitly setted to unpacked?
 */
@Override
public boolean isPacked() {
  if (!isPackable()) {
    return false;
  }
  if (getFile().getSyntax() == FileDescriptor.Syntax.PROTO2) {
    return getOptions().getPacked();
  } else {
    return !getOptions().hasPacked() || getOptions().getPacked();
  }
}
项目:beam    文件:ProtobufUtil.java   
/**
 * Recursively walks the given {@link Message} class and verifies that every field or message
 * linked in uses the Protocol Buffers proto2 syntax.
 */
static void checkProto2Syntax(Class<? extends Message> clazz, ExtensionRegistry registry) {
  for (GenericDescriptor d : getRecursiveDescriptorsForClass(clazz, registry)) {
    Syntax s = d.getFile().getSyntax();
    checkArgument(
        s == Syntax.PROTO2,
        "Message %s or one of its dependencies does not use proto2 syntax: %s in file %s",
        clazz.getName(),
        d.getFullName(),
        d.getFile().getName());
  }
}
项目:closure-templates    文件:ProtoUtils.java   
/**
 * Returns whether or not we should check for presence to emulate jspb nullability semantics in
 * server side soy.
 */
static boolean shouldCheckFieldPresenceToEmulateJspbNullability(FieldDescriptor desc) {
  boolean hasBrokenSemantics = false;
  if (desc.hasDefaultValue() || desc.isRepeated()) {
    return false;
  } else if (desc.getFile().getSyntax() == Syntax.PROTO3 || !hasBrokenSemantics) {
    // in proto3 or proto2 with non-broken semantics we only need to check for presence for
    // message typed fields.
    return desc.getJavaType() == JavaType.MESSAGE;
  } else {
    return true;
  }
}
项目:bazel    文件:Descriptors.java   
/** Get the syntax of the .proto file. */
public Syntax getSyntax() {
  if (Syntax.PROTO3.name.equals(proto.getSyntax())) {
    return Syntax.PROTO3;
  }
  return Syntax.PROTO2;
}
项目:bazel    文件:Descriptors.java   
/** For internal use only. */
public boolean needsUtf8Check() {
  if (type != Type.STRING) {
    return false;
  }
  if (getContainingType().getOptions().getMapEntry()) {
    // Always enforce strict UTF-8 checking for map fields.
    return true;
  }
  if (getFile().getSyntax() == Syntax.PROTO3) {
    return true;
  }
  return getFile().getOptions().getJavaStringCheckUtf8();
}
项目:bazel    文件:Descriptors.java   
/** Does this field have the {@code [packed = true]} option or is this field
 *  packable in proto3 and not explicitly setted to unpacked?
 */
@Override
public boolean isPacked() {
  if (!isPackable()) {
    return false;
  }
  if (getFile().getSyntax() == FileDescriptor.Syntax.PROTO2) {
    return getOptions().getPacked();
  } else {
    return !getOptions().hasPacked() || getOptions().getPacked();
  }
}
项目:bazel    文件:AbstractMessage.java   
@Override
public BuilderType mergeFrom(
    final CodedInputStream input,
    final ExtensionRegistryLite extensionRegistry)
    throws IOException {
  boolean discardUnknown =
      getDescriptorForType().getFile().getSyntax() == Syntax.PROTO3
          ? input.shouldDiscardUnknownFieldsProto3()
          : input.shouldDiscardUnknownFields();
  final UnknownFieldSet.Builder unknownFields =
      discardUnknown ? null : UnknownFieldSet.newBuilder(getUnknownFields());
  while (true) {
    final int tag = input.readTag();
    if (tag == 0) {
      break;
    }

    MessageReflection.BuilderAdapter builderAdapter =
        new MessageReflection.BuilderAdapter(this);
    if (!MessageReflection.mergeFieldFrom(input, unknownFields,
                                          extensionRegistry,
                                          getDescriptorForType(),
                                          builderAdapter,
                                          tag)) {
      // end group tag
      break;
    }
  }
  if (unknownFields != null) {
    setUnknownFields(unknownFields.build());
  }
  return (BuilderType) this;
}
项目:cfapi    文件:Descriptors.java   
Syntax(String name) {
  this.name = name;
}
项目:cfapi    文件:Descriptors.java   
boolean supportsUnknownEnumValue() {
  return getSyntax() == Syntax.PROTO3;
}
项目:play-store-api    文件:Descriptors.java   
Syntax(String name) {
  this.name = name;
}
项目:play-store-api    文件:Descriptors.java   
boolean supportsUnknownEnumValue() {
  return getSyntax() == Syntax.PROTO3;
}
项目:bazel    文件:Descriptors.java   
Syntax(String name) {
  this.name = name;
}
项目:bazel    文件:Descriptors.java   
boolean supportsUnknownEnumValue() {
  return getSyntax() == Syntax.PROTO3;
}
项目:closure-templates    文件:ProtoUtils.java   
/**
 * Proto3 enums fields can accept and return unknown values via the get<Field>Value() methods, we
 * use those methods instead of the methods that deal with the enum constants in order to support
 * unknown enum values. If we didn't, any field with an unknown enum value would throw an
 * exception when we call {@code getNumber()} on the enum.
 *
 * <p>For comparison, in proto2 unknown values always get mapped to 0, so this problem doesn't
 * exist. Also, in proto2, the 'Value' functions don't exist, so we can't use them.
 */
private static boolean isProto3EnumField(FieldDescriptor descriptor) {
  return descriptor.getType() == Descriptors.FieldDescriptor.Type.ENUM
      && descriptor.getFile().getSyntax() == Syntax.PROTO3;
}