]> git.basschouten.com Git - openhab-addons.git/blob
6cf3273d2a5ffaea020673298d7297b03e9979f4
[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.digitalstrom.internal.lib.event.types;
14
15 import java.util.LinkedList;
16 import java.util.List;
17
18 import com.google.gson.JsonArray;
19 import com.google.gson.JsonObject;
20
21 /**
22  * The {@link JSONEventImpl} is the implementation of the {@link Event}.
23  *
24  * @author Alexander Betker
25  */
26 public class JSONEventImpl implements Event {
27
28     private List<EventItem> eventItemList;
29
30     /**
31      * Creates a new {@link JSONEventImpl} from the given digitalSTROM-Event {@link JsonArray}.
32      *
33      * @param jsonEventArray must not be null
34      */
35     public JSONEventImpl(JsonArray jsonEventArray) {
36         this.eventItemList = new LinkedList<>();
37         for (int i = 0; i < jsonEventArray.size(); i++) {
38             if (jsonEventArray.get(i) instanceof JsonObject) {
39                 this.eventItemList.add(new EventItemImpl((JsonObject) jsonEventArray.get(i)));
40             }
41         }
42     }
43
44     @Override
45     public List<EventItem> getEventItems() {
46         return eventItemList;
47     }
48 }