2 * ========================LICENSE_START=================================
5 * Copyright (C) 2021 Nordix Foundation
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 package org.oran.dmaapadapter.repository;
23 import java.util.Collection;
24 import java.util.HashMap;
26 import java.util.Vector;
28 import org.oran.dmaapadapter.exceptions.ServiceException;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class InfoTypes {
33 private static final Logger logger = LoggerFactory.getLogger(InfoTypes.class);
35 private Map<String, InfoType> allTypes = new HashMap<>();
37 public InfoTypes(Collection<InfoType> types) {
39 for (InfoType type : types) {
44 public synchronized InfoType get(String id) {
45 return allTypes.get(id);
48 public synchronized InfoType getType(String id) throws ServiceException {
49 InfoType type = allTypes.get(id);
51 throw new ServiceException("Could not find type: " + id);
56 public static class ConfigFile {
57 Collection<InfoType> types;
60 private synchronized void put(InfoType type) {
61 logger.debug("Put type: {}", type.getId());
62 allTypes.put(type.getId(), type);
65 public synchronized Iterable<InfoType> getAll() {
66 return new Vector<>(allTypes.values());
69 public synchronized Collection<String> typeIds() {
70 return allTypes.keySet();
73 public synchronized int size() {
74 return allTypes.size();
77 public synchronized void clear() {