Skip to content

Commit

Permalink
improve extension API
Browse files Browse the repository at this point in the history
- explicitly specified that CDI implementations don't have to accept
  custom implemetations of the `jakarta.enterprise.lang.model` and
  `jakarta.enterprise.inject.build.compatible.spi` interfaces
- moved to Jakarta Annotation 2.1.0-B1, removed `@ExtensionPriority`
  and specified that `@Priority` should be used on extension methods
- specified that `AnnotationBuilder.build` will throw if some members
  of the annotation type were not defined
- adjusted `AnnotationBuilder` so that its methods no longer accept
  varargs; arrays must be passed in explicitly to avoid ambiguity
  in case of single-element arrays
- added `InterceptorInfo` (extending `BeanInfo`) to provide
  information about interceptors, and allowed `@Processing` methods
  to declare parameters of type `InterceptorInfo`
- adjusted `@Enhancement` so that parameters of type  `DeclarationInfo`
  and `DeclarationConfig` can no longer be declared; it is not clear
  what is the full set of matching values
- replaced the use of `Map<String, Object>` in synthetic components
  functions by a dedicated `Parameters` interface
- adjusted synthetic component builders to allow defining a parameter
  of an enum type, as well as using `ClassInfo` for defining a parameter
  of a `Class` type
- improved `ParameterizedType` to provide access to the type (`ClassType`)
  of the generic class, in addition to the declaration (`ClassInfo`)
- replaced abbreviated forms "isn't", "doesn't" and "can't"
  with their longer forms "is not", "does not" and "cannot"
  • Loading branch information
Ladicek committed Sep 20, 2021
1 parent 3c3d15c commit 6522be7
Show file tree
Hide file tree
Showing 31 changed files with 427 additions and 149 deletions.
18 changes: 18 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@


<properties>
<annotation.api.version>2.1.0-B1</annotation.api.version>
<atinject.api.version>2.0.0</atinject.api.version>
<uel.api.version>4.0.0</uel.api.version>
<interceptor.api.version>2.0.0</interceptor.api.version>
Expand All @@ -154,6 +155,12 @@
<version>6.8.8</version>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${annotation.api.version}</version>
</dependency>

<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
Expand Down Expand Up @@ -182,6 +189,11 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>

