2 * Copyright (c) 2010-2023 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.io.neeo.internal.models;
15 import java.util.Objects;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
21 * Represents the meta data information to a directly result. This class is simply used for serialization of the result
24 * @author Tim Roberts - Initial Contribution
28 public class NeeoDirectoryResultMeta {
29 /** The total items available */
30 private final int totalItems;
32 /** The total matching items (if filtered) available */
33 private final int totalMatchingItems;
35 /** The current position request (that will be sent back to us) */
36 private final NeeoDirectoryRequest current;
38 /** The previous position that will be sent back to us (null if no previous) */
40 private final NeeoDirectoryRequest previous;
42 /** The next position that will be sent back to us (null if no next) */
44 private final NeeoDirectoryRequest next;
47 * Constructs the meta data from the given items
49 * @param totalItems the total items available (>= 0)
50 * @param totalMatchingItems the total matching items available (>= 0)
51 * @param current the non-null current position
52 * @param previous the possibly null previous position
53 * @param next the possibly null next position
55 public NeeoDirectoryResultMeta(int totalItems, int totalMatchingItems, NeeoDirectoryRequest current,
56 @Nullable NeeoDirectoryRequest previous, @Nullable NeeoDirectoryRequest next) {
57 Objects.requireNonNull(current, "current cannot be null");
59 throw new IllegalArgumentException("totalItems must be >= 0");
61 if (totalMatchingItems < 0) {
62 throw new IllegalArgumentException("totalMatchingItems must be >= 0");
65 this.totalItems = totalItems;
66 this.totalMatchingItems = totalMatchingItems;
67 this.current = current;
68 this.previous = previous;
73 * Returns the total items available
75 * @return the total items (>= 0)
77 public int getTotalItems() {
82 * Returns the total matching items available
84 * @return the total matching items (>= 0)
86 public int getTotalMatchingItems() {
87 return totalMatchingItems;
91 * Returns the current position
93 * @return a non-null current position
95 public NeeoDirectoryRequest getCurrent() {
100 * Returns the previous position
102 * @return a possibly null previous position (null if none)
105 public NeeoDirectoryRequest getPrevious() {
110 * Returns the next position
112 * @return a possibly null next position (null if none)
115 public NeeoDirectoryRequest getNext() {
120 public String toString() {
121 return "NeeoDiscoveryListResultMeta [totalItems=" + totalItems + ", totalMatchingItems=" + totalMatchingItems
122 + ", current=" + current + ", previous=" + previous + ", next=" + next + "]";