tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net; |
| 2 | |
tom | 2482e6f | 2014-10-01 16:51:48 -0700 | [diff] [blame^] | 3 | import com.google.common.collect.ImmutableSet; |
| 4 | import com.google.common.collect.Maps; |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 5 | import org.onlab.onos.net.provider.ProviderId; |
| 6 | |
tom | 2482e6f | 2014-10-01 16:51:48 -0700 | [diff] [blame^] | 7 | import java.util.Map; |
| 8 | import java.util.Set; |
| 9 | |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 10 | /** |
| 11 | * Base implementation of a network model entity. |
| 12 | */ |
tom | 2482e6f | 2014-10-01 16:51:48 -0700 | [diff] [blame^] | 13 | public class AbstractModel implements Provided, Annotated { |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 14 | |
| 15 | private final ProviderId providerId; |
| 16 | |
tom | 2482e6f | 2014-10-01 16:51:48 -0700 | [diff] [blame^] | 17 | // FIXME: figure out whether to make this concurrent or immutable |
| 18 | private final Map<String, String> annotations = Maps.newHashMap(); |
| 19 | |
tom | c649132 | 2014-09-19 15:27:40 -0700 | [diff] [blame] | 20 | // For serialization |
| 21 | public AbstractModel() { |
| 22 | providerId = null; |
| 23 | } |
| 24 | |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 25 | /** |
| 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 | |
tom | 2482e6f | 2014-10-01 16:51:48 -0700 | [diff] [blame^] | 39 | @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 | } |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 48 | } |