public boolean isOneof(Field field) { return field.getOneof() != null; } }
@Override public boolean apply(Field field) { return field.getOneof() != null; } };
@Override public boolean apply(Field field) { return field.getOneof() != null; } };
@Nullable @Override public Oneof getOneof() { return protoField.getOneof(); }
public static ImmutableList<ImmutableList<String>> getOneofFieldsNames( List<FieldModel> fields, SurfaceNamer namer) { return fields .stream() .map(f -> ((ProtoField) f).protoField.getOneof()) .filter(Objects::nonNull) .distinct() .map( oneof -> oneof .getFields() .stream() .map(f -> namer.getVariableName(new ProtoField(f))) .collect(ImmutableList.toImmutableList())) .filter(list -> !list.isEmpty()) .collect(ImmutableList.toImmutableList()); }
@VisitsBefore void visit(Field field) { // Resolve type of this field. TypeRef type = resolveType(field.getLocation(), field.getProto().getType(), field.getProto().getTypeName()); if (type != null) { if (field.isRepeated()) { type = type.makeRepeated(); } else if (!field.isOptional()) { type = type.makeRequired(); } field.setType(type); } // Check for resolution of oneof. if (field.getProto().hasOneofIndex() && field.getOneof() == null) { // Indicates the oneof index could not be resolved. model .getDiagReporter() .report( Diag.error( field.getLocation(), "Unresolved oneof reference (indicates internal inconsistency of input; oneof " + "index: %s)", field.getProto().getOneofIndex())); } findOptionTypes(field.getOptionFields()); }
@VisitsBefore void visit(Field field) { // Resolve type of this field. TypeRef type = resolveType(field.getLocation(), field.getProto().getType(), field.getProto().getTypeName()); if (type != null) { if (field.isRepeated()) { type = type.makeRepeated(); } else if (!field.isOptional()) { type = type.makeRequired(); } field.setType(type); } // Check for resolution of oneof. if (field.getProto().hasOneofIndex() && field.getOneof() == null) { // Indicates the oneof index could not be resolved. model .getDiagReporter() .report( Diag.error( field.getLocation(), "Unresolved oneof reference (indicates internal inconsistency of input; oneof " + "index: %s)", field.getProto().getOneofIndex())); } findOptionTypes(field.getOptionFields()); }