Skip to content

Commit

Permalink
Always use "has_value()" method in getters_setters.mustache
Browse files Browse the repository at this point in the history
Summary: Currently the usages are inconsistently.

Reviewed By: yoney

Differential Revision: D67281805

fbshipit-source-id: c0cd5d58d867983f14dbf7ea30e1d491b2745d30
  • Loading branch information
TJ Yin authored and facebook-github-bot committed Dec 17, 2024
1 parent da4bf46 commit 159d731
Show file tree
Hide file tree
Showing 21 changed files with 166 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
const {{type:cpp_type}}* get_{{field:cpp_name}}() const& {
return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}}* get_{{field:cpp_name}}() & {
return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}
{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
Expand All @@ -53,13 +53,13 @@
{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
const {{type:cpp_type}}* get_{{field:cpp_name}}() const& {
return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}

{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
{{type:cpp_type}}* get_{{field:cpp_name}}() & {
return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr;
}
{{> common/field_docblock}}
[[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9108,13 +9108,13 @@ class FOLLY_EXPORT optXcep : public virtual apache::thrift::TException {
/** Glean { "field": "message" } */
[[deprecated("Use `FOO.message().value();` instead of `FOO.get_message();`")]]
const ::std::string* get_message() const& {
return message_ref() ? std::addressof(__fbthrift_field_message) : nullptr;
return message_ref().has_value() ? std::addressof(__fbthrift_field_message) : nullptr;
}

/** Glean { "field": "message" } */
[[deprecated("Use `FOO.message().value();` instead of `FOO.get_message();`")]]
::std::string* get_message() & {
return message_ref() ? std::addressof(__fbthrift_field_message) : nullptr;
return message_ref().has_value() ? std::addressof(__fbthrift_field_message) : nullptr;
}
/** Glean { "field": "message" } */
[[deprecated("Use `FOO.message().value();` instead of `FOO.get_message();`")]]
Expand All @@ -9131,13 +9131,13 @@ class FOLLY_EXPORT optXcep : public virtual apache::thrift::TException {
/** Glean { "field": "errorCode" } */
[[deprecated("Use `FOO.errorCode().value();` instead of `FOO.get_errorCode();`")]]
const ::std::int32_t* get_errorCode() const& {
return errorCode_ref() ? std::addressof(__fbthrift_field_errorCode) : nullptr;
return errorCode_ref().has_value() ? std::addressof(__fbthrift_field_errorCode) : nullptr;
}

/** Glean { "field": "errorCode" } */
[[deprecated("Use `FOO.errorCode().value();` instead of `FOO.get_errorCode();`")]]
::std::int32_t* get_errorCode() & {
return errorCode_ref() ? std::addressof(__fbthrift_field_errorCode) : nullptr;
return errorCode_ref().has_value() ? std::addressof(__fbthrift_field_errorCode) : nullptr;
}
/** Glean { "field": "errorCode" } */
[[deprecated("Use `FOO.errorCode().value();` instead of `FOO.get_errorCode();`")]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,13 @@ class Internship final {
/** Glean { "field": "employer" } */
[[deprecated("Use `FOO.employer().value();` instead of `FOO.get_employer();`")]]
const ::cpp2::Company* get_employer() const& {
return employer_ref() ? std::addressof(__fbthrift_field_employer) : nullptr;
return employer_ref().has_value() ? std::addressof(__fbthrift_field_employer) : nullptr;
}

/** Glean { "field": "employer" } */
[[deprecated("Use `FOO.employer().value();` instead of `FOO.get_employer();`")]]
::cpp2::Company* get_employer() & {
return employer_ref() ? std::addressof(__fbthrift_field_employer) : nullptr;
return employer_ref().has_value() ? std::addressof(__fbthrift_field_employer) : nullptr;
}
/** Glean { "field": "employer" } */
[[deprecated("Use `FOO.employer().value();` instead of `FOO.get_employer();`")]]
Expand All @@ -720,13 +720,13 @@ class Internship final {
/** Glean { "field": "compensation" } */
[[deprecated("Use `FOO.compensation().value();` instead of `FOO.get_compensation();`")]]
const double* get_compensation() const& {
return compensation_ref() ? std::addressof(__fbthrift_field_compensation) : nullptr;
return compensation_ref().has_value() ? std::addressof(__fbthrift_field_compensation) : nullptr;
}

/** Glean { "field": "compensation" } */
[[deprecated("Use `FOO.compensation().value();` instead of `FOO.get_compensation();`")]]
double* get_compensation() & {
return compensation_ref() ? std::addressof(__fbthrift_field_compensation) : nullptr;
return compensation_ref().has_value() ? std::addressof(__fbthrift_field_compensation) : nullptr;
}
/** Glean { "field": "compensation" } */
[[deprecated("Use `FOO.compensation().value();` instead of `FOO.get_compensation();`")]]
Expand All @@ -742,13 +742,13 @@ class Internship final {
/** Glean { "field": "school" } */
[[deprecated("Use `FOO.school().value();` instead of `FOO.get_school();`")]]
const ::std::string* get_school() const& {
return school_ref() ? std::addressof(__fbthrift_field_school) : nullptr;
return school_ref().has_value() ? std::addressof(__fbthrift_field_school) : nullptr;
}

/** Glean { "field": "school" } */
[[deprecated("Use `FOO.school().value();` instead of `FOO.get_school();`")]]
::std::string* get_school() & {
return school_ref() ? std::addressof(__fbthrift_field_school) : nullptr;
return school_ref().has_value() ? std::addressof(__fbthrift_field_school) : nullptr;
}
/** Glean { "field": "school" } */
[[deprecated("Use `FOO.school().value();` instead of `FOO.get_school();`")]]
Expand Down Expand Up @@ -2186,13 +2186,13 @@ class struct4 final {
/** Glean { "field": "b" } */
[[deprecated("Use `FOO.b().value();` instead of `FOO.get_b();`")]]
const double* get_b() const& {
return b_ref() ? std::addressof(__fbthrift_field_b) : nullptr;
return b_ref().has_value() ? std::addressof(__fbthrift_field_b) : nullptr;
}

/** Glean { "field": "b" } */
[[deprecated("Use `FOO.b().value();` instead of `FOO.get_b();`")]]
double* get_b() & {
return b_ref() ? std::addressof(__fbthrift_field_b) : nullptr;
return b_ref().has_value() ? std::addressof(__fbthrift_field_b) : nullptr;
}
/** Glean { "field": "b" } */
[[deprecated("Use `FOO.b().value();` instead of `FOO.get_b();`")]]
Expand All @@ -2208,13 +2208,13 @@ class struct4 final {
/** Glean { "field": "c" } */
[[deprecated("Use `FOO.c().value();` instead of `FOO.get_c();`")]]
const ::std::int8_t* get_c() const& {
return c_ref() ? std::addressof(__fbthrift_field_c) : nullptr;
return c_ref().has_value() ? std::addressof(__fbthrift_field_c) : nullptr;
}

/** Glean { "field": "c" } */
[[deprecated("Use `FOO.c().value();` instead of `FOO.get_c();`")]]
::std::int8_t* get_c() & {
return c_ref() ? std::addressof(__fbthrift_field_c) : nullptr;
return c_ref().has_value() ? std::addressof(__fbthrift_field_c) : nullptr;
}
/** Glean { "field": "c" } */
[[deprecated("Use `FOO.c().value();` instead of `FOO.get_c();`")]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,13 @@ class StructWithNoCustomDefaultValues final {
/** Glean { "field": "optional_integer" } */
[[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]]
const ::std::int32_t* get_optional_integer() const& {
return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
}

/** Glean { "field": "optional_integer" } */
[[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]]
::std::int32_t* get_optional_integer() & {
return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
}
/** Glean { "field": "optional_integer" } */
[[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]]
Expand Down Expand Up @@ -1198,13 +1198,13 @@ class StructWithCustomDefaultValues final {
/** Glean { "field": "optional_integer" } */
[[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]]
const ::std::int32_t* get_optional_integer() const& {
return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
}

/** Glean { "field": "optional_integer" } */
[[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]]
::std::int32_t* get_optional_integer() & {
return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr;
}
/** Glean { "field": "optional_integer" } */
[[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]]
Expand Down
Loading

0 comments on commit 159d731

Please sign in to comment.