本文整理汇总了Java中org.apache.commons.collections.comparators.ReverseComparator类的典型用法代码示例。如果您正苦于以下问题:Java ReverseComparator类的具体用法?Java ReverseComparator怎么用?Java ReverseComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReverseComparator类属于org.apache.commons.collections.comparators包,在下文中一共展示了ReverseComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHookOrdering
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
/**
* creates a sortedset of all hook implementations found for the given hook. Ordering is done through
* {@link com.github.cherimojava.orchidae.hook.HookHandler.HookComparator} in reverse order
*
* @param hook to find all implementations from
* @param url where to search for hook implementations
* @param <H> Hook type
* @return sortedset with all found hook implementation
*/
public static <H> SortedSet<? extends H> getHookOrdering( Class<H> hook, URL url )
{
Configuration config = new ConfigurationBuilder().addUrls( url )
.addUrls( ClasspathHelper.forPackage( HookHandler.class.getPackage().getName() ) )
.setScanners( new SubTypesScanner() );
Reflections reflect = new Reflections( config );
SortedSet<H> hooks = Sets.newTreeSet( new ReverseComparator( comparator ) );
LOG.info( "Searching for hooks of {}", hook );
for ( Class<? extends H> c : reflect.getSubTypesOf( hook ) )
{
try
{
LOG.info( "Found hook {}", c );
hooks.add( c.newInstance() );
}
catch ( IllegalAccessException | InstantiationException e )
{
LOG.error( "Failed to instantiate {} please make sure it has a no param Constructor. {}", c, e );
}
}
return hooks;
}
示例2: getExecutionPeriodsLabels
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
public List<SelectItem> getExecutionPeriodsLabels() {
if (this.executionPeriodsLabels == null) {
this.executionPeriodsLabels = new ArrayList();
final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods();
final ComparatorChain comparatorChain = new ComparatorChain();
comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year")));
comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester")));
Collections.sort(infoExecutionPeriods, comparatorChain);
for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
final SelectItem selectItem = new SelectItem();
selectItem.setValue(infoExecutionPeriod.getExternalId());
selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear());
this.executionPeriodsLabels.add(selectItem);
}
}
return this.executionPeriodsLabels;
}
示例3: getExecutionYears
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
public List<SelectItem> getExecutionYears() {
if (selectedYears == null) {
ExecutionYear year = null;
if (getCompetenceCourse() != null) {
final ExecutionSemester semester = getCompetenceCourse().getStartExecutionSemester();
year = semester != null ? semester.getExecutionYear() : null;
}
selectedYears = new ArrayList<SelectItem>();
for (ExecutionYear executionYear : ExecutionYear.readNotClosedExecutionYears()) {
if (year == null || executionYear.isAfterOrEquals(year)) {
selectedYears.add(new SelectItem(executionYear.getExternalId(), executionYear.getYear()));
}
}
Collections.sort(selectedYears, new ReverseComparator(new BeanComparator("label")));
}
return selectedYears;
}
示例4: provide
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
@Override
public Object provide(Object source, Object currentValue) {
/*
* get executionPeriods after '1 Semestre 2006/2007'
*/
final ExecutionSemester currentExecutionPeriod = ExecutionSemester.readBySemesterAndExecutionYear(1, "2006/2007");
final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>();
for (final ExecutionSemester executionSemester : ExecutionSemester.readNotClosedPublicExecutionPeriods()) {
if (executionSemester.isAfterOrEquals(currentExecutionPeriod)) {
result.add(executionSemester);
}
}
Collections.sort(result, new ReverseComparator());
return result;
}
示例5: provide
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
@Override
public Object provide(Object source, Object obj) {
final ManageEnrolmentsBean bean = (ManageEnrolmentsBean) source;
final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>();
ExecutionSemester each = bean.getProcess().getExecutionYear().getFirstExecutionPeriod();
while (each != null) {
result.add(each);
each = each.getNextExecutionPeriod();
}
Collections.sort(result, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR));
return result;
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:17,代码来源:PhdManageEnrolmentsExecutionSemestersProvider.java
示例6: getExecutionYear
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
private ExecutionYear getExecutionYear(HttpServletRequest request) {
String id = request.getParameter("executionYearId");
if (id == null) {
id = request.getParameter("executionYear");
}
if (id == null) {
TreeSet<ExecutionYear> executionYears = new TreeSet<ExecutionYear>(new ReverseComparator());
executionYears.addAll(getDegreeCurricularPlan(request).getExecutionYears());
if (executionYears.isEmpty()) {
return ExecutionYear.readCurrentExecutionYear();
} else {
return executionYears.first();
}
} else {
return FenixFramework.getDomainObject(id);
}
}
示例7: getContextBean
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
private ThesisContextBean getContextBean(HttpServletRequest request) {
ThesisContextBean bean = getRenderedObject("contextBean");
RenderUtils.invalidateViewState("contextBean");
if (bean != null) {
return bean;
} else {
ExecutionYear executionYear = getExecutionYear(request);
if (executionYear == null) {
executionYear = ExecutionYear.readCurrentExecutionYear();
}
TreeSet<ExecutionYear> executionYears = new TreeSet<ExecutionYear>(new ReverseComparator());
executionYears.addAll(getDegreeCurricularPlan(request).getExecutionYears());
return new ThesisContextBean(executionYears, executionYear);
}
}
示例8: getCurrentCoordinators
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
final private Collection<Coordinator> getCurrentCoordinators(final boolean responsible) {
SortedSet<ExecutionYear> years = new TreeSet<ExecutionYear>(new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR));
years.addAll(getDegreeCurricularPlansExecutionYears());
ExecutionYear current = ExecutionYear.readCurrentExecutionYear();
for (ExecutionYear year : years) {
if (year.isAfter(current)) {
continue;
}
Collection<Coordinator> coordinators = getCoordinators(year, responsible);
if (!coordinators.isEmpty()) {
return coordinators;
}
}
return Collections.emptyList();
}
示例9: doStartTag
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
public int doStartTag() {
if (drugOrders == null || drugOrders.isEmpty()) {
log.error("ForEachDrugOrderTag skipping body due to drugOrders param being null or empty: " + drugOrders);
return SKIP_BODY;
}
// First retrieve all encounters matching the passed concept id, if provided.
// If not provided, return all encounters
matchingDrugOrders = new ArrayList<DrugOrder>();
for (Iterator<DrugOrder> i = drugOrders.iterator(); i.hasNext();) {
DrugOrder d = i.next();
if (d != null) {
// TODO: eventually we might want to have criteria, but not yet
matchingDrugOrders.add(d);
}
}
log.debug("ForEachDrugOrderTag found " + matchingDrugOrders.size() + " drug orders");
// Next, sort the encounters
if (StringUtils.isEmpty(sortBy)) {
sortBy = defaultSortBy;
}
Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator())
: new ComparableComparator()));
try {
Collections.sort(matchingDrugOrders, comp);
}
catch (ClassCastException cce) {
log
.error("ForEachDrugTag unable to compare the list of drug orders passed. Ensure they are compatible with Comparator used.");
}
// Return appropriate number of results
if (matchingDrugOrders.isEmpty()) {
return SKIP_BODY;
} else {
pageContext.setAttribute(var, matchingDrugOrders.get(count++));
return EVAL_BODY_BUFFERED;
}
}
示例10: doStartTag
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
@Override
public int doStartTag() {
if (visits == null || visits.isEmpty()) {
log.debug("ForEachVisitTag skipping body due to 'visits' param = " + visits);
return SKIP_BODY;
}
// First retrieve all visits matching the passed visit type id, if provided.
// If not provided, return all visits
matchingVisits = new ArrayList<Visit>();
for (Iterator<Visit> i = visits.iterator(); i.hasNext();) {
Visit e = i.next();
if (type == null || e.getVisitType().getVisitTypeId().intValue() == type.intValue()) {
matchingVisits.add(e);
}
}
log.debug("ForEachVisitTag found " + matchingVisits.size() + " visits matching type = " + type);
// Next, sort the visits
if (StringUtils.isEmpty(sortBy)) {
sortBy = "visitDatetime";
}
Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator())
: new ComparableComparator()));
Collections.sort(matchingVisits, comp);
// Return appropriate number of results
if (matchingVisits.isEmpty()) {
return SKIP_BODY;
} else {
pageContext.setAttribute(var, matchingVisits.get(count++));
return EVAL_BODY_BUFFERED;
}
}
示例11: doStartTag
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
public int doStartTag() {
if (obs == null || obs.isEmpty()) {
log.error("ForEachObsTag skipping body due to obs param = " + obs);
return SKIP_BODY;
}
// First retrieve all observations matching the passed concept id, if provided.
// If not provided, return all observations
matchingObs = new ArrayList<Obs>();
for (Iterator<Obs> i = obs.iterator(); i.hasNext();) {
Obs o = i.next();
if (conceptId == null
|| (o.getConcept() != null && o.getConcept().getConceptId().intValue() == conceptId.intValue())) {
matchingObs.add(o);
}
}
log.debug("ForEachObsTag found " + matchingObs.size() + " observations matching conceptId = " + conceptId);
// Next, sort these observations
if (StringUtils.isEmpty(sortBy)) {
sortBy = "obsDatetime";
}
Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator())
: new ComparableComparator()));
Collections.sort(matchingObs, comp);
// Return appropriate number of results
if (matchingObs.isEmpty()) {
return SKIP_BODY;
} else {
pageContext.setAttribute(var, matchingObs.get(count++));
return EVAL_BODY_BUFFERED;
}
}
示例12: sortSearchResult
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
protected List<WorkflowInstanceSearchModel> sortSearchResult( List<WorkflowInstanceSearchModel> result, int column, String direction ){
List<WorkflowInstanceSearchModel> unorderedSource = new ArrayList<>( result );
String fieldName = DataTableColumnMapper.from( column ).getFieldName();
BeanComparator<WorkflowInstanceSearchModel> beanComparator;
if( "asc".equalsIgnoreCase( direction ) ){
beanComparator = new BeanComparator<>( fieldName, new NullComparator() );
}
else{
beanComparator = new BeanComparator<>( fieldName, new ReverseComparator( new NullComparator() ) );
}
Collections.sort( unorderedSource, beanComparator );
return unorderedSource;
}
示例13: readPreBolonhaExecutionPeriodItems
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
private List<SelectItem> readPreBolonhaExecutionPeriodItems() {
final List<ExecutionSemester> semesters = new ArrayList<ExecutionSemester>(rootDomainObject.getExecutionPeriodsSet());
Collections.sort(semesters, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR));
final List<SelectItem> result = new ArrayList<SelectItem>();
for (final ExecutionSemester semester : semesters) {
result.add(new SelectItem(semester.getExternalId(), semester.getQualifiedName()));
}
return result;
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:11,代码来源:ManagerCurricularCourseManagementBackingBean.java
示例14: getAcademicIntervals
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
public Collection<SelectItem> getAcademicIntervals() throws FenixServiceException {
List<AcademicInterval> intervals = AcademicInterval.readAcademicIntervals(AcademicPeriod.SEMESTER);
Collections.sort(intervals, new ReverseComparator(AcademicInterval.COMPARATOR_BY_BEGIN_DATE));
List<SelectItem> items = new ArrayList<>();
for (AcademicInterval interval : intervals) {
items.add(new SelectItem(interval.getResumedRepresentationInStringFormat(), interval.getPathName()));
}
return items;
}
示例15: provide
import org.apache.commons.collections.comparators.ReverseComparator; //导入依赖的package包/类
@Override
public Object provide(Object source, Object currentValue) {
Set<ExecutionDegree> result =
new TreeSet<ExecutionDegree>(new ReverseComparator(ExecutionDegree.EXECUTION_DEGREE_COMPARATORY_BY_YEAR));
ExecutionDegreeBean executionDegreeBean = (ExecutionDegreeBean) source;
DegreeCurricularPlan degreeCurricularPlan = executionDegreeBean.getDegreeCurricularPlan();
if (degreeCurricularPlan != null) {
result.addAll(degreeCurricularPlan.getExecutionDegreesSet());
}
return result;
}