FEMAttribute.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // For License please refer to LICENSE file in the root of FastEasyMapping project
  2. #import <Foundation/Foundation.h>
  3. #import "FEMTypes.h"
  4. #import "FEMProperty.h"
  5. @interface FEMAttribute : NSObject <FEMProperty>
  6. - (nullable id)mapValue:(nullable id)value;
  7. - (nullable id)reverseMapValue:(nullable id)value;
  8. - (nonnull instancetype)initWithProperty:(nonnull NSString *)property keyPath:(nullable NSString *)keyPath map:(nullable FEMMapBlock)map reverseMap:(nullable FEMMapBlock)reverseMap;
  9. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nullable NSString *)keyPath map:(nullable FEMMapBlock)map reverseMap:(nullable FEMMapBlock)reverseMap;
  10. @end
  11. @interface FEMAttribute (Shortcut)
  12. /**
  13. * same as +[FEMAttribute mappingOfProperty:property toKeyPath:property];
  14. */
  15. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property;
  16. /**
  17. * same as +[FEMAttribute mappingOfProperty:property toKeyPath:nil map:NULL];
  18. */
  19. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nonnull NSString *)keyPath;
  20. /**
  21. * same as +[FEMAttribute mappingOfProperty:property toKeyPath:nil map:map];
  22. */
  23. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property map:(nonnull FEMMapBlock)map;
  24. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property reverseMap:(nonnull FEMMapBlock)reverseMap;
  25. /**
  26. * same as +[FEMAttribute mappingOfProperty:property toKeyPath:nil map:NULL reverseMap:NULL];
  27. */
  28. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nonnull NSString *)keyPath map:(nonnull FEMMapBlock)map;
  29. /**
  30. * create mapping object, based on NSDateFormatter.
  31. * NSDateFormatter instance uses en_US_POSIX locale and UTC Timezone
  32. */
  33. + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nullable NSString *)keyPath dateFormat:(nonnull NSString *)dateFormat;
  34. /**
  35. * property represented by NSURL, value at keyPath - NSString
  36. */
  37. + (nonnull instancetype)mappingOfURLProperty:(nonnull NSString *)property toKeyPath:(nullable NSString *)keyPath;
  38. @end