@@ -21,24 +21,31 @@ public struct CompositionCondition: Codable, JSONEncodable {
2121 /// triggered, when the specific filter is selected. You can use `filters` on its own or combine it with the
2222 /// `pattern` parameter.
2323 public var filters : String ?
24+ /// Sort criteria that trigger the rule. You can trigger composition rules based on the selected sorting strategy
25+ /// set by the parameter `sortBy`. The rule will trigger if the value passed to `sortBy` matches the one defined in
26+ /// the condition.
27+ public var sortBy : String ?
2428
2529 public init (
2630 pattern: String ? = nil ,
2731 anchoring: CompositionAnchoring ? = nil ,
2832 context: String ? = nil ,
29- filters: String ? = nil
33+ filters: String ? = nil ,
34+ sortBy: String ? = nil
3035 ) {
3136 self . pattern = pattern
3237 self . anchoring = anchoring
3338 self . context = context
3439 self . filters = filters
40+ self . sortBy = sortBy
3541 }
3642
3743 public enum CodingKeys : String , CodingKey , CaseIterable {
3844 case pattern
3945 case anchoring
4046 case context
4147 case filters
48+ case sortBy
4249 }
4350
4451 // Encodable protocol methods
@@ -49,6 +56,7 @@ public struct CompositionCondition: Codable, JSONEncodable {
4956 try container. encodeIfPresent ( self . anchoring, forKey: . anchoring)
5057 try container. encodeIfPresent ( self . context, forKey: . context)
5158 try container. encodeIfPresent ( self . filters, forKey: . filters)
59+ try container. encodeIfPresent ( self . sortBy, forKey: . sortBy)
5260 }
5361}
5462
@@ -57,7 +65,8 @@ extension CompositionCondition: Equatable {
5765 lhs. pattern == rhs. pattern &&
5866 lhs. anchoring == rhs. anchoring &&
5967 lhs. context == rhs. context &&
60- lhs. filters == rhs. filters
68+ lhs. filters == rhs. filters &&
69+ lhs. sortBy == rhs. sortBy
6170 }
6271}
6372
@@ -67,5 +76,6 @@ extension CompositionCondition: Hashable {
6776 hasher. combine ( self . anchoring? . hashValue)
6877 hasher. combine ( self . context? . hashValue)
6978 hasher. combine ( self . filters? . hashValue)
79+ hasher. combine ( self . sortBy? . hashValue)
7080 }
7181}
0 commit comments