2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
10 import java.util.List;
12 import org.opendaylight.controller.config.api.annotations.Description;
13 import org.opendaylight.controller.config.api.annotations.RequireInterface;
14 import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
15 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
16 import org.opendaylight.yangtools.yang.common.QName;
18 import com.google.common.base.Preconditions;
19 import com.google.common.collect.Lists;
21 public class Annotation {
23 final List<Parameter> params;
25 public Annotation(String name, List<Parameter> params) {
30 public String getName() {
34 public List<Parameter> getParams() {
38 public static Annotation createDescriptionAnnotation(String description) {
39 Preconditions.checkNotNull(description,
40 "Cannot create annotation from null description");
41 return new Annotation(Description.class.getCanonicalName(),
42 Lists.newArrayList(new Parameter("value", q(description))));
45 public static Annotation createSieAnnotation(QName qname,
46 String exportedClassName) {
47 Preconditions.checkNotNull(qname,
48 "Cannot create annotation from null qname");
49 Preconditions.checkNotNull(exportedClassName,
50 "Cannot create annotation from null exportedClassName");
52 List<Parameter> params = Lists.newArrayList(new Parameter("value",
53 q(qname.getLocalName())));
54 params.add(new Parameter("osgiRegistrationType", exportedClassName
56 return new Annotation(
57 ServiceInterfaceAnnotation.class.getCanonicalName(), params);
60 public static Annotation createRequireIfcAnnotation(
61 ServiceInterfaceEntry sie) {
62 String reqIfc = sie.getFullyQualifiedName() + ".class";
63 return new Annotation(RequireInterface.class.getCanonicalName(),
64 Lists.newArrayList(new Parameter("value", reqIfc)));
67 private static final String quote = "\"";
69 private static String q(String nullableDescription) {
70 return nullableDescription == null ? null : quote + nullableDescription
74 public static class Parameter {
75 private final String key, value;
77 public Parameter(String key, String value) {
82 public String getKey() {
86 public String getValue() {