RLMProperty.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2014 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Realm/RLMConstants.h>
  19. NS_ASSUME_NONNULL_BEGIN
  20. /// :nodoc:
  21. @protocol RLMInt @end
  22. /// :nodoc:
  23. @protocol RLMBool @end
  24. /// :nodoc:
  25. @protocol RLMDouble @end
  26. /// :nodoc:
  27. @protocol RLMFloat @end
  28. /// :nodoc:
  29. @protocol RLMString @end
  30. /// :nodoc:
  31. @protocol RLMDate @end
  32. /// :nodoc:
  33. @protocol RLMData @end
  34. /// :nodoc:
  35. @interface NSNumber ()<RLMInt, RLMBool, RLMDouble, RLMFloat>
  36. @end
  37. /**
  38. `RLMProperty` instances represent properties managed by a Realm in the context
  39. of an object schema. Such properties may be persisted to a Realm file or
  40. computed from other data from the Realm.
  41. When using Realm, `RLMProperty` instances allow performing migrations and
  42. introspecting the database's schema.
  43. These property instances map to columns in the core database.
  44. */
  45. @interface RLMProperty : NSObject
  46. #pragma mark - Properties
  47. /**
  48. The name of the property.
  49. */
  50. @property (nonatomic, readonly) NSString *name;
  51. /**
  52. The type of the property.
  53. @see `RLMPropertyType`
  54. */
  55. @property (nonatomic, readonly) RLMPropertyType type;
  56. /**
  57. Indicates whether this property is indexed.
  58. @see `RLMObject`
  59. */
  60. @property (nonatomic, readonly) BOOL indexed;
  61. /**
  62. For `RLMObject` and `RLMArray` properties, the name of the class of object stored in the property.
  63. */
  64. @property (nonatomic, readonly, copy, nullable) NSString *objectClassName;
  65. /**
  66. For linking objects properties, the property name of the property the linking objects property is linked to.
  67. */
  68. @property (nonatomic, readonly, copy, nullable) NSString *linkOriginPropertyName;
  69. /**
  70. Indicates whether this property is optional.
  71. */
  72. @property (nonatomic, readonly) BOOL optional;
  73. /**
  74. Indicates whether this property is an array.
  75. */
  76. @property (nonatomic, readonly) BOOL array;
  77. #pragma mark - Methods
  78. /**
  79. Returns whether a given property object is equal to the receiver.
  80. */
  81. - (BOOL)isEqualToProperty:(RLMProperty *)property;
  82. @end
  83. /**
  84. An `RLMPropertyDescriptor` instance represents a specific property on a given class.
  85. */
  86. @interface RLMPropertyDescriptor : NSObject
  87. /**
  88. Creates and returns a property descriptor.
  89. @param objectClass The class of this property descriptor.
  90. @param propertyName The name of this property descriptor.
  91. */
  92. + (instancetype)descriptorWithClass:(Class)objectClass propertyName:(NSString *)propertyName;
  93. /// The class of the property.
  94. @property (nonatomic, readonly) Class objectClass;
  95. /// The name of the property.
  96. @property (nonatomic, readonly) NSString *propertyName;
  97. @end
  98. NS_ASSUME_NONNULL_END