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 23, 2021
1 parent 761a5ef commit 602f89c
Show file tree
Hide file tree
Showing 31 changed files with 440 additions and 151 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,12 @@
* <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 all members of given annotation type must be defined before
* calling {@code build()}, except of annotation members that declare a default value.
* If a value is not defined for an annotation member that does not have a default value,
* {@code build()} will throw an exception. Defining values of members that do not
* exist on given annotation type is possible, but such values will be ignored.
*
* @since 4.0
*/
Expand Down Expand Up @@ -67,7 +73,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 +93,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 +113,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 +133,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 +153,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 +173,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 +193,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 +213,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 +233,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 +253,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 +275,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 +297,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 +317,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 +337,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 +377,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 +397,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 +417,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 +446,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 +464,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 +482,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 +500,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 +518,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 +536,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 +554,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 +572,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 +590,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 +608,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 +628,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 +648,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 +666,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 +684,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 +723,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 +741,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 +759,15 @@ 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 was not set, and that member
* does not declare a default value
*/
AnnotationInfo build();
}
Loading

0 comments on commit 602f89c

Please sign in to comment.