2 * Copyright (c) 2015 Cisco Systems, Inc. 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.impl.statistics.services.direct;
11 import java.util.HashMap;
13 import java.util.Optional;
16 * The Opendaylight direct statistics service provider.
18 public class OpendaylightDirectStatisticsServiceProvider {
19 private Map<Class<? extends AbstractDirectStatisticsService>, AbstractDirectStatisticsService> services = new HashMap<>();
22 * Register direct statistics service.
24 * @param type the service type
25 * @param service the service instance
27 public void register(Class<? extends AbstractDirectStatisticsService> type, AbstractDirectStatisticsService service) {
28 services.put(type, service);
32 * Lookup direct statistics service.
34 * @param type the service type
35 * @return the service instance
37 public Optional<? extends AbstractDirectStatisticsService> lookup(Class<? extends AbstractDirectStatisticsService> type) {
38 return Optional.ofNullable(services.get(type)).map(type::cast);