|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 | * A representation of something that can be annotated.
|
23 | 23 | *
|
24 | 24 | * @author Andy Wilkinson
|
| 25 | + * @author Stephane Nicoll |
25 | 26 | */
|
26 | 27 | public interface Annotatable {
|
27 | 28 |
|
28 |
| - void annotate(Annotation annotation); |
| 29 | + /** |
| 30 | + * Return the {@link AnnotationContainer} to use to configure the annotations of this |
| 31 | + * element. |
| 32 | + * @return the annotation container |
| 33 | + */ |
| 34 | + AnnotationContainer annotations(); |
29 | 35 |
|
30 |
| - List<Annotation> getAnnotations(); |
| 36 | + /** |
| 37 | + * Add the specified {@link Annotation}. |
| 38 | + * @param annotation the annotation to add |
| 39 | + * @deprecated since 0.20.0 in favor of {@link #annotations()} |
| 40 | + */ |
| 41 | + @Deprecated(since = "0.20.0", forRemoval = true) |
| 42 | + default void annotate(Annotation annotation) { |
| 43 | + annotations().add(annotation.getClassName(), (builder) -> builder.from(annotation)); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Return the configured {@linkplain Annotation annotations}. |
| 48 | + * @return the annotations |
| 49 | + * @deprecated since 0.20.0 in favor of {@link #annotations()} |
| 50 | + */ |
| 51 | + @Deprecated(since = "0.20.0", forRemoval = true) |
| 52 | + default List<Annotation> getAnnotations() { |
| 53 | + return annotations().values().toList(); |
| 54 | + } |
31 | 55 |
|
32 | 56 | }
|
0 commit comments