Skip to content

Commit

Permalink
Mark OneofDescriptor.isSynthetic() deprecated.
Browse files Browse the repository at this point in the history
This API will be removed in a future breaking change.

PiperOrigin-RevId: 546004442
  • Loading branch information
zhangskz authored and Copybara-Service committed Jul 6, 2023
1 parent d3c6c9f commit b6b86e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 6 additions & 4 deletions java/core/src/main/java/com/google/protobuf/Descriptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -2820,10 +2820,6 @@ public OneofOptions getOptions() {
return proto.getOptions();
}

public boolean isSynthetic() {
return fields.length == 1 && fields[0].isProto3Optional;
}

/** Get a list of this message type's fields. */
public List<FieldDescriptor> getFields() {
return Collections.unmodifiableList(Arrays.asList(fields));
Expand All @@ -2838,6 +2834,12 @@ public OneofDescriptorProto toProto() {
return proto;
}

@Deprecated
public
boolean isSynthetic() {
return fields.length == 1 && fields[0].isProto3Optional;
}

private void setProto(final OneofDescriptorProto proto) {
this.proto = proto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
package com.google.protobuf;

import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.OneofDescriptor;

/**
* This file is meant to be a temporary housing for legacy descriptor APIs we want to deprecate and
Expand Down Expand Up @@ -69,5 +70,15 @@ public static Syntax getSyntax(FileDescriptor descriptor) {
private LegacyFileDescriptor() {}
}

/** Wraps OneofDescriptor */
public static final class LegacyOneofDescriptor {

public static boolean isSynthetic(OneofDescriptor descriptor) {
return descriptor.isSynthetic();
}

private LegacyOneofDescriptor() {}
}

private LegacyDescriptorsUtil() {}
}

0 comments on commit b6b86e2

Please sign in to comment.