blob: cbafad94286ab079f55eae451bfed0628667f2cd [file] [log] [blame]
tom3065d122014-09-03 21:56:43 -07001package org.onlab.onos.net;
2
tom2482e6f2014-10-01 16:51:48 -07003import com.google.common.collect.ImmutableSet;
4import com.google.common.collect.Maps;
tom3065d122014-09-03 21:56:43 -07005import org.onlab.onos.net.provider.ProviderId;
6
tom2482e6f2014-10-01 16:51:48 -07007import java.util.Map;
8import java.util.Set;
9
tom3065d122014-09-03 21:56:43 -070010/**
11 * Base implementation of a network model entity.
12 */
tom2482e6f2014-10-01 16:51:48 -070013public class AbstractModel implements Provided, Annotated {
tom3065d122014-09-03 21:56:43 -070014
15 private final ProviderId providerId;
16
tom2482e6f2014-10-01 16:51:48 -070017 // FIXME: figure out whether to make this concurrent or immutable
18 private final Map<String, String> annotations = Maps.newHashMap();
19
tomc6491322014-09-19 15:27:40 -070020 // For serialization
21 public AbstractModel() {
22 providerId = null;
23 }
24
tom3065d122014-09-03 21:56:43 -070025 /**
26 * Creates a model entity attributed to the specified provider.
27 *
28 * @param providerId identity of the provider
29 */
30 protected AbstractModel(ProviderId providerId) {
31 this.providerId = providerId;
32 }
33
34 @Override
35 public ProviderId providerId() {
36 return providerId;
37 }
38
tom2482e6f2014-10-01 16:51:48 -070039 @Override
40 public Set<String> annotationKeys() {
41 return ImmutableSet.copyOf(annotations.keySet());
42 }
43
44 @Override
45 public String annotation(String key) {
46 return annotations.get(key);
47 }
tom3065d122014-09-03 21:56:43 -070048}