Report (TCP) port number for switches
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / device / initialization / DeviceInitializerProvider.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.device.initialization;
10
11 import java.util.HashMap;
12 import java.util.Map;
13 import java.util.Optional;
14
15 public class DeviceInitializerProvider {
16
17     private final Map<Short, AbstractDeviceInitializer> initializers = new HashMap<>();
18
19     /**
20      * Register device initializer.
21      *
22      * @param version     the initializer version
23      * @param initializer the initializer instance
24      */
25     public void register(final Short version, final AbstractDeviceInitializer initializer) {
26         initializers.put(version, initializer);
27     }
28
29     /**
30      * Lookup  device initializer.
31      *
32      * @param version the initializer version
33      * @return the initializer instance
34      */
35     public Optional<AbstractDeviceInitializer> lookup(final Short version) {
36         return Optional.ofNullable(initializers.get(version));
37     }
38
39 }