Java Code Examples for org.apache.commons.collections4.MapUtils#isEmpty()
The following examples show how to use
org.apache.commons.collections4.MapUtils#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CarreraConfiguration.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public boolean validate() throws ConfigException { if (CollectionUtils.isEmpty(retryDelays)) { throw new ConfigException("[CarreraConfiguration] retryDelays empty"); } else if (thriftServer == null || !thriftServer.validate()) { throw new ConfigException("[CarreraConfiguration] thriftServer error"); } else if (useKafka && (kafkaProducers <= 0 || MapUtils.isEmpty(kafkaConfigurationMap) || !kafkaConfigurationMap.values().stream().allMatch(KafkaConfiguration::validate))) { throw new ConfigException("[CarreraConfiguration] kafka config error"); } else if (useRocketmq && (rocketmqProducers <= 0 || MapUtils.isEmpty(rocketmqConfigurationMap) || !rocketmqConfigurationMap.values().stream().allMatch(RocketmqConfiguration::validate))) { throw new ConfigException("[CarreraConfiguration] rocketmq config error"); } else if (useAutoBatch && (autoBatch == null || !autoBatch.validate())) { throw new ConfigException("[CarreraConfiguration] autoBatch error"); } else if (maxTps <= 0) { throw new ConfigException("[CarreraConfiguration] maxTps <= 0"); } else if (tpsWarningRatio <= 0) { throw new ConfigException("[CarreraConfiguration] tpsWarningRatio <= 0"); } else if (defaultTopicInfoConf == null) { throw new ConfigException("[CarreraConfiguration] defaultTopicInfoConf is null"); } return true; }
Example 2
Source File: ServiceGetterTest.java From multiapps-controller with Apache License 2.0 | 6 votes |
@ParameterizedTest @MethodSource public void testGetServiceInstanceEntity(Map<String, Object> serviceInstanceGetterResponse, Map<String, Object> userProvidedInstanceGetterResponse) { prepareServiceGetters(serviceInstanceGetterResponse, userProvidedInstanceGetterResponse); Map<String, Object> serviceInstanceEntity = serviceGetter.getServiceInstanceEntity(client, SERVICE_NAME, SPACE_ID); if (MapUtils.isEmpty(serviceInstanceGetterResponse)) { assertEquals(userProvidedInstanceGetterResponse, serviceInstanceEntity); verify(userProvidedInstanceGetter).getServiceInstanceEntity(client, SERVICE_NAME, SPACE_ID); return; } assertEquals(serviceInstanceGetterResponse, serviceInstanceEntity); verify(serviceInstanceGetter).getServiceInstanceEntity(client, SERVICE_NAME, SPACE_ID); }
Example 3
Source File: RedisServiceMonitorRetriever.java From Thunder with Apache License 2.0 | 5 votes |
public Map<String, String> retrieveFromCluster(String traceId) throws Exception { JedisCluster cluster = RedisClusterFactory.getCluster(); if (cluster == null) { throw new MonitorException("No redis cluster found, retrieve failed"); } Map<String, String> monitorStatMap = cluster.hgetAll(traceId); if (MapUtils.isEmpty(monitorStatMap)) { return null; } return monitorStatMap; }
Example 4
Source File: SharedInformerFactory.java From java with Apache License 2.0 | 5 votes |
/** Start all registered informers. */ public synchronized void startAllRegisteredInformers() { if (MapUtils.isEmpty(informers)) { return; } informers.forEach( (informerType, informer) -> startedInformers.computeIfAbsent( informerType, key -> informerExecutor.submit(informer::run))); }
Example 5
Source File: RedisServiceMonitorRetriever.java From Thunder with Apache License 2.0 | 5 votes |
public List<MonitorStat> retrieve(String traceId, RedisType redisType) throws Exception { if (StringUtils.isEmpty(traceId)) { throw new MonitorException("Trace ID is null"); } if (redisType == null) { throw new MonitorException("Redis type is null"); } Map<String, String> monitorStatMap = null; switch (redisType) { case REDIS_SENTINEL: monitorStatMap = retrieveFromSentinel(traceId); break; case REDIS_CLUSTER: monitorStatMap = retrieveFromCluster(traceId); break; } if (MapUtils.isEmpty(monitorStatMap)) { return null; } List<MonitorStat> monitorStatList = retrieve(monitorStatMap); sort(monitorStatList); return monitorStatList; }
Example 6
Source File: ComOptimizationServiceImpl.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public int calculateBestMailing(ComOptimization optimization) { Hashtable<Integer , CampaignStatEntry> stats = optimizationStatService.getStat(optimization); if(MapUtils.isEmpty(stats)) { return -1; } int[] mailingIDs = { optimization.getGroup2(), optimization.getGroup3(), optimization.getGroup4(), optimization.getGroup5() }; int bestMailingID = optimization.getGroup1(); double bestRate = calculateFactor(stats.get(optimization.getGroup1()), optimization.getEvalType()); for(Integer mailingID : mailingIDs) { if( stats.containsKey(mailingID)) { if( bestRate < calculateFactor(stats.get(mailingID),optimization.getEvalType())) { bestMailingID = mailingID; } } } return bestMailingID; }
Example 7
Source File: ConsumeGroupVo.java From DDMQ with Apache License 2.0 | 5 votes |
private static Map<String, List<Long>> getConsumeModeStringMapper(Map<Long, List<Long>> mapper) { if (MapUtils.isEmpty(mapper)) { return null; } Map<String, List<Long>> stringMapper = Maps.newHashMap(); for (Map.Entry<Long, List<Long>> entry : mapper.entrySet()) { stringMapper.put(String.valueOf(entry.getKey()), entry.getValue()); } return stringMapper; }
Example 8
Source File: ConfigManager.java From DDMQ with Apache License 2.0 | 5 votes |
private void checkAndUpdateKafkaConfig(Map<String, KafkaConfiguration> oldConfig, Map<String, KafkaConfiguration> newConfig) { if (MapUtils.isEmpty(newConfig)) { LOGGER.info("rmq config is null or empty, illegal"); return; } for (Map.Entry<String, KafkaConfiguration> config : newConfig.entrySet()) { if (oldConfig == null || !config.getValue().equals(oldConfig.get(config.getKey()))) { if (producerManager != null) { try { producerManager.addAndUpdateRmqProducer(config.getKey(), ProducerType.KAFKA); LogUtils.getMainLogger().info("kafka broker cluster update config success, cluster:{}", config.getKey()); } catch (Exception ex) { LogUtils.logError("ConfigManager.checkAndUpdateKafkaConfig", "broker cluster" + config.getKey() + "start failed", ex); } } } } Set<String> brokerClustersDel = new HashSet<>(oldConfig.keySet()); brokerClustersDel.removeAll(newConfig.keySet()); LogUtils.getMainLogger().info("kafka broker cluster delete:{}", brokerClustersDel); for (String brokerCluster : brokerClustersDel) { producerManager.deleteCluster(brokerCluster); } LogUtils.getMainLogger().info("kafka cluster update completely"); }
Example 9
Source File: NavigationState.java From cuba with Apache License 2.0 | 5 votes |
/** * @return joined by "&" sign URL params, or empty string if no params for this state */ public String getParamsString() { if (MapUtils.isEmpty(params)) { return ""; } return params.entrySet() .stream() .map(entry -> String.format("%s=%s", entry.getKey(), URLEncodeUtils.encodeUtf8(entry.getValue()))) .collect(Collectors.joining("&")); }
Example 10
Source File: BaseEnumUtil.java From spring-boot-plus with Apache License 2.0 | 5 votes |
/** * 通过code获取描述 * * @param baseEnumType * @param code * @return */ public static EnumVo<? extends BaseEnum> getEnumVo(Class<? extends BaseEnum> baseEnumType, Integer code) { Map<Integer, EnumVo<? extends BaseEnum>> map = getMap(baseEnumType); if (MapUtils.isEmpty(map)) { return null; } return map.get(code); }
Example 11
Source File: AlertGroupFilterFactory.java From incubator-pinot with Apache License 2.0 | 5 votes |
public static AlertGroupFilter fromSpec(Map<String, String> spec) { if (MapUtils.isEmpty(spec)) { spec = Collections.emptyMap(); } AlertGroupFilter alertGroupFilter = fromStringType(spec.get(GROUP_FILTER_TYPE_KEY)); alertGroupFilter.setParameters(spec); return alertGroupFilter; }
Example 12
Source File: BaseEnumUtil.java From spring-boot-plus with Apache License 2.0 | 5 votes |
/** * 通过类型获取枚举desc集合 * * @param baseEnumType * @return */ public static Collection<EnumVo<? extends BaseEnum>> getDescList(Class<? extends BaseEnum> baseEnumType) { Map<Integer, EnumVo<? extends BaseEnum>> map = getMap(baseEnumType); if (MapUtils.isEmpty(map)) { return null; } return map.values(); }
Example 13
Source File: PackagesHelper.java From remote-monitoring-services-java with MIT License | 5 votes |
public static boolean isEdgePackage(String packageContent) { final Configuration pckgContent = fromJson(Json.parse(packageContent), Configuration.class); if (MapUtils.isNotEmpty(pckgContent.getContent().getModulesContent()) && MapUtils.isEmpty(pckgContent.getContent().getDeviceContent())) { return true; } return false; }
Example 14
Source File: ServiceOperationGetter.java From multiapps-controller with Apache License 2.0 | 5 votes |
public ServiceOperation getLastServiceOperation(ProcessContext context, CloudServiceInstanceExtended service) { Map<String, Object> serviceInstanceEntity = getServiceInstanceEntity(context, service); if (MapUtils.isEmpty(serviceInstanceEntity)) { return getLastDeleteServiceOperation(context, service); } return getLastServiceOperation(serviceInstanceEntity); }
Example 15
Source File: HygieiaUtils.java From hygieia-core with Apache License 2.0 | 4 votes |
public static boolean allowAutoDiscover(FeatureFlag featureFlag, CollectorType collectorType) { if(featureFlag == null) return false; String key = StringUtils.lowerCase(collectorType.toString()); if(MapUtils.isEmpty(featureFlag.getFlags()) || Objects.isNull(featureFlag.getFlags().get(key))) return false; return BooleanUtils.toBoolean(featureFlag.getFlags().get(StringUtils.lowerCase(collectorType.toString()))); }
Example 16
Source File: ApacheCommonsUtils.java From dss with GNU Lesser General Public License v2.1 | 4 votes |
@Override public boolean isMapEmpty(Map<?,?> map) { return MapUtils.isEmpty(map); }
Example 17
Source File: UserBadgeAssertion.java From sunbird-lms-service with MIT License | 4 votes |
@SuppressWarnings("unchecked") private void updateUserBadgeDataToES(Map<String, Object> map) { Future<Map<String, Object>> resultF = EsClientFactory.getInstance(JsonKey.REST) .getDataByIdentifier( ProjectUtil.EsType.user.getTypeName(), (String) map.get(JsonKey.USER_ID)); Map<String, Object> result = (Map<String, Object>) ElasticSearchHelper.getResponseFromFuture(resultF); if (MapUtils.isEmpty(result)) { ProjectLogger.log( "UserBadgeAssertion:updateUserBadgeDataToES user with userId " + (String) map.get(JsonKey.USER_ID) + " not found", LoggerEnum.INFO.name()); return; } if (CollectionUtils.isNotEmpty( (List<Map<String, Object>>) result.get(BadgingJsonKey.BADGE_ASSERTIONS))) { List<Map<String, Object>> badgeAssertionsList = (List<Map<String, Object>>) result.get(BadgingJsonKey.BADGE_ASSERTIONS); boolean bool = true; Iterator<Map<String, Object>> itr = badgeAssertionsList.iterator(); while (itr.hasNext()) { Map<String, Object> tempMap = itr.next(); if (((String) tempMap.get(JsonKey.ID)).equalsIgnoreCase((String) map.get(JsonKey.ID))) { itr.remove(); bool = false; } } if (bool) { badgeAssertionsList.add(map); } } else { List<Map<String, Object>> mapList = new ArrayList<>(); mapList.add(map); result.put(BadgingJsonKey.BADGE_ASSERTIONS, mapList); } updateDataToElastic( ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.user.getTypeName(), (String) result.get(JsonKey.IDENTIFIER), result); }
Example 18
Source File: ComEmmActionServiceImpl.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
@Override @Transactional public boolean setActiveness(Map<Integer, Boolean> changeMap, @VelocityCheck int companyId, List<UserAction> userActions) { if (MapUtils.isEmpty(changeMap) || companyId <= 0) { return false; } Map<Integer, Boolean> activenessMap = emmActionDao.getActivenessMap(changeMap.keySet(), companyId); List<Integer> entriesToActivate = new ArrayList<>(); List<Integer> entriesToDeactivate = new ArrayList<>(); changeMap.forEach((actionId, active) -> { Boolean wasActive = activenessMap.get(actionId); // Ensure its exists and should be changed (wasActive != active). if (wasActive != null && !wasActive.equals(active)) { if (active) { entriesToActivate.add(actionId); } else { entriesToDeactivate.add(actionId); } } }); if (entriesToActivate.size() > 0 || entriesToDeactivate.size() > 0) { String description = ""; if (entriesToActivate.size() > 0) { emmActionDao.setActiveness(entriesToActivate, true, companyId); description += "Made active: " + StringUtils.join(entriesToActivate, ", "); if (entriesToDeactivate.size() > 0) { description += "\n"; } } if (entriesToDeactivate.size() > 0) { emmActionDao.setActiveness(entriesToDeactivate, false, companyId); description += "Made inactive: " + StringUtils.join(entriesToDeactivate, ", "); } userActions.add(new UserAction("edit action activeness", description)); return true; } return false; }
Example 19
Source File: FlowBus.java From liteFlow with Apache License 2.0 | 4 votes |
public static boolean needInit() { return MapUtils.isEmpty(chainMap); }
Example 20
Source File: CollectionUtil.java From bfmvc with Apache License 2.0 | 2 votes |
/** * 判断map是否为空 * * @param map * @return */ public static boolean isEmpty(Map<?, ?> map) { return MapUtils.isEmpty(map); }