Example usage for java.lang Long compare

List of usage examples for java.lang Long compare

Introduction

In this page you can find the example usage for java.lang Long compare.

Prototype

public static int compare(long x, long y) 

Source Link

Document

Compares two long values numerically.

Usage

From source file:net.mintern.primitive.pair.FloatLongPair.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
 *//* www.  ja v a2 s.  c  om*/
@Override
public int compareTo(FloatLongPair other) {
    int cmp = Float.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Long.compare(getRight(), other.getRight());
}

From source file:net.mintern.primitive.pair.CharLongPair.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  .  ja va 2  s .  com*/
@Override
public int compareTo(CharLongPair other) {
    int cmp = Character.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Long.compare(getRight(), other.getRight());
}

From source file:net.mintern.primitive.pair.DoubleLongPair.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 . j  a va2  s . co  m*/
@Override
public int compareTo(DoubleLongPair other) {
    int cmp = Double.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Long.compare(getRight(), other.getRight());
}

From source file:org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexMeta.java

@Override
public int compareTo(IndexMeta o) {
    return Long.compare(creationTime, o.creationTime);
}

From source file:net.mintern.primitive.pair.BooleanLongPair.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  ww .j ava2s.  c o m
@Override
public int compareTo(BooleanLongPair other) {
    int cmp = Boolean.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Long.compare(getRight(), other.getRight());
}

From source file:com.haulmont.cuba.core.sys.LogControlImpl.java

@Override
public List<String> getLogFileNames() {
    List<String> filenames = new ArrayList<>();
    if (logDir.isDirectory()) {
        File[] files = logDir.listFiles();
        if (files != null) {
            Arrays.sort(files, (a, b) -> Long.compare(b.lastModified(), a.lastModified()));
            for (File f : files) {
                if (f.isFile())
                    filenames.add(f.getName());
            }//  ww  w  .j ava2s .  c  om
        }
    }
    return filenames;
}

From source file:org.onosproject.cordconfig.access.AccessAgentData.java

/**
 * Constructs an agent configuration for a given device.
 *
 * @param deviceId    access device ID//from   w  ww  .  ja v a 2s .  co  m
 * @param oltMacInfo  a map of olt chips and their mac address
 * @param agentMac    the MAC address of the agent
 * @param vtnLocation the location of the agent
 */
public AccessAgentData(DeviceId deviceId, Map<ConnectPoint, MacAddress> oltMacInfo, MacAddress agentMac,
        Optional<ConnectPoint> vtnLocation) {
    this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING);
    this.oltMacInfo = ImmutableMap.copyOf(checkNotNull(oltMacInfo, OLT_INFO_MISSING));
    this.agentMac = checkNotNull(agentMac, AGENT_MAC_MISSING);
    this.vtnLocation = checkNotNull(vtnLocation, VTN_MISSING);

    this.sortedOltChips = oltMacInfo.entrySet().stream()
            .sorted((e1, e2) -> Long.compare(e1.getValue().toLong(), e2.getValue().toLong()))
            .map(e -> Pair.of(e.getKey(), e.getValue())).collect(Collectors.toList());
}

From source file:org.ng200.openolympus.controller.api.SolutionJSONController.java

@RequestMapping("/api/solution")
public @ResponseBody List<Map<String, Object>> solutionApi(@RequestParam(value = "id") final Solution solution,
        final Locale locale) {
    List<Map<String, Object>> cached = null;
    if ((cached = this.cache.getIfPresent(new Pair<>(locale, solution))) != null) {
        return cached;
    }//from  w w  w.ja va  2s  .c om
    final List<Verdict> verdicts = this.solutionService.getVerdicts(solution);
    final List<Map<String, Object>> result = verdicts.stream()
            .sorted((l, r) -> Long.compare(l.getId(), r.getId()))
            .map(verdict -> this.verdictJSONController.showVerdict(verdict, locale))
            .collect(Collectors.toList());
    if (verdicts.stream().anyMatch(verdict -> !verdict.isTested())) {
        return result;
    }
    this.cache.put(new Pair<>(locale, solution), result);
    return result;
}

From source file:org.jtalks.jcommune.web.dto.UserContactDto.java

@Override
public int compareTo(UserContactDto o) {
    return o == null ? -1 : Long.compare(this.type.getId(), o.getType().getId());
}

