List of usage examples for java.util Collections emptyList
@SuppressWarnings("unchecked") public static final <T> List<T> emptyList()
From source file:org.grails.datastore.mapping.redis.query.RedisQueryUtils.java
public static List<Long> transformRedisResults(ConversionService conversionService, Collection<String> results) { List<Long> returnResults; if (!results.isEmpty()) { List<Long> foreignKeys = new ArrayList<Long>(); for (String result : results) { foreignKeys.add(conversionService.convert(result, Long.class)); }//from w ww . j a va2 s. com returnResults = foreignKeys; } else { returnResults = Collections.emptyList(); } return returnResults; }
From source file:Main.java
public static List<Element> elements(Element element, String tagName) { if (element == null || !element.hasChildNodes()) { return Collections.emptyList(); }// w w w . ja v a 2 s.c o m List<Element> elements = new ArrayList<Element>(); for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.ELEMENT_NODE) { Element childElement = (Element) child; String childTagName = childElement.getLocalName(); if (tagName.equals(childTagName)) elements.add(childElement); } } return elements; }
From source file:Main.java
public static List<Attr> attributes(Element element) { NamedNodeMap attributeMap = element.getAttributes(); if ((attributeMap == null) || (attributeMap.getLength() == 0)) { return Collections.emptyList(); }//from w w w. j ava 2 s. c o m List<Attr> attributes = new ArrayList<Attr>(); for (int i = 0; i < attributeMap.getLength(); i++) { attributes.add((Attr) attributeMap.item(i)); } return attributes; }
From source file:ru.mystamps.web.support.spring.security.SecurityContextUtils.java
/** * @author Sergey Chechenev/*from w w w . j a v a 2s . co m*/ */ public static boolean hasAuthority(GrantedAuthority authority) { return Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication()) .map(Authentication::getAuthorities).orElse(Collections.emptyList()).contains(authority); }
From source file:Main.java
public static List<Element> elementsQName(Element element, Set<QName> allowedTagNames) { if (element == null || !element.hasChildNodes()) { return Collections.emptyList(); }//from w w w . jav a 2s . co m List<Element> elements = new ArrayList<Element>(); for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.ELEMENT_NODE) { Element childElement = (Element) child; QName childQName = new QName(childElement.getNamespaceURI(), childElement.getLocalName()); if (allowedTagNames.contains(childQName)) { elements.add(childElement); } } } return elements; }
From source file:alfio.model.result.Result.java
public static <T> Result<T> success(T data) { return new Result<>(ResultStatus.OK, data, Collections.emptyList()); }
From source file:com.spotify.styx.YamlScheduleDefinition.java
@JsonCreator public static YamlScheduleDefinition create( @JsonProperty("schedules") @Nullable List<WorkflowConfiguration> workflowConfigurations) { if (workflowConfigurations == null) { workflowConfigurations = Collections.emptyList(); }/*from w w w .j av a2 s . c o m*/ return new AutoValue_YamlScheduleDefinition(workflowConfigurations); }
From source file:com.cloudera.oryx.ml.param.RandomSearch.java
/** * @param ranges ranges of hyperparameters to try, one per hyperparameters * @param howMany how many combinations of hyperparameters to return * @return combinations of concrete hyperparameter values *//*from w w w.j a va2s.c o m*/ static List<List<?>> chooseHyperParameterCombos(Collection<? extends HyperParamValues<?>> ranges, int howMany) { Preconditions.checkArgument(howMany > 0); int numParams = ranges.size(); if (numParams == 0) { return Collections.singletonList(Collections.emptyList()); } RandomDataGenerator rdg = new RandomDataGenerator(RandomManager.getRandom()); List<List<?>> allCombinations = new ArrayList<>(howMany); for (int i = 0; i < howMany; i++) { List<Object> combination = new ArrayList<>(numParams); for (HyperParamValues<?> range : ranges) { combination.add(range.getRandomValue(rdg)); } allCombinations.add(combination); } return allCombinations; }
From source file:Main.java
public static <E> Collection<List<E>> selectExactly(List<E> original, int nb) { if (nb < 0) { throw new IllegalArgumentException(); }// w w w . j av a 2 s .com if (nb == 0) { return Collections.emptyList(); } if (nb == 1) { final List<List<E>> result = new ArrayList<List<E>>(); for (E element : original) { result.add(Collections.singletonList(element)); } return result; } if (nb > original.size()) { return Collections.emptyList(); } if (nb == original.size()) { return Collections.singletonList(original); } final List<List<E>> result = new ArrayList<List<E>>(); for (List<E> subList : selectExactly(original.subList(1, original.size()), nb - 1)) { final List<E> newList = new ArrayList<E>(); newList.add(original.get(0)); newList.addAll(subList); result.add(Collections.unmodifiableList(newList)); } result.addAll(selectExactly(original.subList(1, original.size()), nb)); return Collections.unmodifiableList(result); }
From source file:Main.java
public static List<String> stringToList(@Nullable String arrayString) { if (TextUtils.isEmpty(arrayString)) { return Collections.emptyList(); }/*from ww w. jav a2 s.c om*/ final String[] splitted = arrayString.trim().split(" "); final ArrayList<String> list = new ArrayList<>(Arrays.asList(splitted)); Collections.sort(list); return list; }