FIRFieldValue+Internal.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "FIRFieldValue.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @interface FIRFieldValue (Internal)
  19. /**
  20. * The method name (e.g. "FieldValue.delete()") that was used to create this FIRFieldValue
  21. * instance, for use in error messages, etc.
  22. */
  23. @property(nonatomic, strong, readonly) NSString *methodName;
  24. @end
  25. /**
  26. * FIRFieldValue class for field deletes. Exposed internally so code can do isKindOfClass checks on
  27. * it.
  28. */
  29. @interface FSTDeleteFieldValue : FIRFieldValue
  30. - (instancetype)init NS_UNAVAILABLE;
  31. @end
  32. /**
  33. * FIRFieldValue class for server timestamps. Exposed internally so code can do isKindOfClass checks
  34. * on it.
  35. */
  36. @interface FSTServerTimestampFieldValue : FIRFieldValue
  37. - (instancetype)init NS_UNAVAILABLE;
  38. @end
  39. /** FIRFieldValue class for array unions. */
  40. @interface FSTArrayUnionFieldValue : FIRFieldValue
  41. - (instancetype)init NS_UNAVAILABLE;
  42. @property(strong, nonatomic, readonly) NSArray<id> *elements;
  43. @end
  44. /** FIRFieldValue class for array removes. */
  45. @interface FSTArrayRemoveFieldValue : FIRFieldValue
  46. - (instancetype)init NS_UNAVAILABLE;
  47. @property(strong, nonatomic, readonly) NSArray<id> *elements;
  48. @end
  49. // TODO(array-features): Move to FIRFieldValue.h once backend support lands.
  50. @interface FIRFieldValue ()
  51. /**
  52. * Returns a special value that can be used with setData() or updateData() that tells the server to
  53. * union the given elements with any array value that already exists on the server. Each
  54. * specified element that doesn't already exist in the array will be added to the end. If the
  55. * field being modified is not already an array it will be overwritten with an array containing
  56. * exactly the specified elements.
  57. *
  58. * @param elements The elements to union into the array.
  59. * @return The FieldValue sentinel for use in a call to setData() or updateData().
  60. */
  61. + (instancetype)fieldValueForArrayUnion:(NSArray<id> *)elements NS_SWIFT_NAME(arrayUnion(_:));
  62. /**
  63. * Returns a special value that can be used with setData() or updateData() that tells the server to
  64. * remove the given elements from any array value that already exists on the server. All
  65. * instances of each element specified will be removed from the array. If the field being
  66. * modified is not already an array it will be overwritten with an empty array.
  67. *
  68. * @param elements The elements to remove from the array.
  69. * @return The FieldValue sentinel for use in a call to setData() or updateData().
  70. */
  71. + (instancetype)fieldValueForArrayRemove:(NSArray<id> *)elements NS_SWIFT_NAME(arrayRemove(_:));
  72. @end
  73. NS_ASSUME_NONNULL_END