blob: 5ebde83981ea764a791a0c1ffaae85d94186e93b [file] [log] [blame]
tomf5d85d42014-10-02 05:27:56 -07001package org.onlab.onos.net;
2
3import static com.google.common.base.Preconditions.checkArgument;
4
5/**
6 * Base implementation of an annotated model description.
7 */
tom5a9383a2014-10-02 07:33:52 -07008public abstract class AbstractDescription implements Annotated {
tomf5d85d42014-10-02 05:27:56 -07009
10 private static final SparseAnnotations EMPTY = DefaultAnnotations.builder().build();
11
12 private final SparseAnnotations annotations;
13
14 // For serialization
15 protected AbstractDescription() {
16 this.annotations = null;
17 }
18
19 /**
20 * Creates a new entity, annotated with the specified annotations.
21 *
22 * @param annotations optional key/value annotations map
23 */
24 protected AbstractDescription(SparseAnnotations... annotations) {
25 checkArgument(annotations.length <= 1, "Only one set of annotations is expected");
26 this.annotations = annotations.length == 1 ? annotations[0] : EMPTY;
27 }
28
29 @Override
30 public SparseAnnotations annotations() {
31 return annotations;
32 }
33
34}