2 * Copyright (c) 2018 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.applications.frm.impl;
11 import java.util.ArrayList;
12 import java.util.List;
14 import java.util.concurrent.ConcurrentHashMap;
15 import org.opendaylight.yangtools.yang.common.Uint32;
17 public class DevicesGroupRegistry {
18 private final Map<String, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
20 public boolean isGroupPresent(String nodeId, Uint32 groupId) {
21 return deviceGroupMapping.get(nodeId) != null ? deviceGroupMapping.get(nodeId).contains(groupId) : false;
24 public void storeGroup(String nodeId, Uint32 groupId) {
25 deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId);
28 public void removeGroup(String nodeId, Uint32 groupId) {
29 deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId);
32 public void clearNodeGroups(String nodeId) {
33 deviceGroupMapping.remove(nodeId);