List of usage examples for java.util Collections emptyList
@SuppressWarnings("unchecked") public static final <T> List<T> emptyList()
From source file:com.alibaba.napoli.metamorphosis.client.consumer.DefaultLoadBalanceStrategy.java
@Override public List<String> getPartitions(final String topic, final String consumerId, final List<String> curConsumers, final List<String> curPartitions) { // ??partition final int nPartsPerConsumer = curPartitions.size() / curConsumers.size(); // ?partitionconsumer final int nConsumersWithExtraPart = curPartitions.size() % curConsumers.size(); log.info("Consumer " + consumerId + " rebalancing the following partitions: " + curPartitions + " for topic " + topic + " with consumers: " + curConsumers); final int myConsumerPosition = curConsumers.indexOf(consumerId); if (myConsumerPosition < 0) { log.warn("No broker partions consumed by consumer " + consumerId + " for topic " + topic); return Collections.emptyList(); }//from w ww . j a va2 s. co m assert myConsumerPosition >= 0; // final int startPart = nPartsPerConsumer * myConsumerPosition + Math.min(myConsumerPosition, nConsumersWithExtraPart); final int nParts = nPartsPerConsumer + (myConsumerPosition + 1 > nConsumersWithExtraPart ? 0 : 1); if (nParts <= 0) { log.warn("No broker partions consumed by consumer " + consumerId + " for topic " + topic); return Collections.emptyList(); } final List<String> rt = new ArrayList<String>(); for (int i = startPart; i < startPart + nParts; i++) { final String partition = curPartitions.get(i); rt.add(partition); } return rt; }
From source file:org.openmrs.module.personalhr.web.taglib.GlobalPropertyTag.java
@Override public int doStartTag() { this.log.debug("Entering GlobalPropertyTag.doStartTag"); try {/* w ww. ja v a 2 s . c o m*/ //Add temporary privilege //PersonalhrUtil.addTemporaryPrivileges(); Object value; if (StringUtils.hasText(this.listSeparator)) { value = Collections.singletonList(this.defaultValue); } else { value = this.defaultValue; } // If user is logged in if (Context.isAuthenticated()) { if (StringUtils.hasText(this.listSeparator)) { final String stringVal = Context.getAdministrationService().getGlobalProperty(this.key, this.defaultValue); if (stringVal.trim().length() == 0) { value = Collections.emptyList(); } else { value = Arrays.asList(stringVal.split(this.listSeparator)); } } else { value = Context.getAdministrationService().getGlobalProperty(this.key, this.defaultValue); } } try { if (this.var != null) { this.pageContext.setAttribute(this.var, value); } else { this.pageContext.getOut().write(value.toString()); } } catch (final Exception e) { this.log.error("error getting global property", e); } } finally { //PersonalhrUtil.removeTemporaryPrivileges(); } return SKIP_BODY; }
From source file:com.heliosdecompiler.helios.controller.RecentFileController.java
public List<File> getRecentFiles() { return configuration.getList(String.class, Settings.RECENT_FILES_KEY, Collections.emptyList()).stream() .map(File::new).collect(Collectors.toList()); }
From source file:de.hybris.platform.mpintgordermanagement.aspects.ConsignmentActionAspect.java
/** * Perform around advice.//from w ww .java2s .c om * * @param joinPoint * - the join point * @return the remaining cancellation entries to be cancelled; never <tt>null</tt> * @throws Throwable * when an exception occurs that has been cleared to be rethrown. */ public Collection<CancellationEntry> advise(final ProceedingJoinPoint joinPoint) throws Throwable { Collection<CancellationEntry> remainingEntries = Collections.emptyList(); final ConsignmentModel consignment = getConsignment(joinPoint); LOGGER.debug("Running consignment action aspect for consignment with code: " + consignment.getCode()); try { getConsignmentBusinessProcessService().triggerChoiceEvent(consignment, MpintgordermanagementConstants.CONSIGNMENT_ACTION_EVENT_NAME, getChoice()); remainingEntries = (Collection<CancellationEntry>) joinPoint.proceed(); triggerAfter(consignment); } catch (final BusinessProcessException e) { throw e; } catch (final Throwable e) { triggerAfter(consignment); if (getExceptionsToRethrow().stream().anyMatch(clazz -> (e.getClass().equals(clazz)))) { throw e; } LOGGER.info(String.format(EXCEPTION_MESSAGE, consignment.getCode())); } return remainingEntries; }
From source file:com.couchbase.workshop.AirportController.java
/** * Returns a list of all airport names, sorted by name. * * This query does not use the DSL as an example, but can easily be converted. * * @return list of airport names/*w w w . j ava2 s .c o m*/ */ @RequestMapping("/allNames") public List<String> allAirportNames() { // TODO: implement me return Collections.emptyList(); }
From source file:com.banyou.backend.service.product.DestService.java
/** * /*from www .ja v a 2s. co m*/ * @param pageSize * ? ?1? * @param pageNo * * @return */ public List<Dest> findDests(Long... ids) { if (ArrayUtils.isEmpty(ids)) { return Collections.emptyList(); } List<Dest> result = new ArrayList<>(ids.length); for (Dest dest : destDao.findAll(Arrays.asList(ids))) { result.add(dest); } return result; }
From source file:cz.cas.lib.proarc.common.workflow.FilterFindParameterQueryTest.java
@Test public void testFilterNoDbParam() { List<TaskParameterView> params = Collections.emptyList(); TaskParameterFilter filter = new TaskParameterFilter(); filter.setTaskId(BigDecimal.TEN); filter.setLocale(Locale.ENGLISH); Task task = new Task(); task.setTypeRef("task.id1"); task.setId(filter.getTaskId());/* w w w . j av a 2 s .c o m*/ List<TaskParameterView> result = new FilterFindParameterQuery(wp).filter(params, filter, task, wp.getProfiles()); assertEquals(2, result.size()); assertEquals("param.id1", result.get(0).getParamRef()); assertEquals(DisplayType.TEXT, result.get(0).getDisplayType()); assertEquals(task.getTypeRef(), result.get(0).getTaskProfileName()); assertEquals(filter.getTaskId(), result.get(0).getTaskId()); }
From source file:com.celements.web.plugin.cmd.SuggestListCommand.java
public List<Object> getSuggestList(DocumentReference classRef, String fieldname, List<String> excludes, String input, String firstCol, String secCol, int limit, XWikiContext context) { SuggestBaseClass sbc = new SuggestBaseClass(classRef, fieldname, context); String classname = getFullNameFromDocRef(classRef); if (excludes == null) { excludes = Collections.emptyList(); }/*from w w w .j av a 2 s . c o m*/ Boolean isMultiSelect = (sbc.isMultiSelect() != null) && sbc.isMultiSelect(); input = getSeparatedInput(input, sbc.getSeparators(), isMultiSelect); String hibquery = sbc.getSql(); QueryManager queryManager = Utils.getComponent(QueryManager.class); Query query = null; String xwql = ""; List<Object> results = Collections.emptyList(); if (isExistingClassAndField(classRef, fieldname, context)) { if ((hibquery != null) && !"".equals(hibquery.trim())) { xwql = getDBStringListXWQL(hibquery, firstCol, secCol); } else { if ((sbc.isRelationalStorage() != null) && sbc.isRelationalStorage() && isMultiSelect) { xwql = "select distinct obj." + fieldname + " from Document as doc, doc.object(" + classname + ") as obj where ?1 member of obj." + fieldname + " "; } else if (isMultiSelect) { xwql = "select distinct obj." + fieldname + " from Document as doc, doc.object(" + classname + "?) as obj where lower(obj." + fieldname + ") like ?1 "; } else { xwql = "select distinct obj." + fieldname + " from Document doc, doc.object(" + classname + ") as obj where lower(obj." + fieldname + ") like ?1 "; } } for (int i = 0; i < excludes.size(); i++) { xwql += "and doc.fullName <> ?" + (i + 2) + " "; } mLogger.trace("searching for xwql " + xwql); try { query = queryManager.createQuery(xwql, Query.XWQL); query.bindValue(1, input); for (int i = 0; i < excludes.size(); i++) { query.bindValue(i + 2, excludes.get(i)); } query.setLimit(limit); mLogger.trace(query.getStatement()); results = query.execute(); } catch (QueryException qe) { mLogger.error("Exception while querying suggest for classname '" + classname + "', fieldname '" + fieldname + "', input '" + input + "'.", qe); } } return results; }
From source file:br.com.thiaguten.persistence.demo.hbmcore.UserDAOImpl.java
@Override public List<User> findByName(String name) { List<Criterion> criterions = Collections .singletonList(Restrictions.ilike("name", name, MatchMode.ANYWHERE)); List<User> results = persistenceProvider.findByCriteria(getPersistenceClass(), criterions); if (results.isEmpty()) { return Collections.emptyList(); } else {// ww w . j a va2 s . com return Collections.unmodifiableList(results); } }
From source file:com.orange.ngsi.model.ContextAttribute.java
public List<ContextMetadata> getMetadata() { if (metadata == null) { return Collections.emptyList(); } return metadata; }