private ChunkSizeFunction determineBatchChunkSize(Class<?> sqlObjectType, Method raw_method) { // this next big if chain determines the batch chunk size. It looks from most specific // scope to least, that is: as an argument, then on the method, then on the class, // then default to Integer.MAX_VALUE int index_of_batch_chunk_size_annotation_on_parameter; if ((index_of_batch_chunk_size_annotation_on_parameter = findBatchChunkSizeFromParam(raw_method)) >= 0) { return new ParamBasedChunkSizeFunction(index_of_batch_chunk_size_annotation_on_parameter); } else if (raw_method.isAnnotationPresent(BatchChunkSize.class)) { final int size = raw_method.getAnnotation(BatchChunkSize.class).value(); if (size <= 0) { throw new IllegalArgumentException("Batch chunk size must be >= 0"); } return new ConstantChunkSizeFunction(size); } else if (sqlObjectType.isAnnotationPresent(BatchChunkSize.class)) { final int size = BatchChunkSize.class.cast(sqlObjectType.getAnnotation(BatchChunkSize.class)).value(); return new ConstantChunkSizeFunction(size); } else { return new ConstantChunkSizeFunction(Integer.MAX_VALUE); } }
private ChunkSizeFunction determineBatchChunkSize(Class<?> sqlObjectType, Method raw_method) { // this next big if chain determines the batch chunk size. It looks from most specific // scope to least, that is: as an argument, then on the method, then on the class, // then default to Integer.MAX_VALUE int index_of_batch_chunk_size_annotation_on_parameter; if ((index_of_batch_chunk_size_annotation_on_parameter = findBatchChunkSizeFromParam(raw_method)) >= 0) { return new ParamBasedChunkSizeFunction(index_of_batch_chunk_size_annotation_on_parameter); } else if (raw_method.isAnnotationPresent(BatchChunkSize.class)) { final int size = raw_method.getAnnotation(BatchChunkSize.class).value(); if (size <= 0) { throw new IllegalArgumentException("Batch chunk size must be >= 0"); } return new ConstantChunkSizeFunction(size); } else if (sqlObjectType.isAnnotationPresent(BatchChunkSize.class)) { final int size = BatchChunkSize.class.cast(sqlObjectType.getAnnotation(BatchChunkSize.class)).value(); return new ConstantChunkSizeFunction(size); } else { return new ConstantChunkSizeFunction(Integer.MAX_VALUE); } }