List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:io.werval.cli.DamnSmallDevShell.java
private static void devshellCommand(boolean debug, File tmpDir, CommandLine cmd) throws IOException { final File classesDir = createClassesDirectory(debug, tmpDir); Set<File> sourceRoots = prepareSourcesRoots(debug, cmd); Set<URL> applicationSourcesSet = new LinkedHashSet<>(sourceRoots.size()); for (File sourceRoot : sourceRoots) { applicationSourcesSet.add(sourceRoot.toURI().toURL()); }/*from ww w. ja va 2s . c o m*/ URL[] applicationSources = applicationSourcesSet.toArray(new URL[applicationSourcesSet.size()]); URL[] applicationClasspath = prepareApplicationClasspath(debug, classesDir); URL[] runtimeClasspath = prepareRuntimeClasspath(debug, sourceRoots, cmd); applySystemProperties(debug, cmd); System.out.println("Loading..."); // Watch Sources SourceWatcher watcher = new JavaWatcher(); // First build rebuild(applicationClasspath, runtimeClasspath, sourceRoots, classesDir); // Run DevShell Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook(tmpDir), "werval-cli-cleanup")); new DevShellCommand(new SPI(applicationSources, applicationClasspath, runtimeClasspath, sourceRoots, watcher, classesDir)).run(); }
From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.DockerService.java
private static String[] environmentFrom(CreateAgentRequest request, PluginSettings settings, String containerName) {// ww w .j a va 2 s . c o m Set<String> env = new HashSet<>(); env.addAll(settings.getEnvironmentVariables()); if (StringUtils.isNotBlank(request.properties().get("Environment"))) { env.addAll(splitIntoLinesAndTrimSpaces(request.properties().get("Environment"))); } env.addAll(Arrays.asList("GO_EA_MODE=" + mode(), "GO_EA_SERVER_URL=" + settings.getGoServerUrl(), "GO_EA_GUID=" + "docker-swarm." + containerName)); env.addAll(request.autoregisterPropertiesAsEnvironmentVars(containerName)); return env.toArray(new String[env.size()]); }
From source file:org.eclipse.virgo.ide.facet.core.FacetUtils.java
public static IProject[] getBundleProjects(IProject parProject) { Set<IProject> bundles = new HashSet<IProject>(); if (isParProject(parProject)) { Par par = getParDefinition(parProject); if (par != null && par.getBundle() != null) { for (Bundle bundle : par.getBundle()) { IProject bundleProject = ResourcesPlugin.getWorkspace().getRoot() .getProject(bundle.getSymbolicName()); if (FacetUtils.isBundleProject(bundleProject)) { bundles.add(bundleProject); }// w ww .ja va 2s . co m } } } return (IProject[]) bundles.toArray(new IProject[bundles.size()]); }
From source file:net.geoprism.ontology.Classifier.java
@Transaction public static String[] restoreSynonym(String synonymId) { ClassifierSynonym synonym = ClassifierSynonym.get(synonymId); Classifier[] classifiers = synonym.restore(); Set<String> ids = new TreeSet<String>(); for (Classifier classifier : classifiers) { ids.add(classifier.getId());/*w ww.j a v a 2 s .c om*/ } return ids.toArray(new String[ids.size()]); }
From source file:AmazonDynamoDBSample.java
private static void oneTimeAddContacts() { String firstNameLastName = ""; String saltS = ""; String ssnhash = ""; Set<String> unionSet = new HashSet<>(); unionSet.addAll(set1);/* w ww .j a v a 2s.co m*/ unionSet.addAll(set2); String strArrr[] = unionSet.toArray(new String[unionSet.size()]); int numEntries = saltHashMap.size(); for (int i = 0; i < numEntries; i++) { firstNameLastName = strArrr[i]; saltS = saltHashMap.get(strArrr[i]); ssnhash = hashedssnHashMap.get(strArrr[i]); Map<String, AttributeValue> item = newContactItem(firstNameLastName, saltS, ssnhash); PutItemRequest putItemRequest = new PutItemRequest("contacts-table", item); PutItemResult putItemResult = dynamoDB.putItem(putItemRequest); } }
From source file:com.baomidou.mybatisplus.toolkit.PackageHelper.java
/** * <p>/*from w w w .j ava 2 s.c o m*/ * ??? * </p> * <p> * <property name="typeAliasesPackage" value="com.baomidou.*.entity"/> * </p> * * @param typeAliasesPackage * ?? * @return */ public static String[] convertTypeAliasesPackage(String typeAliasesPackage) { ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver(); MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver); String pkg = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(typeAliasesPackage) + "/*.class"; /* * ??Resource * ClassLoader.getResource("META-INF")????????? */ try { Set<String> set = new HashSet<String>(); Resource[] resources = resolver.getResources(pkg); if (resources != null && resources.length > 0) { MetadataReader metadataReader = null; for (Resource resource : resources) { if (resource.isReadable()) { metadataReader = metadataReaderFactory.getMetadataReader(resource); set.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage() .getName()); } } } if (!set.isEmpty()) { return set.toArray(new String[] {}); } else { throw new MybatisPlusException("not find typeAliasesPackage:" + pkg); } } catch (Exception e) { throw new MybatisPlusException("not find typeAliasesPackage:" + pkg, e); } }
From source file:caveworld.core.ConfigHelper.java
public static String[] getStringsFromItems(Collection<ItemStack> items) { Set<String> ret = Sets.newLinkedHashSet(); for (ItemStack itemstack : items) { if (itemstack != null && itemstack.getItem() != null) { String name = GameData.getItemRegistry().getNameForObject(itemstack.getItem()); int damage = itemstack.getItemDamage(); if (itemstack.isItemStackDamageable()) { ret.add(name);//from w ww. jav a2s .c o m } else if (itemstack.getHasSubtypes() || damage > 0) { ret.add(name + ":" + damage); } else { ret.add(name); } } } return ret.toArray(new String[ret.size()]); }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
public static void setDefaultSize(int size) { Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet(); Object[] keys = keySet.toArray(new Object[keySet.size()]); for (Object key : keys) { if (key != null && key.toString().toLowerCase().contains("font")) { Font font = UIManager.getDefaults().getFont(key); if (font != null) { font = font.deriveFont((float) size); UIManager.put(key, font); }/*from w ww . j a v a2 s . c o m*/ } } }
From source file:ch.entwine.weblounge.contentrepository.index.SearchIndexRecencyPriorityTest.java
/** * Sets up the solr search index. Since solr sometimes has a hard time * shutting down cleanly, it's done only once for all the tests. * /*from w w w. j ava 2s . c o m*/ * @throws Exception */ @BeforeClass public static void setupClass() throws Exception { // Template template = EasyMock.createNiceMock(PageTemplate.class); EasyMock.expect(template.getIdentifier()).andReturn("templateid").anyTimes(); EasyMock.expect(template.getStage()).andReturn("non-existing").anyTimes(); EasyMock.replay(template); Set<Language> languages = new HashSet<Language>(); languages.add(LanguageUtils.getLanguage("en")); languages.add(LanguageUtils.getLanguage("de")); // Site site = EasyMock.createNiceMock(Site.class); EasyMock.expect(site.getIdentifier()).andReturn("test").anyTimes(); EasyMock.expect(site.getTemplate((String) EasyMock.anyObject())).andReturn(template).anyTimes(); EasyMock.expect(site.getDefaultTemplate()).andReturn(template).anyTimes(); EasyMock.expect(site.getLanguages()).andReturn(languages.toArray(new Language[languages.size()])) .anyTimes(); EasyMock.replay(site); // Resource serializer serializer = new ResourceSerializerServiceImpl(); serializer.addSerializer(new PageSerializer()); serializer.addSerializer(new FileResourceSerializer()); serializer.addSerializer(new ImageResourceSerializer()); serializer.addSerializer(new MovieResourceSerializer()); String rootPath = PathUtils.concat(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); idxRoot = new File(rootPath); System.setProperty("weblounge.home", rootPath); ElasticSearchUtils.createIndexConfigurationAt(idxRoot); idx = new SearchIndex(site, serializer, isReadOnly); }
From source file:org.grails.datastore.mapping.reflect.ReflectionUtils.java
/** * Retrieves all the properties of the given class for the given type * * @param clazz The class to retrieve the properties from * @param propertyType The type of the properties you wish to retrieve * * @return An array of PropertyDescriptor instances *//* w ww . j av a2 s.com*/ public static PropertyDescriptor[] getPropertiesOfType(Class<?> clazz, Class<?> propertyType) { if (clazz == null || propertyType == null) { return new PropertyDescriptor[0]; } Set<PropertyDescriptor> properties = new HashSet<PropertyDescriptor>(); try { for (PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(clazz)) { Class<?> currentPropertyType = descriptor.getPropertyType(); if (isTypeInstanceOfPropertyType(propertyType, currentPropertyType)) { properties.add(descriptor); } } } catch (Exception e) { // if there are any errors in instantiating just return null for the moment return new PropertyDescriptor[0]; } return properties.toArray(new PropertyDescriptor[properties.size()]); }