66// Copyright © 2017 PureSwift. All rights reserved.
77//
88
9- /// Used to represent expressions in a predicate.
10- public enum Expression : Equatable , Hashable , Sendable {
9+ public extension FetchRequest . Predicate {
1110
12- /// Expression that represents a given constant attribute value .
13- case attribute ( AttributeValue )
14-
15- /// Expression that represents a given constant attribute value.
16- case relationship ( RelationshipValue )
17-
18- /// Expression that invokes `valueForKeyPath:` with a given key path .
19- case keyPath ( PredicateKeyPath )
20- }
21-
22- /// Type of predicate expression.
23- public enum ExpressionType : String , Codable , Sendable {
11+ /// Used to represent expressions in a predicate .
12+ enum Expression : Equatable , Hashable , Sendable {
13+
14+ /// Expression that represents a given constant attribute value.
15+ case attribute ( AttributeValue )
16+
17+ /// Expression that represents a given constant attribute value .
18+ case relationship ( RelationshipValue )
19+
20+ /// Expression that invokes `valueForKeyPath:` with a given key path.
21+ case keyPath ( PredicateKeyPath )
22+ }
2423
25- case attribute
26- case relationship
27- case keyPath
24+ /// Type of predicate expression.
25+ enum ExpressionType : String , Codable , Sendable {
26+
27+ case attribute
28+ case relationship
29+ case keyPath
30+ }
2831}
2932
30- public extension Expression {
33+ public extension FetchRequest . Predicate . Expression {
3134
32- var type : ExpressionType {
35+ var type : FetchRequest . Predicate . ExpressionType {
3336 switch self {
3437 case . attribute: return . attribute
3538 case . relationship: return . relationship
@@ -40,7 +43,7 @@ public extension Expression {
4043
4144// MARK: - CustomStringConvertible
4245
43- extension Expression : CustomStringConvertible {
46+ extension FetchRequest . Predicate . Expression : CustomStringConvertible {
4447
4548 public var description : String {
4649
@@ -91,7 +94,7 @@ internal extension RelationshipValue {
9194
9295// MARK: - Codable
9396
94- extension Expression : Codable {
97+ extension FetchRequest . Predicate . Expression : Codable {
9598
9699 internal enum CodingKeys : String , CodingKey {
97100
@@ -102,7 +105,7 @@ extension Expression: Codable {
102105 public init ( from decoder: Decoder ) throws {
103106
104107 let container = try decoder. container ( keyedBy: CodingKeys . self)
105- let type = try container. decode ( ExpressionType . self, forKey: . type)
108+ let type = try container. decode ( FetchRequest . Predicate . ExpressionType. self, forKey: . type)
106109
107110 switch type {
108111 case . attribute:
@@ -135,21 +138,21 @@ extension Expression: Codable {
135138
136139// MARK: - Extensions
137140
138- public extension Expression {
141+ public extension FetchRequest . Predicate . Expression {
139142
140- func compare( _ type: FetchRequest . Predicate . Comparison . Operator , _ rhs: Expression ) -> FetchRequest . Predicate {
143+ func compare( _ type: FetchRequest . Predicate . Comparison . Operator , _ rhs: FetchRequest . Predicate . Expression ) -> FetchRequest . Predicate {
141144
142145 let comparison = FetchRequest . Predicate. Comparison ( left: self , right: rhs, type: type)
143146 return . comparison( comparison)
144147 }
145148
146- func compare( _ type: FetchRequest . Predicate . Comparison . Operator , _ options: Set < FetchRequest . Predicate . Comparison . Option > , _ rhs: Expression ) -> FetchRequest . Predicate {
149+ func compare( _ type: FetchRequest . Predicate . Comparison . Operator , _ options: Set < FetchRequest . Predicate . Comparison . Option > , _ rhs: FetchRequest . Predicate . Expression ) -> FetchRequest . Predicate {
147150
148151 let comparison = FetchRequest . Predicate. Comparison ( left: self , right: rhs, type: type, options: options)
149152 return . comparison( comparison)
150153 }
151154
152- func compare( _ modifier: FetchRequest . Predicate . Comparison . Modifier , _ type: FetchRequest . Predicate . Comparison . Operator , _ options: Set < FetchRequest . Predicate . Comparison . Option > , _ rhs: Expression ) -> FetchRequest . Predicate {
155+ func compare( _ modifier: FetchRequest . Predicate . Comparison . Modifier , _ type: FetchRequest . Predicate . Comparison . Operator , _ options: Set < FetchRequest . Predicate . Comparison . Option > , _ rhs: FetchRequest . Predicate . Expression ) -> FetchRequest . Predicate {
153156
154157 let comparison = FetchRequest . Predicate. Comparison ( left: self , right: rhs, type: type, modifier: modifier, options: options)
155158 return . comparison( comparison)
0 commit comments