Example usage for java.lang Integer compare

List of usage examples for java.lang Integer compare

Introduction

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

Prototype

public static int compare(int x, int y) 

Source Link

Document

Compares two int values numerically.

Usage

From source file:bwem.util.PairGenericMiniTileAltitudeComparator.java

@Override
public int compare(MutablePair<T, MiniTile> o1, MutablePair<T, MiniTile> o2) {
    int a1 = o1.getRight().getAltitude().intValue();
    int a2 = o2.getRight().getAltitude().intValue();
    return Integer.compare(a1, a2);
}

From source file:org.openhab.binding.dwdunwetter.internal.data.SeverityComparator.java

@Override
public int compare(DwdWarningData o1, DwdWarningData o2) {

    Comparator.comparingInt(d -> ((DwdWarningData) d).getSeverity().getOrder());
    Comparator.comparing(DwdWarningData::getOnset);

    int result = Integer.compare(o1.getSeverity().getOrder(), o2.getSeverity().getOrder());
    if (result == 0) {
        result = ObjectUtils.compare(o1.getOnset(), o2.getOnset());
    }//from  www  . j  ava  2  s. c o  m
    return result;
}

From source file:com.github.fauu.natrank.model.entity.BaseEntity.java

@Override
public int compareTo(T other) {
    return Integer.compare(this.getId(), other.getId());
}

From source file:com.joyent.manta.client.MantaObjectDepthComparator.java

/**
 * Sorts two objects showing the deepest objects first.
 *
 * @param o1 the first object to be compared.
 * @param o2 the second object to be compared.
 * @return a negative integer, zero, or a positive integer as the
 *         first argument is less than, equal to, or greater than the
 *         second.//  w  ww  .ja v a 2 s  .c om
 */
private static int comparePathDepth(final MantaObject o1, final MantaObject o2) {
    final int o1Depth = StringUtils.countMatches(o1.getPath(), SEPARATOR);
    final int o2Depth = StringUtils.countMatches(o2.getPath(), SEPARATOR);
    // Note: reversed order - bigger values should come first
    return Integer.compare(o2Depth, o1Depth);
}

From source file:com.smi.travel.monitor.BookingFlightComparator.java

@Override
public int compare(BookingFlight f1, BookingFlight f2) {
    int compareDate = f1.getDepartureDate().compareTo(f2.getDepartureDate());
    if (compareDate != 0) {
        return compareDate;
    } else {/* w  w w.  j a v a  2  s .  c o  m*/
        int departTime1;
        int departTime2;
        if (StringUtils.isEmpty(f1.getDepartTime())) {
            departTime1 = 0;
        } else {
            departTime1 = Integer.valueOf(f1.getDepartTime().trim());
        }
        if (StringUtils.isEmpty(f2.getDepartTime())) {
            departTime2 = 0;
        } else {
            departTime2 = Integer.valueOf(f2.getDepartTime().trim());
        }

        return Integer.compare(departTime1, departTime2);
    }
}

From source file:mi.RankInfo.java

@Override
public int compareTo(RankInfo t) {
    return Integer.compare(id, t.id);
}

From source file:com.jnj.b2b.core.search.solrfacetsearch.provider.entity.VariantValueCategoryModelPriorityComparator.java

@Override
public int compare(final VariantValueCategoryModel variantValueCategory1,
        final VariantValueCategoryModel variantValueCategory2) {
    final LinkedList<CategoryModel> pathToRoot1 = getPathToRoot(variantValueCategory1);
    final LinkedList<CategoryModel> pathToRoot2 = getPathToRoot(variantValueCategory2);

    return Integer.compare(pathToRoot1.size(), pathToRoot2.size());
}

From source file:nu.yona.server.subscriptions.service.migration.MoveVpnPasswordToDevice.java

private UserDevice getDefaultDevice(User user) {
    return user.getDevices().stream()
            .sorted((d1, d2) -> Integer.compare(d1.getDeviceAnonymized().getDeviceIndex(),
                    d2.getDeviceAnonymized().getDeviceIndex()))
            .findFirst().orElseThrow(() -> DeviceServiceException.noDevicesFound(user.getAnonymized().getId()));
}

From source file:persistence.git.document.RevCommitRepository.java

Optional<RevCommit> getLastRevCommit(final Git git) throws SourceControlUnspecifiedException {
    Optional<RevCommit> lastCommit;
    try {//from   w w w  .ja v a2 s  .co m
        lastCommit = Lists.newArrayList(git.log().call()).stream().sorted(Collections.reverseOrder(
                (RevCommit u1, RevCommit u2) -> Integer.compare(u1.getCommitTime(), u2.getCommitTime())))
                .findFirst();
    } catch (GitAPIException e) {
        throw new SourceControlUnspecifiedException(e);
    }

    return lastCommit;
}

From source file:org.apache.ranger.plugin.resourcematcher.ResourceMatcher.java

@Override
public int compareTo(ResourceMatcher other) {
    return Integer.compare(getPriority(), other.getPriority());
}