2 * Copyright (c) 2016 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.unimgr.mef.nrp.api;
11 import java.util.HashSet;
13 import java.util.Optional;
15 import java.util.concurrent.ConcurrentHashMap;
17 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.common.rev171113.Uuid;
20 * Driver builder that can provide stateful driver that are used in NRP forwarding construct transaction.
21 * @author bartosz.michalik@amartus.com
23 public interface ActivationDriverBuilder {
25 * Get driver to participate in connectivity service processing.
26 * @param context (de)activation context
27 * @return {@link Optional#empty()} in case it cannot be instantiated for a port, driver otherwise
29 Optional<ActivationDriver> driverFor(BuilderContext context);
34 * Blackboard pattern that allows for passing the context information between
35 * {@link ActivationDriverBuilder}s taking part in transaction.
37 class BuilderContext {
38 private Map<String, Object> ctx = new ConcurrentHashMap<>();
41 * Get value of a certain type.
43 * @param <T> expected type
44 * @return value or empty
46 @SuppressWarnings("unchecked")
47 public <T> Optional<T> get(String key) {
48 return Optional.ofNullable((T) ctx.get(key));
53 * Put value to blackboard.
55 * @param value value object
57 public void put(String key, Object value) {
62 * Remove value from blackboard.
65 public void remove(String key) {
71 * @return available keys in blackboard
73 public Set<String> keys() {
74 return new HashSet<>(ctx.keySet());