-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add isSet/unset methods to swift structs
Summary: Adding isSet/unset methods to match functionality found in javadeprecated. This is to make migrating projects using this feature easier to migrate to java swift. #forcetdhashing Reviewed By: stevegury, avalonalex Differential Revision: D20970753 fbshipit-source-id: 0ebd324fdc64d2203774f33329d5ddabb09b015b
- Loading branch information
1 parent
495becd
commit e0b19cc
Showing
83 changed files
with
4,674 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
thrift/compiler/generate/templates/java/swift/struct/FieldIsSet.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{{! | ||
Copyright (c) Facebook, Inc. and its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
}} | ||
|
||
/** don't use this method for new code, it's here to make migrating to swift easier */ | ||
@Deprecated | ||
public boolean fieldIsSet{{field:javaCapitalName}}() { | ||
{{#field:isPrimitive?}} | ||
{{#field:optional?}} | ||
return this.{{field:javaName}} != null; | ||
{{/field:optional?}} | ||
{{^field:optional?}} | ||
return __isset_bit_vector.get(_{{field:javaAllCapsName}}); | ||
{{/field:optional?}} | ||
{{/field:isPrimitive?}} | ||
{{^field:isPrimitive?}} | ||
return this.{{field:javaName}} != null; | ||
{{/field:isPrimitive?}} | ||
} | ||
{{! | ||
}}{{#struct:asBean?}}{{! | ||
}}/** don't use this method for new code, it's here to make migrating to swift easier */ | ||
@Deprecated | ||
public void unset{{field:javaCapitalName}}() { | ||
{{#field:isPrimitive?}} | ||
{{#field:optional?}} | ||
this.{{field:javaName}} = null; | ||
{{/field:optional?}} | ||
{{^field:optional?}} | ||
__isset_bit_vector.clear(_{{field:javaAllCapsName}}); | ||
{{/field:optional?}} | ||
{{/field:isPrimitive?}} | ||
{{^field:isPrimitive?}} | ||
this.{{field:javaName}} = null; | ||
{{/field:isPrimitive?}} | ||
}{{! | ||
}}{{/struct:asBean?}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.