FIRFieldValue.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "Firestore/Source/API/FIRFieldValue+Internal.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @interface FIRFieldValue ()
  19. - (instancetype)initPrivate NS_DESIGNATED_INITIALIZER;
  20. @end
  21. #pragma mark - FSTDeleteFieldValue
  22. @interface FSTDeleteFieldValue ()
  23. /** Returns a single shared instance of the class. */
  24. + (instancetype)deleteFieldValue;
  25. @end
  26. @implementation FSTDeleteFieldValue
  27. - (instancetype)initPrivate {
  28. self = [super initPrivate];
  29. return self;
  30. }
  31. + (instancetype)deleteFieldValue {
  32. static FSTDeleteFieldValue *sharedInstance = nil;
  33. static dispatch_once_t onceToken;
  34. dispatch_once(&onceToken, ^{
  35. sharedInstance = [[FSTDeleteFieldValue alloc] initPrivate];
  36. });
  37. return sharedInstance;
  38. }
  39. @end
  40. #pragma mark - FSTServerTimestampFieldValue
  41. @interface FSTServerTimestampFieldValue ()
  42. /** Returns a single shared instance of the class. */
  43. + (instancetype)serverTimestampFieldValue;
  44. @end
  45. @implementation FSTServerTimestampFieldValue
  46. - (instancetype)initPrivate {
  47. self = [super initPrivate];
  48. return self;
  49. }
  50. + (instancetype)serverTimestampFieldValue {
  51. static FSTServerTimestampFieldValue *sharedInstance = nil;
  52. static dispatch_once_t onceToken;
  53. dispatch_once(&onceToken, ^{
  54. sharedInstance = [[FSTServerTimestampFieldValue alloc] initPrivate];
  55. });
  56. return sharedInstance;
  57. }
  58. @end
  59. #pragma mark - FIRFieldValue
  60. @implementation FIRFieldValue
  61. - (instancetype)initPrivate {
  62. self = [super init];
  63. return self;
  64. }
  65. + (instancetype)fieldValueForDelete {
  66. return [FSTDeleteFieldValue deleteFieldValue];
  67. }
  68. + (instancetype)fieldValueForServerTimestamp {
  69. return [FSTServerTimestampFieldValue serverTimestampFieldValue];
  70. }
  71. @end
  72. NS_ASSUME_NONNULL_END