]> git.basschouten.com Git - openhab-addons.git/blob
c4357e6d40a1e15f1eaa87085cd2008f6546345c
[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.netatmo.internal.deserialization;
14
15 import java.util.HashMap;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.netatmo.internal.api.dto.NAObject;
21
22 /**
23  * The {@link NAObjectMap} defines a hashmap of NAObjects identified by their id.
24  *
25  * @author GaĆ«l L'hopital - Initial contribution
26  */
27 @NonNullByDefault
28 public class NAObjectMap<T extends NAObject> extends HashMap<String, T> {
29     private static final long serialVersionUID = 7635233672795516649L;
30
31     @Nullable
32     public T put(T thing) {
33         return super.put(thing.getId(), thing);
34     }
35
36     public Optional<T> getOpt(String key) {
37         return Optional.ofNullable(super.get(key));
38     }
39 }