List of usage examples for java.util Comparator Comparator
Comparator
From source file:com.github.fge.jsonschema.keyword.digest.draftv4.RequiredDigester.java
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final ArrayNode required = FACTORY.arrayNode(); ret.put(keyword, required);//from w w w . j a v a 2s. c o m final List<JsonNode> list = Lists.newArrayList(schema.get(keyword)); Collections.sort(list, new Comparator<JsonNode>() { @Override public int compare(final JsonNode o1, final JsonNode o2) { return o1.textValue().compareTo(o2.textValue()); } }); required.addAll(list); return ret; }
From source file:org.traccar.web.CsvBuilder.java
private SortedSet<Method> getSortedMethods(Object object) { Method[] methodArray = object.getClass().getMethods(); SortedSet<Method> methods = new TreeSet<Method>(new Comparator<Method>() { @Override//w ww . j a v a 2 s. co m public int compare(Method m1, Method m2) { if (m1.getName().equals("getAttributes") && !m1.getName().equals(m2.getName())) { return 1; } if (m2.getName().equals("getAttributes") && !m1.getName().equals(m2.getName())) { return -1; } return m1.getName().compareTo(m2.getName()); } }); methods.addAll(Arrays.asList(methodArray)); return methods; }
From source file:com.github.braully.web.DescriptorHtmlEntity.java
private void parseFieldClass(Class classe1) { ReflectionUtils.doWithFields(classe1, (Field field) -> { addHtmlFormElement(field);/* w w w .j a v a 2 s .co m*/ addHtmlFilterElement(field); addHtmlListElement(field); }); Collections.sort(elementsList, new Comparator<DescriptorHtmlEntity>() { @Override public int compare(DescriptorHtmlEntity t, DescriptorHtmlEntity t1) { try { return t.property.compareToIgnoreCase(t1.property); } catch (Exception e) { } return 0; } }); }
From source file:com.limegroup.gnutella.gui.LanguageUtils.java
/** * Returns an array of supported language as a LanguageInfo[], always having * the English language as the first element. * //w w w .ja v a2 s . c o m * This will only include languages that can be displayed using the given * font. If the font is null, all languages are returned. */ public static Locale[] getLocales(Font font) { final List<Locale> locales = new LinkedList<Locale>(); File jar = FileUtils.getJarFromClasspath(LanguageUtils.class.getClassLoader(), BUNDLE_MARKER); if (jar != null) { addLocalesFromJar(locales, jar); } else { LOG.warn("Could not find bundle jar to determine locales"); } Collections.sort(locales, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName(o1).compareToIgnoreCase(o2.getDisplayName(o2)); } }); locales.remove(Locale.ENGLISH); locales.add(0, Locale.ENGLISH); // remove languages that cannot be displayed using this font if (font != null && !OSUtils.isMacOSX()) { for (Iterator<Locale> it = locales.iterator(); it.hasNext();) { Locale locale = it.next(); if (!GUIUtils.canDisplay(font, locale.getDisplayName(locale))) { it.remove(); } } } return locales.toArray(new Locale[0]); }
From source file:com.facebook.presto.accumulo.examples.Main.java
/** * Gets all available {@link Task} objects, sorted by name * * @return Sorted list of Tasks//from w ww . jav a 2 s . co m */ public static List<Task> getTasks() { // Sort by name Collections.sort(tasks, new Comparator<Task>() { @Override public int compare(Task o1, Task o2) { return o1.getTaskName().compareTo(o2.getTaskName()); } }); return tasks; }
From source file:Service.MessageServiceImpl.java
@Override public String getMessages(int idUser) { List<MessagesEntity> messages = messagesDAO.findByDestinataire(idUser); messages.addAll(messagesDAO.findByAuteur(idUser)); Collections.sort(messages, new Comparator<MessagesEntity>() { @Override//from w w w .ja v a 2s . c o m public int compare(MessagesEntity o1, MessagesEntity o2) { return o2.getDate().compareTo(o1.getDate()); } }); String message = ""; for (MessagesEntity me : messages) { message += "<div class=\"message\">"; // Conteneur du statut message += me.getEmetteur().getPrenom() + " " + me.getEmetteur().getNom(); message += "<div class=\"message-texte\">"; // Conteneur du texte du statut message += me.getTexte(); message += "<br/>"; message += "</div>"; message += "</div>"; } return message; }
From source file:edu.cmu.sv.modelinference.eventtool.classification.Clusterer1D.java
private static ClassificationResult buildResult(List<? extends Cluster<DataWrapper>> results) { LinkedList<EventClass> clusters = new LinkedList<>(); for (int i = 0; i < results.size(); i++) { TreeMultiset<Event> clusterDataPoints = TreeMultiset.create(new Comparator<Event>() { @Override/*from w w w . java 2 s .c o m*/ public int compare(Event o1, Event o2) { return Double.compare(o1.getFeature().getData(), o2.getFeature().getData()); } }); for (DataWrapper dataWrapper : results.get(i).getPoints()) { clusterDataPoints.add(dataWrapper.getWrappedData()); } clusters.addLast(new EventClass(clusterDataPoints)); } return new ClassificationResult(clusters); }
From source file:com.gu.management.switching.SwitchboardServlet.java
public SwitchboardServlet(Collection<Switchable> switches) { this.switches = new ArrayList<Switchable>(switches); Collections.sort(this.switches, new Comparator<Switchable>() { @Override//from w w w. ja va 2 s . co m public int compare(Switchable o1, Switchable o2) { return o1.getWordForUrl().compareTo(o2.getWordForUrl()); } }); }
From source file:com.acrutiapps.browser.tasks.SearchUrlTask.java
public List<SearchUrlGroup> getResults() { List<SearchUrlGroup> result = new ArrayList<SearchUrlGroup>(); for (SearchUrlGroup group : mResults.values()) { group.sort();/*from w w w. j av a 2s. co m*/ result.add(group); } Collections.sort(result, new Comparator<SearchUrlGroup>() { @Override public int compare(SearchUrlGroup lhs, SearchUrlGroup rhs) { return lhs.getName().compareTo(rhs.getName()); } }); return result; }
From source file:com.jxt.web.vo.AgentActiveThreadCountList.java
public List<AgentActiveThreadCount> getAgentActiveThreadRepository() { // sort agentId Collections.sort(agentActiveThreadRepository, new Comparator<AgentActiveThreadCount>() { @Override/*from w ww .j a v a2 s . c o m*/ public int compare(AgentActiveThreadCount o1, AgentActiveThreadCount o2) { final String agentId1 = StringUtils.defaultString(o1.getAgentId(), ""); final String agentId2 = StringUtils.defaultString(o2.getAgentId(), ""); return agentId1.compareTo(agentId2); } }); return agentActiveThreadRepository; }