/** Provides a TypedValue for the given enum FieldModel. */ @Override public TypedValue getEnumValue(FieldModel type, EnumValue value) { return getEnumValue((((ProtoField) type).getType().getProtoType()), value); }
private GrpcStreamingConfig(Field resourcesField, GrpcStreamingType type) { this.resourcesField = resourcesField == null ? null : new ProtoField(resourcesField); this.type = type; }
@Override public String getNameAsParameter() { return getNameAsParameterName().toLowerUnderscore(); }
Oneof oneof = parameterField.getOneof(); if (oneof != null) { String oneofName = oneof.getName(); String resourceNameType = protoParser.getResourceReference(parameterField.getProtoField()); if (!Strings.isNullOrEmpty(resourceNameType)) { resourceNameTreatment = ResourceNameTreatment.STATIC_TYPES;
/** Return the list of "one of" instances associated with the fields. */ @Override public ImmutableList<ImmutableList<String>> getOneofNames(SurfaceNamer namer) { return ProtoField.getOneofFieldsNames(getOptionalFields(), namer); } }
@Override public Name getNameAsParameterName() { return Name.from(getSimpleName()); }
/** Provides a TypeName for the element type of the given FieldModel. */ @Override public TypeName getTypeNameForElementType(FieldModel type) { return getTypeNameForElementType((((ProtoField) type).getType().getProtoType())); }
@Override public FieldModel getLastField() { return new ProtoField(fieldSelector.getLastField()); } }
/** Renders the given value if it is a primitive type. */ @Override public String renderPrimitiveValue(FieldModel type, String value) { return renderPrimitiveValue((((ProtoField) type).getType().getProtoType()), value); } }
@Override public List<ProtoField> getInputFields() { if (inputFields != null) { return inputFields; } ImmutableList.Builder<ProtoField> fieldsBuilder = ImmutableList.builder(); for (Field field : method.getInputType().getMessageType().getFields()) { fieldsBuilder.add(new ProtoField(field)); } inputFields = fieldsBuilder.build(); return inputFields; }
@Override public String getFullNameForElementType(FieldModel type) { return getFullNameForElementType((((ProtoField) type).getType().getProtoType())); }
@Override public List<ProtoField> getOutputFields() { if (outputFields != null) { return outputFields; } ImmutableList.Builder<ProtoField> fieldsBuilder = ImmutableList.builder(); for (Field field : method.getOutputType().getMessageType().getFields()) { fieldsBuilder.add(new ProtoField(field)); } outputFields = fieldsBuilder.build(); return outputFields; }
@Override public String getFullNameFor(FieldModel type) { return getFullNameFor((((ProtoField) type).getType().getProtoType())); }
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()); }
@Override public String getNicknameFor(FieldModel type) { return getNicknameFor((((ProtoField) type).getType().getProtoType())); }
@Override public ProtoField getInputField(String fieldName) { Field inputField = method.getInputType().getMessageType().lookupField(fieldName); return inputField == null ? null : new ProtoField(inputField); }
/** Returns the enum value string */ @Override public String getEnumValue(FieldModel type, String value) { return getEnumValue((((ProtoField) type).getType().getProtoType()), value); }
@Override public ProtoField getOutputField(String fieldName) { Field outputField = method.getOutputType().getMessageType().lookupField(fieldName); return outputField == null ? null : new ProtoField(outputField); }
/** Get the full name for the element type of the given type. */ @Override public String getFullNameForElementType(FieldModel type) { return getFullNameForElementType((((ProtoField) type).getType().getProtoType())); }
/** * Returns oneof config for the field of a given type, or null if the field is not a part of any * oneofs */ public OneofConfig getOneOfConfig(String fieldName) { MessageType message = this.getProtoType().getMessageType(); for (Oneof oneof : message.getOneofs()) { for (Field field : oneof.getFields()) { if (field.getSimpleName().equals(fieldName)) { return new AutoValue_OneofConfig( Name.from(oneof.getName()), message, new ProtoField(field)); } } } return null; } }