/**
   * Retrieves the first object that matches a set of keys and values, when sorted with the
   * specified sort orderings.
   *
   * @param context The editing context to use
   * @param sortOrderings the sort orderings
   * @param keysAndValues a dictionary of keys and values to match
   * @return the first entity that was retrieved, or null if there was none
   */
  public static UserMessageSubscription firstObjectMatchingValues(
      EOEditingContext context,
      NSArray<EOSortOrdering> sortOrderings,
      NSDictionary<String, Object> keysAndValues) {
    @SuppressWarnings("unchecked")
    EOFetchSpecification fspec =
        new WCFetchSpecification(
            ENTITY_NAME, EOQualifier.qualifierToMatchAllValues(keysAndValues), sortOrderings);
    fspec.setFetchLimit(1);

    NSArray<UserMessageSubscription> objects = objectsWithFetchSpecification(context, fspec);

    if (objects.count() == 0) {
      return null;
    } else {
      return objects.objectAtIndex(0);
    }
  }