Update MRI upstreams for Phosphorus
[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 package org.opendaylight.openflowplugin.impl.device.initialization;
9
10 import java.util.HashMap;
11 import java.util.Map;
12 import java.util.Optional;
13 import org.opendaylight.yangtools.yang.common.Uint8;
14
15 public class DeviceInitializerProvider {
16     private final Map<Uint8, AbstractDeviceInitializer> initializers = new HashMap<>();
17
18     /**
19      * Register device initializer.
20      *
21      * @param version     the initializer version
22      * @param initializer the initializer instance
23      */
24     void register(final Uint8 version, final AbstractDeviceInitializer initializer) {
25         initializers.put(version, initializer);
26     }
27
28     /**
29      * Lookup  device initializer.
30      *
31      * @param version the initializer version
32      * @return the initializer instance
33      */
34     public Optional<AbstractDeviceInitializer> lookup(final Uint8 version) {
35         return Optional.ofNullable(initializers.get(version));
36     }
37
38 }