当前位置: 首页>>代码示例>>Java>>正文


Java ComparatorChain.addComparator方法代码示例

本文整理汇总了Java中org.apache.commons.collections.comparators.ComparatorChain.addComparator方法的典型用法代码示例。如果您正苦于以下问题:Java ComparatorChain.addComparator方法的具体用法?Java ComparatorChain.addComparator怎么用?Java ComparatorChain.addComparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections.comparators.ComparatorChain的用法示例。


在下文中一共展示了ComparatorChain.addComparator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sortResults

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
/**
 * sort the result set for the user locale
 * 
 * @param locale
 *            The locale to use.
 * @param results
 *            the result
 * @param <L>
 *            the list item
 */
@SuppressWarnings("unchecked")
public static <L extends TagData> void sortResults(Locale locale,
        List<L> results) {
    if (results.size() == 0) {
        return;
    }
    Collator primaryCollator = Collator.getInstance(locale);
    primaryCollator.setStrength(Collator.SECONDARY);
    Collator secondaryCollator = Collator.getInstance(locale);
    secondaryCollator.setStrength(Collator.TERTIARY);
    ComparatorChain chain = new ComparatorChain();
    chain.addComparator(new BeanComparator("name", primaryCollator));
    chain.addComparator(new BeanComparator("name", secondaryCollator));
    Collections.sort(results, chain);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:26,代码来源:TagHelper.java

示例2: run

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
@Atomic
public static SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, AcademicInterval academicInterval)
        throws FenixServiceException {
    final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID);

    final ComparatorChain comparator = new ComparatorChain();
    comparator.addComparator(new BeanComparator("curricularYear"));
    comparator.addComparator(new BeanComparator("curricularSemester"));
    comparator.addComparator(new BeanComparator("curricularCourse.externalId"));
    comparator.addComparator(new BeanComparator("branch"));

    final SortedSet<DegreeModuleScope> scopes = new TreeSet<DegreeModuleScope>(comparator);

    for (DegreeModuleScope degreeModuleScope : degreeCurricularPlan.getDegreeModuleScopes()) {
        if (degreeModuleScope.isActiveForAcademicInterval(academicInterval)) {
            scopes.add(degreeModuleScope);
        }
    }

    return scopes;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:22,代码来源:ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java

示例3: getExecutionPeriodsLabels

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的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;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:19,代码来源:DisplayEvaluationsForStudentToEnrol.java

