/** * Determines if the given entity has validation warnings. * * @param entity the entity to check * @return <tt>true</tt> if there are validation warnings, <tt>false</tt> otherwise */ public boolean hasValidationWarnings(Object entity) { for (BiConsumer<Object, Consumer<String>> validator : validateHandlers) { ValueHolder<Boolean> hasWarnings = ValueHolder.of(false); validator.accept(entity, warning -> hasWarnings.accept(true)); if (hasWarnings.get()) { return true; } } return false; }
/** * Executes the given query returning the first matching row. * <p> * If the resulting row contains a {@link Blob} an {@link OutputStream} as to be passed in as parameter * with the name name as the column. The contents of the blob will then be written into the given * output stream (without closing it). * * @return the first matching row for the given query or <tt>null</tt> if no matching row was found * @throws SQLException in case of a database error */ @Nullable public Row queryFirst() throws SQLException { ValueHolder<Row> result = ValueHolder.of(null); iterateAll(result, Limit.singleItem()); return result.get(); }
/** * Returns the first item matched by the query. * * @return the first item matched by the query or <tt>null</tt> if there are no matches. */ public E queryFirst() { ValueHolder<E> result = ValueHolder.of(null); limit(1); iterate(r -> { result.set(r); return false; }); return result.get(); }
protected void deleteByIteration(boolean force) throws Exception { ValueHolder<Exception> error = ValueHolder.of(null); iterate(e -> { try { if (force) { indexAccess.forceDelete(e); } else { indexAccess.delete(e); } } catch (Exception ex) { error.set(ex); } return true; }); if (error.get() != null) { throw error.get(); } } }