2 * Copyright (c) 2010-2024 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 week profile ids and week profiles that exists.
27 * @author Jørgen Austvik - Initial contribution
30 public final class WeekProfileRegister {
32 private @NotNull Map<Integer, WeekProfile> register = new HashMap<Integer, WeekProfile>();
35 * Stores a new week profile in the register. If a week profile exists with the same id, that value is overwritten.
37 * @param profile The week profile to store.
39 public void put(WeekProfile profile) {
40 register.put(profile.getId(), profile);
44 * Removes a WeekProfile from the registry.
46 * @param weekProfileId The week profile to remove
47 * @return The week profile that is removed. Null if the week profile is not found.
49 public @Nullable WeekProfile remove(int weekProfileId) {
50 return register.remove(weekProfileId);
54 * Returns a WeekProfile from the registry.
56 * @param weekProfileId The id of the week profile to return.
57 * @return Returns the week profile, or null if it doesnt exist in the registry.
59 public @Nullable WeekProfile get(int weekProfileId) {
60 return register.get(weekProfileId);
64 * Returns all WeekProfiles from the registry.
66 * @return Returns the week profile, or empty list if no profiles.
68 public Collection<WeekProfile> values() {
69 return register.values();
72 public boolean isEmpty() {
73 return register.isEmpty();