/** * Return {@code true} if any element in '{@code candidates}' is contained * in '{@code source}'; otherwise returns {@code false}. * * @param source the source Collection * @param candidates the candidates to search for * @return whether any of the candidates has been found */ public static boolean containsAny(Collection<?> source, Collection<?> candidates) { if (isEmpty(source) || isEmpty(candidates)) { return false; } for (Object candidate : candidates) { if (source.contains(candidate)) { return true; } } return false; }
public String select(List<String> clientProtocols) { if (!CollectionUtils.isEmpty(clientProtocols)) { for (String p : supportedProtocols) { if (clientProtocols.contains(p)) { log.debug("ALPN local server selected protocol -> {}", p); return p; } } } return null; } }
public String select(List<String> clientProtocols) { if (!CollectionUtils.isEmpty(clientProtocols)) { for (String p : supportedProtocols) { if (clientProtocols.contains(p)) { log.debug("ALPN local server selected protocol -> {}", p); return p; } } } return null; } }
/** * Assert that a collection has elements; that is, it must not be * {@code null} and must have at least one element. * * <pre class="code"> * Assert.notEmpty(collection, "Collection must have elements"); * </pre> * * @param collection the collection to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the collection is {@code null} or has no elements */ public static void notEmpty(Collection<?> collection, String message) { if (CollectionUtils.isEmpty(collection)) { throw new IllegalArgumentException(message); } }
/** * Assert that a Map has entries; that is, it must not be {@code null} and * must have at least one entry. * * <pre class="code"> * Assert.notEmpty(map, "Map must have entries"); * </pre> * * @param map the map to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the map is {@code null} or has no entries */ public static void notEmpty(Map<?, ?> map, String message) { if (CollectionUtils.isEmpty(map)) { throw new IllegalArgumentException(message); } }
/** * Assert that a Map has entries; that is, it must not be {@code null} and * must have at least one entry. * * <pre class="code"> * Assert.notEmpty(map, "Map must have entries"); * </pre> * * @param map the map to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the map is {@code null} or has no entries */ public static void notEmpty(Map<?, ?> map, String message) { if (CollectionUtils.isEmpty(map)) { throw new IllegalArgumentException(message); } }
/** * Assert that a collection has elements; that is, it must not be * {@code null} and must have at least one element. * * <pre class="code"> * Assert.notEmpty(collection, "Collection must have elements"); * </pre> * * @param collection the collection to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the collection is {@code null} or has no elements */ public static void notEmpty(Collection<?> collection, String message) { if (CollectionUtils.isEmpty(collection)) { throw new IllegalArgumentException(message); } }
protected void drawChildren() { if (!CollectionUtils.isEmpty(children)) { Graphics2D g = bufferedImage.createGraphics(); for (GraphicsComponent component : children) { BufferedImage img = component.draw(); g.drawImage(img, component.getX(), component.getY(), img.getWidth(), img.getHeight(), null); } g.dispose(); } }
protected void drawChildren() { if (!CollectionUtils.isEmpty(children)) { Graphics2D g = bufferedImage.createGraphics(); for (GraphicsComponent component : children) { BufferedImage img = component.draw(); g.drawImage(img, component.getX(), component.getY(), img.getWidth(), img.getHeight(), null); } g.dispose(); } }
@Override public Mono<List<Inventory>> listByProductId(List<Long> productIdList) { if (CollectionUtils.isEmpty(productIdList)) { return Mono.just(Collections.emptyList()); } String sql = "select * from `coffee_store`.`inventory` where `product_id` in ( " + toWildcard(productIdList) + " )"; return db.newTransaction(c -> c.queryForList(sql, Inventory.class, productIdList.toArray())); }
private void findRouter(String value, Matcher.MatchType matchType, Map<Router, Set<Matcher.MatchType>> routerMatchTypes, Map<Router, Map<String, String>> routerParameters) { matcherMap.get(matchType) .stream() .map(m -> m.match(value)) .filter(Objects::nonNull) .forEach(result -> result.getRouters().forEach(router -> { routerMatchTypes.computeIfAbsent(router, k -> new HashSet<>()).add(result.getMatchType()); if (!CollectionUtils.isEmpty(result.getParameters())) { routerParameters.computeIfAbsent(router, k -> new HashMap<>()) .putAll(result.getParameters().get(router)); } })); }
private void findRouter(String value, Matcher.MatchType matchType, Map<Router, Set<Matcher.MatchType>> routerMatchTypes, Map<Router, Map<String, String>> routerParameters) { matcherMap.get(matchType) .stream() .map(m -> m.match(value)) .filter(Objects::nonNull) .forEach(result -> result.getRouters().forEach(router -> { routerMatchTypes.computeIfAbsent(router, k -> new HashSet<>()).add(result.getMatchType()); if (!CollectionUtils.isEmpty(result.getParameters())) { routerParameters.computeIfAbsent(router, k -> new HashMap<>()) .putAll(result.getParameters().get(router)); } })); }
@Override public Mono<List<Product>> list(List<Long> idList, ReactiveSQLConnection connection) { if (CollectionUtils.isEmpty(idList)) { return Mono.just(Collections.emptyList()); } String sql = "select * from `coffee_store`.`product` where id in ( " + toWildcard(idList) + " )"; return connection.inTransaction(c -> c.queryForList(sql, Product.class, idList.toArray())); }
public boolean useConnectionManager() { return configuration.getAddressProvider() != null || !CollectionUtils.isEmpty(configuration.getServerUrlSet()); }
public boolean useConnectionManager() { return configuration.getAddressProvider() != null || !CollectionUtils.isEmpty(configuration.getServerUrlSet()); }
public ConscryptALPNSelector(SSLEngine sslEngine, List<String> supportedProtocolList) { if (CollectionUtils.isEmpty(supportedProtocolList)) { this.supportedProtocolList = Collections.unmodifiableList(Arrays.asList("h2", "http/1.1")); } else { this.supportedProtocolList = supportedProtocolList; } supportedProtocols = this.supportedProtocolList.toArray(StringUtils.EMPTY_STRING_ARRAY); this.sslEngine = sslEngine; if (sslEngine.getUseClientMode()) { Conscrypt.setApplicationProtocols(sslEngine, supportedProtocols); } else { Conscrypt.setApplicationProtocolSelector(sslEngine, new ConscryptApplicationProtocolSelector()); } }
public ConscryptALPNSelector(SSLEngine sslEngine, List<String> supportedProtocolList) { if (CollectionUtils.isEmpty(supportedProtocolList)) { this.supportedProtocolList = Collections.unmodifiableList(Arrays.asList("h2", "http/1.1")); } else { this.supportedProtocolList = supportedProtocolList; } supportedProtocols = this.supportedProtocolList.toArray(StringUtils.EMPTY_STRING_ARRAY); this.sslEngine = sslEngine; if (sslEngine.getUseClientMode()) { Conscrypt.setApplicationProtocols(sslEngine, supportedProtocols); } else { Conscrypt.setApplicationProtocolSelector(sslEngine, new ConscryptApplicationProtocolSelector()); } }
public ExtensionFactory() { availableExtensions = new HashMap<>(); for (Extension ext : extensionLoader) { if (ext != null) { availableExtensions.put(ext.getName(), ext.getClass()); } } if (CollectionUtils.isEmpty(availableExtensions)) { availableExtensions.put(new DeflateFrameExtension().getName(), DeflateFrameExtension.class); availableExtensions.put(new PerMessageDeflateExtension().getName(), PerMessageDeflateExtension.class); availableExtensions.put(new XWebkitDeflateFrameExtension().getName(), XWebkitDeflateFrameExtension.class); availableExtensions.put(new IdentityExtension().getName(), IdentityExtension.class); availableExtensions.put(new FragmentExtension().getName(), FragmentExtension.class); } }
@Override public Mono<Boolean> buy(ProductBuyRequest request) { if (request == null) { return Mono.error(new IllegalArgumentException("The product request is required")); } if (request.getUserId() == null || request.getUserId().equals(0L)) { return Mono.error(new IllegalArgumentException("The user id is required")); } if (CollectionUtils.isEmpty(request.getProducts())) { return Mono.error(new IllegalArgumentException("The products must bu not empty")); } return db.newTransaction(c -> buy(request, c)); }
public ExtensionFactory() { availableExtensions = new HashMap<>(); for (Extension ext : extensionLoader) { if (ext != null) { availableExtensions.put(ext.getName(), ext.getClass()); } } if (CollectionUtils.isEmpty(availableExtensions)) { availableExtensions.put(new DeflateFrameExtension().getName(), DeflateFrameExtension.class); availableExtensions.put(new PerMessageDeflateExtension().getName(), PerMessageDeflateExtension.class); availableExtensions.put(new XWebkitDeflateFrameExtension().getName(), XWebkitDeflateFrameExtension.class); availableExtensions.put(new IdentityExtension().getName(), IdentityExtension.class); availableExtensions.put(new FragmentExtension().getName(), FragmentExtension.class); } }