]> git.basschouten.com Git - openhab-addons.git/blob
4c852e1c5b8b9635c64cfddc326188a000cf7fcd
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.io.neeo.internal.models;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * This class represents a directory position (within an overall list of items). This class is simply used for
20  * serialization and deserialization with the NEEO Brain.
21  *
22  * @author Tim Roberts - Initial Contribution
23  *
24  */
25 @NonNullByDefault
26 public class NeeoDirectoryRequest {
27     /** The offset position within the overall list */
28     private final int offset;
29
30     /** The limit (total items) for this position */
31     private final int limit;
32
33     /** The browse identifier identifying this position */
34     @Nullable
35     private final String browseIdentifier;
36
37     /**
38      * Constructs the position from the given parameters
39      *
40      * @param offset a non-negative offset
41      * @param limit a non-negative limit
42      * @param browseIdentifier a potentially null, potentially empty browse identifier
43      */
44     public NeeoDirectoryRequest(int offset, int limit, @Nullable String browseIdentifier) {
45         if (offset < 0) {
46             throw new IllegalArgumentException("offset cannot be negative");
47         }
48         if (limit < 0) {
49             throw new IllegalArgumentException("limit cannot be negative");
50         }
51         this.offset = offset;
52         this.limit = limit;
53         this.browseIdentifier = browseIdentifier;
54     }
55
56     /**
57      * The offset for this position
58      *
59      * @return the offset (>= 0)
60      */
61     public int getOffset() {
62         return offset;
63     }
64
65     /**
66      * The limit for this position
67      *
68      * @return the limit (>= 0)
69      */
70     public int getLimit() {
71         return limit;
72     }
73
74     /**
75      * The browse identifier
76      *
77      * @return a potentially null, potentially empty browse identifier
78      */
79     @Nullable
80     public String getBrowseIdentifier() {
81         return browseIdentifier;
82     }
83
84     @Override
85     public String toString() {
86         return "NeeoDiscoveryListResultPosition [offset=" + offset + ", limit=" + limit + ", browseIdentifier="
87                 + browseIdentifier + "]";
88     }
89 }