Example usage for java.util Collections max

List of usage examples for java.util Collections max

Introduction

In this page you can find the example usage for java.util Collections max.

Prototype

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) 

Source Link

Document

Returns the maximum element of the given collection, according to the order induced by the specified comparator.

Usage

From source file:edu.uiowa.icts.bluebutton.json.view.StatsFinder.java

public Double getMax() {
    List<Double> dList = this.getDoubleList();
    Double max = Collections.max(dList, new Comparator<Double>() {
        public int compare(Double d, Double d2) {
            if (d > d2) {
                return 1;
            } else if (d < d2) {
                return -1;
            }/*from   w  w w  . ja v a 2  s .  c o  m*/
            return 0;
        }
    });
    return max;
}

From source file:net.sourceforge.fenixedu.domain.candidacy.Candidacy.java

public CandidacySituation getActiveCandidacySituation() {
    return !getCandidacySituationsSet().isEmpty()
            ? Collections.max(getCandidacySituationsSet(), CandidacySituation.DATE_COMPARATOR)
            : null;/*from w ww . ja v a 2 s  . c om*/
}

From source file:net.sourceforge.fenixedu.domain.accounting.util.RectoratePaymentCodeGenerator.java

private PaymentCode findLastPaymentCode() {

    final List<RectoratePaymentCode> rectoratePaymentCodes = RectoratePaymentCode.getAllRectoratePaymentCodes();
    return rectoratePaymentCodes.isEmpty() ? null
            : Collections.max(rectoratePaymentCodes, COMPARATOR_BY_PAYMENT_SEQUENTIAL_DIGITS);
}

From source file:net.sourceforge.fenixedu.domain.accounting.util.IndividualCandidacyPaymentCodeGenerator.java

private PaymentCode findLastPaymentCode(PaymentCodeType paymentCodeType) {
    final List<IndividualCandidacyPaymentCode> individualCandidacyPaymentCodes = getAllIndividualCandidacyPaymentCodesForType(
            paymentCodeType);// w  w  w. j a va 2s  . c  o m
    return individualCandidacyPaymentCodes.isEmpty() ? null
            : Collections.max(individualCandidacyPaymentCodes, COMPARATOR_BY_PAYMENT_SEQUENTIAL_DIGITS);
}

From source file:net.sourceforge.fenixedu.domain.Guide.java

public static Integer generateGuideNumber() {
    return Collections.max(Bennu.getInstance().getGuidesSet(), Guide.yearAndNumberComparator).getNumber() + 1;

}

From source file:net.sourceforge.fenixedu.domain.accounting.util.PersonRotationPaymentCodeGenerator.java

private PaymentCode findLastPaymentCode(final PaymentCodeType paymentCodeType, Person person) {
    final List<PaymentCode> paymentCodes = new ArrayList<PaymentCode>();
    for (PaymentCode code : person.getPaymentCodesBy(paymentCodeType)) {
        if (isCodeMadeByThisFactory(code)) {
            paymentCodes.add(code);/* w ww. j  a  v  a2  s  .  c om*/
        }
    }
    return paymentCodes.isEmpty() ? null
            : Collections.max(paymentCodes, COMPARATOR_BY_PAYMENT_CODE_CONTROL_DIGITS);
}

From source file:net.sourceforge.fenixedu.domain.accounting.PaymentPlan.java

public Installment getLastInstallment() {
    return (getInstallmentsSet().size() == 0) ? null
            : Collections.max(getInstallmentsSet(), Installment.COMPARATOR_BY_ORDER);
}

From source file:org.libreplan.business.planner.entities.allocationalgorithms.Distributor.java

private EffortDuration getMaxExtraEffort(Capacity[] capacities) {
    if (capacities.length == 0) {
        return null;
    }/*from  w w  w  .j  a  v a2s . c  om*/
    Capacity max = Collections.max(Arrays.asList(capacities), new Comparator<Capacity>() {

        @Override
        public int compare(Capacity o1, Capacity o2) {
            if (o1.getAllowedExtraEffort() == o2.getAllowedExtraEffort()) {
                return 0;
            } else if (o1.getAllowedExtraEffort() == null) {
                return -1;
            } else if (o2.getAllowedExtraEffort() == null) {
                return 1;
            }
            return o1.getAllowedExtraEffort().compareTo(o2.getAllowedExtraEffort());
        }
    });
    return max.getAllowedExtraEffort();

}

From source file:org.artifactory.build.DetailedBuildRunImpl.java

@Override
public String getReleaseStatus() {
    List<PromotionStatus> statuses = build.getStatuses();
    if (statuses == null) {
        return null;
    }/*w w w  .  j ava  2s  . c o m*/
    return Collections.max(statuses, new Comparator<PromotionStatus>() {
        @Override
        public int compare(PromotionStatus o1, PromotionStatus o2) {
            return o1.getTimestampDate().compareTo(o2.getTimestampDate());
        }
    }).getStatus();
}

From source file:net.sourceforge.fenixedu.domain.Guide.java

static public Guide readLastVersionByNumberAndYear(Integer number, Integer year) {
    Set<Guide> result = new HashSet<Guide>();
    for (Guide guide : Bennu.getInstance().getGuidesSet()) {
        if (guide.getYear().equals(year) && guide.getNumber().equals(number)) {
            result.add(guide);/*  w w w  .j a v  a2  s . c o m*/
        }
    }

    if (result.isEmpty()) {
        return null;
    }

    return Collections.max(result, Guide.COMPARATOR_BY_VERSION);
}