RLMProperty.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 <Foundation/Foundation.h>
  19. #import <Realm/RLMConstants.h>
  20. NS_ASSUME_NONNULL_BEGIN
  21. /// :nodoc:
  22. @protocol RLMInt
  23. @end
  24. /// :nodoc:
  25. @protocol RLMBool
  26. @end
  27. /// :nodoc:
  28. @protocol RLMDouble
  29. @end
  30. /// :nodoc:
  31. @protocol RLMFloat
  32. @end
  33. /// :nodoc:
  34. @interface NSNumber ()<RLMInt, RLMBool, RLMDouble, RLMFloat>
  35. @end
  36. /**
  37. `RLMProperty` instances represent properties managed by a Realm in the context of an object schema. Such properties may
  38. be persisted to a Realm file or computed from other data from the Realm.
  39. When using Realm, `RLMProperty` instances allow performing migrations and introspecting the database's schema.
  40. These property instances map to columns in the core database.
  41. */
  42. @interface RLMProperty : NSObject
  43. #pragma mark - Properties
  44. /**
  45. The name of the property.
  46. */
  47. @property (nonatomic, readonly) NSString *name;
  48. /**
  49. The type of the property.
  50. @see `RLMPropertyType`
  51. */
  52. @property (nonatomic, readonly) RLMPropertyType type;
  53. /**
  54. Indicates whether this property is indexed.
  55. @see `RLMObject`
  56. */
  57. @property (nonatomic, readonly) BOOL indexed;
  58. /**
  59. For `RLMObject` and `RLMArray` properties, the name of the class of object stored in the property.
  60. */
  61. @property (nonatomic, readonly, copy, nullable) NSString *objectClassName;
  62. /**
  63. For linking objects properties, the property name of the property the linking objects property is linked to.
  64. */
  65. @property (nonatomic, readonly, copy, nullable) NSString *linkOriginPropertyName;
  66. /**
  67. Indicates whether this property is optional.
  68. */
  69. @property (nonatomic, readonly) BOOL optional;
  70. #pragma mark - Methods
  71. /**
  72. Returns whether a given property object is equal to the receiver.
  73. */
  74. - (BOOL)isEqualToProperty:(RLMProperty *)property;
  75. @end
  76. /**
  77. An `RLMPropertyDescriptor` instance represents a specific property on a given class.
  78. */
  79. @interface RLMPropertyDescriptor : NSObject
  80. /**
  81. Creates and returns a property descriptor.
  82. @param objectClass The class of this property descriptor.
  83. @param propertyName The name of this property descriptor.
  84. */
  85. + (instancetype)descriptorWithClass:(Class)objectClass propertyName:(NSString *)propertyName;
  86. /// The class of the property.
  87. @property (nonatomic, readonly) Class objectClass;
  88. /// The name of the property.
  89. @property (nonatomic, readonly) NSString *propertyName;
  90. @end
  91. NS_ASSUME_NONNULL_END