當前位置: 首頁>>代碼示例>>Java>>正文


Java CollectionUtils.isEmpty方法代碼示例

本文整理匯總了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;
}
 
開發者ID:rvillars,項目名稱:edoras-one-initializr,代碼行數:20,代碼來源:UiController.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:ServletServerHttpResponse.java

示例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;

}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:25,代碼來源:ReleaseService.java

示例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();
        }
    }
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:18,代碼來源:InterfaceCacheVo.java

示例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();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:AdvisedSupport.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:21,代碼來源:AbstractProcessListener.java

示例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);
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:9,代碼來源:BaseService4PayOrder.java

示例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);
    }
}
 
開發者ID:ukubuka,項目名稱:ukubuka-core,代碼行數:16,代碼來源:UkubukaTransformer.java

示例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;
}
 
開發者ID:namics,項目名稱:spring-i18n-support,代碼行數:18,代碼來源:SqlScriptWriter.java

示例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;
}
 
開發者ID:marlonwang,項目名稱:raven,代碼行數:50,代碼來源:JsonUtils.java

示例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;
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:18,代碼來源:AbstractXTreeBuilder.java

示例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);

}
 
開發者ID:muxiangqiu,項目名稱:linq,代碼行數:17,代碼來源:JpaUtil.java

示例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;
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:16,代碼來源:NamespaceService.java

示例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));
}
 
開發者ID:drtrang,項目名稱:dynamic-data-source-demo,代碼行數:10,代碼來源:BaseCodeServiceImpl.java


注:本文中的org.springframework.util.CollectionUtils.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。