private MethodSpec messageFieldsConstructor(NameAllocator nameAllocator, MessageType type) { MethodSpec.Builder result = MethodSpec.constructorBuilder(); result.addModifiers(PUBLIC); result.addCode("this("); for (Field field : type.fieldsAndOneOfFields()) { TypeName javaType = fieldType(field); String fieldName = nameAllocator.get(field); ParameterSpec.Builder param = ParameterSpec.builder(javaType, fieldName); if (emitAndroidAnnotations && field.isOptional()) { param.addAnnotation(NULLABLE); } result.addParameter(param.build()); result.addCode("$L, ", fieldName); } result.addCode("$T.EMPTY);\n", BYTE_STRING); return result.build(); }
if (emitAndroidAnnotations && field.isOptional()) { param.addAnnotation(NULLABLE);
fieldBuilder.addAnnotation(Deprecated.class); if (emitAndroidAnnotations && field.isOptional()) { fieldBuilder.addAnnotation(NULLABLE);
private AnnotationSpec wireFieldAnnotation(Field field) { AnnotationSpec.Builder result = AnnotationSpec.builder(WireField.class); int tag = field.tag(); result.addMember("tag", String.valueOf(tag)); if (field.type().isMap()) { result.addMember("keyAdapter", "$S", adapterString(field.type().keyType())); result.addMember("adapter", "$S", adapterString(field.type().valueType())); } else { result.addMember("adapter", "$S", adapterString(field.type())); } if (!field.isOptional()) { if (field.isPacked()) { result.addMember("label", "$T.PACKED", WireField.Label.class); } else if (field.label() != null) { result.addMember("label", "$T.$L", WireField.Label.class, field.label()); } } if (field.isRedacted()) { result.addMember("redacted", "true"); } return result.build(); }
private MethodSpec messageFieldsConstructor(NameAllocator nameAllocator, MessageType type) { MethodSpec.Builder result = MethodSpec.constructorBuilder(); result.addModifiers(PUBLIC); result.addCode("this("); for (Field field : type.fieldsAndOneOfFields()) { TypeName javaType = fieldType(field); String fieldName = nameAllocator.get(field); ParameterSpec.Builder param = ParameterSpec.builder(javaType, fieldName); if (emitAndroid && field.isOptional()) { param.addAnnotation(NULLABLE); } result.addParameter(param.build()); result.addCode("$L, ", fieldName); } result.addCode("$T.EMPTY);\n", BYTE_STRING); return result.build(); }
String fieldName = localNameAllocator.get(field); ParameterSpec.Builder param = ParameterSpec.builder(javaType, fieldName); if (emitAndroid && field.isOptional()) { param.addAnnotation(NULLABLE);
String fieldName = localNameAllocator.get(field); ParameterSpec.Builder param = ParameterSpec.builder(javaType, fieldName); if (emitAndroid && field.isOptional()) { param.addAnnotation(NULLABLE);
fieldBuilder.addAnnotation(Deprecated.class); if (emitAndroid && field.isOptional()) { fieldBuilder.addAnnotation(NULLABLE);
fieldBuilder.addAnnotation(Deprecated.class); if (emitAndroid && field.isOptional()) { fieldBuilder.addAnnotation(NULLABLE);
private AnnotationSpec wireFieldAnnotation(Field field) { AnnotationSpec.Builder result = AnnotationSpec.builder(WireField.class); int tag = field.tag(); result.addMember("tag", String.valueOf(tag)); if (field.type().isMap()) { result.addMember("keyAdapter", "$S", adapterString(field.type().keyType())); result.addMember("adapter", "$S", adapterString(field.type().valueType())); } else { result.addMember("adapter", "$S", adapterString(field.type())); } if (!field.isOptional()) { if (field.isPacked()) { result.addMember("label", "$T.PACKED", WireField.Label.class); } else if (field.label() != null) { result.addMember("label", "$T.$L", WireField.Label.class, field.label()); } } if (field.isRedacted()) { result.addMember("redacted", "true"); } return result.build(); }