示例4: getComparator

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Comparator<NormalizedRankListItem<RankTagListItem>> getComparator(Locale locale) {
    Collator primaryCollator = Collator.getInstance(locale);
    primaryCollator.setStrength(Collator.SECONDARY);
    Collator secondaryCollator = Collator.getInstance(locale);
    secondaryCollator.setStrength(Collator.TERTIARY);
    ComparatorChain chain = new ComparatorChain();
    chain.addComparator(new BeanComparator("item.name", primaryCollator));
    chain.addComparator(new BeanComparator("item.name", secondaryCollator));
    return chain;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:15,代码来源:RankTagListItemNormalizer.java

示例5: getComparator

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Comparator<NormalizedRankListItem<RankUserListItem>> getComparator(Locale locale) {
    ComparatorChain chain = new ComparatorChain();
    Collator collator = Collator.getInstance(locale);
    collator.setStrength(Collator.SECONDARY);
    chain.addComparator(new BeanComparator("item.lastName", collator));
    chain.addComparator(new BeanComparator("item.firstName", collator));
    chain.addComparator(new BeanComparator("item.email", collator));
    chain.addComparator(new BeanComparator("item.alias", collator));
    return chain;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:15,代码来源:RankUserListItemNormalizer.java

示例6: getComparator

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
/**
 * The comparator to use for sorting the resulting items. If null they will not be sorted.
 * 
 * @return The comparator
 */
private static Comparator<Object> getComparator() {
    Collator primaryCollator = Collator.getInstance(Locale.ENGLISH);
    primaryCollator.setStrength(Collator.IDENTICAL);

    ComparatorChain chain = new ComparatorChain();
    chain.addComparator(new BeanComparator("rawOffset"));
    chain.addComparator(new BeanComparator("sortingName", primaryCollator));
    return chain;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:15,代码来源:TimeZoneProvider.java

示例7: getComparator

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
/**
 * The comparator to use for sorting the resulting items. If null they will not be sorted.
 *
 * @param locale
 *            the locale
 * @return The comparator
 */
@SuppressWarnings("rawtypes")
private Comparator getComparator(Locale locale) {
    Collator primaryCollator = Collator.getInstance(locale);
    primaryCollator.setStrength(Collator.SECONDARY);
    Collator secondaryCollator = Collator.getInstance(locale);
    secondaryCollator.setStrength(Collator.TERTIARY);
    ComparatorChain chain = new ComparatorChain();
    chain.addComparator(new BeanComparator(CountryConstants.NAME, primaryCollator));
    chain.addComparator(new BeanComparator(CountryConstants.NAME, secondaryCollator));
    return chain;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:19,代码来源:MasterDataManagementImpl.java

示例8: sortMembers

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
/**
 * Sorts a list of members according to a list of SortKeySpecs.
 * An in-place, Stable sort.
 * Helper function for MDX OrderSet function.
 *
 * <p>NOTE: Does not preserve the contents of the validator.
 */
static List<Member> sortMembers(
    Evaluator evaluator,
    Iterable<Member> memberIter,
    List<Member> memberList,
    List<SortKeySpec> keySpecList)
{
    if ((memberList != null) && (memberList.size() <= 1)) {
        return memberList;
    }
    if (memberList == null) {
        memberList = new ArrayList<Member>();
        for (Member member : memberIter) {
            memberList.add(member);
        }
        if (memberList.size() <= 1) {
            return memberList;
        }
    }

    ComparatorChain chain = new ComparatorChain();
    for (SortKeySpec key : keySpecList) {
        boolean brk = key.direction.brk;
        MemberComparator comp;
        if (brk) {
            comp = new BreakMemberComparator(
                evaluator, key.key, key.direction.descending);
        } else {
            comp = new HierarchicalMemberComparator(
                evaluator, key.key, key.direction.descending);
        }
        comp.preloadValues(memberList);
        chain.addComparator(comp.wrap(), false);
    }

    Collections.sort(memberList, chain);
    return memberList;
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:45,代码来源:FunUtil.java

示例9: getInfoEnrolmentsSorted

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
public List getInfoEnrolmentsSorted() {
    final List<InfoEnrolment> infoEnrolments = getInfoEnrolments();
    ComparatorChain comparatorChain = new ComparatorChain();
    comparatorChain.addComparator(new BeanComparator("infoExecutionPeriod.infoExecutionYear.year"));
    comparatorChain.addComparator(new BeanComparator("infoExecutionPeriod.semester"));
    comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name", Collator.getInstance()));
    Collections.sort(infoEnrolments, comparatorChain);
    return infoEnrolments;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:10,代码来源:InfoStudentCurricularPlan.java

示例10: compare

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
@Override
public int compare(final Party o1, final Party o2) {
    final ComparatorChain comparatorChain = new ComparatorChain();
    comparatorChain.addComparator(Party.COMPARATOR_BY_NAME);
    comparatorChain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID);

    return comparatorChain.compare(o1, o2);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:9,代码来源:Party.java

示例11: sortScopes

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
private void sortScopes(List<InfoCurricularCourseScope> scopes) {
    ComparatorChain comparatorChain = new ComparatorChain();
    comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.infoCurricularYear.year"));
    comparatorChain.addComparator(new BeanComparator("infoBranch.name"));
    comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.semester"));
    comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name"));
    Collections.sort(scopes, comparatorChain);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:9,代码来源:DisplayCurricularPlan.java

示例12: getComparator

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
private Comparator getComparator(HttpServletRequest request) {
    final String orderParameter = request.getParameter(ORDER_PARAMETER);
    final String orderGetter =
            StringUtils.isEmpty(orderParameter) ? DEFAULT_ORDER_GETTER : orderParameter.substring(0,
                    orderParameter.indexOf(ORDER_MARKER));

    final String orderDir =
            StringUtils.isEmpty(orderParameter) ? DEFAULT_ORDER_DIR : orderParameter.substring(
                    orderParameter.indexOf(ORDER_MARKER) + 1, orderParameter.length());
    final boolean orderAsc = Arrays.asList(ASC_ORDER_DIR).contains(orderDir);

    if (orderGetter.equals(REQUEST_NUMBER_YEAR)) {
        return orderAsc ? AcademicServiceRequest.COMPARATOR_BY_NUMBER : new ReverseComparator(
                AcademicServiceRequest.COMPARATOR_BY_NUMBER);
    } else if (orderGetter.equals(EXECUTION_YEAR)) {
        return orderAsc ? AcademicServiceRequest.EXECUTION_YEAR_AND_OID_COMPARATOR : new ReverseComparator(
                AcademicServiceRequest.EXECUTION_YEAR_AND_OID_COMPARATOR);
    } else if (orderGetter.equals(REGISTRATION_NUMBER) || orderGetter.equals(DESCRIPTION)
            || orderGetter.equals(URGENT_REQUEST) || orderGetter.equals(REGISTRATION_NUMBER)
            || orderGetter.equals(REQUEST_DATE) || orderGetter.equals(ACTIVE_SITUATION_DATE)) {
        final ComparatorChain chain = new ComparatorChain();
        chain.addComparator(orderAsc ? new BeanComparator(orderGetter) : new ReverseComparator(
                new BeanComparator(orderGetter)));
        chain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID);
        return chain;
    }

    return null;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:30,代码来源:AcademicServiceRequestsManagementDispatchAction.java

示例13: compare

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
@Override
public int compare(ExecutionDegree o1, ExecutionDegree o2) {
    final ComparatorChain comparatorChain = new ComparatorChain();
    comparatorChain.addComparator(EXECUTION_DEGREE_COMPARATORY_BY_DEGREE_TYPE_AND_NAME);
    comparatorChain.addComparator(EXECUTION_DEGREE_COMPARATORY_BY_YEAR);

    return comparatorChain.compare(o1, o2);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:9,代码来源:ExecutionDegree.java

示例14: compare

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
@Override
final public int compare(ICurriculumEntry o1, ICurriculumEntry o2) {
    final ComparatorChain comparatorChain = new ComparatorChain();
    comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_EXECUTION_PERIOD);
    comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_ID);

    return comparatorChain.compare(o1, o2);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:9,代码来源:ICurriculumEntry.java

示例15: compare

import org.apache.commons.collections.comparators.ComparatorChain; //导入方法依赖的package包/类
@Override
final public int compare(ConclusionProcessVersion o1, ConclusionProcessVersion o2) {
    final ComparatorChain chain = new ComparatorChain();
    chain.addComparator(ConclusionProcessVersion.COMPARATOR_BY_CREATION_DATE_TIME);
    chain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID);
    return chain.compare(o1, o2);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:8,代码来源:ConclusionProcessVersion.java


注:本文中的org.apache.commons.collections.comparators.ComparatorChain.addComparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。