public int compareTo(Qualifier o) { // The natural order of the qualifiers is the order in // which they should appear in the flat file. if (this.equals(o)) { return 0; } final CompareToBuilder builder = new CompareToBuilder(); Integer thisOrder = ORDER_QUALS.get(this.name); if (thisOrder == null) { thisOrder = DEFAULT_ORDER_QUALS; } Integer otherOrder = ORDER_QUALS.get(o.name); if (otherOrder == null) { otherOrder = DEFAULT_ORDER_QUALS; } builder.append(thisOrder, otherOrder); return builder.toComparison(); }
@Override public int compareTo(Step other) { // Sort steps by file and then sequentially within the file to achieve the // desired order. There is no concurrent map structure in the JDK that // maintains insertion order, so instead we attach a sequence number to each // step and sort on read. return new CompareToBuilder().append(file, other.file) .append(sequenceNumber, other.sequenceNumber).toComparison(); }
/** * Comparison method for natural ordering. Compares based on the logical * triple (the s/p/o/context information in the underlying RyaStatement) * and then by the metadata contained in the RyaStatement if the triples are * the same. * @return Zero if both RyaStatementWritables contain equivalent statements * or both have null statements; otherwise, an integer whose sign * corresponds to a consistent ordering. */ @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); // should throw NPE if other is null, as per Comparable contract builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); }
public void putIndexNamesByRegion(IndexRegion bean) { Set<IndexRegion> list = regionMap.get(bean.regionName()); if (list == null) { list = new ConcurrentSkipListSet<IndexRegion>(new Comparator<IndexRegion>() { @Override public int compare(IndexRegion o1, IndexRegion o2) { return new CompareToBuilder().append(o1.orderNo(), o2.orderNo()).append(o1.indexName(), o2.indexName()) .toComparison(); } }); regionMap.put(bean.regionName(), list); } list.add(bean); }
public void putIndexNamesByTestRegion(IndexRegion bean) { Set<IndexRegion> list = testRegionMap.get(bean.regionName()); if (list == null) { list = new ConcurrentSkipListSet<IndexRegion>(new Comparator<IndexRegion>() { @Override public int compare(IndexRegion o1, IndexRegion o2) { return new CompareToBuilder().append(o1.orderNo(), o2.orderNo()).append(o1.indexName(), o2.indexName()) .toComparison(); } }); testRegionMap.put(bean.regionName(), list); } list.add(bean); }
@Override public int compare(final GbStudentGradeInfo g1, final GbStudentGradeInfo g2) { final CourseGrade cg1 = g1.getCourseGrade().getCourseGrade(); final CourseGrade cg2 = g2.getCourseGrade().getCourseGrade(); String letterGrade1 = cg1.getMappedGrade(); if (cg1.getEnteredGrade() != null) { letterGrade1 = cg1.getEnteredGrade(); } String letterGrade2 = cg2.getMappedGrade(); if (cg2.getEnteredGrade() != null) { letterGrade2 = cg2.getEnteredGrade(); } final int gradeIndex1 = this.ascendingGrades.indexOf(letterGrade1); final int gradeIndex2 = this.ascendingGrades.indexOf(letterGrade2); final Double calculatedGrade1 = cg1.getCalculatedGrade() == null ? null : Double.valueOf(cg1.getCalculatedGrade()); final Double calculatedGrade2 = cg2.getCalculatedGrade() == null ? null : Double.valueOf(cg2.getCalculatedGrade()); return new CompareToBuilder() .append(gradeIndex1, gradeIndex2) .append(calculatedGrade1, calculatedGrade2) .toComparison(); }
@Override public int compare(VersionInfo o1, VersionInfo o2) { int value; if (o1 == o2) { return 0; } if (o1 == null) { value = -1; } else if (o2 == null) { value = +1; } else { value = new CompareToBuilder().append(o1.getTitle(), o2.getTitle()).toComparison(); } return (ascending) ? value : -value; }
@Override public int compare(VersionInfo o1, VersionInfo o2) { int value; if (o1 == o2) { return 0; } if (o1 == null) { value = -1; } else if (o2 == null) { value = +1; } else { value = new CompareToBuilder().append(o1.getRevision(), o2.getRevision()).toComparison(); } return (ascending) ? value : -value; }
@Override public int compare(VersionInfo o1, VersionInfo o2) { int value; if (o1 == o2) { return 0; } if (o1 == null) { value = -1; } else if (o2 == null) { value = +1; } else { value = new CompareToBuilder().append(o1.getTimestamp(), o2.getTimestamp()).toComparison(); } return (ascending) ? value : -value; }
@Override public int compare(VersionInfo o1, VersionInfo o2) { int value; if (o1 == o2) { return 0; } if (o1 == null) { value = -1; } else if (o2 == null) { value = +1; } else { value = new CompareToBuilder().append(o1.getVersion(), o2.getVersion()).toComparison(); } return (ascending) ? value : -value; }
@Override public int compare(VersionInfo o1, VersionInfo o2) { int value; if (o1 == o2) { return 0; } if (o1 == null) { value = -1; } else if (o2 == null) { value = +1; } else { value = new CompareToBuilder().append(o1.getVendorId(), o2.getVendorId()).toComparison(); } return (ascending) ? value : -value; }
private WrappedList<JsonEffectCurveCovariateInfluence> convertToDto( List<EffectCurveCovariateInfluence> effectCurveCovariateInfluences) { List<JsonEffectCurveCovariateInfluence> dtos = new ArrayList<>(); if (!effectCurveCovariateInfluences.isEmpty()) { for (EffectCurveCovariateInfluence covariateInfluence : effectCurveCovariateInfluences) { dtos.add(new JsonEffectCurveCovariateInfluence(covariateInfluence)); } Collections.sort(dtos, new Comparator<JsonEffectCurveCovariateInfluence>() { @Override public int compare(JsonEffectCurveCovariateInfluence o1, JsonEffectCurveCovariateInfluence o2) { return new CompareToBuilder() .append(o1.getName(), o2.getName()) .append(o1.getCovariateValue(), o2.getCovariateValue()) .toComparison(); } }); } return new WrappedList<>(dtos); }
private List<ColumnTracker> getNextColumnTrackers(int maxVarsPerPdu) { List<ColumnTracker> trackers = new ArrayList<ColumnTracker>(maxVarsPerPdu); List<ColumnTracker> sortedTrackerList = new ArrayList<ColumnTracker>(m_columnTrackers); Collections.sort(sortedTrackerList, new Comparator<ColumnTracker>() { public int compare(ColumnTracker o1, ColumnTracker o2) { return new CompareToBuilder() .append(o1.getLastInstance(), o2.getLastInstance()) .toComparison(); } }); for(Iterator<ColumnTracker> it = sortedTrackerList.iterator(); it.hasNext() && trackers.size() < maxVarsPerPdu; ) { ColumnTracker tracker = it.next(); if (!tracker.isFinished()) { trackers.add(tracker); } } return trackers; }
/** * {@inheritDoc} * Compares this instance with the <code>other</code> registered service based on * evaluation order, name. The name comparison is case insensitive. * * @see #getEvaluationOrder() */ @Override public int compareTo(final RegisteredService other) { return new CompareToBuilder() .append(this.getEvaluationOrder(), other.getEvaluationOrder()) .append(this.getName().toLowerCase(), other.getName().toLowerCase()) .append(this.getServiceId(), other.getServiceId()) .toComparison(); }
/** * Sort the groups using order id. * * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override public int compareTo(Group group) { return new CompareToBuilder().append(this.getOrderId(), group.getOrderId()) .append(this.getGroupId(), group.getGroupId()).append(this.getGroupName(), group.getGroupName()) .append(this.getGroupUIID(), group.getGroupUIID()).toComparison(); }
public int compare(Object o1, Object o2) { CoverageInfo c1 = (CoverageInfo) o1; CoverageInfo c2 = (CoverageInfo) o2; // this will take care of null values as well return new CompareToBuilder().append(c1.getTitle(), c2.getTitle()).toComparison(); }
/** * @see Comparable#compareTo(Object) */ public int compareTo(IntakeAnswerElement answerElement) { CompareToBuilder compareToBuilder = new CompareToBuilder(); compareToBuilder.append(getId(), answerElement.getId()); compareToBuilder.append(getElement(), answerElement.getElement()); return compareToBuilder.toComparison(); }
/** * @see Comparable#compareTo(Object) */ public int compareTo(IntakeAnswer answer) { CompareToBuilder compareToBuilder = new CompareToBuilder(); compareToBuilder.append(getId(), answer.getId()); compareToBuilder.append(getNode().getId(), answer.getNode().getId()); compareToBuilder.append(getIndex(),answer.getIndex()); return compareToBuilder.toComparison(); }
/** * 设置值 * * @param product * 商品 */ private void setValue(Product product) { if (product == null) { return; } if (StringUtils.isEmpty(product.getSn())) { String sn; do { sn = snDao.generate(Type.product); } while (productDao.snExists(sn)); product.setSn(sn); } StringBuffer fullName = new StringBuffer(product.getName()); if (product.getSpecificationValues() != null && !product.getSpecificationValues().isEmpty()) { List<SpecificationValue> specificationValues = new ArrayList<SpecificationValue>(product.getSpecificationValues()); Collections.sort(specificationValues, new Comparator<SpecificationValue>() { public int compare(SpecificationValue a1, SpecificationValue a2) { return new CompareToBuilder().append(a1.getSpecification(), a2.getSpecification()).toComparison(); } }); fullName.append(Product.FULL_NAME_SPECIFICATION_PREFIX); int i = 0; for (Iterator<SpecificationValue> iterator = specificationValues.iterator(); iterator.hasNext(); i++) { if (i != 0) { fullName.append(Product.FULL_NAME_SPECIFICATION_SEPARATOR); } fullName.append(iterator.next().getName()); } fullName.append(Product.FULL_NAME_SPECIFICATION_SUFFIX); } product.setFullName(fullName.toString()); }
/** * 设置值 * * @param product * 商品 */ private void setValue(Product product) { if (product == null) { return; } if (StringUtils.isEmpty(product.getSn())) { String sn; do { sn = snDao.generate(Type.product); } while (snExists(sn)); product.setSn(sn); } StringBuffer fullName = new StringBuffer(product.getName()); if (product.getSpecificationValues() != null && !product.getSpecificationValues().isEmpty()) { List<SpecificationValue> specificationValues = new ArrayList<SpecificationValue>(product.getSpecificationValues()); Collections.sort(specificationValues, new Comparator<SpecificationValue>() { public int compare(SpecificationValue a1, SpecificationValue a2) { return new CompareToBuilder().append(a1.getSpecification(), a2.getSpecification()).toComparison(); } }); fullName.append(Product.FULL_NAME_SPECIFICATION_PREFIX); int i = 0; for (Iterator<SpecificationValue> iterator = specificationValues.iterator(); iterator.hasNext(); i++) { if (i != 0) { fullName.append(Product.FULL_NAME_SPECIFICATION_SEPARATOR); } fullName.append(iterator.next().getName()); } fullName.append(Product.FULL_NAME_SPECIFICATION_SUFFIX); } product.setFullName(fullName.toString()); }
@Override public int compare(Horario horario1, Horario horario2) { return new CompareToBuilder() .append(horario1.getHorarioInicio(), horario2.getHorarioInicio()) .append(horario1.getHorarioFim(), horario2.getHorarioFim()) .append(horario1.getStrDiaSemana(), horario2.getStrDiaSemana()) .toComparison(); }
private void ordenaHorarios() { horarios.sort((horarioUm, horarioDois) -> new CompareToBuilder() .append(horarioUm.getDiaSemana(), horarioDois.getDiaSemana()) .append(horarioUm.getHorarioInicio(), horarioDois.getHorarioInicio()) .append(horarioUm.getHorarioFim(), horarioDois.getHorarioFim()) .toComparison()); }
public int compareTo(XRef o) { final CompareToBuilder builder = new CompareToBuilder(); builder.append(this.database, o.database); builder.append(this.primaryAccession, o.primaryAccession); builder.append(this.secondaryAccession, o.secondaryAccession); return builder.toComparison(); }
public int compareTo(Person o) { final Person other = o; final CompareToBuilder builder = new CompareToBuilder(); builder.append(this.surname, other.surname); builder.append(this.firstName, other.firstName); return builder.toComparison(); }
public int compareTo(Patent o) { final Patent other = o; final CompareToBuilder builder = new CompareToBuilder(); builder.appendSuper(super.compareTo(other)); builder.append(this.patentOffice, other.patentOffice); builder.append(this.patentNumber, other.patentNumber); builder.append(this.patentType, other.patentType); builder.append(this.sequenceNumber, other.sequenceNumber); builder.append(this.day, other.day); String[] thisApplicants = this.applicants.toArray(new String[this.applicants.size()]); String[] otherApplicants = other.applicants.toArray(new String[this.applicants.size()]); builder.append(thisApplicants, otherApplicants); return builder.toComparison(); }
public int compareTo(Reference o) { final Reference other = o; final CompareToBuilder builder = new CompareToBuilder(); builder.append(this.referenceNumber, other.referenceNumber); builder.append(this.publication, other.publication); builder.append(this.comment, other.comment); // TODO builder.append(this.locations, other.locations); return builder.toComparison(); }
public int compareTo(Thesis o) { final Thesis other = o; final CompareToBuilder builder = new CompareToBuilder(); builder.appendSuper(super.compareTo(other)); builder.append(this.institute, other.institute); builder.append(this.year, other.year); return builder.toComparison(); }
public int compareTo(Publication obj) { Publication other = obj; final CompareToBuilder builder = new CompareToBuilder(); builder.append(this.title, other.title); builder.append(this.consortium, other.consortium); Person[] thisAuthors = this.authors.toArray(new Person[this.authors.size()]); Person[] otherAuthors = other.authors.toArray(new Person[other.authors.size()]); builder.append(thisAuthors, otherAuthors); XRef[] thisXRefs = this.xRefs.toArray(new XRef[this.xRefs.size()]); XRef[] otherXRefs = other.xRefs.toArray(new XRef[other.xRefs.size()]); builder.append(thisXRefs, otherXRefs); return builder.toComparison(); }
public int compareTo(Article o) { final Article other = (Article) o; final CompareToBuilder builder = new CompareToBuilder(); builder.appendSuper(super.compareTo(other)); builder.append(this.firstPage, other.firstPage); builder.append(this.lastPage, other.lastPage); builder.append(this.volume, other.volume); builder.append(this.issue, other.issue); builder.append(this.journal, other.journal); builder.append(this.year, other.year); return builder.toComparison(); }
public int compareTo(Book o) { final Book other = (Book) o; final CompareToBuilder builder = new CompareToBuilder(); builder.appendSuper(super.compareTo(other)); builder.append(this.bookTitle, other.bookTitle); builder.append(this.firstPage, other.firstPage); builder.append(this.lastPage, other.lastPage); builder.append(this.publisher, other.publisher); builder.append(this.year, other.year); Person[] thisEditors = this.editors.toArray(new Person[this.editors.size()]); Person[] otherEditors = other.editors.toArray(new Person[other.editors.size()]); builder.append(thisEditors, otherEditors); return builder.toComparison(); }
public int compareTo(Submission o) { final Submission other = o; final CompareToBuilder builder = new CompareToBuilder(); builder.appendSuper(super.compareTo(other)); builder.append(this.day, other.day); builder.append(this.submitterAddress, other.submitterAddress); return builder.toComparison(); }
public int compareTo(ElectronicReference o) { final ElectronicReference other = (ElectronicReference) o; final CompareToBuilder builder = new CompareToBuilder(); builder.appendSuper(super.compareTo(other)); builder.append(this.text, other.text); return builder.toComparison(); }
/** * Compare ValidationResults so they will be listed in the desired * order: by validationRule, period, attributeOptionCombo and orgUnit. * * @param other The other ValidationResult to compare with. * @return a negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. */ @Override public int compareTo( ValidationResult other ) { return new CompareToBuilder() .append( this.validationRule, other.getValidationRule() ) .append( this.period, other.getPeriod() ) .append( this.attributeOptionCombo, other.getAttributeOptionCombo() ) .append( this.organisationUnit, other.getOrganisationUnit() ) .append( this.id, other.getId() ) .toComparison(); }
/** * Compares the quadruple based on the first element followed by the second * element followed by the third element followed by the fourth element. * <p> * The element types must be {@code Comparable}. * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater */ @Override public int compareTo(Quadruple<A, B, C, D> other) { return new CompareToBuilder() .append(_first, other._first) .append(_second, other._second) .append(_third, other._third) .append(_fourth, other._fourth) .toComparison(); }
@Override public int compare(ManageableExchangeDetail detail1, ManageableExchangeDetail detail2) { return new CompareToBuilder() .append(detail1.getProductGroup(), detail2.getProductGroup()) .append(detail1.getProductName(), detail2.getProductName()) .append(detail1.getCalendarStart(), detail2.getCalendarStart()) .append(detail1.getCalendarEnd(), detail2.getCalendarEnd()) .append(detail1.getDayStart(), detail2.getDayStart()) .append(detail1.getDayEnd(), detail2.getDayEnd()) .append(detail1.getPhaseName(), detail2.getPhaseName()) .append(detail1.getPhaseStart(), detail2.getPhaseStart()) .toComparison(); }
@Override public int compareTo(CalculationResultKey other) { return new CompareToBuilder() .append(getCalcConfigName(), other.getCalcConfigName()) .append(getTargetId(), other.getTargetId()) .appendSuper(comparePaths(getPath(), other.getPath())) .append(getValueName(), other.getValueName()) .append(getProperties(), other.getProperties()) .toComparison(); }