List of usage examples for java.util Collections emptyList
@SuppressWarnings("unchecked") public static final <T> List<T> emptyList()
From source file:com.xtructure.xutil.valid.strategy.UTestArgumentValidationStrategy.java
@Test(expectedExceptions = { IllegalArgumentException.class }) public void constructorWithNoPredicatesThrowsException() { List<Condition> empty = Collections.emptyList(); new ArgumentValidationStrategy<Object>(empty); }
From source file:com.pinterest.teletraan.security.UserDataHelper.java
public List<String> getUserGroups(String token) throws Exception { if (StringUtils.isEmpty(groupDataUrl)) { return Collections.emptyList(); }//w w w . ja v a 2 s .co m // Get user groups through auth server with user oauth token HTTPClient client = new HTTPClient(); HashMap<String, String> params = new HashMap<>(); params.put("access_token", token); String jsonResponse = client.get(groupDataUrl, params, null, 3); // Parse response Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonElement element = parser.parse(jsonResponse); if (element.getAsJsonObject().has("groups")) { JsonArray jsonArray = element.getAsJsonObject().getAsJsonArray("groups"); String[] groups = gson.fromJson(jsonArray, String[].class); LOG.info("Retrieved groups " + Arrays.asList(groups).toString() + " from token."); return Arrays.asList(groups); } return null; }
From source file:de.mgd.simplesoundboard.dao.FileSystemSoundResourceDao.java
@Override public List<SoundResource> findExistingSoundResources(final String category) { List<File> files = findFilesInStorageDirectoryIfAny(this::isMediaFile, category); if (files.isEmpty()) { return Collections.emptyList(); }/*from ww w . j a v a 2 s . co m*/ files.sort(NameFileComparator.NAME_INSENSITIVE_COMPARATOR); return files.stream().map(f -> soundResourceService.createSoundResourceFromFile(f)) .collect(Collectors.toList()); }
From source file:com.haulmont.timesheets.global.WorkTimeConfigBean.java
public List<DayOfWeek> getWorkDays() { List<String> days = workTimeConfig.getWorkDays(); if (days.isEmpty()) { return Collections.emptyList(); }//from w w w .j a v a 2 s. c o m List<DayOfWeek> workDays = new ArrayList<>(days.size()); for (String day : days) { workDays.add(DayOfWeek.fromAbbreviation(day)); } return Collections.unmodifiableList(workDays); }
From source file:com.redhat.ipaas.api.v1.rest.IntegrationDAO.java
@Override public ListResult<Integration> fetchAll() { ConfigMapList list = kubernetesClient.configMaps().withLabel(Integration.LABEL_NAME).list(); List<ConfigMap> maps = list != null ? list.getItems() : Collections.emptyList(); List<Integration> integrations = maps.stream().map(c -> toIntegration(c)).collect(Collectors.toList()); return new ListResult.Builder<Integration>().items(integrations).totalCount(integrations.size()).build(); }
From source file:com.evanzeimet.queryinfo.jpa.result.AbstractTupleToPojoQueryInfoResultConverter.java
@Override public List<QueryInfoResultType> convert(List<Tuple> tuples) throws QueryInfoException { List<QueryInfoResultType> result; if (tuples.isEmpty()) { result = Collections.emptyList(); } else {/* w w w .ja v a 2 s.c o m*/ Tuple peek = tuples.get(0); List<TupleElement<?>> tupleElements = peek.getElements(); try { Map<String, MethodHandle> methodHandles = mapElementMethodHandles(tupleElements); result = convertTuples(methodHandles, tuples); } catch (Throwable e) { throw new QueryInfoException(e); } } return result; }
From source file:gov.ca.cwds.cals.service.FasFacilityService.java
@UnitOfWork(FAS) List<FacilityInspectionDto> findInspectionsByFacilityId(String licenseNumber) { if (StringUtils.isNotBlank(licenseNumber)) { return inspectionDao.findDeficienciesByFacilityNumber(licenseNumber).stream() .map(facilityInspectionMapper::toFacilityInspectionDto).collect(Collectors.toList()); }/*from ww w.jav a 2 s.c om*/ return Collections.emptyList(); }
From source file:org.alfresco.util.exec.RuntimeExecBootstrapBean.java
/** * Initializes the bean/* ww w .ja v a2 s .c o m*/ * <ul> * <li>failOnError = true</li> * <li>killProcessesOnShutdown = true</li> * <li>enabled = true</li> * </ul> */ public RuntimeExecBootstrapBean() { this.startupCommands = Collections.emptyList(); this.executionResults = new ArrayList<ExecutionResult>(1); failOnError = true; killProcessesOnShutdown = true; enabled = true; }
From source file:com.alibaba.cobar.manager.util.CobarStringUtil.java
/** * e.g. {"mysql_1","mysql_2","mysql_3","mysql_5"} will return * {"mysql_$1-3","mysql_5"}<br/>//from ww w. j av a 2s . co m * only merge last number */ public static List<String> mergeListedString(String[] input) { if (input == null || input.length < 1) return Collections.emptyList(); if (input.length == 1) { List<String> rst = new ArrayList<String>(1); rst.add(input[0]); return rst; } List<String> list = new ArrayList<String>(input.length); for (String str : input) list.add(str); Collections.sort(list, new Comparator<String>() { @Override public int compare(String o1, String o2) { if (StringUtils.equals(o1, o2)) return 0; if (o1.length() == o2.length()) return o1.compareTo(o2); return o1.length() < o2.length() ? -1 : 1; } }); List<String> rst = new ArrayList<String>(); String prefix = null; Integer from = null; Integer to = null; String last = list.get(0); for (int i = 1; i < list.size(); ++i) { String cur = list.get(i); if (StringUtils.equals(last, cur)) continue; int commonInd = indexOfLastEqualCharacter(last, cur); boolean isCon = false; if (commonInd >= 0) { String suffixLast = last.substring(1 + commonInd); String suffixCur = cur.substring(1 + commonInd); try { int il = Integer.parseInt(suffixLast); int ic = Integer.parseInt(suffixCur); if (ic - il == 1) isCon = true; } catch (Exception e) { } } if (isCon) { if (prefix == null) prefix = last.substring(0, commonInd + 1); if (from == null) from = Integer.parseInt(last.substring(commonInd + 1)); to = Integer.parseInt(cur.substring(commonInd + 1)); } else if (prefix != null) { rst.add(new StringBuilder(prefix).append('$').append(from).append('-').append(to).toString()); prefix = null; from = to = null; } else { rst.add(last); } last = cur; } if (prefix != null) { rst.add(new StringBuilder(prefix).append('$').append(from).append('-').append(to).toString()); prefix = null; from = to = null; } else { rst.add(last); } return rst; }