本文整理汇总了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()));
}
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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));
}