Skip to content

Package: SortFieldXmlAdapter

SortFieldXmlAdapter

nameinstructionbranchcomplexitylinemethod
SortFieldXmlAdapter()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
marshal(List)
M: 28 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
unmarshal(XmlAdaptedSortFields)
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2018, 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 javax.xml.bind.annotation.adapters.XmlAdapter;
16: import java.util.ArrayList;
17: import java.util.List;
18:
19: /**
20: * {@link SortField}s {@link XmlAdapter}.
21: *
22: * @since 1.0.0
23: */
24: public class SortFieldXmlAdapter extends XmlAdapter<XmlAdaptedSortFields, List<SortField>> {
25:
26: @Override
27: public XmlAdaptedSortFields marshal(List<SortField> sortFields) {
28: XmlAdaptedSortFields xmlAdaptedSortFields = new XmlAdaptedSortFields();
29:• for (SortField sortField : sortFields) {
30: xmlAdaptedSortFields.getAdaptedSortFields().add(new XmlAdaptedSortField(sortField.getSortDirection(), sortField.getField()));
31: }
32: return xmlAdaptedSortFields;
33: }
34:
35: @Override
36: public List<SortField> unmarshal(XmlAdaptedSortFields xmlAdaptedSortFields) throws Exception {
37: List<SortField> sortFields = new ArrayList<>();
38:• for (XmlAdaptedSortField xmlAdaptedSortField : xmlAdaptedSortFields.getAdaptedSortFields()) {
39: sortFields.add(SortField.of(xmlAdaptedSortField.getField(), xmlAdaptedSortField.getDirection()));
40: }
41: return sortFields;
42: }
43: }