本文整理匯總了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;
}