EntityQueryComparator
The base class for all concrete entity query comparators.
Declaration
class EntityQueryComparator<Property, PropertyType, InputType, ComparatorMappingType> where Property : EntityProperty<PropertyType>, PropertyType : _IntentValue, PropertyType : Sendable, InputType : _IntentValueOverview
An entity query comparator specifies a particular query comparison that can be made against a EntityQueryProperty. For each query property comparator, mappingTransform maps the user-supplied Value at runtime into a ComparatorMappingType type of your choice.
The following example illustrates the declaration of a EntityQueryProperty on a fictional IntentPersonEntity that allows finding entities by strict equality or prefix on the entity firstName property by defining its supported EntityQueryComparators:
Property(\.$firstName) {
EqualToComparator { value in
// This is called at runtime with `value` being the user-supplied value.
// For example, value would be: "John" when the user says:
// "Hey Siri, find persons named John", given the appropriate mapping
// in the application's Siri metadata.
// This closure returns an object of type `ComparatorMappingType`. In the context of
// a `EntityQuery`, every `EntityQueryComparator` must return the same output type,
// which is the Query's `ComparatorMappingType`.
return "firstName must be equal to \{value}"
}
HasPrefixComparator { "firstName must start with \{$0}" }
}Resolvers
Additionally, you can supply a set of Resolvers to fine-tune how the system will transform a user’s supplied value into into the target Value type.