List of usage examples for java.util Collections sort
@SuppressWarnings("unchecked") public static <T extends Comparable<? super T>> void sort(List<T> list)
From source file:com.intuit.tank.vm.settings.LocationsConfig.java
@SuppressWarnings("unchecked") private void initConfig() { locations = new ArrayList<SelectableItem>(); if (config != null) { List<HierarchicalConfiguration> e = config.configurationsAt(KEY_LOCATION); if (e != null) { for (HierarchicalConfiguration c : e) { locations.add(new SelectableItem(c.getString(KEY_DISPLAY_NAME), c.getString(KEY_NAME))); }//from w ww . j ava 2 s. com } } Collections.sort(locations); }
From source file:edu.temple.cis3238.wiki.utils.CollectionsUtilitiesTest.java
/** * Test of filterList+ pluck methods of class CollectionsUtilities. *//*from w ww.ja va 2s. c o m*/ @Test public void testFilterList() { Set<String> actualSet = new TreeSet<String>(); ; System.out.println( "pluck column from Object and return CSV" + "\n=======================================\n\n"); GeneralDAO dao = new GeneralDAO(dbc); Set expResult = null; ArrayList<TagsVO> tagVOLIst; String expected = ""; String actual; tagVOLIst = dao.getTags(); Collections.sort(tagVOLIst); for (int i = 0; i < tagVOLIst.size(); i++) { expected += tagVOLIst.get(i).getTagName(); if (i < tagVOLIst.size() - 1) { expected += ","; } } Set<String> result = CollectionsUtilities.pluckList(tagVOLIst, "tagname"); actualSet.addAll(result); actual = setToCSV(result); System.out.println("====================\nactual" + "\n------------------------------------\n" + actual + "\n------------------------------------\n"); System.out.println("====================\nexpected" + "\n------------------------------------\n" + expected + "\n------------------------------------\n"); assertEquals(result, actualSet); }
From source file:com.boyuanitsm.pay.alipay.util.AlipayCore.java
/** * ??=???&??/*ww w . jav a2 s . co m*/ * @param params ???? * @return ? */ public static String createLinkString(Map<String, String> params) { List<String> keys = new ArrayList<String>(params.keySet()); Collections.sort(keys); String prestr = ""; for (int i = 0; i < keys.size(); i++) { String key = keys.get(i); String value = params.get(key); if (i == keys.size() - 1) {//??& prestr = prestr + key + "=" + value; } else { prestr = prestr + key + "=" + value + "&"; } } return prestr; }
From source file:com.glaf.core.tree.helper.DTreeHelper.java
/** * dtree//from w w w. j a v a 2 s . c o m * * @param components * @return */ public String buildTreeScript(List<TreeModel> treeModels, String iTree, boolean showLink) { Collections.sort(treeModels); TreeRepositoryBuilder builder = new TreeRepositoryBuilder(); TreeRepository repository = builder.build(treeModels); StringBuffer buffer = new StringBuffer(); List<?> topComponents = repository.getTopTrees(); for (int i = 0, len = topComponents.size(); i < len; i++) { TreeComponent component = (TreeComponent) topComponents.get(i); buffer.append(newline); buffer.append(" ").append(iTree).append(".add('").append(component.getId()).append("', '-1', '") .append(component.getTitle()).append("'"); if (showLink) { if (StringUtils.isNotEmpty(component.getLocation())) { buffer.append(", \"javascript:gotoLink('").append(component.getId()).append("','") .append(component.getTitle()).append("','").append(component.getLocation()) .append("');\""); } else { buffer.append(", '").append("'"); } if (StringUtils.isNotEmpty(component.getTarget())) { buffer.append(", '").append(component.getTarget()).append("'"); } } else { buffer.append(",'',''"); } buffer.append(");"); buffer.append(newline); buffer.append(buildTreeModel(component, iTree, showLink)); buffer.append(newline); } buffer.append(newline); return buffer.toString(); }
From source file:com.google.mr4c.sources.InMemoryArchiveSource.java
public List<String> getAllFileNames() throws IOException { List<String> names = new ArrayList<String>(m_files.keySet()); Collections.sort(names); return names; }
From source file:biz.netcentric.vlt.upgrade.handler.GroovyConsoleHandler.java
@Override public void execute(InstallContext ctx) throws RepositoryException { this.ctx = ctx; scripts = getScriptsFromConfig();/*from www . java 2s . c o m*/ Collections.sort(scripts.get(ctx.getPhase())); // make sure we're executing in alphabetical order for (String scriptPath : scripts.get(ctx.getPhase())) { runScript(scriptPath); } }
From source file:edu.northwestern.bioinformatics.studycalendar.dao.ActivityDao.java
/** * Returns a list of all the activities currently available. * * @return list of all the Activities currently available *///from ww w . j a v a 2 s . c om @Override @SuppressWarnings({ "unchecked" }) public List<Activity> getAll() { List<Activity> sortedList = super.getAll(); Collections.sort(sortedList); return sortedList; }
From source file:ilarkesto.form.DropdownFormField.java
public DropdownFormField<E> setSelectableItems(Collection<E> items) { List<E> itemList = (List<E>) (items instanceof List ? items : new ArrayList<E>(items)); if (!itemList.isEmpty() && itemList.get(0) instanceof Comparable) Collections.sort((List) itemList); this.selectableItems = new TreeMap<String, E>(); int i = 0;//w w w . j a v a 2 s .co m for (E item : itemList) { String key = Str.fillUpLeft(String.valueOf(i++), "0", 4); selectableItems.put(key, item); } return this; }
From source file:gov.nih.nci.caintegrator.web.action.study.management.EditStudyLogAction.java
/** * {@inheritDoc}//from ww w . j a va2 s . c o m */ @Override public void prepare() { super.prepare(); displayableLogEntries.clear(); for (LogEntry logEntry : getStudyConfiguration().getLogEntries()) { displayableLogEntries .add(new DisplayableLogEntry(getStudyManagementService().getRefreshedEntity(logEntry))); } Collections.sort(displayableLogEntries); }
From source file:com.dianping.avatar.cache.util.CacheAnnotationUtils.java
/** * Retrieve the cache key values from entity instance */// w w w . j a va 2 s .co m public static Object[] getCacheKeyValues(Object entity) { if (entity == null) { throw new IllegalArgumentException("Entity is null."); } Class<?> cz = entity.getClass(); Cache cache = cz.getAnnotation(Cache.class); if (cache == null) { throw new SystemException("The entity must be annotated by Cache."); } Field[] fields = ClassUtils.getDeclaredFields(cz); final List<OrderedField> cacheFields = new ArrayList<OrderedField>(); // Extract annotated fields for (int i = 0; i < fields.length; i++) { Field f = fields[i]; CacheParam fCache = f.getAnnotation(CacheParam.class); if (fCache != null) { cacheFields.add(new OrderedField(f, i, fCache.order())); } } // Extract declared fields for (int i = 0; i < cache.fields().length; i++) { String fieldName = cache.fields()[i]; if (fieldName.isEmpty()) { continue; } Field f = ReflectionUtils.findField(cz, fieldName); if (f == null) { throw new IllegalArgumentException( "Invalid cahce parameter " + fieldName + ", the filed is not exists."); } cacheFields.add(new OrderedField(f, i, -Integer.MAX_VALUE + i)); } Collections.sort(cacheFields); Object[] values = new Object[cacheFields.size()]; for (int i = 0; i < cacheFields.size(); i++) { OrderedField oField = cacheFields.get(i); ReflectionUtils.makeAccessible((Field) oField.field); values[i] = ReflectionUtils.getField((Field) oField.field, entity); } return values; }