• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / displaytag / 1753

12 Feb 2026 03:17AM UTC coverage: 77.321% (-0.01%) from 77.334%
1753

push

github

web-flow
Merge pull request #1102 from hazendaz/renovate/javax-support-logback-monorepo

Update dependency ch.qos.logback:logback-classic to v1.5.29 (javax-support)

1438 of 2003 branches covered (71.79%)

Branch coverage included in aggregate %.

4034 of 5074 relevant lines covered (79.5%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/displaytag/src/main/java/org/displaytag/model/DefaultComparator.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2002-2026 Fabrizio Giustina, the Displaytag team
6
 */
7
package org.displaytag.model;
8

9
import java.text.Collator;
10
import java.util.Comparator;
11

12
/**
13
 * Default comparator. Was previously part of RowSorter.
14
 */
15
public class DefaultComparator implements Comparator<Object> {
16

17
    /**
18
     * Use this collator.
19
     */
20
    private final Collator collator;
21

22
    /**
23
     * Instantiate a default comparator with no collator specified.
24
     */
25
    public DefaultComparator() {
26
        this(Collator.getInstance());
×
27
    }
×
28

29
    /**
30
     * Instantiate a default comparator with a specified collator.
31
     *
32
     * @param collatorToUse
33
     *            collator instance
34
     */
35
    public DefaultComparator(final Collator collatorToUse) {
1✔
36
        this.collator = collatorToUse;
1✔
37
        this.collator.setStrength(Collator.PRIMARY); // ignore case and accents
1✔
38
    }
1✔
39

40
    /**
41
     * Compares two given objects. Not comparable objects are compared using their string representation. String
42
     * comparisons are done using a Collator.
43
     *
44
     * @param object1
45
     *            first parameter
46
     * @param object2
47
     *            second parameter
48
     *
49
     * @return the value
50
     */
51
    @Override
52
    public int compare(final Object object1, final Object object2) {
53
        int returnValue;
54
        if (object1 instanceof String && object2 instanceof String) {
1!
55
            returnValue = this.collator.compare(object1, object2);
1✔
56
        } else if (object1 instanceof Cell) {
1✔
57
            return ((Cell) object1).compareTo(object2, this.collator);
1✔
58
        } else if (object1 instanceof Comparable && object2 instanceof Comparable) {
1!
59
            returnValue = ((Comparable<Object>) object1).compareTo(object2);
1✔
60
        } else {
61
            // if object are not null and don't implement comparable, compare using string values
62
            returnValue = this.collator.compare(object1.toString(), object2.toString());
×
63
        }
64
        return returnValue;
1✔
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc