2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.datastore;
11 import java.util.HashMap;
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;
17 public class MultipartWriterProvider {
19 private final Map<MultipartType, AbstractMultipartWriter> writers = new HashMap<>();
22 * Register statistics writer.
24 * @param type the writer type
25 * @param writer the writer instance
27 public void register(final MultipartType type, final AbstractMultipartWriter writer) {
28 writers.put(type, writer);
32 * Lookup statistics writer.
34 * @param type the writer type
35 * @return the writer instance
37 public Optional<AbstractMultipartWriter> lookup(final MultipartType type) {
38 return Optional.ofNullable(writers.get(type));