2 * Copyright (c) 2010-2022 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.HashMap;
18 import javax.validation.constraints.NotNull;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
24 * Stores a mapping between override ids and overrides that are in place.
26 * @author Jørgen Austvik - Initial contribution
27 * @author Espen Fossen - Initial contribution
30 public final class OverrideRegister {
32 private final @NotNull Map<Integer, OverridePlan> register = new HashMap<>();
35 * Stores a new Override in the register. If an override exists with the same id, that value is overwritten.
37 * @param overridePlan The Override to store.
39 public void put(OverridePlan overridePlan) {
40 register.put(overridePlan.getId(), overridePlan);
44 * Removes an override from the registry.
46 * @param overrideId The override to remove
47 * @return The override that is removed. Null if the override is not found.
49 public @Nullable OverridePlan remove(int overrideId) {
50 return register.remove(overrideId);
54 * Returns an Override from the registry.
56 * @param overrideId The id of the override to return.
57 * @return Returns the override, or null if it doesnt exist in the regestry.
59 public @Nullable OverridePlan get(int overrideId) {
60 return register.get(overrideId);