Skip to content

Package: SortDirection

SortDirection

nameinstructionbranchcomplexitylinemethod
fromString(String)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 24 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.storable.model.query;
14:
15: import org.eclipse.kapua.KapuaIllegalArgumentException;
16:
17: /**
18: * {@link SortDirection} definition.
19: * <p>
20: * It define which sorting direction to use when processing {@link StorableQuery}.
21: *
22: * @since 1.0.0
23: */
24: public enum SortDirection {
25:
26: /**
27: * Ascending.
28: *
29: * @since 1.0.0
30: */
31: ASC,
32:
33: /**
34: * Descending.
35: *
36: * @since 1.0.0
37: */
38: DESC;
39:
40: /**
41: * It returns a {@link SortDirection} from the given {@link String}
42: * <p>
43: * It is case insensitive.
44: *
45: * @param value The {@link String} to convert.
46: * @return The converted {@link SortDirection}.
47: * @throws KapuaIllegalArgumentException If given {@link String} cannot be converted.
48: * @since 1.0.0
49: */
50: public static SortDirection fromString(String value) throws KapuaIllegalArgumentException {
51: String ucValue = value.toUpperCase();
52: try {
53: return valueOf(ucValue);
54: } catch (Exception e) {
55: throw new KapuaIllegalArgumentException("sortDirection", value);
56: }
57: }
58: }