]> git.basschouten.com Git - openhab-addons.git/blob
d7971277381ae33ac4f2eebe600ffd9486830b0a
[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.binding.semsportal.internal.dto;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The base response contains the generic properties of each response from the portal. Depending on the request, the
20  * data component contains different information. The subclasses of the BaseResponse contain the mapping of the data
21  * with respect to their request context.
22  *
23  * @author Iwan Bron - Initial contribution
24  */
25 @NonNullByDefault
26 public class BaseResponse {
27     public static final String OK = "0";
28
29     public static final String NO_SESSION = "100001";
30     public static final String SESSION_EXPIRED = "100002";
31     public static final String INVALID = "100005";
32     public static final String EXCEPTION = "innerexception";
33
34     private @Nullable String code;
35     private @Nullable String msg;
36
37     public @Nullable String getCode() {
38         return code;
39     }
40
41     public @Nullable String getMsg() {
42         return msg;
43     }
44
45     public boolean isOk() {
46         return OK.equals(code);
47     }
48
49     public boolean isError() {
50         return EXCEPTION.equals(code);
51     }
52
53     public boolean isSessionInvalid() {
54         return NO_SESSION.equals(code) || SESSION_EXPIRED.equals(code);
55     }
56 }