List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:it.attocchi.utils.ListUtils.java
public static String[] toArray(List<String> aList) { String[] res = null;// ww w . jav a 2s. c o m if (aList != null) { res = aList.toArray(new String[aList.size()]); // for (String s : anArray) { // res.add(s); // } } return res; }
From source file:android.net.ProxyInfo.java
/** * Constructs a {@link ProxyInfo} object that points at a Direct proxy * on the specified host and port.//from w w w . ja v a 2s .c o m * * The proxy will not be used to access any host in exclusion list, exclList. * * @param exclList Hosts to exclude using the proxy on connections for. These * hosts can use wildcards such as *.example.com. */ public static ProxyInfo buildDirectProxy(String host, int port, List<String> exclList) { String[] array = exclList.toArray(new String[exclList.size()]); return new ProxyInfo(host, port, TextUtils.join(",", array), array); }
From source file:com.netflix.genie.core.jpa.specifications.JpaClusterSpecs.java
/** * Generate a specification given the parameters. * * @param name The name of the cluster to find * @param statuses The statuses of the clusters to find * @param tags The tags of the clusters to find * @param minUpdateTime The minimum updated time of the clusters to find * @param maxUpdateTime The maximum updated time of the clusters to find * @return The specification/*from w ww .j a v a 2s . c o m*/ */ public static Specification<ClusterEntity> find(final String name, final Set<ClusterStatus> statuses, final Set<String> tags, final Date minUpdateTime, final Date maxUpdateTime) { return (final Root<ClusterEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> { final List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(name)) { predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb, root.get(ClusterEntity_.name), name)); } if (minUpdateTime != null) { predicates.add(cb.greaterThanOrEqualTo(root.get(ClusterEntity_.updated), minUpdateTime)); } if (maxUpdateTime != null) { predicates.add(cb.lessThan(root.get(ClusterEntity_.updated), maxUpdateTime)); } if (tags != null && !tags.isEmpty()) { predicates .add(cb.like(root.get(ClusterEntity_.tags), JpaSpecificationUtils.getTagLikeString(tags))); } if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array final List<Predicate> orPredicates = statuses.stream() .map(status -> cb.equal(root.get(ClusterEntity_.status), status)) .collect(Collectors.toList()); predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); }; }
From source file:com.kolich.havalo.client.service.HavaloAbstractService.java
/** * Appends the given key to the end of the prefix list, then returns a * a new String[] array representing that list. * @param key//from w w w .jav a2 s.com * @param prefixes * @return */ public static final String[] appendKeyToPrefixes(final String key, final String... prefixes) { checkNotNull(key, "The key to append cannot be null!"); checkNotNull(prefixes, "The prefix list cannot be null!"); final List<String> prl = new ArrayList<String>(Arrays.asList(prefixes)); // The "key" becomes the last element in the prefix list. prl.add(key); return prl.toArray(new String[] {}); }
From source file:com.netflix.genie.server.repository.jpa.CommandSpecs.java
/** * Get all the clusters given the specified parameters. * * @param applicationId The id of the application that is registered with these commands * @param statuses The status of the commands * @return The specification// w w w .ja v a2 s. c o m */ public static Specification<Command> findCommandsForApplication(final String applicationId, final Set<CommandStatus> statuses) { return new Specification<Command>() { @Override public Predicate toPredicate(final Root<Command> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) { final List<Predicate> predicates = new ArrayList<>(); final Join<Command, Application> application = root.join(Command_.application); predicates.add(cb.equal(application.get(Application_.id), applicationId)); if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array final List<Predicate> orPredicates = new ArrayList<>(); for (final CommandStatus status : statuses) { orPredicates.add(cb.equal(root.get(Command_.status), status)); } predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } return cb.and(predicates.toArray(new Predicate[predicates.size()])); } }; }
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.SampleTranslator.java
public final static SampleParentWithDerived translate(final SampleParentWithDerivedDTO sampleGenerationDTO, String baseIndexURL) {/*from w w w .ja va 2 s.c o m*/ final SampleParentWithDerived sampleGeneration = new SampleParentWithDerived(); sampleGeneration.setParent(SampleTranslator.translate(sampleGenerationDTO.getParent(), baseIndexURL)); final List<Sample> generated = new ArrayList<Sample>(); for (SamplePE samplePE : sampleGenerationDTO.getDerived()) { generated.add(SampleTranslator.translate(samplePE, baseIndexURL, false)); } sampleGeneration.setDerived(generated.toArray(new Sample[generated.size()])); return sampleGeneration; }
From source file:com.twitter.hraven.etl.FileLister.java
/** * Gets the list of files for a given path filtered as per the input path range filter * Can go into directories recursively/*from w ww .jav a 2s. co m*/ * * @param recurse - whether or not to traverse recursively * @param hdfs - the file system * @param inputPath - the path to traverse for getting the list of files * @param jobFileModifiedRangePathFilter - the filter to include/exclude certain files * * @return array of file status. * @throws IOException */ public static FileStatus[] listFiles(boolean recurse, FileSystem hdfs, Path inputPath, JobFileModifiedRangePathFilter jobFileModifiedRangePathFilter) throws IOException { if (recurse) { List<FileStatus> fileStatusesList = new ArrayList<FileStatus>(); traverseDirs(fileStatusesList, hdfs, inputPath, jobFileModifiedRangePathFilter); FileStatus[] fileStatuses = (FileStatus[]) fileStatusesList .toArray(new FileStatus[fileStatusesList.size()]); return fileStatuses; } else { return hdfs.listStatus(inputPath, jobFileModifiedRangePathFilter); } }
From source file:MBeanTyper.java
/** * create a typed object from an mbean/*from ww w . ja va 2s. c o m*/ */ public static final Object typeMBean(MBeanServer server, ObjectName mbean, Class mainInterface) throws Exception { List interfaces = new ArrayList(); if (mainInterface.isInterface()) { interfaces.add(mainInterface); } addInterfaces(mainInterface.getInterfaces(), interfaces); Class cl[] = (Class[]) interfaces.toArray(new Class[interfaces.size()]); if (DEBUG) { System.err .println("typeMean->server=" + server + ",mbean=" + mbean + ",mainInterface=" + mainInterface); for (int c = 0; c < cl.length; c++) { System.err.println(" :" + cl[c]); } } return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), cl, new MBeanTyperInvoker(server, mbean)); }
From source file:jease.cms.service.Contents.java
/** * Returns all descendants for given nodes. *//* w w w . ja v a 2 s.c o m*/ public static Content[] getDescendants(Content[] nodes) { List<Content> contents = new ArrayList<>(); if (nodes != null) { for (Content node : nodes) { Collections.addAll(contents, node.getDescendants(Content.class)); } } return contents.toArray(new Content[contents.size()]); }
From source file:com.asakusafw.runtime.stage.input.TemporaryInputFormat.java
private static FileSplit getSplit(BlockMap blockMap, Path path, long start, long end) { DirectInputFragment f = blockMap.get(start, end); List<String> owners = f.getOwnerNodeNames(); FileSplit split = new FileSplit(path, start, end - start, owners.toArray(new String[owners.size()])); return split; }