-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNSFetchRequest+Explain.h
More file actions
170 lines (143 loc) · 6.78 KB
/
NSFetchRequest+Explain.h
File metadata and controls
170 lines (143 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Copyright 2012 Florian Agsteiner
*/
#import <CoreData/NSManagedObjectContext.h>
#import <CoreData/NSFetchRequest.h>
#import <Foundation/NSPredicate.h>
@interface NSPredicate (Explain)
/**
* Creates a explain description by applying the predicate to the object.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
* If the predicate contains an error or keypath it will show it to easily detect mistakes or false positives.
*
* @param object The object to evalutate
* @param bindings The mapping of substitution variables or nil
*/
- (NSString*) explainWithObject:(id)object substitutionVariables:(NSDictionary *)bindings;
/**
* Creates a explain description by applying the predicate to the object.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
* If the predicate contains an error or keypath it will show it to easily detect mistakes or false positives.
*
* @param object The object to evalutate
*/
- (NSString*) explainWithObject:(id)object;
/**
* Creates a explain description based on the predicate.
* It doesn't evaluates the predicate it just prints a formated description.
*/
- (NSString*) explain;
@end
@interface NSFetchRequest (Explain)
/**
* Creates a explain description by applying the predicate of the request to the result array.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
* You can avoid the output of every element and only show the summary by setting aggregateOnly to YES.
*
* @param result The array of elements to evalutate
* @param aggregateOnly Set to YES to only display a aggregation of all evaluations
*/
- (NSString*) explainWithResult:(NSArray*)result aggregateOnly:(BOOL)aggregateOnly;
/**
* Creates a explain description by applying the predicate of the request to the result array.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
*
* @param result The array of elements to evalutate
*/
- (NSString*) explainWithResult:(NSArray*)result;
/**
* Creates a explain description by applying the predicate of the fetch request to the object.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
* If the predicate contains an error or keypath it will show it to easily detect mistakes or false positives.
*
* @param object The object to evalutate
*/
- (NSString*) explainWithObject:(id)object;
/**
* Creates a explain description based on the predicate of the fetch request.
* It doesn't evaluates the predicate it just prints a formated description.
*/
- (NSString*) explain;
@end
@interface NSManagedObjectContext (Explain)
/**
* Creates a explain description by applying the predicate to the result of the fetch request.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
* You can avoid the output of every element and only show the summary by setting aggregateOnly to YES.
*
* @param request The fetchrequest which predicate and result to evalutate
* @param showIgnored Ignore the predicate when performing the fetchrequest to identify false positives
* @param fetchLimit You can limit the number of elements fetched (default: 100)
* @param aggregateOnly Set to YES to only display a aggregation of all evaluations
*/
- (NSString*) explainFetchRequest:(NSFetchRequest*)request showIgnored:(BOOL)showIgnored fetchLimit:(NSUInteger)fetchlimit aggregateOnly:(BOOL)aggregateOnly;
/**
* Creates a explain description by applying the predicate to the result of the fetch request.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
*
* @param request The fetchrequest which predicate and result to evalutate
* @param showIgnored Ignore the predicate when performing the fetchrequest to identify false positives
*/
- (NSString*) explainFetchRequest:(NSFetchRequest*)request showIgnored:(BOOL)showIgnored;
/**
* Creates a explain description by applying the predicate to the result of the fetch request.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
*
* @param request The fetchrequest which predicate and result to evalutate
*/
- (NSString*) explainFetchRequest:(NSFetchRequest*)request;
@end
@interface NSArray (Explain)
/**
* Creates a explain description by applying the predicate to all elements of the array.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
* You can avoid the output of every element and only show the summary by setting aggregateOnly to YES.
*
* @param predicate The predicate to evalutate
* @param aggregateOnly Set to YES to only display a aggregation of all evaluations
*/
- (NSString*) explainWithPredicate:(NSPredicate*)predicate aggregateOnly:(BOOL)aggregateOnly;
/**
* Creates a explain description by applying the predicate to all elements of the array.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
*
* @param predicate The predicate to evalutate
*/
- (NSString*) explainWithPredicate:(NSPredicate*)predicate;
@end
@interface NSSet (Explain)
/**
* Creates a explain description by applying the predicate to all elements of the set.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
* You can avoid the output of every element and only show the summary by setting aggregateOnly to YES.
*
* @param predicate The predicate to evalutate
* @param aggregateOnly Set to YES to only display a aggregation of all evaluations
*/
- (NSString*) explainWithPredicate:(NSPredicate*)predicate aggregateOnly:(BOOL)aggregateOnly;
/**
* Creates a explain description by applying the predicate to all elements of the set.
* It evaluates the predicate and prints out the recursive path where the predicate fails or matches.
*
* The method will print a explaination for each element and a summary at the end.
*
* @param predicate The predicate to evalutate
*/
- (NSString*) explainWithPredicate:(NSPredicate*)predicate;
@end