X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=information-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fics%2Frepository%2FMultiMap.java;fp=information-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fics%2Frepository%2FMultiMap.java;h=0000000000000000000000000000000000000000;hb=dfff24a65d219ce3985edbf744b034d1882e452f;hp=0f3be0a206a0380434f922d2ca2434435b1d687a;hpb=a5b0c057710ba2a4f13e73c2d1279f5ae9ec813c;p=nonrtric.git diff --git a/information-coordinator-service/src/main/java/org/oransc/ics/repository/MultiMap.java b/information-coordinator-service/src/main/java/org/oransc/ics/repository/MultiMap.java deleted file mode 100644 index 0f3be0a2..00000000 --- a/information-coordinator-service/src/main/java/org/oransc/ics/repository/MultiMap.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.oransc.ics.repository; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; - -/** - * A map, where each key can be bound to may values (where each value has an own - * ID) - */ -public class MultiMap { - - private final Map> map = new HashMap<>(); - - public void put(String key, String id, T value) { - this.map.computeIfAbsent(key, k -> new HashMap<>()).put(id, value); - } - - public T remove(String key, String id) { - Map innerMap = this.map.get(key); - if (innerMap != null) { - T removedElement = innerMap.remove(id); - if (innerMap.isEmpty()) { - this.map.remove(key); - } - return removedElement; - } - return null; - } - - public Collection get(String key) { - Map innerMap = this.map.get(key); - if (innerMap == null) { - return Collections.emptyList(); - } - return new Vector<>(innerMap.values()); - } - - public void clear() { - this.map.clear(); - } - -}