summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm')
-rw-r--r--platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm44
1 files changed, 43 insertions, 1 deletions
diff --git a/platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm b/platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm
index ac2d598d05..5b54d66aeb 100644
--- a/platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm
+++ b/platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm
@@ -1,7 +1,7 @@
#import "NSComparisonPredicate+MGLAdditions.h"
#import "NSPredicate+MGLAdditions.h"
-#import "NSExpression+MGLAdditions.h"
+#import "NSExpression+MGLPrivateAdditions.h"
@implementation NSComparisonPredicate (MGLAdditions)
@@ -294,3 +294,45 @@
}
@end
+
+@implementation NSComparisonPredicate (MGLExpressionAdditions)
+
+- (id)mgl_jsonExpressionObject {
+ NSString *op;
+ switch (self.predicateOperatorType) {
+ case NSLessThanPredicateOperatorType:
+ op = @"<";
+ break;
+ case NSLessThanOrEqualToPredicateOperatorType:
+ op = @"<=";
+ break;
+ case NSGreaterThanPredicateOperatorType:
+ op = @">";
+ break;
+ case NSGreaterThanOrEqualToPredicateOperatorType:
+ op = @">=";
+ break;
+ case NSEqualToPredicateOperatorType:
+ op = @"==";
+ break;
+ case NSNotEqualToPredicateOperatorType:
+ op = @"!=";
+ break;
+ case NSMatchesPredicateOperatorType:
+ case NSLikePredicateOperatorType:
+ case NSBeginsWithPredicateOperatorType:
+ case NSEndsWithPredicateOperatorType:
+ case NSInPredicateOperatorType:
+ case NSCustomSelectorPredicateOperatorType:
+ case NSContainsPredicateOperatorType:
+ case NSBetweenPredicateOperatorType:
+ [NSException raise:NSInvalidArgumentException
+ format:@"NSPredicateOperatorType:%lu is not supported.", (unsigned long)self.predicateOperatorType];
+ }
+ if (op) {
+ return @[op, self.leftExpression.mgl_jsonExpressionObject, self.rightExpression.mgl_jsonExpressionObject];
+ }
+ return nil;
+}
+
+@end