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.binding.nobohub.internal.model;
15 import java.util.Collection;
16 import java.util.HashMap;
19 import javax.validation.constraints.NotNull;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
25 * Stores a mapping between zone ids and zones that exists.
27 * @author Jørgen Austvik - Initial contribution
28 * @author Espen Fossen - Initial contribution
31 public final class ZoneRegister {
33 private final @NotNull Map<Integer, Zone> register = new HashMap<Integer, Zone>();
36 * Stores a new Zone in the register. If a zone exists with the same id, that value is overwritten.
38 * @param zone The Zone to store.
40 public void put(Zone zone) {
41 register.put(zone.getId(), zone);
45 * Removes a zone from the registry.
47 * @param zoneId The zone to remove
48 * @return The zone that is removed. Null if the zone is not found.
50 public @Nullable Zone remove(int zoneId) {
51 return register.remove(zoneId);
55 * Returns a Zone from the registry.
57 * @param zoneId The id of the zone to return.
58 * @return Returns the zone, or null if it doesnt exist in the regestry.
60 public @Nullable Zone get(int zoneId) {
61 return register.get(zoneId);
64 public Collection<Zone> values() {
65 return register.values();