Example usage for org.apache.commons.lang3.builder CompareToBuilder CompareToBuilder

List of usage examples for org.apache.commons.lang3.builder CompareToBuilder CompareToBuilder

Introduction

In this page you can find the example usage for org.apache.commons.lang3.builder CompareToBuilder CompareToBuilder.

Prototype

public CompareToBuilder() 

Source Link

Document

Constructor for CompareToBuilder.

Starts off assuming that the objects are equal.

Usage

From source file:com.moviejukebox.model.artwork.Artwork.java

public int compareTo(Artwork other) {
    return new CompareToBuilder().append(this.sourceSite, other.sourceSite).append(this.type, other.type)
            .append(this.url, other.url).toComparison();
}

From source file:io.netlibs.bgp.rib.Route.java

/**
 * compare only the network / routeing relevant
 * /* ww  w .j  a va2 s.c o  m*/
 * @param o
 * @return
 */
public int networkCompareTo(Route o) {
    CompareToBuilder builder = (new CompareToBuilder()).append(getAddressFamilyKey(), o.getAddressFamilyKey())
            .append(getNlri(), o.getNlri()).append(getPathAttributes().size(), o.getPathAttributes().size())
            .append(getNextHop(), o.getNextHop());

    if (builder.toComparison() == 0) {
        Iterator<PathAttribute> lit = getPathAttributes().iterator();
        Iterator<PathAttribute> rit = o.getPathAttributes().iterator();

        while (lit.hasNext())
            builder.append(lit.next(), rit.next());
    }

    return builder.toComparison();
}

From source file:io.netlibs.bgp.protocol.attributes.MultiProtocolUnreachableNLRI.java

@Override
protected int subclassCompareTo(final PathAttribute obj) {
    final MultiProtocolUnreachableNLRI o = (MultiProtocolUnreachableNLRI) obj;

    final CompareToBuilder builer = (new CompareToBuilder())
            .append(this.getAddressFamily(), o.getAddressFamily())
            .append(this.getSubsequentAddressFamily(), o.getSubsequentAddressFamily())
            .append(this.getNlris().size(), o.getNlris().size());

    if (builer.toComparison() == 0) {
        final Iterator<NetworkLayerReachabilityInformation> lit = this.getNlris().iterator();
        final Iterator<NetworkLayerReachabilityInformation> rit = o.getNlris().iterator();

        while (lit.hasNext()) {
            builer.append(lit.next(), rit.next());
        }/* w  w w . j a  v  a 2 s  .  c  o m*/
    }

    return builer.toComparison();
}

From source file:io.github.karols.hocr4j.Word.java

@Override
public int compareTo(Word that) {
    return new CompareToBuilder().append(this.text, that.text).append(this.bounds, that.bounds)
            .append(this.isBold, that.isBold).append(this.isItalic, that.isItalic).toComparison();
}

From source file:ca.travelagency.identity.SystemUser.java

@Override
public int compareTo(SystemUser other) {
    return new CompareToBuilder().append(getName(), other.getName()).toComparison();
}

From source file:com.github.naoghuman.cm.model.matrix.MatrixModel.java

@Override
public int compareTo(MatrixModel other) {
    return new CompareToBuilder().append(this.getTitle(), other.getTitle()).append(this.getId(), other.getId())
            .append(this.getGenerationTime(), other.getGenerationTime()).toComparison();
}

From source file:com.github.naoghuman.cm.model.notes.NotesModel.java

@Override
public int compareTo(NotesModel other) {
    return new CompareToBuilder().append(this.getId(), other.getId())
            .append(this.getMatrixId(), other.getMatrixId())
            .append(this.getGenerationTime(), other.getGenerationTime()).toComparison();
}

From source file:gov.nih.nci.firebird.data.WorkHistory.java

@Override
public int compareTo(WorkHistory other) {
    return new CompareToBuilder().append(getEffectiveDate(), other.getEffectiveDate())
            .append(getExpirationDate(), other.getExpirationDate()).append(getIssuer(), other.getIssuer())
            .toComparison();/*from   w ww. j a v  a2  s .  c  o  m*/
}

From source file:io.lavagna.service.ExcelExportService.java

private HSSFWorkbook getWorkbookFromSearchFilters(int projectId, String sheetName, List<SearchFilter> filters,
        UserWithPermission user) {/*from  w ww . j  a va2s . com*/

    List<CardLabel> labels = cardLabelRepository.findLabelsByProject(projectId);
    CollectionUtils.filter(labels, new Predicate<CardLabel>() {
        @Override
        public boolean evaluate(CardLabel cl) {
            if (cl.getDomain().equals(CardLabel.LabelDomain.SYSTEM)) {
                if (cl.getName().equals("ASSIGNED") || cl.getName().equals("DUE_DATE")
                        || cl.getName().equals("MILESTONE")) {
                    return true;
                }
                return false;
            }
            return true;
        }
    });
    Collections.sort(labels, new Comparator<CardLabel>() {
        public int compare(CardLabel l1, CardLabel l2) {
            return new CompareToBuilder().append(l1.getDomain(), l2.getDomain())
                    .append(l1.getName(), l2.getName()).toComparison();
        }
    });

    SearchResults cards = searchService.find(filters, projectId, null, user);

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet(sheetName);

    Row header = sheet.createRow(0);

    int colPos = 0;
    header.createCell(colPos++).setCellValue("ID");
    header.createCell(colPos++).setCellValue("Name");
    header.createCell(colPos++).setCellValue("Column");
    header.createCell(colPos++).setCellValue("Status");
    for (CardLabel cl : labels) {
        header.createCell(colPos++).setCellValue(WordUtils.capitalizeFully(cl.getName().replace("_", " ")));
    }

    Map<Integer, BoardColumnInfo> colCache = new HashMap<>();
    Map<Integer, String> userCache = new HashMap<>();
    Map<Integer, String> cardCache = new HashMap<>();
    Map<Integer, String> listValueCache = new HashMap<>();
    int rowPos = 1;
    for (CardFullWithCounts card : cards.getFound()) {

        colPos = 0;
        Row row = sheet.createRow(rowPos++);

        // ID
        row.createCell(colPos++)
                .setCellValue(String.format("%s-%s", card.getBoardShortName(), card.getSequence()));
        // Name
        row.createCell(colPos++).setCellValue(card.getName());
        // Column
        if (!colCache.containsKey(card.getColumnId())) {
            colCache.put(card.getColumnId(), boardColumnRepository.getColumnInfoById(card.getColumnId()));
        }
        BoardColumnInfo col = colCache.get(card.getColumnId());
        row.createCell(colPos++).setCellValue(col.getColumnName());
        // ColumnDefinition
        row.createCell(colPos++).setCellValue(card.getColumnDefinition().toString());
        // Labels
        fillLabelValues(row, colPos, labels, cardLabelRepository.findCardLabelValuesByCardId(card.getId()),
                userCache, cardCache, listValueCache);
    }

    return wb;
}

From source file:com.github.naoghuman.abclist.model.ExerciseTerm.java

@Override
public int compareTo(ExerciseTerm other) {
    return new CompareToBuilder().append(this.getExerciseId(), other.getExerciseId())
            .append(this.getTermId(), other.getTermId()).append(this.getId(), other.getId()).toComparison();
}