List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:com.bfd.harpc.common.configure.ResourceUtils.java
private static URL[] load1(String locationPattern) throws IOException, URISyntaxException { String location = locationPattern.substring(ResourceConstants.CLASSPATH_ALL_URL_PREFIX.getValue().length()); if (location.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) { location = location.substring(1); }//from ww w .ja v a 2 s . c o m Enumeration<URL> resourceUrls = getDefaultClassLoader().getResources(location); Set<URL> result = new LinkedHashSet<URL>(16); while (resourceUrls.hasMoreElements()) { URL url = resourceUrls.nextElement(); result.add(PathUtils.cleanPath(url)); } return result.toArray(new URL[result.size()]); }
From source file:edu.byu.nlp.data.app.AnnotationStream2Annotators.java
public static double[][][] aggregateAnnotatorParameterClusters(double[][][] annotatorParameters, int[] clusterAssignments) { // group clustered parameters Map<Integer, Set<double[][]>> clusterMap = Maps.newHashMap(); for (int i = 0; i < clusterAssignments.length; i++) { int clusterAssignment = clusterAssignments[i]; if (!clusterMap.containsKey(clusterAssignment)) { clusterMap.put(clusterAssignment, Sets.<double[][]>newIdentityHashSet()); }/*from w w w. ja va2s . c o m*/ clusterMap.get(clusterAssignment).add(annotatorParameters[i]); } // aggregate clustered parameters List<double[][]> clusteredAnnotatorParameters = Lists.newArrayList(); for (Set<double[][]> cluster : clusterMap.values()) { double[][][] clusterTensor = cluster.toArray(new double[][][] {}); double[][] averagedConfusions = Matrices.sumOverFirst(clusterTensor); Matrices.divideToSelf(averagedConfusions, cluster.size()); clusteredAnnotatorParameters.add(averagedConfusions); } // re-assign confusions return clusteredAnnotatorParameters.toArray(new double[][][] {}); }
From source file:io.cloudslang.maven.compiler.CloudSlangMavenCompiler.java
protected static Set<String> getSourceFilesForSourceRoot(CompilerConfiguration config, String sourceLocation) { Path path = Paths.get(sourceLocation); if (!Files.exists(path)) { return emptySet(); }//from ww w .ja v a 2s.c o m DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(sourceLocation); Set<String> includes = config.getIncludes(); if (includes != null && !includes.isEmpty()) { String[] inclStrs = includes.toArray(new String[includes.size()]); scanner.setIncludes(inclStrs); } else { scanner.setIncludes(new String[] { "**/*.sl.yaml", "**/*.sl", "**/*.sl.yml" }); } Set<String> configExcludes = config.getExcludes(); if (configExcludes != null && !configExcludes.isEmpty()) { String[] exclStrs = configExcludes.toArray(new String[configExcludes.size()]); scanner.setExcludes(exclStrs); } else { scanner.setExcludes(new String[] { "**/*prop.sl" }); } scanner.scan(); String[] sourceDirectorySources = scanner.getIncludedFiles(); Set<String> sources = new HashSet<>(); for (String sourceDirectorySource : sourceDirectorySources) { sources.add(new File(sourceLocation, sourceDirectorySource).getPath()); } return sources; }
From source file:net.mojodna.searchable.util.SearchableUtils.java
/** * @param clazz/*from w w w . ja v a 2s . com*/ * @return Field names. */ public static final String[] getFieldNames(final Class<? extends Searchable> clazz) { Set<String> fieldNames = new HashSet<String>(); for (Field fields : getFields(clazz)) { fieldNames.add(fields.name()); } return fieldNames.toArray(new String[] {}); }
From source file:com.mirth.connect.util.MirthSSLUtil.java
public static String[] getEnabledHttpsProtocols(String[] requestedProtocols) { logger.debug("Requested SSL protocols: " + Arrays.toString(requestedProtocols)); SSLContext sslContext = SSLContexts.createDefault(); String[] supportedProtocols = sslContext.getSupportedSSLParameters().getProtocols(); Set<String> enabledProtocols = new LinkedHashSet<String>(); for (String protocol : requestedProtocols) { if (ArrayUtils.contains(supportedProtocols, protocol)) { enabledProtocols.add(protocol); }//from w w w . jav a 2 s . c om } logger.debug("Enabled SSL protocols: " + String.valueOf(enabledProtocols)); return enabledProtocols.toArray(new String[enabledProtocols.size()]); }
From source file:org.bremersee.common.spring.autoconfigure.JaxbAutoConfiguration.java
public static Jaxb2Marshaller createJaxbMarshaller(final Collection<String> packages) { final Set<String> packageSet = createPackageSet(packages); Jaxb2Marshaller m = new Jaxb2Marshaller(); Map<String, Object> marshallerProperties = new HashMap<>(); marshallerProperties.put(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.setMarshallerProperties(marshallerProperties); m.setContextPaths(packageSet.toArray(new String[packageSet.size()])); return m;/*from w w w .ja v a 2 s.c o m*/ }
From source file:com.cassius.spring.assembly.test.common.toolbox.ContextUtil.java
/** * Get context configuration./*from w w w.j a v a 2 s. c o m*/ * * @param testInstance the test instance * @return the string [ ] */ public static String[] getContextConfiguration(Object testInstance) { Class<?> testClass = testInstance.getClass(); SpringAssemblyConfigure springAssemblyConfigure = AnnotationUtils.findAnnotation(testClass, SpringAssemblyConfigure.class); Set<String> files = com.cassius.spring.assembly.test.common.toolbox.ContextUtil .getSpringContextLocations(testClass); if (springAssemblyConfigure.createSpy()) { files.add(SPY_PROCESSOR_CONFIG); } String[] configurationLocations = new String[files.size()]; configurationLocations = files.toArray(configurationLocations); return configurationLocations; }
From source file:com.atomikos.jms.AtomikosJmsXaSessionProxy.java
public static Object newInstance(XASession s, XATransactionalResource jmsTransactionalResource, SessionHandleStateChangeListener pooledConnection, SessionHandleStateChangeListener connectionProxy) throws JMSException { AtomikosJmsXaSessionProxy proxy = new AtomikosJmsXaSessionProxy(s, jmsTransactionalResource, pooledConnection, connectionProxy); Set<Class> interfaces = PropertyUtils.getAllImplementedInterfaces(s.getClass()); //see case 24532 interfaces.add(DynamicProxy.class); Class[] interfaceClasses = (Class[]) interfaces.toArray(new Class[0]); Set<Class> minimumSetOfInterfaces = new HashSet<Class>(); minimumSetOfInterfaces.add(Reapable.class); minimumSetOfInterfaces.add(DynamicProxy.class); minimumSetOfInterfaces.add(javax.jms.Session.class); Class[] minimumSetOfInterfaceClasses = (Class[]) minimumSetOfInterfaces.toArray(new Class[0]); List<ClassLoader> classLoaders = new ArrayList<ClassLoader>(); classLoaders.add(Thread.currentThread().getContextClassLoader()); classLoaders.add(s.getClass().getClassLoader()); classLoaders.add(AtomikosJmsXaSessionProxy.class.getClassLoader()); return (Session) ClassLoadingHelper.newProxyInstance(classLoaders, minimumSetOfInterfaceClasses, interfaceClasses, proxy);//from www .j a v a2 s . c o m }
From source file:net.audumla.climate.ClimateDataFactory.java
/** * Replaces the climate data with a writable version. * * @param cd the existing climate data bean * @return the climate data//from ww w.j a va 2s . c o m */ public static WritableClimateData convertToWritableClimateData(ClimateData cd) { if (cd == null) { return null; } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); interfaces.addAll(ClassUtils.getAllInterfaces(cd.getClass())); return BeanUtils.convertBean(cd, WritableClimateData.class, interfaces.toArray(new Class<?>[interfaces.size()])); }
From source file:net.audumla.climate.ClimateDataFactory.java
/** * Replaces the climate observation with a readonly version. * * @param cd the existing climate data bean * @return the climate data//from w w w .j ava 2s .c o m */ public static WritableClimateObservation convertToWritableClimateObservation(ClimateObservation cd) { if (cd == null) { return null; } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); interfaces.addAll(ClassUtils.getAllInterfaces(cd.getClass())); return BeanUtils.convertBean(cd, WritableClimateObservation.class, interfaces.toArray(new Class<?>[interfaces.size()])); }