/** * Null-safe check if the specified collection is not empty. * <p> * Null returns false. * * @param coll the collection to check, may be null * @return true if non-null and non-empty * @since 3.2 */ public static boolean isNotEmpty(final Collection<?> coll) { return !isEmpty(coll); }
private boolean validateUserSelection(List<String> userNames, BulkUpdateUsersOperationResult result) { if (CollectionUtils.isEmpty(userNames)) { result.badRequest("No users selected."); return false; } return true; }
public void addLogInfos(List<LogInfo> logInfos) { if (!isEmpty(logInfos)) { getLogInfoList().addAll(logInfos); } }
public void addTouchAccounts(Set<byte[]> accounts) { if (!isEmpty(accounts)) { getTouchedAccounts().addAll(accounts); } }
public void addDeleteAccounts(Set<DataWord> accounts) { if (!isEmpty(accounts)) { getDeleteAccounts().addAll(accounts); } }
@Override public Customer readCustomerByUsername(String username, Boolean cacheable) { List<Customer> customers = readCustomersByUsername(username, cacheable); return CollectionUtils.isEmpty(customers) ? null : customers.get(0); }
@Override public Customer readCustomerByEmail(String emailAddress) { List<Customer> customers = readCustomersByEmail(emailAddress); return CollectionUtils.isEmpty(customers) ? null : customers.get(0); }
@Override public Customer readCustomerByExternalId(String id) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Customer> criteria = builder.createQuery(Customer.class); Root<? extends Customer> customer = criteria.from(entityConfiguration.lookupEntityClass(Customer.class.getName(), Customer.class)); criteria.select(customer); criteria.where(builder.equal(customer.get("externalId"), id)); TypedQuery<Customer> query = em.createQuery(criteria); query.setHint(QueryHints.HINT_CACHEABLE, false); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Customer"); List<Customer> resultList = query.getResultList(); return CollectionUtils.isEmpty(resultList) ? null : resultList.get(0); }
private static boolean isEmpty(final ProcessGroupDTO dto) { if (dto == null) { return true; } final FlowSnippetDTO contents = dto.getContents(); if (contents == null) { return true; } return CollectionUtils.isEmpty(contents.getProcessors()) && CollectionUtils.isEmpty(contents.getConnections()) && CollectionUtils.isEmpty(contents.getFunnels()) && CollectionUtils.isEmpty(contents.getLabels()) && CollectionUtils.isEmpty(contents.getOutputPorts()) && CollectionUtils.isEmpty(contents.getProcessGroups()) && CollectionUtils.isEmpty(contents.getProcessors()) && CollectionUtils.isEmpty(contents.getRemoteProcessGroups()); }
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnv) { if (CollectionUtils.isEmpty(set)) return false; Map<String, TypeElement> converterMap = findAnnotation(roundEnv); if (!converterMap.isEmpty()) createRegister(converterMap); return true; }
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnv) { if (CollectionUtils.isEmpty(set)) return false; Map<String, List<TypeElement>> interceptorMap = findAnnotation(roundEnv); if (!interceptorMap.isEmpty()) createRegister(interceptorMap); return true; }
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnv) { if (CollectionUtils.isEmpty(set)) return false; Map<String, List<TypeElement>> websiteMap = findAnnotation(roundEnv); if (!websiteMap.isEmpty()) createRegister(websiteMap); return true; }
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnv) { if (CollectionUtils.isEmpty(set)) return false; Map<String, TypeElement> resolverMap = findAnnotation(roundEnv); if (!resolverMap.isEmpty()) createRegister(resolverMap); return true; }
protected Sku findMatchingSku(Product product, Map<String, String> attributeValuesForSku) { Sku matchingSku = null; List<Long> possibleSkuIds = new ArrayList<>(); for (Map.Entry<String, String> entry : MapUtils.emptyIfNull(attributeValuesForSku).entrySet()) { possibleSkuIds = productOptionValidationService.findSkuIdsForProductOptionValues(product.getId(), entry.getKey(), entry.getValue(), possibleSkuIds); if (CollectionUtils.isEmpty(possibleSkuIds)) { break; } } if (CollectionUtils.isNotEmpty(possibleSkuIds)) { matchingSku = catalogService.findSkuById(possibleSkuIds.iterator().next()); } return matchingSku; }
private void findMapping(Set<? extends Element> set, Map<TypeElement, List<ExecutableElement>> controllerMap) { for (Element element : set) { if (element instanceof ExecutableElement) { ExecutableElement execute = (ExecutableElement)element; Element enclosing = element.getEnclosingElement(); if (!(enclosing instanceof TypeElement)) continue; TypeElement type = (TypeElement)enclosing; Annotation restController = type.getAnnotation(RestController.class); Annotation controller = type.getAnnotation(Controller.class); if (restController == null && controller == null) { mLog.w(String.format("Controller/RestController annotations may be missing on %s.", type.getQualifiedName())); continue; } String host = type.getQualifiedName() + "#" + execute.getSimpleName() + "()"; Set<Modifier> modifiers = execute.getModifiers(); Validate.isTrue(!modifiers.contains(Modifier.PRIVATE), "The modifier private is redundant on %s.", host); if (modifiers.contains(Modifier.STATIC)) { mLog.w(String.format("The modifier static is redundant on %s.", host)); } List<ExecutableElement> elementList = controllerMap.get(type); if (CollectionUtils.isEmpty(elementList)) { elementList = new ArrayList<>(); controllerMap.put(type, elementList); } elementList.add(execute); } } }
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnv) { if (CollectionUtils.isEmpty(set)) return false; Map<TypeElement, List<ExecutableElement>> controllers = new HashMap<>(); findMapping(roundEnv.getElementsAnnotatedWith(RequestMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(GetMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(PostMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(PutMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(PatchMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(DeleteMapping.class), controllers); if (!controllers.isEmpty()) createHandlerAdapter(controllers); return true; }
protected boolean canSellDefaultSku(Product product) { return CollectionUtils.isEmpty(product.getAdditionalSkus()) || product.getCanSellWithoutOptions(); }
public static final boolean isRestoreEnabled(IConfiguration conf, InstanceInfo instanceInfo) { boolean isRestoreMode = StringUtils.isNotBlank(conf.getRestoreSnapshot()); boolean isBackedupRac = (CollectionUtils.isEmpty(conf.getBackupRacs()) || conf.getBackupRacs().contains(instanceInfo.getRac())); return (isRestoreMode && isBackedupRac); }
protected void updateOrderItemCartMessages(OrderItem orderItem) { List<String> cartMessages = gatherOrderItemCartMessages(orderItem); if (CollectionUtils.isEmpty(cartMessages)) { cartMessages = gatherProductCartMessages(orderItem); } orderItem.setCartMessages(cartMessages); orderItemService.saveOrderItem(orderItem); }
@Override @Transactional(TransactionUtils.DEFAULT_TRANSACTION_MANAGER) public GenericResponse sendForgotUsernameNotification(String emailAddress) { GenericResponse response = new GenericResponse(); List<Customer> customers = null; if (emailAddress != null) { customers = customerDao.readCustomersByEmail(emailAddress); } if (CollectionUtils.isEmpty(customers)) { response.addErrorCode("notFound"); } else { List<String> activeUsernames = new ArrayList<String>(); for (Customer customer : customers) { if (!customer.isDeactivated()) { activeUsernames.add(customer.getUsername()); } } if (activeUsernames.size() > 0) { HashMap<String, Object> vars = new HashMap<String, Object>(); vars.put("userNames", activeUsernames); sendEmail(emailAddress, getForgotUsernameEmailInfo(), vars); } else { // send inactive username found email. response.addErrorCode("inactiveUser"); } } return response; }