List of usage examples for java.util Set toArray
<T> T[] toArray(T[] a);
From source file:com.hazelcast.simulator.tests.map.SerializationStrategyTest.java
private String[] generateUniqueStrings(int uniqueStringsCount) { Set<String> stringsSet = new HashSet<String>(uniqueStringsCount); do {//ww w . j a v a 2 s . c om String randomString = RandomStringUtils.randomAlphabetic(30); stringsSet.add(randomString); } while (stringsSet.size() != uniqueStringsCount); uniqueStrings.addAll(stringsSet); return stringsSet.toArray(new String[uniqueStringsCount]); }
From source file:guru.qas.martini.gherkin.DefaultGherkinResourceLoader.java
@Override public Resource[] getFeatureResources() { ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(loader); Set<Resource> resources = new HashSet<>(); patterns.forEach(p -> {/*from www . ja v a2s . c o m*/ try { Resource[] resourceArray = resolver.getResources(p); resources.addAll(Lists.newArrayList(resourceArray)); } catch (IOException e) { throw new RuntimeException("unable to load Resource for pattern " + p, e); } }); return resources.toArray(new Resource[resources.size()]); }
From source file:springfox.documentation.spring.data.rest.EntityRequestHandler.java
@Override public PatternsRequestCondition getPatternsCondition() { PatternsRequestCondition repositoryPatterns = requestMapping.getPatternsCondition(); Set<String> patterns = newHashSet(); for (String each : repositoryPatterns.getPatterns()) { patterns.add(each.replace("{repository}", resource.getPath().toString())); }/* w w w . j a va 2 s . c o m*/ return new PatternsRequestCondition(patterns.toArray(new String[patterns.size()])); }
From source file:de.tudarmstadt.ukp.lmf.transform.DBToXMLTransformer.java
/** * Transforms a {@link LexicalResource} instance retrieved from a database * to a XML file. The created XML only contains {@link Lexicon} instances which * names are specified in the consumed {@link Set}. {@link SenseAxis} instances are omitted. * * @param lexicalResource the lexical resource retrieved from the database * * @param lexicons the set of names of lexicons which should be written to XML file * * @throws SAXException if a severe error occurs when writing to a file * * @since UBY 0.2.0/*from w w w . ja va2 s . c om*/ * * @see #transform(LexicalResource) * @see #transformSenseAxes(LexicalResource) */ public void transformLexicons(final LexicalResource lexicalResource, final Set<String> lexicons) throws SAXException { this.lexicalResource = lexicalResource; openSession(); try { doTransform(false, lexicons.toArray(new Lexicon[0])); } finally { closeSession(); } }
From source file:com.espertech.esper.epl.named.NamedWindowIndexRepository.java
public IndexMultiKey[] getIndexDescriptors() { Set<IndexMultiKey> keySet = tableIndexesRefCount.keySet(); return keySet.toArray(new IndexMultiKey[keySet.size()]); }
From source file:com.berwickheights.spring.svc.security.UserRolesSvcImpl.java
@Override public GrantedAuthority[] getUserRoles(Set<Short> userRoles) { Set<GrantedAuthority> auths = new TreeSet<GrantedAuthority>(); for (Short userRole : userRoles) { Set<GrantedAuthority> authsForRole = rolesMap.get(userRole); if (authsForRole == null) { logger.warn("No authorities for given userRole: " + userRole); } else {/*from w w w. j a v a 2s . c om*/ auths.addAll(authsForRole); } } return auths.toArray(new GrantedAuthority[auths.size()]); }
From source file:com.redhat.rhn.frontend.action.user.AssignedGroupsSetupAction.java
/** * Get the String versions of the Default System Groups * @param user group strings to get from * @return array of strings//from ww w . j a v a2s . com */ private String[] getDefaultGroupStrings(User user) { // We need to be setting the defaultGroups stuff to a String[], but // we are getting a Set of Longs, so convert it and set it. Set groups = user.getDefaultSystemGroupIds(); Set groupStrings = new HashSet(); Iterator i = groups.iterator(); while (i.hasNext()) { Object o = i.next(); groupStrings.add(o.toString()); } return (String[]) groupStrings.toArray(new String[0]); }
From source file:info.dolezel.fatrat.plugins.helpers.JarClassLoader.java
public Class[] findAnnotatedClasses(String packageName, Class ann) throws IOException, ClassNotFoundException { Set<Class> rv = new HashSet<Class>(); rv.addAll(findAnnotatedClassesLocal(packageName, ann)); for (JarClassLoader cl : children.values()) { rv.addAll(cl.findAnnotatedClassesLocal(packageName, ann)); }/* w w w . ja v a2 s . co m*/ return rv.toArray(new Class[rv.size()]); }
From source file:fr.gael.dhus.api.stub.admin.AdminUserController.java
private List<UserData> convertUserToUserData(Iterator<User> it, int max) { int n = 0;/* w w w . ja v a 2 s . c om*/ List<UserData> user_data_list = new ArrayList<>(); while (n < max && it.hasNext()) { User user = it.next(); Set<AccessRestriction> restrictions = user.getRestrictions(); String reason = null; if (!restrictions.isEmpty()) { reason = restrictions.toArray(new AccessRestriction[restrictions.size()])[0].getBlockingReason(); } List<RoleData> roles = new ArrayList<>(); for (Role role : user.getRoles()) { roles.add(RoleData.valueOf(role.name())); } UserData user_data = new UserData(user.getId(), user.getUsername(), user.getFirstname(), user.getLastname(), user.getEmail(), roles, user.getPhone(), user.getAddress(), reason, user.getCountry(), user.getUsage(), user.getSubUsage(), user.getDomain(), user.getSubDomain()); user_data_list.add(user_data); n++; } return user_data_list; }
From source file:org.wrml.runtime.service.rest.RestService.java
@Override public Model get(final Keys keys, final Dimensions dimensions) { final Context context = getContext(); final URI uri = keys.getValue(context.getSchemaLoader().getDocumentSchemaUri()); final Set<Header> requestHeaders = RestUtils.extractRequestHeaders(context, dimensions); final HttpGet httpGet = new HttpGet(uri); final Header[] requestHeaderArray = new Header[requestHeaders.size()]; httpGet.setHeaders(requestHeaders.toArray(requestHeaderArray)); final HttpResponse response = executeRequest(httpGet); final Dimensions responseDimensions = RestUtils.extractResponseDimensions(context, response, dimensions); return readResponseModel(response, context, keys, responseDimensions); }