List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.consol.citrus.samples.kubernetes.ListKubernetesResourcesIT.java
@Test @CitrusTest/*from w w w . java2 s . co m*/ public void testListReplicationControllers() { kubernetes().client(k8sClient).replicationControllers().list().namespace("default") .validate((result, context) -> { Assert.assertTrue(CollectionUtils.isEmpty(result.getResult().getItems())); }); }
From source file:com.fredhopper.core.connector.index.generate.validator.FloatAttributeValidator.java
@Override protected void validateValue(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); final Map<Optional<Locale>, String> valueMap = values.row(Optional.empty()); if (CollectionUtils.isEmpty(valueMap) || valueMap.entrySet().size() != 1 || !valueMap.containsKey(Optional.empty())) { rejectValue(attribute, violations, "The \"float\" attribute value cannot be localized."); return;// w w w. j a v a2s . c o m } final String value = valueMap.get(Optional.empty()); try { if (StringUtils.isBlank(value) || !(Float.parseFloat(value) > 0 && Double.valueOf(Float.MAX_VALUE).compareTo(Double.valueOf(value)) > 0)) { rejectValue(attribute, violations, "The \"float\" attribute value is not in the supported value range."); } } catch (final NumberFormatException ex) { rejectValue(attribute, violations, "The \"float\" attribute value does not have the appropriate format."); } }
From source file:com.fredhopper.core.connector.index.generate.validator.AssetAttributeValidator.java
@Override protected void validateValue(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); final Map<Optional<Locale>, String> valueMap = values.row(Optional.empty()); if (CollectionUtils.isEmpty(valueMap) || valueMap.containsKey(Optional.empty()) || valueMap.containsKey(null)) { rejectValue(attribute, violations, "The \"asset\" value's Locale key must be set."); return;//from w w w . j a va2 s .co m } for (final Entry<Optional<Locale>, String> entry : valueMap.entrySet()) { if (StringUtils.isBlank(entry.getValue())) { rejectValue(attribute, violations, "The \"asset\" value must not be blank."); } } }
From source file:com.ericsson.eiffel.remrem.publish.service.MessageServiceRMQImpl.java
@Override public SendResult send(Map<String, String> routingKeyMap, Map<String, String> msgs, MsgService msgService) { List<PublishResultItem> results = new ArrayList<>(); SendResult sendResult = null;/* w w w .ja va 2 s . c om*/ PublishResultItem event = null; if (!CollectionUtils.isEmpty(msgs)) { for (Map.Entry<String, String> entry : msgs.entrySet()) { String message = sendMessage(routingKeyMap.get(entry.getKey()), entry.getValue(), msgService); if (PropertiesConfig.SUCCESS.equals(message)) { event = new PublishResultItem(entry.getKey(), 200, PropertiesConfig.SUCCESS, PropertiesConfig.SUCCESS_MESSAGE); } else { event = new PublishResultItem(entry.getKey(), 500, PropertiesConfig.SERVER_DOWN, PropertiesConfig.SERVER_DOWN_MESSAGE); checkEventStatus = false; } results.add(event); } sendResult = new SendResult(results); } return sendResult; }
From source file:nc.noumea.mairie.organigramme.core.utility.MessageErreurUtil.java
/** * Retourne une reprsentation textuelle de la liste des messages d'erreurs * (un message par ligne, prfixs par des tirets s'il y a plusieurs * messages)//ww w .ja v a2s .c o m * * @param listeMessageErreur * liste concerne * @return une reprsentation multi-lignes, "" si la liste en entre est * vide ou null */ public static String construitReprListeMessageErreur(List<MessageErreur> listeMessageErreur) { if (CollectionUtils.isEmpty(listeMessageErreur)) { return ""; } StringBuilder result = new StringBuilder(); boolean plusieursErreurs = listeMessageErreur.size() >= 2; for (MessageErreur messageErreur : listeMessageErreur) { if (messageErreur == null) { continue; // ne devrait pas arriver } if (plusieursErreurs) { // tirets seulement intressants // visuellement si plusieurs erreurs result.append("- "); } result.append(messageErreur.getMessage()); result.append("\n"); } return result.toString(); }
From source file:nc.noumea.mairie.organigramme.dto.FichePosteTreeNodeDto.java
@JSON(include = false) public String getServiceAffichageExportYed() { return (CollectionUtils.isEmpty(fichePostesEnfant) || getService() == null ? "" : WordUtils.wrap(getService(), 25)); }
From source file:com.alibaba.otter.manager.biz.monitor.impl.ExceptionRuleMonitor.java
@Override public void feed(Object data, Long pipelineId) { if (!(data instanceof NodeAlarmEvent)) { return;/*from w w w. ja v a 2s.c o m*/ } NodeAlarmEvent alarmEvent = (NodeAlarmEvent) data; // ? String message = String.format(MESAGE_FORMAT, alarmEvent.getPipelineId(), alarmEvent.getNid(), alarmEvent.getMessage()); logRecordAlarm(pipelineId, alarmEvent.getNid(), MonitorName.EXCEPTION, message); // List<AlarmRule> rules = alarmRuleService.getAlarmRules(pipelineId, AlarmRuleStatus.ENABLE); // TODO ? alarmRuleService ?? Date now = new Date(); List<AlarmRule> exceptionRules = new ArrayList<AlarmRule>(); for (AlarmRule rule : rules) { if (MonitorName.EXCEPTION.equals(rule.getMonitorName()) && checkEnable(rule, now)) { exceptionRules.add(rule); } } if (CollectionUtils.isEmpty(exceptionRules)) { return; } for (AlarmRule rule : exceptionRules) { check(rule, alarmEvent); } }
From source file:nl.surfnet.coin.ldap.LdapClientImpl.java
/** * * Find the Person in the LDAP. The identifier can either be the urn * (urn:collab:person:nl.myuniversity:s123456) or the persistent identifier * (hashed urn specific for the SP).//w w w . j a v a 2s . c o m * * @param identifier * unique identifier of the Person * @return Person object */ @Override @SuppressWarnings("unchecked") public Person findPerson(String identifier) { Filter query = getFilter(identifier); List<Person> search = findPersons(query); if (CollectionUtils.isEmpty(search)) { return null; } if (search.size() > 1) { throw new RuntimeException("Found more then one LDAP entry for identifier(" + query.toString() + ")"); } return search.get(0); }
From source file:pe.gob.mef.gescon.service.impl.WikiServiceImpl.java
@Override public List<Consulta> getConcimientosDisponibles(HashMap filters) { List<Consulta> lista = new ArrayList<Consulta>(); try {//from ww w .ja va2 s .c o m WikiDao wikiDao = (WikiDao) ServiceFinder.findBean("WikiDao"); List<HashMap> consulta = wikiDao.getConcimientosDisponibles(filters); if (!CollectionUtils.isEmpty(consulta)) { for (HashMap map : consulta) { Consulta c = new Consulta(); c.setIdconocimiento((BigDecimal) map.get("ID")); c.setCodigo((String) map.get("NUMERO")); c.setNombre((String) map.get("NOMBRE")); c.setSumilla((String) map.get("SUMILLA")); c.setFechaPublicacion((Date) map.get("FECHA")); c.setIdCategoria((BigDecimal) map.get("IDCATEGORIA")); c.setCategoria((String) map.get("CATEGORIA")); c.setIdTipoConocimiento((BigDecimal) map.get("IDTIPOCONOCIMIENTO")); c.setTipoConocimiento((String) map.get("TIPOCONOCIMIENTO")); c.setIdEstado((BigDecimal) map.get("IDESTADO")); c.setEstado((String) map.get("ESTADO")); lista.add(c); } } } catch (Exception e) { e.getMessage(); e.printStackTrace(); } return lista; }
From source file:com.mauersu.util.redis.DefaultListOperations.java
public V leftPop(K key, long timeout, TimeUnit unit) { final int tm = (int) TimeoutUtils.toSeconds(timeout, unit); return execute(new ValueDeserializingRedisCallback(key) { protected byte[] inRedis(byte[] rawKey, RedisConnection connection) { connection.select(dbIndex);//from w w w . ja v a2 s. c om List<byte[]> lPop = connection.bLPop(tm, rawKey); return (CollectionUtils.isEmpty(lPop) ? null : lPop.get(1)); } }, true); }