blob: f29ad43b4b1d68f57bcc6d2075f57202763bf177 [file] [log] [blame]
package org.onlab.onos.net;
import static com.google.common.base.Preconditions.checkArgument;
/**
* Base abstraction of an annotated entity.
*/
public class AbstractAnnotated implements Annotated {
private static final Annotations EMPTY = DefaultAnnotations.builder().build();
private final Annotations annotations;
// For serialization
protected AbstractAnnotated() {
this.annotations = null;
}
/**
* Creates a new entity, annotated with the specified annotations.
*
* @param annotations optional key/value annotations map
*/
protected AbstractAnnotated(Annotations... annotations) {
checkArgument(annotations.length <= 1, "Only one set of annotations is expected");
this.annotations = annotations.length == 1 ? annotations[0] : EMPTY;
}
@Override
public Annotations annotations() {
return annotations;
}
}