FEMRelationship.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // For License please refer to LICENSE file in the root of FastEasyMapping project
  2. #import <Foundation/Foundation.h>
  3. #import "FEMAssignmentPolicy.h"
  4. #import "FEMProperty.h"
  5. NS_ASSUME_NONNULL_BEGIN
  6. @class FEMMapping;
  7. @interface FEMRelationship : NSObject <FEMProperty>
  8. @property (nonatomic, strong) FEMMapping *mapping;
  9. @property (nonatomic, getter=isToMany) BOOL toMany;
  10. @property (nonatomic) BOOL weak;
  11. @property (nonatomic, copy) FEMAssignmentPolicy assignmentPolicy;
  12. - (instancetype)init NS_UNAVAILABLE;
  13. - (instancetype)initWithProperty:(NSString *)property keyPath:(nullable NSString *)keyPath mapping:(FEMMapping *)mapping NS_DESIGNATED_INITIALIZER;
  14. - (instancetype)initWithProperty:(NSString *)property mapping:(FEMMapping *)mapping;
  15. - (instancetype)initWithProperty:(NSString *)property keyPath:(NSString *)keyPath mapping:(FEMMapping *)mapping assignmentPolicy:(FEMAssignmentPolicy)assignmentPolicy;
  16. - (void)setMapping:(FEMMapping *)mapping forKeyPath:(nullable NSString *)keyPath;
  17. @end
  18. @interface FEMRelationship (Deprecated)
  19. - (void)setObjectMapping:(FEMMapping *)objectMapping forKeyPath:(nullable NSString *)keyPath __attribute__((deprecated("Use -[FEMRelationship setMappaing:forKeyPath:] instead")));
  20. - (instancetype)initWithProperty:(NSString *)property
  21. keyPath:(nullable NSString *)keyPath
  22. assignmentPolicy:(nullable FEMAssignmentPolicy)policy
  23. objectMapping:(nullable FEMMapping *)objectMapping __attribute__((deprecated("Use -[FEMRelationship initWithProperty:keyPath:mapping:assignmentPolicy:] instead")));
  24. /**
  25. * same as + [FEMRelationship mappingOfProperty:property toKeyPath:nil mapping:mapping];
  26. */
  27. + (instancetype)mappingOfProperty:(NSString *)property objectMapping:(FEMMapping *)objectMapping __attribute__((deprecated("Use -[FEMRelationship initWithProperty:mapping:] instead")));
  28. + (instancetype)mappingOfProperty:(NSString *)property
  29. toKeyPath:(nullable NSString *)keyPath
  30. objectMapping:(FEMMapping *)objectMapping __attribute__((deprecated("Use -[FEMRelationship initWithProperty:keyPath:mapping:] instead")));
  31. @property (nonatomic, strong) FEMMapping *objectMapping __attribute__((deprecated("Use FEMRelationship.mapping instead")));
  32. @end
  33. @interface FEMRelationship (Unavailable)
  34. + (instancetype)mappingOfProperty:(NSString *)property
  35. configuration:(void (^)(FEMRelationship *__mapping))configuration __attribute__((unavailable("Use -[FEMRelationship initWithProperty:keyPath:mapping:] instead")));
  36. + (instancetype)mappingOfProperty:(NSString *)property
  37. toKeyPath:(nullable NSString *)keyPath
  38. configuration:(void (^)(FEMRelationship *__mapping))configuration __attribute__((unavailable("Use -[FEMRelationship initWithProperty:keyPath:mapping:] instead")));
  39. @end
  40. NS_ASSUME_NONNULL_END