Improve registration of the same hint for multiple classes

Based on the feedback in #28977 an easy way to create a list of
type references based on a vararg of classes is helpful when
registering the same hints for several types.
This commit is contained in:
Stephane Nicoll
2022-08-18 06:52:34 +02:00
parent 4556895e6e
commit d6afa8df2d
11 changed files with 158 additions and 124 deletions

View File

@@ -16,6 +16,9 @@
package org.springframework.aot.hint;
import java.util.Arrays;
import java.util.List;
import org.springframework.lang.Nullable;
/**
@@ -81,4 +84,14 @@ public interface TypeReference {
return SimpleTypeReference.of(className);
}
/**
* Create a list of {@link TypeReference type references} mapped by the specified
* types.
* @param types the types to map
* @return a list of type references
*/
static List<TypeReference> listOf(Class<?>... types) {
return Arrays.stream(types).map(TypeReference::of).toList();
}
}