Skip to content

Commit

Permalink
Improve Javadoc for RepeatableContainers
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Dec 14, 2022
1 parent fb6d3f5 commit 6e08c56
Showing 1 changed file with 14 additions and 12 deletions.
Expand Up @@ -53,10 +53,12 @@ private RepeatableContainers(@Nullable RepeatableContainers parent) {


/**
* Add an additional explicit relationship between a contained and
* Add an additional explicit relationship between a container and
* repeatable annotation.
* @param container the container type
* @param repeatable the contained repeatable type
* <p>WARNING: the arguments supplied to this method are in the reverse order
* of those supplied to {@link #of(Class, Class)}.
* @param container the container annotation type
* @param repeatable the repeatable annotation type
* @return a new {@link RepeatableContainers} instance
*/
public RepeatableContainers and(Class<? extends Annotation> container,
Expand Down Expand Up @@ -103,7 +105,9 @@ public static RepeatableContainers standardRepeatables() {
/**
* Create a {@link RepeatableContainers} instance that uses predefined
* repeatable and container types.
* @param repeatable the contained repeatable annotation type
* <p>WARNING: the arguments supplied to this method are in the reverse order
* of those supplied to {@link #and(Class, Class)}.
* @param repeatable the repeatable annotation type
* @param container the container annotation type or {@code null}. If specified,
* this annotation must declare a {@code value} attribute returning an array
* of repeatable annotations. If not specified, the container will be
Expand All @@ -122,7 +126,7 @@ public static RepeatableContainers of(
}

/**
* Create a {@link RepeatableContainers} instance that does not expand any
* Create a {@link RepeatableContainers} instance that does not support any
* repeatable annotations.
* @return a {@link RepeatableContainers} instance
*/
Expand Down Expand Up @@ -208,20 +212,18 @@ private static class ExplicitRepeatableContainer extends RepeatableContainers {
}
Class<?> returnType = valueMethod.getReturnType();
if (!returnType.isArray() || returnType.getComponentType() != repeatable) {
throw new AnnotationConfigurationException("Container type [" +
container.getName() +
"] must declare a 'value' attribute for an array of type [" +
repeatable.getName() + "]");
throw new AnnotationConfigurationException(
"Container type [%s] must declare a 'value' attribute for an array of type [%s]"
.formatted(container.getName(), repeatable.getName()));
}
}
catch (AnnotationConfigurationException ex) {
throw ex;
}
catch (Throwable ex) {
throw new AnnotationConfigurationException(
"Invalid declaration of container type [" + container.getName() +
"] for repeatable annotation [" + repeatable.getName() + "]",
ex);
"Invalid declaration of container type [%s] for repeatable annotation [%s]"
.formatted(container.getName(), repeatable.getName()), ex);
}
this.repeatable = repeatable;
this.container = container;
Expand Down

0 comments on commit 6e08c56

Please sign in to comment.