List of usage examples for org.apache.commons.lang.builder CompareToBuilder CompareToBuilder
public CompareToBuilder()
Constructor for CompareToBuilder.
Starts off assuming that the objects are equal.
From source file:org.andromda.timetracker.vo.UserVO.java
/** * @param object to compare this object against * @return int if equal//from w w w. j a v a2 s. c o m * @see Comparable#compareTo(Object) */ public int compareTo(final UserVO object) { if (object == null) { return -1; } // Check if the same object instance if (object == this) { return 0; } return new CompareToBuilder().append(this.getId(), object.getId()) .append(this.getUsername(), object.getUsername()).append(this.getFirstName(), object.getFirstName()) .append(this.getLastName(), object.getLastName()).toComparison(); }
From source file:org.apache.cayenne.access.loader.mapper.DbType.java
/** * Compare by specificity the most specific DbPath should be first in ordered list *///from w w w. j ava 2 s.com @Override public int compareTo(DbType dbType) { return new CompareToBuilder().append(dbType.jdbc, jdbc).append(dbType.getSpecificity(), getSpecificity()) .append(dbType.length, length).append(dbType.precision, precision).append(dbType.scale, scale) .append(dbType.notNull, notNull).toComparison(); }
From source file:org.apache.cayenne.dbsync.reverse.db.ExportedKey.java
@Override public int compareTo(Object obj) { if (obj == null || !obj.getClass().equals(getClass())) { throw new IllegalArgumentException(); }/* w w w.j ava 2s . c o m*/ if (obj == this) { return 0; } ExportedKey rhs = (ExportedKey) obj; return new CompareToBuilder().append(pkCatalog, rhs.pkCatalog).append(pkSchema, rhs.pkSchema) .append(pkTable, rhs.pkTable).append(pkName, rhs.pkName).append(fkCatalog, rhs.fkCatalog) .append(fkSchema, rhs.fkSchema).append(fkTable, rhs.fkTable).append(fkName, rhs.fkName) .append(keySeq, rhs.keySeq).append(pkColumn, rhs.pkColumn).append(fkColumn, rhs.fkColumn) .toComparison(); }
From source file:org.apache.cayenne.dbsync.reverse.dbload.ExportedKey.java
@Override public int compareTo(Object obj) { if (obj == null || !obj.getClass().equals(getClass())) { throw new IllegalArgumentException(); }/*from w w w. jav a2s.c o m*/ if (obj == this) { return 0; } ExportedKey rhs = (ExportedKey) obj; return new CompareToBuilder().append(pk, rhs.pk).append(fk, rhs.fk).append(keySeq, rhs.keySeq) .toComparison(); }
From source file:org.apache.hadoop.hdfs.server.namenode.startupprogress.Step.java
@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();//from www. j a v a 2s .c o m }
From source file:org.apache.qpid.disttest.results.formatting.CSVOrderParticipantResultComparator.java
@Override public int compare(ParticipantResult left, ParticipantResult right) { return new CompareToBuilder().append(getTypeCode(left), getTypeCode(right)) .append(left.getParticipantName(), right.getParticipantName()).toComparison(); }
From source file:org.apache.qpid.server.security.access.config.Rule.java
@Override public int compareTo(Rule r) { return new CompareToBuilder().append(getAction(), r.getAction()).append(getIdentity(), r.getIdentity()) .append(getPermission(), r.getPermission()).toComparison(); }
From source file:org.apache.rya.accumulo.mr.merge.util.GroupedRow.java
/** * Natural ordering; compares based on group and then key. *///from w w w . j a va2 s .c om @Override public int compareTo(final GroupedRow o) { if (o == null) { return 1; } return new CompareToBuilder().append(group, o.group).append(key, o.key).append(value, o.value) .toComparison(); }
From source file:org.apache.rya.accumulo.mr.RyaStatementWritable.java
/** * 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.//ww w . j a v a2 s.co m * @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(); }
From source file:org.apache.rya.api.domain.RyaType.java
/** * Define a natural ordering based on data, datatype, and language. * @param o The object to compare with/*from www . j ava 2s . co m*/ * @return 0 if the data string, the datatype string, and the language * string representation match between the objects, where matching is * defined by string comparison or all being null; * Otherwise, an integer whose sign yields a consistent ordering. */ @Override public int compareTo(final RyaType o) { if (o == null) { return 1; } final String dataTypeStr = getDataType() != null ? getDataType().stringValue() : null; final String otherDataTypeStr = o.getDataType() != null ? o.getDataType().stringValue() : null; final CompareToBuilder builder = new CompareToBuilder().append(getData(), o.getData()) .append(dataTypeStr, otherDataTypeStr).append(getLanguage(), o.getLanguage()); return builder.toComparison(); }