*/
package org.opendaylight.protocol.bgp.rib.impl;
+import com.google.common.base.Preconditions;
+
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
final class RIBTables {
- private static final Logger LOG = LoggerFactory.getLogger(RIBTables.class);
-
- private final Map<TablesKey, AdjRIBsIn> tables = new HashMap<>();
- private final RIBExtensionConsumerContext registry;
-
- RIBTables(final RIBExtensionConsumerContext extensions) {
- this.registry = Preconditions.checkNotNull(extensions);
- }
-
- public synchronized AdjRIBsIn get(final TablesKey key) {
- LOG.debug("Looking for key {} in tables {}", key, this.tables);
- final AdjRIBsIn ret = this.tables.get(key);
- LOG.trace("Key found {}", ret);
- return ret;
- }
-
- public synchronized AdjRIBsIn create(final DataModificationTransaction trans, final RibReference rib, final TablesKey key) {
- if (this.tables.containsKey(key)) {
- LOG.warn("Duplicate create request for key {}", key);
- return this.tables.get(key);
- }
-
- final AdjRIBsInFactory f = this.registry.getAdjRIBsInFactory(key.getAfi(), key.getSafi());
- if (f == null) {
- LOG.debug("RIBsInFactory not found for key {}, returning null", key);
- return null;
- }
-
- final AdjRIBsIn table = Preconditions.checkNotNull(f.createAdjRIBsIn(trans, rib, key));
- LOG.debug("Table {} created for key {}", table, key);
- this.tables.put(key, table);
- return table;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(RIBTables.class);
+
+ private final Map<TablesKey, AdjRIBsIn> tables = new HashMap<>();
+ private final RIBExtensionConsumerContext registry;
+
+ RIBTables(final RIBExtensionConsumerContext extensions) {
+ this.registry = Preconditions.checkNotNull(extensions);
+ }
+
+ public synchronized AdjRIBsIn get(final TablesKey key) {
+ LOG.debug("Looking for key {} in tables {}", key, this.tables);
+ final AdjRIBsIn ret = this.tables.get(key);
+ LOG.trace("Key found {}", ret);
+ return ret;
+ }
+
+ public synchronized AdjRIBsIn create(final DataModificationTransaction trans, final RibReference rib, final TablesKey key) {
+ if (this.tables.containsKey(key)) {
+ LOG.warn("Duplicate create request for key {}", key);
+ return this.tables.get(key);
+ }
+
+ final AdjRIBsInFactory f = this.registry.getAdjRIBsInFactory(key.getAfi(), key.getSafi());
+ if (f == null) {
+ LOG.debug("RIBsInFactory not found for key {}, returning null", key);
+ return null;
+ }
+
+ final AdjRIBsIn table = Preconditions.checkNotNull(f.createAdjRIBsIn(trans, rib, key));
+ LOG.debug("Table {} created for key {}", table, key);
+ this.tables.put(key, table);
+ return table;
+ }
}