<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
Expand All @@ -190,6 +202,12 @@
<dependency>
<groupId>jakarta.interceptor</groupId>
<artifactId>jakarta.interceptor-api</artifactId>
<exclusions>
<exclusion>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* <li>call {@link #build()} to create an {@link AnnotationInfo}.</li>
* </ol>
* One builder instance should not be used to create multiple annotations.
* <p>
* Note that values of <em>all</em> members of given annotation type must be defined
* before calling {@code build()}. If they are not, {@code build()} will throw an exception.
*
* @since 4.0
*/
Expand Down Expand Up @@ -67,7 +70,7 @@ default AnnotationBuilder value(boolean value) {
* @param values the boolean array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(boolean... values) {
default AnnotationBuilder value(boolean[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -87,7 +90,7 @@ default AnnotationBuilder value(byte value) {
* @param values the byte array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(byte... values) {
default AnnotationBuilder value(byte[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -107,7 +110,7 @@ default AnnotationBuilder value(short value) {
* @param values the short array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(short... values) {
default AnnotationBuilder value(short[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -127,7 +130,7 @@ default AnnotationBuilder value(int value) {
* @param values the int array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(int... values) {
default AnnotationBuilder value(int[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -147,7 +150,7 @@ default AnnotationBuilder value(long value) {
* @param values the long array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(long... values) {
default AnnotationBuilder value(long[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -167,7 +170,7 @@ default AnnotationBuilder value(float value) {
* @param values the float array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(float... values) {
default AnnotationBuilder value(float[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -187,7 +190,7 @@ default AnnotationBuilder value(double value) {
* @param values the double array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(double... values) {
default AnnotationBuilder value(double[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -207,7 +210,7 @@ default AnnotationBuilder value(char value) {
* @param values the char array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(char... values) {
default AnnotationBuilder value(char[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -227,7 +230,7 @@ default AnnotationBuilder value(String value) {
* @param values the String array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(String... values) {
default AnnotationBuilder value(String[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -247,7 +250,7 @@ default AnnotationBuilder value(Enum<?> value) {
* @param values the enum array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(Enum<?>... values) {
default AnnotationBuilder value(Enum<?>[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -269,7 +272,7 @@ default AnnotationBuilder value(Class<? extends Enum<?>> enumType, String enumVa
* @param enumValues names of the enum constants, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(Class<? extends Enum<?>> enumType, String... enumValues) {
default AnnotationBuilder value(Class<? extends Enum<?>> enumType, String[] enumValues) {
return member(AnnotationMember.VALUE, enumType, enumValues);
}

Expand All @@ -291,7 +294,7 @@ default AnnotationBuilder value(ClassInfo enumType, String enumValue) {
* @param enumValues names of the enum constants, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(ClassInfo enumType, String... enumValues) {
default AnnotationBuilder value(ClassInfo enumType, String[] enumValues) {
return member(AnnotationMember.VALUE, enumType, enumValues);
}

Expand All @@ -311,7 +314,7 @@ default AnnotationBuilder value(Class<?> value) {
* @param values the class array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(Class<?>... values) {
default AnnotationBuilder value(Class<?>[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -331,7 +334,7 @@ default AnnotationBuilder value(ClassInfo value) {
* @param values the class array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(ClassInfo... values) {
default AnnotationBuilder value(ClassInfo[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand Down Expand Up @@ -371,7 +374,7 @@ default AnnotationBuilder value(Type value) {
* @return this {@code AnnotationBuilder}
* @throws IllegalArgumentException if any given type is invalid, as described above
*/
default AnnotationBuilder value(Type... values) {
default AnnotationBuilder value(Type[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -391,7 +394,7 @@ default AnnotationBuilder value(AnnotationInfo value) {
* @param values the annotation array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(AnnotationInfo... values) {
default AnnotationBuilder value(AnnotationInfo[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand All @@ -411,7 +414,7 @@ default AnnotationBuilder value(Annotation value) {
* @param values the annotation array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
default AnnotationBuilder value(Annotation... values) {
default AnnotationBuilder value(Annotation[] values) {
return member(AnnotationMember.VALUE, values);
}

Expand Down Expand Up @@ -440,7 +443,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the boolean array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, boolean... values);
AnnotationBuilder member(String name, boolean[] values);

/**
* Adds a byte-valued annotation member with given {@code name}.
Expand All @@ -458,7 +461,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the byte array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, byte... values);
AnnotationBuilder member(String name, byte[] values);

/**
* Adds a short-valued annotation member with given {@code name}.
Expand All @@ -476,7 +479,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the short array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, short... values);
AnnotationBuilder member(String name, short[] values);

/**
* Adds an int-valued annotation member with given {@code name}.
Expand All @@ -494,7 +497,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the int array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, int... values);
AnnotationBuilder member(String name, int[] values);

/**
* Adds a long-valued annotation member with given {@code name}.
Expand All @@ -512,7 +515,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the long array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, long... values);
AnnotationBuilder member(String name, long[] values);

/**
* Adds a float-valued annotation member with given {@code name}.
Expand All @@ -530,7 +533,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the float array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, float... values);
AnnotationBuilder member(String name, float[] values);

/**
* Adds a double-valued annotation member with given {@code name}.
Expand All @@ -548,7 +551,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the double array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, double... values);
AnnotationBuilder member(String name, double[] values);

/**
* Adds a char-valued annotation member with given {@code name}.
Expand All @@ -566,7 +569,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the char array, must not be {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, char... values);
AnnotationBuilder member(String name, char[] values);

/**
* Adds a String-valued annotation member with given {@code name}.
Expand All @@ -584,7 +587,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the String array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, String... values);
AnnotationBuilder member(String name, String[] values);

/**
* Adds an enum-valued annotation member with given {@code name}.
Expand All @@ -602,7 +605,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the enum array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, Enum<?>... values);
AnnotationBuilder member(String name, Enum<?>[] values);

/**
* Adds an enum-valued annotation member with given {@code name}.
Expand All @@ -622,7 +625,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param enumValues names of the enum constants, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, Class<? extends Enum<?>> enumType, String... enumValues);
AnnotationBuilder member(String name, Class<? extends Enum<?>> enumType, String[] enumValues);

/**
* Adds an enum-valued annotation member with given {@code name}.
Expand All @@ -642,7 +645,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param enumValues names of the enum constants, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, ClassInfo enumType, String... enumValues);
AnnotationBuilder member(String name, ClassInfo enumType, String[] enumValues);

/**
* Adds a class-valued annotation member with given {@code name}.
Expand All @@ -660,7 +663,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the class array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, Class<?>... values);
AnnotationBuilder member(String name, Class<?>[] values);

/**
* Adds a class-valued annotation member with given {@code name}.
Expand All @@ -678,7 +681,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the class array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, ClassInfo... values);
AnnotationBuilder member(String name, ClassInfo[] values);

/**
* Adds a class-valued annotation member with given {@code name}.
Expand Down Expand Up @@ -717,7 +720,7 @@ default AnnotationBuilder value(Annotation... values) {
* @return this {@code AnnotationBuilder}
* @throws IllegalArgumentException if any given type is invalid, as described above
*/
AnnotationBuilder member(String name, Type... values);
AnnotationBuilder member(String name, Type[] values);

/**
* Adds an annotation-valued annotation member with given {@code name}.
Expand All @@ -735,7 +738,7 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the annotation array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, AnnotationInfo... values);
AnnotationBuilder member(String name, AnnotationInfo[] values);

/**
* Adds an annotation-valued annotation member with given {@code name}.
Expand All @@ -753,13 +756,14 @@ default AnnotationBuilder value(Annotation... values) {
* @param values the annotation array, must not be {@code null} or contain {@code null}
* @return this {@code AnnotationBuilder}
*/
AnnotationBuilder member(String name, Annotation... values);
AnnotationBuilder member(String name, Annotation[] values);

/**
* Returns an {@link AnnotationInfo} that includes all annotation members defined by previous method calls
* on this builder. After {@code build()} is called, this builder instance should be discarded.
*
* @return the built {@link AnnotationInfo}, never {@code null}
* @throws IllegalStateException if a value of some annotation member wasn't set
*/
AnnotationInfo build();
}
Loading

0 comments on commit 6522be7

Please sign in to comment.