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.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
16 import org.opendaylight.yangtools.yang.common.Uint32;
18 public class DevicesGroupRegistry {
19 private final Map<NodeId, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
21 public boolean isGroupPresent(NodeId nodeId, Uint32 groupId) {
22 return deviceGroupMapping.get(nodeId) != null ? deviceGroupMapping.get(nodeId).contains(groupId) : false;
25 public void storeGroup(NodeId nodeId, Uint32 groupId) {
26 deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId);
29 public void removeGroup(NodeId nodeId, Uint32 groupId) {
30 deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId);
33 public void clearNodeGroups(NodeId nodeId) {
34 deviceGroupMapping.remove(nodeId);