本文整理了Java中org.apache.commons.collections4.CollectionUtils.isEmpty()
方法的一些代码示例,展示了CollectionUtils.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.isEmpty()
方法的具体详情如下:
包路径:org.apache.commons.collections4.CollectionUtils
类名称:CollectionUtils
方法名:isEmpty
[英]Null-safe check if the specified collection is empty.
Null returns true.
[中]空安全检查指定的集合是否为空。
Null返回true。
代码示例来源:origin: org.apache.commons/commons-collections4
/**
* 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);
}
代码示例来源:origin: gocd/gocd
private boolean validateUserSelection(List<String> userNames, BulkUpdateUsersOperationResult result) {
if (CollectionUtils.isEmpty(userNames)) {
result.badRequest("No users selected.");
return false;
}
return true;
}
代码示例来源:origin: ethereum/ethereumj
public void addLogInfos(List<LogInfo> logInfos) {
if (!isEmpty(logInfos)) {
getLogInfoList().addAll(logInfos);
}
}
代码示例来源:origin: ethereum/ethereumj
public void addTouchAccounts(Set<byte[]> accounts) {
if (!isEmpty(accounts)) {
getTouchedAccounts().addAll(accounts);
}
}
代码示例来源:origin: ethereum/ethereumj
public void addDeleteAccounts(Set<DataWord> accounts) {
if (!isEmpty(accounts)) {
getDeleteAccounts().addAll(accounts);
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public Customer readCustomerByUsername(String username, Boolean cacheable) {
List<Customer> customers = readCustomersByUsername(username, cacheable);
return CollectionUtils.isEmpty(customers) ? null : customers.get(0);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public Customer readCustomerByEmail(String emailAddress) {
List<Customer> customers = readCustomersByEmail(emailAddress);
return CollectionUtils.isEmpty(customers) ? null : customers.get(0);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@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);
}
代码示例来源:origin: apache/nifi
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());
}
代码示例来源:origin: yanzhenjie/AndServer
@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;
}
代码示例来源:origin: yanzhenjie/AndServer
@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;
}
代码示例来源:origin: yanzhenjie/AndServer
@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;
}
代码示例来源:origin: yanzhenjie/AndServer
@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;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
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;
}
代码示例来源:origin: yanzhenjie/AndServer
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);
}
}
}
代码示例来源:origin: yanzhenjie/AndServer
@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;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected boolean canSellDefaultSku(Product product) {
return CollectionUtils.isEmpty(product.getAdditionalSkus()) || product.getCanSellWithoutOptions();
}
代码示例来源:origin: Netflix/Priam
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);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected void updateOrderItemCartMessages(OrderItem orderItem) {
List<String> cartMessages = gatherOrderItemCartMessages(orderItem);
if (CollectionUtils.isEmpty(cartMessages)) {
cartMessages = gatherProductCartMessages(orderItem);
}
orderItem.setCartMessages(cartMessages);
orderItemService.saveOrderItem(orderItem);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@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;
}
内容来源于网络,如有侵权,请联系作者删除!