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
8 package org.opendaylight.openflowplugin.applications.frm.impl;
10 import java.util.ArrayList;
11 import java.util.List;
13 import java.util.concurrent.ConcurrentHashMap;
14 import org.opendaylight.yangtools.yang.common.Uint32;
16 public class DevicesGroupRegistry {
17 private final Map<String, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
19 public boolean isGroupPresent(final String nodeId, final Uint32 groupId) {
20 final List<Uint32> groups = deviceGroupMapping.get(nodeId);
21 return groups != null && groups.contains(groupId);
24 public void storeGroup(final String nodeId, final Uint32 groupId) {
25 deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId);
28 public void removeGroup(final String nodeId, final Uint32 groupId) {
29 deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId);
32 public void clearNodeGroups(final String nodeId) {
33 deviceGroupMapping.remove(nodeId);