本文整理汇总了Java中org.springframework.util.CollectionUtils.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.isEmpty方法的具体用法?Java CollectionUtils.isEmpty怎么用?Java CollectionUtils.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapDependency
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
private static Map<String, Object> mapDependency(DependencyItem item) {
Map<String, Object> result = new HashMap<>();
Dependency d = item.dependency;
result.put("id", d.getId());
result.put("name", d.getName());
result.put("group", item.group);
if (d.getDescription() != null) {
result.put("description", d.getDescription());
}
if (d.getWeight() > 0) {
result.put("weight", d.getWeight());
}
if (!CollectionUtils.isEmpty(d.getKeywords()) || !CollectionUtils.isEmpty(d.getAliases())) {
List<String> all = new ArrayList<>(d.getKeywords());
all.addAll(d.getAliases());
result.put("keywords", StringUtils.collectionToCommaDelimitedString(all));
}
return result;
}
示例2: get
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
@Override
public List<String> get(Object key) {
Assert.isInstanceOf(String.class, key, "Key must be a String-based header name");
Collection<String> values1 = servletResponse.getHeaders((String) key);
boolean isEmpty1 = CollectionUtils.isEmpty(values1);
List<String> values2 = super.get(key);
boolean isEmpty2 = CollectionUtils.isEmpty(values2);
if (isEmpty1 && isEmpty2) {
return null;
}
List<String> values = new ArrayList<String>();
if (!isEmpty1) {
values.addAll(values1);
}
if (!isEmpty2) {
values.addAll(values2);
}
return values;
}
示例3: calculateBranchModifiedItemsAccordingToRelease
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
private Map<String, String> calculateBranchModifiedItemsAccordingToRelease(
Map<String, String> masterReleaseConfigs,
Map<String, String> branchReleaseConfigs) {
Map<String, String> modifiedConfigs = new HashMap<>();
if (CollectionUtils.isEmpty(branchReleaseConfigs)) {
return modifiedConfigs;
}
if (CollectionUtils.isEmpty(masterReleaseConfigs)) {
return branchReleaseConfigs;
}
for (Map.Entry<String, String> entry : branchReleaseConfigs.entrySet()) {
if (!Objects.equals(entry.getValue(), masterReleaseConfigs.get(entry.getKey()))) {
modifiedConfigs.put(entry.getKey(), entry.getValue());
}
}
return modifiedConfigs;
}
示例4: getKeyFromServer
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
private String getKeyFromServer() {
RestTemplate keyUriRestTemplate = new RestTemplate();
if (!CollectionUtils.isEmpty(this.customizers)) {
for (JwtAccessTokenConverterRestTemplateCustomizer customizer : this.customizers) {
customizer.customize(keyUriRestTemplate);
}
}
HttpHeaders headers = new HttpHeaders();
String username = this.resource.getClientId();
String password = this.resource.getClientSecret();
if (username != null && password != null) {
byte[] token = Base64.getEncoder()
.encode((username + ":" + password).getBytes());
headers.add("Authorization", "Basic " + new String(token));
}
HttpEntity<Void> request = new HttpEntity<>(headers);
String url = this.resource.getJwt().getKeyUri();
return (String) keyUriRestTemplate
.exchange(url, HttpMethod.GET, request, Map.class).getBody()
.get("value");
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:22,代码来源:ResourceServerTokenServicesConfiguration.java
示例5: setIface
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
public void setIface(InterfaceInfo iface) {
if (iface != null) {
this.interfaceId = iface.getInterfaceId();
this.interfaceName = iface.getInterfaceName();
if (iface.getCreateTime() != null) {
this.createTime = iface.getCreateTime().getTime();
}
if (!CollectionUtils.isEmpty(iface.getVersionList())) {
for (IfaceAliasVersion version : iface.getVersionList()) {
versionMap.put(version.getAlias(), version.getDataVersion());
}
}
if (iface.getConfigUpdateTime() != null) {
this.configUpdateTime = iface.getConfigUpdateTime().getTime();
}
}
}
示例6: addAdvisors
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* Add all of the given advisors to this proxy configuration.
* @param advisors the advisors to register
*/
public void addAdvisors(Collection<Advisor> advisors) {
if (isFrozen()) {
throw new AopConfigException("Cannot add advisor: Configuration is frozen.");
}
if (!CollectionUtils.isEmpty(advisors)) {
for (Advisor advisor : advisors) {
if (advisor instanceof IntroductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
}
Assert.notNull(advisor, "Advisor must not be null");
this.advisors.add(advisor);
}
updateAdvisorArray();
adviceChanged();
}
}
示例7: compareReply
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* 将当前的符合条件的processIds和当前的reply queue进行校对,剔除不在processIds里的内容
*/
protected synchronized void compareReply(List<Long> processIds) {
Object[] replyIds = replyProcessIds.toArray();
for (Object replyId : replyIds) {
if (processIds.contains((Long) replyId) == false) { // 判断reply id是否在当前processId列表中
// 因为存在并发问题,如在执行Listener事件的同时,可能触发了process的创建,这时新建的processId会进入到reply队列中
// 此时接受到的processIds变量为上一个版本的内容,所以会删除新建的process,导致整个通道被挂住
if (CollectionUtils.isEmpty(processIds) == false) {
Long processId = processIds.get(0);
if (processId > (Long) replyId) { // 如果当前最小的processId都大于replyId, processId都是递增创建的
logger.info("## {} remove reply id [{}]", ClassUtils.getShortClassName(this.getClass()),
(Long) replyId);
replyProcessIds.remove((Long) replyId);
}
}
}
}
}
示例8: baseSelectByMchIdAndMchOrderNo
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
public PayOrder baseSelectByMchIdAndMchOrderNo(String mchId, String mchOrderNo) {
PayOrderExample example = new PayOrderExample();
PayOrderExample.Criteria criteria = example.createCriteria();
criteria.andMchIdEqualTo(mchId);
criteria.andMchOrderNoEqualTo(mchOrderNo);
List<PayOrder> payOrderList = payOrderMapper.selectByExample(example);
return CollectionUtils.isEmpty(payOrderList) ? null : payOrderList.get(0);
}
示例9: performTypeOperations
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* Perform Type Operations
*
* @param fileContents
* @param transformOperations
* @throws TransformException
*/
private void performTypeOperations(FileContents fileContents,
final List<TransformOperations> transformOperations)
throws TransformException {
if (!CollectionUtils.isEmpty(transformOperations)) {
LOGGER.info("Transform Count: #{}", transformOperations.size());
performTransformOperations(fileContents, transformOperations);
}
}
示例10: replacePlaceholders
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* Replaces the placeholders in the query template with correct configured item names.
*/
private String replacePlaceholders(String template) {
LOG.info("Replace placeholders " + template);
String result = template.replaceAll("##MESSAGE##", this.message);
result = result.replaceAll("##TABLE##", this.table);
result = result.replaceAll("##CODEID##", this.codeId);
result = result.replaceAll("##LANGID##", this.langId);
result = result.replaceAll("##TYPE##", this.type);
if (!CollectionUtils.isEmpty(this.placeholders)) {
for (Entry<String, String> entry : this.placeholders.entrySet()) {
result = result.replaceAll(entry.getKey(), entry.getValue());
}
}
return result;
}
示例11: json2map
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
*
* 将json串转为map对象<br>
*
* @param jsonStr
* @param clazz
* @return
* Map<String,T>
* @Author fanyaowu
* @data 2014年7月9日
* @exception
* @version
*
*/
public static <T> Map<String, T> json2map(String jsonStr, Class<T> clazz)
{
// 入參校驗
if (StringUtils.isEmpty(jsonStr))
{
return null;
}
Map<String, Map<String, Object>> map = null;
try
{
map = objectMapper.readValue(jsonStr,
new TypeReference<Map<String, T>>()
{
});
}
catch (IOException e)
{
}
// 非空校验
if (CollectionUtils.isEmpty(map))
{
return null;
}
Map<String, T> result = new HashMap<String, T>();
for (Entry<String, Map<String, Object>> entry : map.entrySet())
{
result.put(entry.getKey(), map2pojo(entry.getValue(), clazz));
}
return result;
}
示例12: getTreeNodeById
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* 根据treeNodeId获取TreeNode对象
* @param treeNodeId
* @param allTreeNodeList
* @return
*/
protected T getTreeNodeById(I treeNodeId, List<T> allTreeNodeList) {
if(CollectionUtils.isEmpty(allTreeNodeList) || ObjectUtils.isEmpty(treeNodeId)){
return null;
}
for(T treeNode : allTreeNodeList){
if(treeNode != null && treeNodeId.equals(getTreeNodeId(treeNode))){
return treeNode;
}
}
return null;
}
示例13: index
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
/**
* source转Map,Key为source元素主键属性属性值,Value为该元素
* @param source 源集合
* @param <K> propertyName对应的属性的类型
* @param <V> source集合元素类型
* @return 索引Map
*/
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> index(Collection<V> source) {
if (CollectionUtils.isEmpty(source)) {
return Collections.EMPTY_MAP;
}
String idName = getIdName(source.iterator().next().getClass());
return index(source, idName);
}
示例14: filterChildNamespace
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
private List<Namespace> filterChildNamespace(List<Namespace> namespaces) {
List<Namespace> result = new LinkedList<>();
if (CollectionUtils.isEmpty(namespaces)) {
return result;
}
for (Namespace namespace : namespaces) {
if (!isChildNamespace(namespace)) {
result.add(namespace);
}
}
return result;
}
示例15: checkList
import org.springframework.util.CollectionUtils; //导入方法依赖的package包/类
private static Optional<List<BaseCode>> checkList(List<BaseCode> all, Integer officeAddress) {
if (CollectionUtils.isEmpty(all)) {
return Optional.empty();
}
//将查询结果按照 office-address 分组,office-address 不能为 null,默认值为 0
Map<Integer, List<BaseCode>> map = all.stream().collect(groupingBy(BaseCode::getOfficeAddress));
//查找当前 office-address 的 value,若没有,则返回默认值,0 为默认值,若没有默认值则返回 Optional.empty()
return map.containsKey(officeAddress) ? Optional.of(map.get(officeAddress)) : Optional.ofNullable(map.get(0));
}