2 * Copyright (c) 2017 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
9 package org.opendaylight.mdsal.binding.javav2.model.api;
11 import com.google.common.annotations.Beta;
12 import com.google.common.collect.ImmutableList;
13 import java.util.List;
14 import java.util.NoSuchElementException;
17 * The Annotation Type interface is designed to hold information about
18 * annotation for any type that could be annotated in Java. <br>
19 * For sake of simplicity the Annotation Type is not designed to model exact
20 * behaviour of annotation mechanism, but just to hold information needed to
21 * model annotation over java Type definition.
22 * By using in collections, implementations are expected
23 * to implement {@link #hashCode()} and {@link #equals(Object)} methods.
27 public interface AnnotationType extends Type, Comparable<AnnotationType> {
30 * Returns the List of Annotations. <br>
31 * Each Annotation Type MAY have defined multiple Annotations.
33 * @return the List of Annotations.
35 List<AnnotationType> getAnnotations();
38 * Returns Parameter Definition assigned for given parameter name. <br>
39 * If Annotation does not contain parameter with specified param name, the
40 * method MAY return <code>null</code> value.
44 * @return Parameter Definition assigned for given parameter name.
46 Parameter getParameter(final String paramName);
49 * Returns List of all parameters assigned to Annotation Type.
51 * @return List of all parameters assigned to Annotation Type.
53 List<Parameter> getParameters();
56 * Returns List of parameter names.
58 * @return List of parameter names.
60 List<String> getParameterNames();
63 * Returns <code>true</code> if annotation contains parameters.
65 * @return <code>true</code> if annotation contains parameters.
67 default boolean containsParameters() {
68 return !getParameters().isEmpty();
72 boolean equals(Object o);
78 int compareTo(AnnotationType o);
81 * Annotation Type parameter interface. For simplicity the Parameter
82 * contains values and value types as Strings. Every annotation which
83 * contains parameters could contain either single parameter or array of
84 * parameters. To model this purposes the by contract if the parameter
85 * contains single parameter the {@link #getValues()} method will return
86 * empty List and {@link #getSingleValue()} MUST always return non-
87 * <code>null</code> parameter. If the Parameter holds List of values the
88 * singular {@link #getSingleValue()} parameter MAY return <code>null</code>
96 * Returns the Name of the parameter.
98 * @return the Name of the parameter.
103 * Returns value in String format if Parameter contains singular value,
104 * otherwise should return first value only. Implementation should throw
105 * exception if there is no value to return.
107 * @return value in String format.
108 * @throws NoSuchElementException If such value not found
110 String getSingleValue();
113 * Returns List of Parameter assigned values in order in which they were
114 * assigned for given parameter name. <br>
115 * If there are multiple values assigned for given parameter name the
116 * method MUST NOT return empty List.
117 * As we consider getSingleValue() as a primary method, default
118 * implementation of getValues() is provided here.
120 * @return List of Parameter assigned values in order in which they were
121 * assigned for given parameter name.
123 default List<String> getValues() {
124 return ImmutableList.of(getSingleValue());