List of usage examples for java.lang Integer compare
public static int compare(int x, int y)
From source file:com.evolveum.midpoint.model.api.util.EvaluatedPolicyRuleUtil.java
private static void sortTriggersInt(TreeNode<EvaluatedPolicyRuleTrigger<?>> node) { Comparator<? super TreeNode<EvaluatedPolicyRuleTrigger<?>>> comparator = (t1, t2) -> { PolicyConstraintPresentationType p1 = t1.getUserObject().getConstraint().getPresentation(); PolicyConstraintPresentationType p2 = t2.getUserObject().getConstraint().getPresentation(); int o1 = p1 != null && p1.getDisplayOrder() != null ? p1.getDisplayOrder() : Integer.MAX_VALUE; int o2 = p2 != null && p2.getDisplayOrder() != null ? p2.getDisplayOrder() : Integer.MAX_VALUE; return Integer.compare(o1, o2); };/*from w ww . j a va 2s .c o m*/ node.getChildren().sort(comparator); node.getChildren().forEach(child -> sortTriggersInt(child)); }
From source file:io.horizondb.model.core.fields.ByteField.java
/** * {@inheritDoc}/*from w w w. ja v a 2 s . co m*/ */ @Override public int compareTo(Field other) { return Integer.compare(this.value, other.getByte()); }
From source file:com.offbynull.voip.kademlia.GraphHelper.java
public GraphHelper(Id baseId, Address graphAddress, Router router) { Validate.notNull(baseId);// w ww .ja v a2s . co m Validate.notNull(graphAddress); Validate.notNull(router); this.baseId = baseId; this.graphAddress = graphAddress.appendSuffix(baseId.getBitString().toString()); List<BitString> prefixes = router.dumpBucketPrefixes(); Collections.sort(prefixes, (x, y) -> Integer.compare(x.getBitLength(), y.getBitLength())); this.routerBucketPrefixes = new LinkedHashSet<>(); // order matters, smallest prefixes first this.routerBucketPrefixes.addAll(prefixes); this.routeTreePrefixToIds = new LinkedHashMap<>(); // order matters, smallest prefixes first IdXorMetricComparator idComparator = new IdXorMetricComparator(baseId); this.nearBucketIds = new TreeSet<>(idComparator); // order matters, based on closeness of ids }
From source file:uni.bielefeld.cmg.sparkhit.util.HelpParam.java
public void printConverterHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new Comparator<Option>() { public int compare(Option o1, Option o2) { return Integer.compare(parameterMap.get(o1.getOpt()), parameterMap.get(o2.getOpt())); }//from w w w. java2 s . com }); final String executable = System.getProperty("executable", "spark-submit [spark parameter] --class uni.bielefeld.cmg.sparkhit.main.MainOfConverter Sparkhit.jar"); err.println("Name:"); err.println("\tSparkHit Converter"); err.println(); err.println("Options:"); formatter.printOptions(new PrintWriter(err, true), 85, parameter, 2, 3); /* print formatted parameters */ err.println(); err.println("Usage:"); err.println("\tConvert different file format :"); err.println(executable + " [parameters] -fastq query.fq.tar.bz2 -outfile ./outdir"); err.println(); }
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractConfigDialog.java
@Override public void initializeWithModel() { configModel = model;// w ww. j a v a2 s . c o m addCss(); ControllerService cv = ControllerService.get(); List<TabConfig> tabs = getConfigurationTabs(); tabs.sort((e1, e2) -> Integer.compare(e1.prio, e2.prio)); for (TabConfig tabc : tabs) { Pair<Pane, ? extends AbstractConfigTabController<?>> wc = cv .loadControllerControl(tabc.tabControlerClass, Pane.class, this); createTab(tabc.configModel, wc); } AnchorPane.setTopAnchor(mainPane, 5.0); AnchorPane.setRightAnchor(mainPane, 5.0); AnchorPane.setLeftAnchor(mainPane, 5.0); AnchorPane.setBottomAnchor(mainPane, 50.0); AnchorPane.setTopAnchor(configurationTabs, 5.0); AnchorPane.setRightAnchor(configurationTabs, 5.0); AnchorPane.setLeftAnchor(configurationTabs, 5.0); AnchorPane.setBottomAnchor(configurationTabs, 5.0); // AnchorPane.setTopAnchor(buttonHBox, 5.0); AnchorPane.setRightAnchor(buttonPane, 5.0); AnchorPane.setLeftAnchor(buttonPane, 5.0); AnchorPane.setBottomAnchor(buttonPane, 5.0); }
From source file:com.github.lukaszkusek.xml.comparator.comparators.order.XMLCheckChildrenOrderComparator.java
private List<String> getSortedChildrenXPaths(Node node) { return Maps/* www . j a va 2s . c om*/ .transformEntries(node.getChildren().asMap(), (xpath, nodes) -> new XpathWithIndex(xpath, first(nodes).getIndex())) .values().stream().sorted((xpath1, xpath2) -> Integer.compare(xpath1.index, xpath2.index)) .map(xPathWithIndex -> xPathWithIndex.xPath).collect(Collectors.toList()); }
From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java
@Override public boolean saveSettings(Element element) { element.addAttribute("horizontalScroll", String.valueOf(table.isHorizontalScrollEnabled())); saveFontPreferences(element);/*from w ww . ja v a2s .c o m*/ Element columnsElem = element.element("columns"); if (columnsElem != null) { element.remove(columnsElem); } columnsElem = element.addElement("columns"); final List<TableColumn> visibleTableColumns = table.getColumns(); final List<Table.Column> visibleColumns = new ArrayList<>(); for (TableColumn tableColumn : visibleTableColumns) { visibleColumns.add((Table.Column) tableColumn.getIdentifier()); } List<TableColumn> columns = table.getColumns(true); Collections.sort(columns, new Comparator<TableColumn>() { @SuppressWarnings("SuspiciousMethodCalls") @Override public int compare(TableColumn col1, TableColumn col2) { if (col1 instanceof TableColumnExt && !((TableColumnExt) col1).isVisible()) { return 1; } if (col2 instanceof TableColumnExt && !((TableColumnExt) col2).isVisible()) { return -1; } int i1 = visibleColumns.indexOf(col1.getIdentifier()); int i2 = visibleColumns.indexOf(col2.getIdentifier()); return Integer.compare(i1, i2); } }); for (TableColumn column : columns) { Element colElem = columnsElem.addElement("column"); colElem.addAttribute("id", column.getIdentifier().toString()); int width = column.getWidth(); colElem.addAttribute("width", String.valueOf(width)); if (column instanceof TableColumnExt) { Boolean visible = ((TableColumnExt) column).isVisible(); colElem.addAttribute("visible", visible.toString()); } } if (table.getRowSorter() != null) { TableColumn sortedColumn = table.getSortedColumn(); List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys(); if (sortedColumn != null && !sortKeys.isEmpty()) { columnsElem.addAttribute("sortColumn", String.valueOf(sortedColumn.getIdentifier())); columnsElem.addAttribute("sortOrder", sortKeys.get(0).getSortOrder().toString()); } } return true; }
From source file:org.diorite.impl.world.io.requests.Request.java
@Override public int compareTo(final Request<?> o) { return Integer.compare(o.priority, this.priority); }
From source file:org.eclipse.dataset.slicer.SliceNDGenerator.java
public static Comparator<SliceND> getStartComparator(final int rank, final int[] incrementOrder) { final int[] full = getDimensionSortingArray(rank, incrementOrder); return new Comparator<SliceND>() { @Override/*w ww. j a v a 2 s . com*/ public int compare(SliceND o1, SliceND o2) { int[] s1 = o1.getStart(); int[] s2 = o2.getStart(); for (int i : full) { int val = Integer.compare(s1[i], s2[i]); if (val != 0) return val; } return 0; } }; }
From source file:sf.net.experimaestro.manager.plans.Join.java
@Override protected void doPostInit(List<Map<Operator, Integer>> parentStreams) { super.doPostInit(parentStreams); // Order the joins in function of the orders of streams // We can pick any parent since they share the same order Order<Operator> order = ((OrderBy) parents.get(0)).order; order.flatten();//from w w w .j a v a 2 s . c om int rank = 0; final Object2IntOpenHashMap<Operator> rankMap = new Object2IntOpenHashMap<>(); for (Operator operator : order.items()) { rankMap.put(operator, rank++); } Collections.sort(joins, (o1, o2) -> Integer.compare(rankMap.get(o1.operator), rankMap.get(o2.operator))); // Get the context index for each join & stream int joinRank = 0; for (JoinReference reference : joins) { reference.rank = joinRank++; reference.contextIndices = new int[parents.size()]; for (int i = 0; i < parentStreams.size(); i++) { Map<Operator, Integer> map = parentStreams.get(i); Integer index = map.get(reference.operator); reference.contextIndices[i] = index.intValue(); } } }