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


Java CollectionUtils.emptyIfNull方法代碼示例

本文整理匯總了Java中org.apache.commons.collections4.CollectionUtils.emptyIfNull方法的典型用法代碼示例。如果您正苦於以下問題:Java CollectionUtils.emptyIfNull方法的具體用法?Java CollectionUtils.emptyIfNull怎麽用?Java CollectionUtils.emptyIfNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.collections4.CollectionUtils的用法示例。


在下文中一共展示了CollectionUtils.emptyIfNull方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateVirtualSystems

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
public void validateVirtualSystems(List<Long> vsIds, VirtualizationConnector vc) throws Exception {
	// make sure all the virtual system in the sfc dto list exist otherwise
	// throw
       for (Long vsId : CollectionUtils.emptyIfNull(vsIds)) {
           VirtualSystem virtualSystem = VirtualSystemEntityMgr.findById(this.em, vsId);
           if (virtualSystem == null) {
               throw new VmidcBrokerValidationException("VirtualSytem with id " + vsId + " is not found.");
           } else if (!vc.getVirtualSystems().contains(virtualSystem)) {
               throw new VmidcBrokerValidationException(String.format(
                       "Virtual system with id %s and with Virtualization Connector id %s does not match the virtualization connector"
                               + " under which this Service function chain is being created/updated",
                       vsId, virtualSystem.getVirtualizationConnector().getId()));
           }
       }

}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:17,代碼來源:ServiceFunctionChainRequestValidator.java

示例2: exec

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
@Override
public BaseResponse exec(AddOrUpdateServiceFunctionChainRequest request, EntityManager em) throws Exception {

	if (this.validator == null) {
		this.validator = this.validatorFactory.create(em);
	}

	//TODO: karimull Check for SFC in use before update ; after binding and installinspectionhook task are done

	ServiceFunctionChain sfc = this.validator.validateAndLoad(request);

	// remove old/existing list

       if (CollectionUtils.emptyIfNull(sfc.getVirtualSystems()) != null) {
           sfc.getVirtualSystems().clear();
       }

	//update the entity to remove all the primary key association in case of a shuffle in the vsid list
	OSCEntityManager.update(em, sfc, this.txBroadcastUtil);
	em.flush();

	// add the new vsid list to entity
	for (Long vsId : CollectionUtils.emptyIfNull(request.getVirtualSystemIds())) {
		sfc.addVirtualSystem(VirtualSystemEntityMgr.findById(em, vsId));
	}
	OSCEntityManager.update(em, sfc, this.txBroadcastUtil);

	BaseResponse response = new BaseResponse();
	response.setId(sfc.getId());

	return response;
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:33,代碼來源:UpdateServiceFunctionChainService.java

示例3: registerServiceFunctionChain

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
protected ServiceFunctionChain registerServiceFunctionChain(String name, Long entityId, VirtualizationConnector vc,
		List<Long> vsIds) {
	List<VirtualSystem> virutalSystems = new ArrayList<VirtualSystem>();

	for (Long vsId : CollectionUtils.emptyIfNull(vsIds)) {
		VirtualSystem vs = newVirtualSystem(vc);
		vs.setId(vsId);
		virutalSystems.add(vs);
	}
	ServiceFunctionChain sfc = new ServiceFunctionChain(name, vc);
	sfc.setVirtualSystems(virutalSystems);
	sfc.setId(entityId);
	when(this.em.find(ServiceFunctionChain.class, sfc.getId())).thenReturn(sfc);
	return sfc;
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:16,代碼來源:BaseServiceFunctionChainRequestValidatorTest.java

示例4: getFortifyResource

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Create an authenticated request and return the data. The created
 * processor is entirely managed : opened and closed.
 */
@SuppressWarnings("unchecked")
private Collection<Map<String, Object>> getFortifyResource(final Map<String, String> parameters,
		final String resource) throws IOException {
	final FortifyCurlProcessor processor = new FortifyCurlProcessor();
	try {
		authenticate(parameters, processor);
		return CollectionUtils
				.emptyIfNull((List<Map<String, Object>>) getFortifyResource(parameters, resource, processor));
	} finally {
		processor.close();
	}
}
 
開發者ID:ligoj,項目名稱:plugin-security-fortify,代碼行數:17,代碼來源:FortifyPluginResource.java

示例5: exec

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
@Override
public BaseResponse exec(AddOrUpdateServiceFunctionChainRequest request, EntityManager em) throws Exception {

	if (this.validator == null) {
		this.validator = this.validatorFactory.create(em);
	}
	this.validator.validate(request);

	VirtualizationConnector vc = VirtualizationConnectorEntityMgr.findById(em, request.getDto().getParentId());

	ServiceFunctionChain sfc = new ServiceFunctionChain(request.getName(), vc);

	for (Long vsId : CollectionUtils.emptyIfNull(request.getVirtualSystemIds())) {
		sfc.addVirtualSystem(VirtualSystemEntityMgr.findById(em, vsId));
	}

	OSCEntityManager.create(em, sfc, this.txBroadcastUtil);

	BaseResponse response = new BaseResponse();
	response.setId(sfc.getId());

	return response;

}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:25,代碼來源:AddServiceFunctionChainService.java

示例6: remove

import org.apache.commons.collections4.CollectionUtils; //導入方法依賴的package包/類
/**
 * Removes all values associated with the specified key.
 * <p>
 * A subsequent <code>get(Object)</code> would return an empty collection.
 *
 * @param key  the key to remove values from
 * @return the <code>Collection</code> of values removed, will return an
 *   empty, unmodifiable collection for no mapping found
 */
@Override
public Collection<V> remove(Object key) {
    return CollectionUtils.emptyIfNull(getMap().remove(key));
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:14,代碼來源:AbstractMultiValuedMap.java


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