本文整理汇总了Java中org.apache.commons.collections.MapUtils.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java MapUtils.isEmpty方法的具体用法?Java MapUtils.isEmpty怎么用?Java MapUtils.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections.MapUtils
的用法示例。
在下文中一共展示了MapUtils.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEventParams
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
* 创建Webhook事件参数
*
* @param webhookId
* @param eventType
* @param paramMap
* @return
*/
public List<WebhookEventParam> createEventParams(int webhookId, int eventType, Map<String, String> paramMap) {
if (MapUtils.isEmpty(paramMap)) {
return Collections.emptyList();
}
List<WebhookEventParam> webhookEventParams = new ArrayList<>();
WebhookEventParam webhookEventParam = null;
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
webhookEventParam = newWebhookEventParam(webhookId, eventType, entry.getKey(), entry.getValue());
webhookEventParams.add(webhookEventParam);
}
if (CollectionUtils.isNotEmpty(webhookEventParams)) {
eventParamMapper.batchInsert(webhookEventParams);
}
return webhookEventParams;
}
示例2: createRequestParams
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
* 创建Webhook请求参数
*
* @param webhookId
* @param paramMap
* @return
*/
public List<WebhookRequestParam> createRequestParams(int webhookId, Map<String, String> paramMap) {
if (MapUtils.isEmpty(paramMap)) {
return Collections.emptyList();
}
List<WebhookRequestParam> webhookRequestParams = new ArrayList<>();
WebhookRequestParam webhookRequestParam = null;
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
webhookRequestParam = newWebhookRequestParam(webhookId, entry.getKey(), entry.getValue());
webhookRequestParams.add(webhookRequestParam);
}
if (CollectionUtils.isNotEmpty(webhookRequestParams)) {
webhookRequestParamMapper.batchInsert(webhookRequestParams);
}
return webhookRequestParams;
}
示例3: extractServiceMetaData
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private Map<String, Object> extractServiceMetaData(RouteVM routeVM) {
Objects.requireNonNull(routeVM,
"Can't extract service metadata because routeVM is not pass");
Map<String, String> serviceInstancesStatus = routeVM.getServiceInstancesStatus();
if (MapUtils.isEmpty(serviceInstancesStatus)) {
log.error("Microservice instances has no statuses");
return null;
}
Map<String, Object> result = null;
for (ServiceInstance instance : routeVM.getServiceInstances()) {
if (instance.getUri() == null || StringUtils.isBlank(instance.getUri().toString())) {
continue;
}
String uri = instance.getUri().toString();
if ("UP".equals(serviceInstancesStatus.get(uri))) {
if (result == null) {
result = new HashMap<>();
}
result.put(uri, getInstanceInfo(uri));
}
}
return result;
}
示例4: afterPropertiesSet
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
//获取服务注册中心
IRegisterCenter4Invoker registerCenter4Consumer = ZKRegisterCenter.singleton();
//初始化服务提供者列表到本地缓存
registerCenter4Consumer.initProviderMap(remoteAppKey, groupName);
//初始化Netty Channel,providerMap提供几个服务接口就是几个
Map<String, List<ProviderService>> providerMap = registerCenter4Consumer.getServiceMetaDataMap4Consume();
if (MapUtils.isEmpty(providerMap)) {
throw new RuntimeException("service provider list is empty.");
}
NettyChannelPoolFactory.channelPoolFactoryInstance().initChannelPoolFactory(providerMap);
//获取服务提供者代理对象
RevokerProxyBeanFactory proxyFactory = RevokerProxyBeanFactory.singleton(targetInterface, timeout, clusterStrategy);
this.serviceObject = proxyFactory.getProxy();
//将消费者信息注册到注册中心
InvokerService invoker = new InvokerService();
invoker.setServiceItf(targetInterface);
invoker.setRemoteAppKey(remoteAppKey);
invoker.setGroupName(groupName);
registerCenter4Consumer.registerInvoker(invoker);
}
示例5: getBeanMap
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private Map<Object, Object> getBeanMap(Object obj) throws Exception {
Map oMap = new BeanMap(obj);
Map rMap = new HashMap();
if (MapUtils.isEmpty(oMap)) {
throw new Exception("实体类没有可用属性");
} else {
// 去除class属性
for (Object key : oMap.keySet()) {
if (!"class".equals(key)) {
rMap.put(key, oMap.get(key));
}
}
}
return rMap;
}
示例6: registerBeans
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
* 注册,可以对beanName进行修改
*
* @param beanDefinitions BeanDefinition的map集合(key为beanName, value为BeanDefinition)
* @param registry spring注册Bean的对象
*/
public static void registerBeans(Map<String, BeanDefinition> beanDefinitions, BeanDefinitionRegistry registry, BeanNameBuilder builder) {
if (MapUtils.isEmpty(beanDefinitions)) {
return;
}
if (registry == null) {
return;
}
Set<String> beanNames = beanDefinitions.keySet();
for (String beanName : beanNames) {
BeanDefinition bean = beanDefinitions.get(beanName);
beanName = builder.buildBeanName(beanName, bean);
if (registry.containsBeanDefinition(beanName)) {
continue;
}
registry.registerBeanDefinition(beanName, bean);
}
}
示例7: podRequestsCNI
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private static boolean podRequestsCNI(PodSpec podSpec) {
// if we don't have a cluster that supports CNI port mapping make sure that we don't either (1) specify
// any networks and/ (2) if we are make sure we didn't explicitly do any port mapping or that
// any of the tasks ask for ports (which will automatically be forwarded, this requiring port mapping).
for (NetworkSpec networkSpec : podSpec.getNetworks()) {
if (!MapUtils.isEmpty(networkSpec.getPortMappings())) {
return true;
}
}
for (TaskSpec taskSpec : podSpec.getTasks()) {
for (ResourceSpec resourceSpec : taskSpec.getResourceSet().getResources()) {
if (resourceSpec.getName().equals("ports")) {
return true;
}
}
}
return false;
}
示例8: policyExists
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private boolean policyExists( String policyId )
{
if ( MapUtils.isEmpty( prePolicies ) )
{
log.error( "No PreDownloadPolicies found!" );
return false;
}
if ( MapUtils.isEmpty( postPolicies ) )
{
log.error( "No PostDownloadPolicies found!" );
return false;
}
return ( prePolicies.containsKey( policyId ) || postPolicies.containsKey( policyId )
|| downloadErrorPolicies.containsKey( policyId ) );
}
示例9: getServiceProviderMappedUserRoles
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
* @param applicationConfig
* @param locallyMappedUserRoles
* @return
*/
private static String getServiceProviderMappedUserRoles(ApplicationConfig applicationConfig,
List<String> locallyMappedUserRoles, String claimSeparator)
throws FrameworkException {
Map<String, String> localToSpRoleMapping = applicationConfig.getRoleMappings();
if (!MapUtils.isEmpty(localToSpRoleMapping)) {
for (Map.Entry<String, String> roleMapping : localToSpRoleMapping.entrySet()) {
if (locallyMappedUserRoles.contains(roleMapping.getKey())) {
locallyMappedUserRoles.remove(roleMapping.getKey());
locallyMappedUserRoles.add(roleMapping.getValue());
}
}
}
return StringUtils.join(locallyMappedUserRoles, claimSeparator);
}
示例10: setEnv
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private void setEnv() {
if (CollectionUtils.isNotEmpty(config.getEnv())) {
Map<String, Object> envsToAdd = new HashMap<>(config.getEnv().size());
for (MarathonVars var : config.getEnv()) {
envsToAdd.put(
Util.replaceMacro(var.getName(), envVars),
Util.replaceMacro(var.getValue(), envVars));
}
if (MapUtils.isEmpty(getApp().getEnv())) {
getApp().setEnv(envsToAdd);
} else {
getApp().getEnv().putAll(envsToAdd);
}
}
}
示例11: convertPropertiesToMap
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
public static void convertPropertiesToMap(Map<String, String> results, Properties properties) {
if(results == null) {
LOGGER.error("params:[results] is null");
return;
}
if(MapUtils.isEmpty(properties)) {
LOGGER.error(("params:[properties] is empty"));
return;
}
Iterator<?> iterator = properties.keySet().iterator();
String key = null;
String value = null;
while(iterator.hasNext()) {
key = iterator.next().toString();
if(key.startsWith(COMMENT_PREFIX)) {
// 注释的属性不加载
continue;
}
value = properties.getProperty(key);
if(StringUtils.isBlank(value)) {
LOGGER.error(String.format("properties file has valid value, key[%s]", key));
continue;
}
results.put(key, value);
}
}
示例12: buildEntityWithBodyParam
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
*
* @param map
*
* @return HttpEntity
*/
public static HttpEntity buildEntityWithBodyParam(Map<String, String> map) {
if (MapUtils.isEmpty(map)) {
return null;
}
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
map.forEach((k, v) -> builder.addTextBody(k, v));
return builder.build();
}
示例13: buildMultiPartEntity
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
* @param buildMap
* @param partParam
*
* @return HttpEntity
*/
public static HttpEntity buildMultiPartEntity(Map<String, String> buildMap, Map<String, ContentBody> partParam) {
if (MapUtils.isEmpty(buildMap)) {
return null;
}
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
buildMap.forEach((k, v) -> builder.addTextBody(k, v));
if (MapUtils.isNotEmpty(partParam)) {
partParam.forEach((k, v) -> builder.addPart(k, v));
}
return builder.build();
}
示例14: articlesFromChannelMap
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private List<Article> articlesFromChannelMap(long userId, Map<Channel, List<Document>> channelMap, int limit) {
if (MapUtils.isEmpty(channelMap)) {
return Collections.emptyList();
}
Map<Channel, List<Document>> filteredMap = new HashMap<>();
channelMap.entrySet().forEach(e -> filteredMap.put(e.getKey(), e.getValue().stream().limit(limit).collect(Collectors.toList())));
List<Article> articles = new ArrayList<>();
filteredMap.entrySet().forEach(e -> articles.addAll(Article.of(e.getKey(), e.getValue().stream().collect(Collectors.toList()))));
FeedUtils.markBookmarks(articles, articleDao.getBookmarked(userId));
return FeedUtils.sort(articles);
}
示例15: doRequest
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
protected int doRequest(Jedis jedis, String redisAddress) {
Map<byte[], byte[]> redisData = jedis.hgetAll(key.getBytes());
redisDataList[index] = redisData;
if (MapUtils.isEmpty(redisData)) {
String verbose = String.format("get all for key [%s] from [%s] is empty", key, redisAddress);
LOGGER.debug(verbose);
return 1;
}
return 0;
}