List of usage examples for java.lang Boolean compare
public static int compare(boolean x, boolean y)
From source file:net.mintern.primitive.pair.LongBooleanPair.java
/** * Compares the pair based on the left element followed by the right element. * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater *///from ww w . j a v a 2 s. com @Override public int compareTo(LongBooleanPair other) { int cmp = Long.compare(getLeft(), other.getLeft()); return cmp != 0 ? cmp : Boolean.compare(getRight(), other.getRight()); }
From source file:net.mintern.primitive.pair.FloatBooleanPair.java
/** * Compares the pair based on the left element followed by the right element. * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater *//*w w w.j a v a2 s .c o m*/ @Override public int compareTo(FloatBooleanPair other) { int cmp = Float.compare(getLeft(), other.getLeft()); return cmp != 0 ? cmp : Boolean.compare(getRight(), other.getRight()); }
From source file:net.mintern.primitive.pair.CharBooleanPair.java
/** * Compares the pair based on the left element followed by the right element. * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater *///from w w w . ja v a 2s . com @Override public int compareTo(CharBooleanPair other) { int cmp = Character.compare(getLeft(), other.getLeft()); return cmp != 0 ? cmp : Boolean.compare(getRight(), other.getRight()); }
From source file:net.mintern.primitive.pair.DoubleBooleanPair.java
/** * Compares the pair based on the left element followed by the right element. * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater *//*from ww w .java 2s . c o m*/ @Override public int compareTo(DoubleBooleanPair other) { int cmp = Double.compare(getLeft(), other.getLeft()); return cmp != 0 ? cmp : Boolean.compare(getRight(), other.getRight()); }
From source file:com.google.uzaygezen.core.BitVectorTest.java
private void checkCompareTo(Function<Integer, BitVector> factory1, Function<Integer, BitVector> factory2) { for (int j = 0; j < 128; j++) { BitVector b = factory1.apply(j); boolean[] bBits = new boolean[j]; for (int k = 0; k < j; ++k) { bBits[k] = random.nextBoolean(); }/*from www. java 2 s . c o m*/ for (int k = 0; k < j; ++k) { b.set(k, bBits[k]); } BitVector c = factory2.apply(j); boolean[] cBits = new boolean[j]; for (int k = 0; k < j; ++k) { cBits[k] = random.nextBoolean(); } for (int k = 0; k < j; ++k) { c.set(k, cBits[k]); } int cmp = b.compareTo(c); int k = j; while (--k != -1 && bBits[k] == cBits[k]) { } int expected = (k == -1) ? 0 : Boolean.compare(bBits[k], cBits[k]); Assert.assertEquals(Integer.signum(expected), Integer.signum(cmp)); Assert.assertEquals(Integer.signum(cmp), -Integer.signum(-cmp)); Assert.assertEquals(Integer.signum(cmp), b.toBigInteger().compareTo(c.toBigInteger())); } }
From source file:com.jivesoftware.os.amza.api.partition.PartitionName.java
@Override public int compareTo(PartitionName o) { int i = Boolean.compare(systemPartition, o.systemPartition); if (i != 0) { return i; }/* ww w .j a v a 2s . com*/ i = UnsignedBytes.lexicographicalComparator().compare(ringName, o.ringName); if (i != 0) { return i; } i = UnsignedBytes.lexicographicalComparator().compare(name, o.name); if (i != 0) { return i; } return i; }
From source file:info.magnolia.ui.framework.command.ImportZipCommand.java
@Override public boolean execute(Context context) throws Exception { this.context = context; File tmpFile = null;/*from w w w. j av a 2s . co m*/ FileOutputStream tmpStream = null; try { tmpFile = File.createTempFile(ZIP_TMP_FILE_PREFIX, ZIP_TMP_FILE_SUFFIX); tmpStream = new FileOutputStream(tmpFile); IOUtils.copy(inputStream, tmpStream); } catch (IOException e) { log.error("Failed to dump zip file to temp file: ", e); throw e; } finally { IOUtils.closeQuietly(tmpStream); IOUtils.closeQuietly(inputStream); } if (isValid(tmpFile)) { ZipFile zip = new ZipFile(tmpFile, getEncoding()); // We use the ant-1.6.5 zip package to workaround encoding issues of the sun implementation (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499) // For some reason, entries are not in the opposite order as how they appear in most tools - reversing here. // Note that java.util.zip does not show this behaviour, and ant-1.7.1 seems to enumerate entries in alphabetical or random order. // Another alternative might be http://truezip.dev.java.net final List zipEntries = EnumerationUtils.toList(zip.getEntries()); Collections.sort(zipEntries, new Comparator() { @Override public int compare(Object first, Object second) { ZipArchiveEntry firstEntry = ((ZipArchiveEntry) first); ZipArchiveEntry secondEntry = ((ZipArchiveEntry) second); if (firstEntry.isDirectory() != secondEntry.isDirectory()) { // order folders first return Boolean.compare(secondEntry.isDirectory(), firstEntry.isDirectory()); } // order alphabetically return firstEntry.getName().compareTo(secondEntry.getName()); } }); final Iterator it = zipEntries.iterator(); while (it.hasNext()) { ZipArchiveEntry entry = (ZipArchiveEntry) it.next(); processEntry(zip, entry); } context.getJCRSession(getRepository()).save(); } return false; }
From source file:termint.gui.vt.VTElement.java
public int compareTo(VTElement o) { int cmp = Character.compare(c, o.c); if (cmp != 0) return cmp; cmp = bg.compareTo(o.bg);/*from w ww . j a v a 2 s. co m*/ if (cmp != 0) return cmp; cmp = fg.compareTo(o.fg); if (cmp != 0) return cmp; cmp = Boolean.compare(bold, o.bold); if (cmp != 0) return cmp; cmp = Boolean.compare(invert, o.invert); if (cmp != 0) return cmp; cmp = Boolean.compare(invisible, o.invisible); if (cmp != 0) return cmp; cmp = Boolean.compare(low, o.low); if (cmp != 0) return cmp; cmp = Boolean.compare(underline, o.underline); return cmp; }
From source file:org.ng200.openolympus.services.TestingService.java
@Autowired public TestingService(final SolutionService solutionService, final SolutionRepository solutionRepository, final UserRepository userRepository, final VerdictRepository verdictRepository, final StorageService storageService, final TaskContainerCache taskContainerCache) { super();// w w w . j a v a 2 s.c om this.verdictRepository = verdictRepository; this.taskContainerCache = taskContainerCache; this.dataProvider.setParameter("storageService", storageService); final HashSet<Verdict> alreadyScheduledJobs = new HashSet<>(); this.verdictCheckSchedulingExecutorService.scheduleAtFixedRate(() -> { this.logInAsSystem(); solutionService.getPendingVerdicts().stream() .filter((verdict) -> !alreadyScheduledJobs.contains(verdict)).sorted((l, r) -> { if (l.isViewableWhenContestRunning() != r.isViewableWhenContestRunning()) { // Schedule base tests first return Boolean.compare(r.isViewableWhenContestRunning(), l.isViewableWhenContestRunning()); } return Long.compare(l.getId(), r.getId()); }).forEach((verdict) -> { alreadyScheduledJobs.add(verdict); this.processVerdict(verdict); }); }, 0, 100, TimeUnit.MILLISECONDS); }
From source file:net.iaeste.iws.core.transformers.CSVTransformer.java
static void transformTypeOfWork(final Map<String, String> errors, final Verifiable obj, final OfferFields field, final CSVRecord record) { final Boolean typeR = convertBoolean(record.get(OfferFields.WORK_TYPE_P.getField())); final Boolean typeO = convertBoolean(record.get(OfferFields.WORK_TYPE_R.getField())); final Boolean typeF = convertBoolean(record.get(OfferFields.WORK_TYPE_W.getField())); if (convertBoolean(record.get(OfferFields.WORK_TYPE_N.getField()))) { LOG.info("Ignoring the TypeOfWork 'N'."); }// w w w . ja v a2 s . c o m // Using the Boolean comparison as it reduces the NPath complexity final int sum = Boolean.compare(typeR, false) + Boolean.compare(typeO, false) + Boolean.compare(typeF, false); if (sum > 1) { errors.put(field.getField(), "Multiple TypeOfWork is set, only one is allowed."); } else if (sum == 0) { errors.put(field.getField(), "No TypeOfWork defined."); } else { final TypeOfWork value; if (typeR) { value = TypeOfWork.R; } else if (typeO) { value = TypeOfWork.O; } else { value = TypeOfWork.F; } invokeMethodOnObject(errors, obj, field, value); } }