List of usage examples for java.util Collections min
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
From source file:org.squashtest.tm.domain.campaign.Iteration.java
private Date getFirstExecutedTestPlanDate() { if (getTestPlans().isEmpty()) { return null; } else {/* w w w .j a va2 s . c o m*/ IterationTestPlanItem firstTestPlan = Collections.min(getTestPlans(), CascadingAutoDateComparatorBuilder.buildTestPlanFirstDateSorter()); return firstTestPlan.getLastExecutedOn(); } }
From source file:net.sourceforge.fenixedu.domain.DegreeCurricularPlan.java
public ExecutionDegree getFirstExecutionDegree() { if (getExecutionDegreesSet().isEmpty()) { return null; }//w w w .ja v a 2 s . co m return Collections.min(getExecutionDegreesSet(), ExecutionDegree.EXECUTION_DEGREE_COMPARATORY_BY_YEAR); }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
public StudentCurricularPlan getFirstStudentCurricularPlan() { return !getStudentCurricularPlansSet().isEmpty() ? (StudentCurricularPlan) Collections.min(getStudentCurricularPlansSet(), StudentCurricularPlan.STUDENT_CURRICULAR_PLAN_COMPARATOR_BY_START_DATE) : null;/*from w w w . ja v a 2s. c o m*/ }
From source file:net.sourceforge.fenixedu.domain.DegreeCurricularPlan.java
public EnrolmentPeriodInSpecialSeasonEvaluations getNextSpecialSeasonEnrolmentPeriod() { final List<EnrolmentPeriodInSpecialSeasonEvaluations> positivesSet = new ArrayList<EnrolmentPeriodInSpecialSeasonEvaluations>(); for (final EnrolmentPeriod enrolmentPeriod : this.getEnrolmentPeriodsSet()) { if (enrolmentPeriod instanceof EnrolmentPeriodInSpecialSeasonEvaluations && enrolmentPeriod.isUpcomingPeriod()) { positivesSet.add((EnrolmentPeriodInSpecialSeasonEvaluations) enrolmentPeriod); }/*w w w . j av a2 s . co m*/ } return positivesSet.isEmpty() ? null : Collections.min(positivesSet, EnrolmentPeriodInSpecialSeasonEvaluations.COMPARATOR_BY_START); }
From source file:org.libreplan.business.planner.entities.ResourceAllocation.java
private List<? extends T> withoutAlreadyPresent(Collection<? extends T> assignments) { if (assignments.isEmpty()) { return Collections.emptyList(); }/* ww w. j a v a 2 s . c om*/ LocalDate min = Collections.min(assignments, DayAssignment.byDayComparator()).getDay(); LocalDate max = Collections.max(assignments, DayAssignment.byDayComparator()).getDay(); Set<LocalDate> daysPresent = DayAssignment.byDay(getAssignments(min, max.plusDays(1))).keySet(); List<T> result = new ArrayList<>(); for (T each : assignments) { if (!daysPresent.contains(each.getDay())) { result.add(each); } } return result; }
From source file:com.ape.camera2raw.Camera2RawFragment.java
/** * Given {@code choices} of {@code Size}s supported by a camera, choose the smallest one that * is at least as large as the respective texture view size, and that is at most as large as the * respective max size, and whose aspect ratio matches with the specified value. If such size * doesn't exist, choose the largest one that is at most as large as the respective max size, * and whose aspect ratio matches with the specified value. * * @param choices The list of sizes that the camera supports for the intended output * class/*www . jav a2 s . co m*/ * @param textureViewWidth The width of the texture view relative to sensor coordinate * @param textureViewHeight The height of the texture view relative to sensor coordinate * @param maxWidth The maximum width that can be chosen * @param maxHeight The maximum height that can be chosen * @param aspectRatio The aspect ratio * @return The optimal {@code Size}, or an arbitrary one if none were big enough */ private static Size chooseOptimalSize(Size[] choices, int textureViewWidth, int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) { // Collect the supported resolutions that are at least as big as the preview Surface List<Size> bigEnough = new ArrayList<>(); // Collect the supported resolutions that are smaller than the preview Surface List<Size> notBigEnough = new ArrayList<>(); int w = aspectRatio.getWidth(); int h = aspectRatio.getHeight(); for (Size option : choices) { if (option.getWidth() <= maxWidth && option.getHeight() <= maxHeight && option.getHeight() == option.getWidth() * h / w) { if (option.getWidth() >= textureViewWidth && option.getHeight() >= textureViewHeight) { bigEnough.add(option); } else { notBigEnough.add(option); } } } // Pick the smallest of those big enough. If there is no one big enough, pick the // largest of those not big enough. if (bigEnough.size() > 0) { return Collections.min(bigEnough, new CompareSizesByArea()); } else if (notBigEnough.size() > 0) { return Collections.max(notBigEnough, new CompareSizesByArea()); } else { Log.e(TAG, "Couldn't find any suitable preview size"); return choices[0]; } }
From source file:org.fenixedu.academic.domain.DegreeCurricularPlan.java
public ExecutionInterval getBegin() { Set<ExecutionYear> beginContextExecutionYears = getBeginContextExecutionYears(); return beginContextExecutionYears.isEmpty() ? null : Collections.min(beginContextExecutionYears, ExecutionYear.COMPARATOR_BY_YEAR); }
From source file:net.sourceforge.fenixedu.domain.DegreeCurricularPlan.java
public ExecutionYear getInauguralExecutionYear() { return Collections.min(getExecutionDegreesSet(), ExecutionDegree.EXECUTION_DEGREE_COMPARATORY_BY_YEAR) .getExecutionYear(); }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
public boolean hasActiveFirstState(final ExecutionYear period) { final Set<RegistrationState> states = getRegistrationStates(period); return states.isEmpty() ? false : Collections.min(states, RegistrationState.DATE_COMPARATOR).isActive(); }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
public RegistrationState getFirstRegistrationState() { return !getRegistrationStatesSet().isEmpty() ? Collections.min(getRegistrationStatesSet(), RegistrationState.DATE_COMPARATOR) : null;//from ww w . j a v a2s .co m }