2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.vigicrues.internal.dto.opendatasoft;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.Optional;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
22 import com.google.gson.annotations.SerializedName;
25 * The {@link OpenDatasoftResponse} is the Java class used to map the JSON
26 * response to an opendatasoft endpoint request.
28 * @author Gaƫl L'hopital - Initial contribution
31 public class OpenDatasoftResponse {
32 @SerializedName("nhits")
34 private @Nullable Parameters parameters;
35 private List<Record> records = new ArrayList<>();
37 public int getNHits() {
41 public Optional<Parameters> getParameters() {
42 Parameters parameters = this.parameters;
43 if (parameters != null) {
44 return Optional.of(parameters);
46 return Optional.empty();
49 public Optional<VigiCruesFields> getFirstRecord() {
50 return records.stream().findFirst().flatMap(Record::getFields);