/** * Retrieve a single object using a list of keys and values to match. * * @param context The editing context to use * @param qualifier The qualifier to use * @return the single entity that was retrieved * @throws EOUtilities.MoreThanOneException if there is more than one matching object */ public static UserMessageSubscription uniqueObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier) throws EOUtilities.MoreThanOneException { NSArray<UserMessageSubscription> objects = objectsMatchingQualifier(context, qualifier); if (objects.size() > 1) { String msg = "fetching UserMessageSubscription"; try { if (qualifier != null) { msg += " where " + qualifier; } msg += ", result = " + objects; } catch (Exception e) { log.error( "Exception building MoreThanOneException message, " + "contents so far: " + msg, e); } throw new EOUtilities.MoreThanOneException(msg); } return (objects.size() > 0) ? objects.get(0) : null; }
/** * Retrieve the first object that matches a qualifier, when sorted with the specified sort * orderings. * * @param context The editing context to use * @param qualifier The qualifier to use * @param sortOrderings the sort orderings * @return the first entity that was retrieved, or null if there was none */ public static UserMessageSubscription firstObjectMatchingQualifier( EOEditingContext context, EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) { NSArray<UserMessageSubscription> objects = objectsMatchingQualifier(context, qualifier, sortOrderings); return (objects.size() > 0) ? objects.get(0) : null; }