Merge "Add arbitrary mask for nxm-reg"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / datastore / MultipartWriterProvider.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.datastore;
10
11 import java.util.HashMap;
12 import java.util.Map;
13 import java.util.Optional;
14 import org.opendaylight.openflowplugin.impl.datastore.multipart.AbstractMultipartWriter;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
16
17 public class MultipartWriterProvider {
18
19     private final Map<MultipartType, AbstractMultipartWriter> writers = new HashMap<>();
20
21     /**
22      * Register statistics writer.
23      *
24      * @param type    the writer type
25      * @param writer the writer instance
26      */
27     public void register(final MultipartType type, final AbstractMultipartWriter writer) {
28         writers.put(type, writer);
29     }
30
31     /**
32      * Lookup  statistics writer.
33      *
34      * @param type the writer type
35      * @return the writer instance
36      */
37     public Optional<AbstractMultipartWriter> lookup(final MultipartType type) {
38         return Optional.ofNullable(writers.get(type));
39     }
40
41 }