we changed Iterable -> List in Data spec

This commit is contained in:
Gavin King 2024-03-23 12:21:18 +01:00
parent c7504d4ada
commit b7038b2294
2 changed files with 14 additions and 22 deletions

View File

@ -40,16 +40,13 @@ public interface BookAuthorRepository {
void insertBooks0(Book[] books); void insertBooks0(Book[] books);
@Insert @Insert
void insertBooks1(Iterable<Book> books); void insertBooks1(List<Book> books);
@Insert @Insert
void insertBooks2(Set<Book> books); List<Book> insertBooks2(List<Book> books);
@Insert @Insert
List<Book> insertBooks3(List<Book> books); Book[] insertBooks3(Book[] books);
@Insert
Book[] insertBooks4(Book[] books);
@Find @Find
Book book(String isbn); Book book(String isbn);
@ -61,7 +58,7 @@ public interface BookAuthorRepository {
Book[] books(@By("isbn") String[] isbns); Book[] books(@By("isbn") String[] isbns);
@Find @Find
List<Book> booksWithPages(Iterable<Integer> pages); List<Book> booksWithPages(List<Integer> pages);
@Find @Find
List<Book> booksWithPages(int pages); List<Book> booksWithPages(int pages);
@ -196,7 +193,4 @@ public interface BookAuthorRepository {
@Update @Update
Book edit(Book book); Book edit(Book book);
@Insert
Iterable<Book> createAll(Iterable<Book> books);
} }

View File

@ -64,7 +64,6 @@ import static java.beans.Introspector.decapitalize;
import static java.lang.Boolean.FALSE; import static java.lang.Boolean.FALSE;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static javax.lang.model.element.ElementKind.CLASS;
import static javax.lang.model.util.ElementFilter.fieldsIn; import static javax.lang.model.util.ElementFilter.fieldsIn;
import static javax.lang.model.util.ElementFilter.methodsIn; import static javax.lang.model.util.ElementFilter.methodsIn;
import static org.hibernate.internal.util.StringHelper.qualify; import static org.hibernate.internal.util.StringHelper.qualify;
@ -1176,10 +1175,9 @@ public class AnnotationMetaEntity extends AnnotationMeta {
//INTENTIONAL FALL THROUGH //INTENTIONAL FALL THROUGH
case DECLARED: case DECLARED:
final DeclaredType declaredType = (DeclaredType) parameterType; final DeclaredType declaredType = (DeclaredType) parameterType;
final Elements elements = context.getElementUtils(); final TypeElement typeElement = (TypeElement) declaredType.asElement();
if ( types.isAssignable( declaredType, if ( typeElement.getQualifiedName().contentEquals(LIST)
types.erasure( elements.getTypeElement(ITERABLE).asType() ) ) && !declaredType.getTypeArguments().isEmpty() ) {
&& !declaredType.getTypeArguments().isEmpty() ) {
final TypeMirror elementType = types.erasure( declaredType.getTypeArguments().get(0) ); final TypeMirror elementType = types.erasure( declaredType.getTypeArguments().get(0) );
return elementType.getKind() == TypeKind.DECLARED ? (DeclaredType) elementType : null; return elementType.getKind() == TypeKind.DECLARED ? (DeclaredType) elementType : null;
} }
@ -1792,7 +1790,7 @@ public class AnnotationMetaEntity extends AnnotationMeta {
*/ */
private boolean checkParameterType(TypeElement entityType, VariableElement param, TypeMirror attributeType) { private boolean checkParameterType(TypeElement entityType, VariableElement param, TypeMirror attributeType) {
final Types types = context.getTypeUtils(); final Types types = context.getTypeUtils();
if ( entityType.getKind() == CLASS ) { // do no checks if the entity type is a type variable // if ( entityType.getKind() == CLASS ) { // do no checks if the entity type is a type variable
TypeMirror parameterType = parameterType( param ); TypeMirror parameterType = parameterType( param );
if ( types.isSameType( parameterType, attributeType ) ) { if ( types.isSameType( parameterType, attributeType ) ) {
return false; return false;
@ -1809,8 +1807,8 @@ public class AnnotationMetaEntity extends AnnotationMeta {
parameterType = typeVariable.getUpperBound(); parameterType = typeVariable.getUpperBound();
// INTENTIONAL FALL-THROUGH // INTENTIONAL FALL-THROUGH
case DECLARED: case DECLARED:
final TypeElement iterable = context.getTypeElementForFullyQualifiedName(ITERABLE); final TypeElement list = context.getTypeElementForFullyQualifiedName(LIST);
if ( types.isAssignable( parameterType, types.getDeclaredType( iterable, attributeType) ) ) { if ( types.isSameType( parameterType, types.getDeclaredType( list, attributeType) ) ) {
return true; return true;
} }
else { else {
@ -1836,10 +1834,10 @@ public class AnnotationMetaEntity extends AnnotationMeta {
} }
} }
} }
} // }
else { // else {
return false; // return false;
} // }
} }
private void parameterTypeError(TypeElement entityType, VariableElement param, TypeMirror attributeType) { private void parameterTypeError(TypeElement entityType, VariableElement param, TypeMirror attributeType) {