List of usage examples for java.util Set toArray
Object[] toArray();
From source file:it.mb.whatshare.Utils.java
/** * An equivalent of Python's <code>str.join()</code> function on lists: it * returns a String which is the concatenation of the strings in the * argument list. The separator between elements is the string providing * this method. The separator is appended after the first element and it is * not after the last element.//www . j ava 2 s.com * * @param toJoin * the separator * @param set * a set of <code>Object</code>s on which * {@link Object#toString()} will be called * @return the concatenation of String representations of the objects in the * set */ public static String join(String toJoin, Set<?> set) { return join(toJoin, set.toArray()); }
From source file:Main.java
static <E> Set<E> ungrowableSet(final Set<E> s) { return new Set<E>() { @Override/*from ww w. ja v a 2s. c o m*/ public int size() { return s.size(); } @Override public boolean isEmpty() { return s.isEmpty(); } @Override public boolean contains(Object o) { return s.contains(o); } @Override public Object[] toArray() { return s.toArray(); } @Override public <T> T[] toArray(T[] a) { return s.toArray(a); } @Override public String toString() { return s.toString(); } @Override public Iterator<E> iterator() { return s.iterator(); } @Override public boolean equals(Object o) { return s.equals(o); } @Override public int hashCode() { return s.hashCode(); } @Override public void clear() { s.clear(); } @Override public boolean remove(Object o) { return s.remove(o); } @Override public boolean containsAll(Collection<?> coll) { return s.containsAll(coll); } @Override public boolean removeAll(Collection<?> coll) { return s.removeAll(coll); } @Override public boolean retainAll(Collection<?> coll) { return s.retainAll(coll); } @Override public boolean add(E o) { throw new UnsupportedOperationException(); } @Override public boolean addAll(Collection<? extends E> coll) { throw new UnsupportedOperationException(); } }; }
From source file:edu.umass.cs.utils.Util.java
public static Object getRandomOtherThan(Set<?> all, Set<?> exclude) { Object[] allArray = all.toArray(); int index = -1; if (exclude.containsAll(all)) return null; while (exclude.contains(allArray[index = (int) (Math.random() * allArray.length)])) ;/* w ww. java 2 s . c o m*/ return allArray[index]; }
From source file:com.aurel.track.admin.customize.category.filter.parameters.FilterSelectsParametersUtil.java
/** * Get a list of IntegerStringBean for those fields which are parameterized * @param filterSelectsTO/*from ww w.j a va 2 s . c o m*/ * @return */ public static List<IntegerStringBean> getParameterizedFields(FilterUpperTO filterSelectsTO) { List<IntegerStringBean> result = new LinkedList<IntegerStringBean>(); List<Integer> upperSelectFields = getUpperSelectFields(filterSelectsTO); Set<Integer> fieldIDs = new HashSet<Integer>(); for (Integer fieldID : upperSelectFields) { if (containsParameter(filterSelectsTO.getSelectedValuesForField(fieldID))) { fieldIDs.add(fieldID); } } if (!fieldIDs.isEmpty()) { List<TFieldBean> allFields = FieldBL.loadByFieldIDs(fieldIDs.toArray()); for (TFieldBean fieldBean : allFields) { result.add(new IntegerStringBean(fieldBean.getName(), fieldBean.getObjectID())); } } //PSEUDO FIELDS if (containsParameter(filterSelectsTO.getSelectedConsultantsInformants())) { result.add(new IntegerStringBean("watcher", PSEUDO_FIELDS.CONSULTANT_INFORMNAT_FIELD_ID)); } return result; }
From source file:com.bloomreach.bstore.highavailability.utils.SolrInteractionUtils.java
/** * Create a solr collection with extra solrcore.properties path * if the solrcoreHttpPath is given then we will create the collection use a customized parameter * collection.dynamicProperties to create the collection with that file * * @param solrHosts/*w ww . j a v a2 s. c o m*/ * @param collectionName * @param configName * @param numShards * @param replicationFactor * @param numShardsPerNode * @param solrcoreHttpPath * @throws Exception */ public static void createCollection(Set<String> solrHosts, String collectionName, String configName, int numShards, int replicationFactor, int numShardsPerNode, String solrcoreHttpPath) throws Exception { logger.info("createCollection this is the collection " + collectionName + " and this is the replicationFactor: " + replicationFactor); String command = String.format( "http://%s:%s/solr/admin/collections?wt=json&action=CREATE&name=%s&numShards=%d&replicationFactor=%d&collection.configName=%s&maxShardsPerNode=%d", solrHosts.toArray()[0], DEFAULT_SOLR_PORT, collectionName, numShards, replicationFactor, configName, numShardsPerNode); if (!StringUtils.isBlank(solrcoreHttpPath)) { command += "&collection.solrcoreproperties=" + solrcoreHttpPath; } logger.info("createCollection this is the collection " + collectionName + " and this is the command: " + command); String result = SolrInteractionUtils.executeSolrCommand(command); logger.info(result); }
From source file:com.aurel.track.admin.customize.lists.systemOption.IssueTypeBL.java
public static List<TListTypeBean> loadByPersonAndProjectAndRight(Integer personID, Integer projectID, int[] rightFlags, boolean documents) { List<TListTypeBean> resultList = new LinkedList<TListTypeBean>(); if (projectID == null) { return resultList; }//from w w w.j a v a2 s .co m //allowed by project type TProjectBean projectBean = LookupContainer.getProjectBean(projectID); List<TListTypeBean> issueTypesAllowedByProjectType = loadAllowedByProjectType(projectBean.getProjectType(), documents); //get the roles Set<Integer> rolesSet = AccessBeans.getRolesWithRightForPersonInProject(personID, projectID, rightFlags); if (rolesSet == null || rolesSet.isEmpty()) { return resultList; } Object[] roleIDs = rolesSet.toArray(); //roles with issueType restrictions List<TRoleBean> roleWithExplicitIssueType = RoleBL.loadWithExplicitIssueType(roleIDs); //at least one role has no restrictions for listType if (roleWithExplicitIssueType != null && roleWithExplicitIssueType.size() < rolesSet.size()) { //load all list types allowed in project type return issueTypesAllowedByProjectType; } //all roles have explicit issue type restrictions //get all those explicit issueTypes for roles List<TListTypeBean> allowedByRoles = issueTypeDAO.loadForRoles(roleIDs); Map<Integer, TListTypeBean> allowedByProjectTypeMap = GeneralUtils .createMapFromList(issueTypesAllowedByProjectType); if (allowedByRoles != null) { Iterator<TListTypeBean> iterator = allowedByRoles.iterator(); while (iterator.hasNext()) { TListTypeBean listTypeBean = iterator.next(); if (!allowedByProjectTypeMap.containsKey(listTypeBean.getObjectID())) { iterator.remove(); } } } return allowedByRoles; }
From source file:com.matel.pg.dao.impl.SalesItemDAOImpl.java
@Override public void save(Set<SalesItem> salesItemsToSave) { if (salesItemsToSave.toArray().length > 0) { System.out.println(".................................." + salesItemsToSave.size()); System.out.println(((SalesItem) (salesItemsToSave.toArray()[0])).getQboId()); // System.out.println(((SalesItem) (salesItemsToSave.toArray()[1])).getQboId()); }//from www .j a v a 2s .c o m // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:com.matel.pg.dao.impl.CustomerDAOImpl.java
@Override public void save(Set<Customer> customersToSave) { if (customersToSave.toArray().length > 0) { System.out.println(((Customer) (customersToSave.toArray()[0])).getQboId()); }// www. ja va 2 s . c om // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:demo.vmware.commands.CommandPurgeAllRegions.java
/** * Iterates across aregion deleting everything * //from w w w.j ava2 s . com * @param region */ private void removeAllFromRegion(Region<?, ?> region) { Set regionKeys = region.keySet(); Object regionKeyArray[] = regionKeys.toArray(); for (Object oneKey : regionKeyArray) { region.remove(oneKey); } }
From source file:it.geosolutions.geobatch.ui.mvc.FlowManagerInfoController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Catalog catalog = (Catalog) getApplicationContext().getBean("catalog"); String fmId = request.getParameter("fmId"); ModelAndView mav = new ModelAndView("flowinfo"); FileBasedFlowManager fm = catalog.getResource(fmId, FileBasedFlowManager.class); mav.addObject("flowManager", fm); Set<BaseEventConsumer> tree = fm.getEventConsumers(); mav.addObject("ecList", tree.toArray()); return mav;//from www. jav a 2 s . c om }