List of usage examples for java.util Comparator Comparator
Comparator
From source file:ch.silviowangler.dox.web.admin.StatisticsController.java
@RequestMapping(value = "/admin/stats/documentReferences", method = GET) @ResponseStatus(OK)/*from w ww .ja va 2 s . c o m*/ public @ResponseBody List<DocumentReferenceClickStats> showDocumentReferenceStats() { List<DocumentReferenceClickStats> stats = statisticsService.fetchDocumentReferenceClickStats(); Collections.sort(stats, new Comparator<DocumentReferenceClickStats>() { @Override public int compare(DocumentReferenceClickStats o1, DocumentReferenceClickStats o2) { return Long.valueOf(o2.getCount()).compareTo(o1.getCount()); } }); return stats; }
From source file:de.micromata.genome.tpsb.httpmockup.MockWebElementConfig.java
public void sortMappingDefs() { List<? extends MockMapDef> mapDef = getMappingDefs(); Collections.sort(mapDef, new Comparator<MockMapDef>() { int getMapDefPrio(MockMapDef md) { String up = md.getUrlPattern(); if (up.equals("/") == true) { return 10000; }/*from w ww .j ava2 s . c o m*/ if (up.startsWith("*.") == true) { return 1000; } if (up.contains("*") == false) { return up.length() * 100; } return up.length(); } @Override public int compare(MockMapDef o1, MockMapDef o2) { int o1prio = getMapDefPrio(o1); int o2prio = getMapDefPrio(o2); int ret = o1prio - o2prio; return ret; } }); }
From source file:net.chrissearle.flickrvote.web.admin.ShowPhotographerImagesAction.java
@Override public String execute() throws Exception { photographer = new DisplayPhotographer(photographyService.findById(id)); images = new ArrayList<DisplayImage>(); for (ImageItem image : photographyService.getImagesForPhotographer(id)) { images.add(new DisplayImage(image)); }// w w w . j a v a 2 s .c o m Collections.sort(images, new Comparator<DisplayImage>() { public int compare(DisplayImage o1, DisplayImage o2) { return o2.getChallengeTag().compareTo(o1.getChallengeTag()); } }); return SUCCESS; }
From source file:de.kp.ames.web.core.json.DoubleCollector.java
public DoubleCollector() { collector = new TreeMap<Double, ArrayList<JSONObject>>(new Comparator<Double>() { public int compare(Double double1, Double double2) { return double1.compareTo(double2); }/*from ww w . j a va 2s .co m*/ }); }
From source file:de.xwic.appkit.webbase.actions.EntityActionsHelper.java
/** * @param site/* ww w .jav a 2s . c o m*/ * @param entityProvider * @param view * @param entityClass * @return */ public static Map<String, List<IEntityAction>> getEntityActionsInGroups(Site site, IEntityProvider entityProvider, String view, Class<? extends IEntity> entityClass) { Map<String, List<IEntityAction>> actionsInGroups = new LinkedHashMap<String, List<IEntityAction>>(); DAO dao = DAOSystem.findDAOforEntity(entityClass); List<IExtension> extensions = ExtensionRegistry.getInstance().getExtensions(EXTENSION_POINT_ACTIONS); Collections.sort(extensions, new Comparator<IExtension>() { @Override public int compare(IExtension e0, IExtension e1) { // AI 05-Jun-2013: no longer sort by groups alphabetically - keep only the index sorting and // make sure you define the actions in extensions.xml exactly in the order you want them // String g0 = e0.getAttribute("group"); // if (g0 == null) { // g0 = ""; // } // // String g1 = e1.getAttribute("group"); // if (g1 == null) { // g1 = ""; // } // // if (!g0.equals(g1)) { // return g0.compareTo(g1); // } String strIndex0 = e0.getAttribute("index"); int i0 = strIndex0 != null ? Integer.parseInt(strIndex0) : 0; String strIndex1 = e1.getAttribute("index"); int i1 = strIndex1 != null ? Integer.parseInt(strIndex1) : 0; return i0 < i1 ? -1 : i0 == i1 ? 0 : 1; } }); for (IExtension extension : extensions) { String applyToView = extension.getAttribute("applyToView"); String applyToEntity = extension.getAttribute("applyToEntity"); boolean applies = (applyToView != null && !applyToView.isEmpty() && ("*".equals(applyToView) || applyToView.contains(view))) || (applyToEntity != null && !applyToEntity.isEmpty() && ("*".equals(applyToEntity) || applyToEntity.contains(entityClass.getName()))); if (applies) { IEntityAction action = createEntityAction(site, extension.getId(), dao, entityProvider); if (action != null) { String inDropDown = extension.getAttribute("inDropDown"); action.setInDropDown(inDropDown != null && "true".equalsIgnoreCase(inDropDown)); String group = extension.getAttribute("group"); if (group == null) { group = ""; } List<IEntityAction> actions = null; if (actionsInGroups.containsKey(group)) { actions = actionsInGroups.get(group); } else { actions = new ArrayList<IEntityAction>(); actionsInGroups.put(group, actions); } actions.add(action); } } } return actionsInGroups; }
From source file:com.js.quickestquail.ui.stats.RatingStat.java
private CategoryDataset generateDataset() { Map<Double, Integer> ratingFrequency = new HashMap<>(); for (String id : DriveManager.get().getSelected().values()) { Movie mov = CachedMovieProvider.get().getMovieByID(id); int temp = ((int) (mov.getImdbRating() * 10)); double rating = (temp - temp % 5) / 10.0; if (!ratingFrequency.containsKey(rating)) { ratingFrequency.put(rating, 1); } else {//w ww . j ava 2 s . c o m ratingFrequency.put(rating, ratingFrequency.get(rating) + 1); } } // sort List<Entry<Double, Integer>> entries = new ArrayList<>(ratingFrequency.entrySet()); java.util.Collections.sort(entries, new Comparator<Entry<Double, Integer>>() { @Override public int compare(Entry<Double, Integer> o1, Entry<Double, Integer> o2) { return o1.getKey().compareTo(o2.getKey()); } }); // convert to proper format DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Map.Entry<Double, Integer> en : entries) { dataset.addValue(en.getValue(), java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.rating.xaxis"), en.getKey()); } // return return dataset; }
From source file:de.kp.ames.web.core.json.DateCollector.java
public DateCollector() { collector = new TreeMap<Date, ArrayList<JSONObject>>(new Comparator<Date>() { public int compare(Date date1, Date date2) { // this is a descending sorting of two dates return (-1) * date1.compareTo(date2); }/*from ww w . j a v a 2 s. com*/ }); }
From source file:py.una.pol.karaku.replication.server.FirstChangeProviderHandler.java
@PostConstruct @SuppressWarnings("rawtypes") void sort() {//from w w w .j a v a2 s.c o m Collections.sort(providers, new Comparator<FirstChangeProvider>() { @Override public int compare(FirstChangeProvider arg0, FirstChangeProvider arg1) { return arg1.getPriority().compareTo(arg0.getPriority()); } }); }
From source file:com.cronutils.parser.field.CronParserField.java
/** * Create a Comparator that compares CronField instances using CronFieldName value. * @return Comparator for CronField instance, never null. *//* ww w . java 2 s .com*/ public static Comparator<CronParserField> createFieldTypeComparator() { return new Comparator<CronParserField>() { @Override public int compare(CronParserField o1, CronParserField o2) { return o1.getField().getOrder() - o2.getField().getOrder(); } }; }
From source file:de.kp.ames.web.core.json.StringCollector.java
public StringCollector() { collector = new TreeMap<String, ArrayList<JSONObject>>(new Comparator<String>() { public int compare(String name1, String name2) { return name1.compareTo(name2); }/*from w ww . j a v a 2 s . co m*/ }); }