@Nullable public Connection getConnection(Class<? extends Connection> connectionType) { return CollectionUtils.findValueOfType(this.connections, connectionType); }
@Nullable public Session getSession(Class<? extends Session> sessionType, @Nullable Connection connection) { List<Session> sessions = (connection != null ? this.sessionsPerConnection.get(connection) : this.sessions); return CollectionUtils.findValueOfType(sessions, sessionType); }
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or {@code null} if none or more than one such value found */ @Nullable public static Object findValueOfType(Collection<?> collection, Class<?>[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (Class<?> type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or {@code null} if none or more than one such value found */ @Nullable public static Object findValueOfType(Collection<?> collection, Class<?>[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (Class<?> type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
/** * <p>Locate the {@link Source} object in the supplied model, * converting objects as required. * The default implementation first attempts to look under the configured * {@link #setSourceKey source key}, if any, before attempting to locate * an object of {@link #getSourceTypes() supported type}. * @param model the merged model Map * @return the XSLT Source object (or {@code null} if none found) * @throws Exception if an error occurred during locating the source * @see #setSourceKey * @see #convertSource */ @Nullable protected Source locateSource(Map<String, Object> model) throws Exception { if (this.sourceKey != null) { return convertSource(model.get(this.sourceKey)); } Object source = CollectionUtils.findValueOfType(model.values(), getSourceTypes()); return (source != null ? convertSource(source) : null); }
/** * <p>Locate the {@link Source} object in the supplied model, * converting objects as required. * The default implementation first attempts to look under the configured * {@link #setSourceKey source key}, if any, before attempting to locate * an object of {@link #getSourceTypes() supported type}. * @param model the merged model Map * @return the XSLT Source object (or {@code null} if none found) * @throws Exception if an error occurred during locating the source * @see #setSourceKey * @see #convertSource */ @Nullable protected Source locateSource(Map<String, Object> model) throws Exception { if (this.sourceKey != null) { return convertSource(model.get(this.sourceKey)); } Object source = CollectionUtils.findValueOfType(model.values(), getSourceTypes()); return (source != null ? convertSource(source) : null); }
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or <code>null</code> if none or more than one such value found */ public static Object findValueOfType(Collection<?> collection, Class<?>[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (Class<?> type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
public Connection getConnection(Class<? extends Connection> connectionType) { return CollectionUtils.findValueOfType(this.connections, connectionType); }
public Connection getConnection(Class<? extends Connection> connectionType) { return CollectionUtils.findValueOfType(this.connections, connectionType); }
/** * Find a value of one of the given types in the given collection: * searching the collection for a value of the first type, then * searching for a value of the second type, etc. * @param coll the collection to search * @param types the types to look for, in prioritized order * @return a of one of the given types found, or <code>null</code> if none * @throws IllegalArgumentException if more than one value * of the given type found */ public static Object findValueOfType(Collection coll, Class[] types) throws IllegalArgumentException { for (int i = 0; i < types.length; i++) { Object value = findValueOfType(coll, types[i]); if (value != null) { return value; } } return null; }
public Session getSession(Class<? extends Session> sessionType, Connection connection) { List<Session> sessions = this.sessions; if (connection != null) { sessions = this.sessionsPerConnection.get(connection); } return CollectionUtils.findValueOfType(sessions, sessionType); }
@Nullable public Connection getConnection(Class<? extends Connection> connectionType) { return CollectionUtils.findValueOfType(this.connections, connectionType); }
/** * Find a single connection of this type. * @param connectionType the type. * @return the connection or null. * @deprecated Not used. */ @Deprecated @Nullable public Connection getConnection(Class<? extends Connection> connectionType) { return CollectionUtils.findValueOfType(this.connections, connectionType); }
/** * Find a single connection of this type. * @param connectionType the type. * @return the connection or null. * @deprecated Not used. */ @Deprecated @Nullable public Connection getConnection(Class<? extends Connection> connectionType) { return CollectionUtils.findValueOfType(this.connections, connectionType); }
@Nullable public Session getSession(Class<? extends Session> sessionType, @Nullable Connection connection) { List<Session> sessions = (connection != null ? this.sessionsPerConnection.get(connection) : this.sessions); return CollectionUtils.findValueOfType(sessions, sessionType); }
/** * Find a single value of one of the given types in the given Collection: searching the Collection for a value of * the first type, then searching for a value of the second type, etc. * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, or <code>null</code> if none or more * than one such value found */ public static Object findValueOfType(Collection<?> collection, Class<?>[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (Class<?> type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or <code>null</code> if none or more than one such value found */ public static Object findValueOfType(Collection collection, Class[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (Class type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
public Session getSession(Class<? extends Session> sessionType, Connection connection) { List<Session> sessions = (connection != null ? this.sessionsPerConnection.get(connection) : this.sessions); return CollectionUtils.findValueOfType(sessions, sessionType); }
/** * <p>Locate the {@link Source} object in the supplied model, * converting objects as required. * The default implementation first attempts to look under the configured * {@link #setSourceKey source key}, if any, before attempting to locate * an object of {@link #getSourceTypes() supported type}. * @param model the merged model Map * @return the XSLT Source object (or {@code null} if none found) * @throws Exception if an error occurred during locating the source * @see #setSourceKey * @see #convertSource */ protected Source locateSource(Map<String, Object> model) throws Exception { if (this.sourceKey != null) { return convertSource(model.get(this.sourceKey)); } Object source = CollectionUtils.findValueOfType(model.values(), getSourceTypes()); return (source != null ? convertSource(source) : null); }
/** * Create an appropriate {@code JRDataSource} for passed-in report data. * Called by {@link #fillReport} when its own lookup steps were not successful. * <p>The default implementation looks for a value of type {@code java.util.Collection} * or object array (in that order). Can be overridden in subclasses. * @param model the model map, as passed in for view rendering * @return the {@code JRDataSource} or {@code null} if the data source is not found * @see #getReportDataTypes * @see #convertReportData */ protected JRDataSource getReportData(Map<String, Object> model) { // Try to find matching attribute, of given prioritized types. Object value = CollectionUtils.findValueOfType(model.values(), getReportDataTypes()); return (value != null ? convertReportData(value) : null); }