• 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

78.38
/displaytag/src/main/java/org/displaytag/properties/SortOrderEnum.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.properties;
8

9
import java.io.Serializable;
10
import java.util.Iterator;
11

12
import org.apache.commons.collections4.iterators.ArrayIterator;
13
import org.apache.commons.lang3.builder.HashCodeBuilder;
14

15
/**
16
 * Enumeration for sort order.
17
 */
18
public final class SortOrderEnum implements Serializable {
19

20
    /**
21
     * Stable serialVersionUID.
22
     */
23
    private static final long serialVersionUID = 42L;
24

25
    /**
26
     * Sorted in descending order (1, "descending").
27
     */
28
    public static final SortOrderEnum DESCENDING = new SortOrderEnum(1, "descending"); //$NON-NLS-1$
1✔
29

30
    /**
31
     * Sorted in ascending order (2, "ascending").
32
     */
33
    public static final SortOrderEnum ASCENDING = new SortOrderEnum(2, "ascending"); //$NON-NLS-1$
1✔
34

35
    /**
36
     * array containing all the export types.
37
     */
38
    static final SortOrderEnum[] ALL = { SortOrderEnum.DESCENDING, SortOrderEnum.ASCENDING };
1✔
39

40
    /**
41
     * Code; this is the primary key for these objects.
42
     */
43
    private final int enumCode;
44

45
    /**
46
     * description.
47
     */
48
    private final String enumName;
49

50
    /**
51
     * private constructor. Use only constants.
52
     *
53
     * @param code
54
     *            int code
55
     * @param name
56
     *            description of enumerated type
57
     */
58
    private SortOrderEnum(final int code, final String name) {
1✔
59
        this.enumCode = code;
1✔
60
        this.enumName = name;
1✔
61
    }
1✔
62

63
    /**
64
     * returns the int code.
65
     *
66
     * @return int code
67
     */
68
    public int getCode() {
69
        return this.enumCode;
1✔
70
    }
71

72
    /**
73
     * returns the description.
74
     *
75
     * @return String description of the sort order ("ascending" or "descending")
76
     */
77
    public String getName() {
78
        return this.enumName;
1✔
79
    }
80

81
    /**
82
     * lookup a SortOrderEnum by key.
83
     *
84
     * @param key
85
     *            int code
86
     *
87
     * @return SortOrderEnum or null if no SortOrderEnum is found with the given key
88
     */
89
    public static SortOrderEnum fromCode(final int key) {
90
        for (final SortOrderEnum element : SortOrderEnum.ALL) {
1!
91
            if (key == element.getCode()) {
1✔
92
                return element;
1✔
93
            }
94
        }
95
        // lookup failed
96
        return null;
×
97
    }
98

99
    /**
100
     * lookup a SortOrderEnum by an Integer key.
101
     *
102
     * @param key
103
     *            Integer code - null safe: a null key returns a null Enum
104
     *
105
     * @return SortOrderEnum or null if no SortOrderEnum is found with the given key
106
     */
107
    public static SortOrderEnum fromCode(final Integer key) {
108
        if (key == null) {
1✔
109
            return null;
1✔
110
        }
111

112
        return SortOrderEnum.fromCode(key.intValue());
1✔
113
    }
114

115
    /**
116
     * lookup a SortOrderEnum by an Integer key.
117
     *
118
     * @param key
119
     *            Integer code - null safe: a null key returns a null Enum
120
     *
121
     * @return SortOrderEnum or null if no SortOrderEnum is found with the given key
122
     *
123
     * @deprecated use fromCode(Integer)
124
     */
125
    @Deprecated
126
    public static SortOrderEnum fromIntegerCode(final Integer key) {
127
        return SortOrderEnum.fromCode(key);
×
128
    }
129

130
    /**
131
     * Lookup a SortOrderEnum by a String key.
132
     *
133
     * @param code
134
     *            String code - null safe: a null key returns a null Enum
135
     *
136
     * @return SortOrderEnum or null if no SortOrderEnum is found with the given key
137
     */
138
    public static SortOrderEnum fromName(final String code) {
139
        for (final SortOrderEnum element : SortOrderEnum.ALL) {
1!
140
            if (element.getName().equals(code)) {
1✔
141
                return element;
1✔
142
            }
143
        }
144
        // lookup failed
145
        return null;
×
146
    }
147

148
    /**
149
     * returns an iterator on all the enumerated instances.
150
     *
151
     * @return iterator
152
     */
153
    public static Iterator<SortOrderEnum> iterator() {
154
        return new ArrayIterator(SortOrderEnum.ALL);
×
155
    }
156

157
    /**
158
     * returns the enumeration description.
159
     *
160
     * @return the string
161
     *
162
     * @see java.lang.Object#toString()
163
     */
164
    @Override
165
    public String toString() {
166
        return this.getName();
×
167
    }
168

169
    /**
170
     * Only a single instance of a specific enumeration can be created, so we can check using ==.
171
     *
172
     * @param o
173
     *            the object to compare to
174
     *
175
     * @return hashCode
176
     */
177
    @Override
178
    public boolean equals(final Object o) {
179
        return this == o;
1✔
180
    }
181

182
    /**
183
     * Hash code.
184
     *
185
     * @return the int
186
     *
187
     * @see java.lang.Object#hashCode()
188
     */
189
    @Override
190
    public int hashCode() {
191
        return new HashCodeBuilder(1123997057, -1289836553).append(this.enumCode).toHashCode();
×
192
    }
193

194
}
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