From 1bea8f85c8b58a4807160f6ed75803a54ade5b02 Mon Sep 17 00:00:00 2001 From: Saul Moreno Abril Date: Tue, 3 Oct 2017 11:35:10 +0200 Subject: [PATCH 1/3] Add initialiser to change the default value of "cleanValuesOnReplacement" --- Files/WACDSCustomMapping.h | 14 +++++++++++++- Files/WACDSCustomMapping.m | 8 ++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Files/WACDSCustomMapping.h b/Files/WACDSCustomMapping.h index 5574df0..ae7f1df 100644 --- a/Files/WACDSCustomMapping.h +++ b/Files/WACDSCustomMapping.h @@ -32,6 +32,18 @@ typedef NSDate* _Nonnull (^WACDSMappingExpirationDateBuilder)(id _Nonnull object uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder; +/** + * Init the mapping + * + * @param objectEntityName The object entity name + * @param uniqueIdentifierPattern A pattern for unique identifier. Ex: booking_{#bookingID#} + * @param searchableItemAttributeSetBuilder A block which will be called for each object to index. You need to return an attribute set + * @param cleanValuesOnReplacement A bool which is used to change the default behaviour. By default is NO. + * + * @return a fresh mapping + */ +- (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uniqueIdentifierPattern:(NSString *)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder)searchableItemAttributeSetBuilder cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement; + /** * Get the unique identifier from an object based on the pattern * @@ -105,4 +117,4 @@ typedef NSDate* _Nonnull (^WACDSMappingExpirationDateBuilder)(id _Nonnull object uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder __deprecated_msg("Use `initWithManagedObjectEntityName: uniqueIdentifierPattern: searchableItemAttributeSetBuilder:` instead"); -@end \ No newline at end of file +@end diff --git a/Files/WACDSCustomMapping.m b/Files/WACDSCustomMapping.m index 80b516e..ccdb01a 100644 --- a/Files/WACDSCustomMapping.m +++ b/Files/WACDSCustomMapping.m @@ -26,6 +26,10 @@ @interface WACDSCustomMapping () @implementation WACDSCustomMapping - (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uniqueIdentifierPattern:(NSString *)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder)searchableItemAttributeSetBuilder { + return [self initWithManagedObjectEntityName:objectEntityName uniqueIdentifierPattern:uniqueIdentifierPattern searchableItemAttributeSetBuilder:searchableItemAttributeSetBuilder cleanValuesOnReplacement:NO]; +} + +- (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uniqueIdentifierPattern:(NSString *)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder)searchableItemAttributeSetBuilder cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement { WACDSClassAssertion(objectEntityName, NSString); WACDSClassAssertion(uniqueIdentifierPattern, NSString); @@ -37,7 +41,7 @@ - (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uni self->_searchableItemAttributeSetBuilder = searchableItemAttributeSetBuilder; // Create the pattern - self->_uniqueIdentifierStringPattern = [[WACDSStringPattern alloc] initWithPattern:uniqueIdentifierPattern cleanValuesOnReplacement:NO]; + self->_uniqueIdentifierStringPattern = [[WACDSStringPattern alloc] initWithPattern:uniqueIdentifierPattern cleanValuesOnReplacement:cleanValuesOnReplacement]; } return self; @@ -89,4 +93,4 @@ - (instancetype)initWithManagedObjectClass:(Class)objectClass uniqueIdentifierPa searchableItemAttributeSetBuilder:searchableItemAttributeSetBuilder]; } -@end \ No newline at end of file +@end From 41adf7967d673b908efe9dcb8f09ac65e06da122 Mon Sep 17 00:00:00 2001 From: Saul Moreno Abril Date: Mon, 9 Oct 2017 10:45:55 +0200 Subject: [PATCH 2/3] Add _Nonnull to the parameters --- Files/WACDSCustomMapping.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Files/WACDSCustomMapping.h b/Files/WACDSCustomMapping.h index ae7f1df..7347ec0 100644 --- a/Files/WACDSCustomMapping.h +++ b/Files/WACDSCustomMapping.h @@ -42,7 +42,10 @@ typedef NSDate* _Nonnull (^WACDSMappingExpirationDateBuilder)(id _Nonnull object * * @return a fresh mapping */ -- (instancetype)initWithManagedObjectEntityName:(NSString *)objectEntityName uniqueIdentifierPattern:(NSString *)uniqueIdentifierPattern searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder)searchableItemAttributeSetBuilder cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement; +- (instancetype)initWithManagedObjectEntityName:(NSString *_Nonnull)objectEntityName + uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern + searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder + cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement; /** * Get the unique identifier from an object based on the pattern From eb8d0ab54568605d851736a828c8a55055f6ac1c Mon Sep 17 00:00:00 2001 From: Saul Moreno Abril Date: Mon, 9 Oct 2017 11:03:49 +0200 Subject: [PATCH 3/3] Add other forgotten nonnull --- Files/WACDSCustomMapping.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Files/WACDSCustomMapping.h b/Files/WACDSCustomMapping.h index 7347ec0..dc4523b 100644 --- a/Files/WACDSCustomMapping.h +++ b/Files/WACDSCustomMapping.h @@ -42,10 +42,10 @@ typedef NSDate* _Nonnull (^WACDSMappingExpirationDateBuilder)(id _Nonnull object * * @return a fresh mapping */ -- (instancetype)initWithManagedObjectEntityName:(NSString *_Nonnull)objectEntityName - uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern - searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder - cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement; +- (instancetype _Nonnull)initWithManagedObjectEntityName:(NSString *_Nonnull)objectEntityName + uniqueIdentifierPattern:(NSString *_Nonnull)uniqueIdentifierPattern + searchableItemAttributeSetBuilder:(WACDSSearchableItemAttributeSetBuilder _Nonnull)searchableItemAttributeSetBuilder + cleanValuesOnReplacement:(BOOL)cleanValuesOnReplacement; /** * Get the unique identifier from an object based on the pattern