本文整理匯總了Java中org.apache.commons.lang.builder.CompareToBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java CompareToBuilder類的具體用法?Java CompareToBuilder怎麽用?Java CompareToBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompareToBuilder類屬於org.apache.commons.lang.builder包,在下文中一共展示了CompareToBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compareTo
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
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();
}
示例2: compareTo
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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();
}
示例3: compareTo
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
/**
* 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();
}
示例4: putIndexNamesByRegion
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
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);
}
示例5: putIndexNamesByTestRegion
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
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);
}
示例6: compare
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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();
}
示例7: compare
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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;
}
示例8: compare
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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;
}
示例9: compare
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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;
}
示例10: compare
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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;
}
示例11: compare
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
@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;
}
示例12: convertToDto
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
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);
}
示例13: getNextColumnTrackers
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
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;
}
示例14: compareTo
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
/**
* {@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();
}
示例15: compareTo
import org.apache.commons.lang.builder.CompareToBuilder; //導入依賴的package包/類
/**
* 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();
}