List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.sinet.gage.provision.controller.DomainController.java
/** * Returns all child domains domains/* www . ja va 2 s.co m*/ * * @param domainId * @return */ @RequestMapping(value = "/list/school/{domainId}", method = RequestMethod.GET) @ResponseBody public Message getAllChildDomainsWithDomainData(@PathVariable("domainId") String domainId, @RequestParam(value = "querystring", required = false, defaultValue = "0") String queryString, @RequestParam(value = "searchtext", required = false, defaultValue = "") String searchText, @RequestParam(value = "limit", required = false, defaultValue = "0") Integer limit, @RequestHeader(value = "token", required = false) String token) { List<DomainResponse> listOfDomainResponse = domainService.findAllChildDomainsWithDomainData(token, domainId, queryString, searchText, limit); if (!CollectionUtils.isEmpty(listOfDomainResponse)) { LOGGER.debug("Found " + listOfDomainResponse.size() + " child domains " + domainId); return messageUtil.createMessageWithPayload(MessageConstants.DOMAINS_FOUND, listOfDomainResponse, Collections.singletonMap("dataModels", "domains"), DomainResponse.class); } else { LOGGER.debug("No child domains available for parent " + domainId); return messageUtil.createMessage(MessageConstants.DOMAINS_NOT_FOUND, Boolean.FALSE); } }
From source file:com.stormpath.spring.security.provider.CustomDataPermissionResolver.java
/** * Returns a set of {@link Permission} instances stored in the specified {@link com.stormpath.sdk.directory.CustomData} resource. This * implementation will:/*from www . ja va 2 s .c o m*/ * <ol> * <li>{@link #getPermissionStrings(com.stormpath.sdk.directory.CustomData) Get all permission strings} stored * in the CustomData instance</li> * <li>Loop over these strings, and for each one, create a {@link Permission} instance using the * {@link #getPermissionResolver() permissionResolver} property.</li> * <li>Return the total constructed Set of Permission instances to the caller.</li> * </ol> * * @param customData the CustomData instance that may contain permission strings to obtain * @return a set of {@link Permission} instances stored in the specified {@link com.stormpath.sdk.directory.CustomData} resource. */ protected Set<Permission> getPermissions(CustomData customData) { Set<String> permStrings = getPermissionStrings(customData); if (CollectionUtils.isEmpty(permStrings)) { return Collections.emptySet(); } PermissionResolver permissionResolver = getPermissionResolver(); Set<Permission> permissions = new HashSet<Permission>(permStrings.size()); for (String s : permStrings) { Permission permission = permissionResolver.resolvePermission(s); permissions.add(permission); } return permissions; }
From source file:com.excilys.ebi.bank.util.Asserts.java
public static void notEmpty(Map<?, ?> map, String messagePattern, Object... args) { if (CollectionUtils.isEmpty(map)) { throw new IllegalArgumentException(MessageFormatter.arrayFormat(messagePattern, args).getMessage()); }/*w w w. ja va2s .co m*/ }
From source file:com.alibaba.otter.node.etl.transform.transformer.RowDataTransformer.java
private void translatePkColumn(EventData data, List<EventColumn> pks, List<EventColumn> oldPks, List<EventColumn> columns, DataMediaPair dataMediaPair, Multimap<String, String> translateColumnNames, TableInfoHolder tableHolder) {//w w w .j av a 2s . c o m if (CollectionUtils.isEmpty(oldPks)) { // ?? List<EventColumn> tpks = new ArrayList<EventColumn>(); for (EventColumn scolumn : pks) { EventColumn tcolumn = translateColumn(data, scolumn, tableHolder, dataMediaPair, translateColumnNames); if (tcolumn != null) { tpks.add(tcolumn); } } data.setKeys(tpks); } else { // ? // modify by ljh at 2012-11-07 , ??view???update table xxx // set pk = newPK where pk = oldPk? List<EventColumn> tnewPks = new ArrayList<EventColumn>(); List<EventColumn> toldPks = new ArrayList<EventColumn>(); for (int i = 0; i < pks.size(); i++) { EventColumn newPk = pks.get(i); EventColumn oldPk = oldPks.get(i); // new pk EventColumn tnewPk = translateColumn(data, newPk, tableHolder, dataMediaPair, translateColumnNames); if (tnewPk != null) { tnewPks.add(tnewPk); // old pk??translateColumnNamesnew // pk?removeview name toldPks.add(translateColumn(tnewPk, oldPk.getColumnValue(), dataMediaPair)); } } data.setKeys(tnewPks); data.setOldKeys(toldPks); // ?sql // update table xxx set pk = newPK where pk = oldPk; // for (int i = 0; i < pks.size(); i++) { // EventColumn scolumn = pks.get(i); // EventColumn oldPk = oldPks.get(i); // // EventColumn updatePk = translateColumn(scolumn, tableHolder, // dataMediaPair, translateColumnNames); // if (scolumn.getColumnValue().equals(oldPk.getColumnValue())) {// // ? // tcolumns.add(updatePk); // } else { // columns.add(updatePk);// ?, set pk = newPK // // where pk = oldPk? // tcolumns.add(translateColumn(updatePk, oldPk.getColumnValue(), // dataMediaPair)); // } // } } }
From source file:com.deloitte.smt.service.SignalDetectionService.java
/** * @param signalDetection/*www.j a v a 2s . c o m*/ * @param soc */ private void savePt(SignalDetection signalDetection, Soc soc) { List<Pt> pts = soc.getPts(); if (!CollectionUtils.isEmpty(pts)) { for (Pt pt : pts) { pt.setSocId(soc.getId()); pt.setDetectionId(signalDetection.getId()); } ptRepository.save(pts); } }
From source file:nc.noumea.mairie.organigramme.services.exportGraphML.impl.ExportGraphMLServiceOrgaEntitesImpl.java
/** * Renvoie le libell mettre dans la case Yed * /*from w ww . j ava 2 s.co m*/ * @param entiteDto * : l'entit * @param withEntiteChildren * : selon si l'entit est dplie ou non on affiche les FDP des * enfants ou non * @return le libell mettre dans la case Yed */ private String getLibelleCaseWithLibelleFdp(EntiteDto entiteDto, boolean withEntiteChildren) { String result = ""; InfoEntiteDto infoEntiteDto = sirhWSConsumer.getInfoFDPByEntite(entiteDto.getIdEntite(), withEntiteChildren); if (infoEntiteDto != null && !CollectionUtils.isEmpty(infoEntiteDto.getListeInfoFDP())) { for (GroupeInfoFichePosteDto groupeInfoFichePosteDto : infoEntiteDto.getListeInfoFDP()) { if (new Double(groupeInfoFichePosteDto.getNbFDP()).equals(groupeInfoFichePosteDto.getTauxETP())) { result += groupeInfoFichePosteDto.getTitreFDP() + " (" + groupeInfoFichePosteDto.getNbFDP() + ")\n"; } else { result += groupeInfoFichePosteDto.getTitreFDP() + " (" + groupeInfoFichePosteDto.getNbFDP() + " / " + groupeInfoFichePosteDto.getTauxETP() + " ETP)\n"; } HashSet<String> setCategorieGrade = new HashSet<String>(); for (InfoFichePosteDto infoFichePosteDto : groupeInfoFichePosteDto.getListInfoFichePosteDto()) { setCategorieGrade.add(infoFichePosteDto.getLibelleGradeCategorie()); } if (!CollectionUtils.isEmpty(setCategorieGrade)) { result += StringUtils.join(setCategorieGrade, ", ") + "\n\n"; } } } return result; }
From source file:pe.gob.mef.gescon.service.impl.ConocimientoServiceImpl.java
@Override public List<Consulta> getConcimientosByVinculoBaseLegalId(BigDecimal id) { List<Consulta> lista = new ArrayList<Consulta>(); try {/*from w ww.ja va 2s .c om*/ ConocimientoDao conocimientoDao = (ConocimientoDao) ServiceFinder.findBean("ConocimientoDao"); List<HashMap> consulta = conocimientoDao.getConcimientosByVinculoBaseLegalId(id); if (!CollectionUtils.isEmpty(consulta)) { for (HashMap map : consulta) { Consulta c = new Consulta(); c.setIdconocimiento(new BigDecimal(map.get("ID").toString())); lista.add(c); } } } catch (Exception e) { e.getMessage(); e.printStackTrace(); } return lista; }
From source file:com.formkiq.core.service.generator.pdfbox.PdfEditorServiceImpl.java
/** * Add Field to Page Map.//from ww w . j a va2s .c o m * * @param objMap {@link Map} of {@link COSDictionary} objects by * Page Number. * @param field {@link PDField} * @param map {@link Map} * @throws IOException IOException */ private void addFieldToPageMap(final Map<COSDictionary, Integer> objMap, final PDField field, final Map<Integer, List<PDField>> map) throws IOException { List<PDAnnotationWidget> widgets = field.getWidgets(); if (field instanceof PDNonTerminalField) { PDNonTerminalField tf = (PDNonTerminalField) field; for (PDField f : tf.getChildren()) { addFieldToPageMap(objMap, f, map); } } else { if (!CollectionUtils.isEmpty(widgets)) { LOG.log(Level.FINE, "addFieldToPageMap='" + field.getFullyQualifiedName() + "',class=" + field.getClass().getName()); Integer page = getPageNumber(objMap, field); if (!map.containsKey(page)) { map.put(page, new ArrayList<>()); } map.get(page).add(field); } else { LOG.log(Level.FINE, "skip addFieldToPageMap='" + field.getFullyQualifiedName() + "',class=" + field.getClass().getName()); } } }
From source file:com.qpark.eip.core.failure.FailureAssert.java
/** * Assert that a collection has elements; that is, it must not be * <code>null</code> and must have at least one element. * * <pre class="code">// ww w . j av a 2 s. co m * Assert.notEmpty(collection, "Collection must have elements"); * </pre> * * @param collection * the collection to check * @param errorCode * the error code to use if the assertion fails * @param data * additional information to the error code. * @throws IllegalArgumentException * if the collection is <code>null</code> or has no elements */ public static void notEmpty(final Collection<?> collection, final String errorCode, final Object... data) { if (CollectionUtils.isEmpty(collection)) { BaseFailureHandler.throwFailureException(errorCode, data); } }
From source file:com.alibaba.otter.shared.arbitrate.impl.setl.rpc.RpcStageController.java
/** * ?processId/*w w w.j a v a 2 s.c o m*/ */ private synchronized void compareProgress(List<Long> processIds) { if (CollectionUtils.isEmpty(processIds) == false) { Long minProcessId = processIds.get(0); // progress???processId // ?restartprocess? for (Long processId : progress.keySet()) { if (processId < minProcessId) { progress.remove(processId); } } } }