From source file:org.eclipse.packagedrone.utils.rpm.info.RpmInformations.java

public static RpmInformation makeInformation(final RpmInputStream in) throws IOException {
    final InputHeader<RpmTag> header = in.getPayloadHeader();
    final InputHeader<RpmSignatureTag> signature = in.getSignatureHeader();

    final RpmInformation result = new RpmInformation();

    result.setHeaderStart(header.getStart());
    result.setHeaderEnd(header.getStart() + header.getLength());

    result.setName(asString(header.getTag(RpmTag.NAME)));
    result.setArchitecture(asString(header.getTag(RpmTag.ARCH)));
    result.setSummary(asString(header.getTag(RpmTag.SUMMARY)));
    result.setDescription(asString(header.getTag(RpmTag.DESCRIPTION)));
    result.setPackager(asString(header.getTag(RpmTag.PACKAGER)));
    result.setUrl(asString(header.getTag(RpmTag.URL)));
    result.setLicense(asString(header.getTag(RpmTag.LICENSE)));
    result.setVendor(asString(header.getTag(RpmTag.VENDOR)));
    result.setGroup(asString(header.getTag(RpmTag.GROUP)));

    result.setBuildHost(asString(header.getTag(RpmTag.BUILDHOST)));
    result.setBuildTimestamp(asLong(header.getTag(RpmTag.BUILDTIME)));
    result.setSourcePackage(asString(header.getTag(RpmTag.SOURCE_PACKAGE)));

    result.setInstalledSize(asLong(header.getTag(RpmTag.SIZE)));
    result.setArchiveSize(asLong(header.getTag(RpmTag.ARCHIVE_SIZE)));
    if (result.getArchiveSize() == null) {
        result.setArchiveSize(asLong(signature.getTag(RpmSignatureTag.PAYLOAD_SIZE)));
    }//from  ww  w .  ja  va  2 s  .  co  m

    // version

    final RpmInformation.Version ver = new RpmInformation.Version(asString(header.getTag(RpmTag.VERSION)),
            asString(header.getTag(RpmTag.RELEASE)), asString(header.getTag(RpmTag.EPOCH)));
    result.setVersion(ver);

    // changelog

    final Object val = header.getTag(RpmTag.CHANGELOG_TIMESTAMP);
    if (val instanceof Long[]) {
        final Long[] ts = (Long[]) val;
        final String[] authors = (String[]) header.getTag(RpmTag.CHANGELOG_AUTHOR);
        final String[] texts = (String[]) header.getTag(RpmTag.CHANGELOG_TEXT);

        final List<RpmInformation.Changelog> changes = new ArrayList<>(ts.length);

        for (int i = 0; i < ts.length; i++) {
            changes.add(new RpmInformation.Changelog(ts[i], authors[i], texts[i]));
        }

        Collections.sort(changes, (o1, o2) -> Long.compare(o1.getTimestamp(), o2.getTimestamp()));

        result.setChangelog(changes);
    }

    // dependencies

    result.setProvides(
            makeDependencies(header, RpmTag.PROVIDE_NAME, RpmTag.PROVIDE_VERSION, RpmTag.PROVIDE_FLAGS));
    result.setRequires(
            makeDependencies(header, RpmTag.REQUIRE_NAME, RpmTag.REQUIRE_VERSION, RpmTag.REQUIRE_FLAGS));
    result.setConflicts(
            makeDependencies(header, RpmTag.CONFLICT_NAME, RpmTag.CONFLICT_VERSION, RpmTag.CONFLICT_FLAGS));
    result.setObsoletes(
            makeDependencies(header, RpmTag.OBSOLETE_NAME, RpmTag.OBSOLETE_VERSION, RpmTag.OBSOLETE_FLAGS));

    // files

    final CpioArchiveInputStream cpio = in.getCpioStream();
    CpioArchiveEntry cpioEntry;
    while ((cpioEntry = cpio.getNextCPIOEntry()) != null) {
        final String name = normalize(cpioEntry.getName());

        if (cpioEntry.isRegularFile()) {
            result.getFiles().add(name);
        } else if (cpioEntry.isDirectory()) {
            result.getDirectories().add(name);
        }
    }
    cpio.close();

    return result;
}