// Path: src/main/java/io/github/sskorol/model/DataSupplierMetaData.java
// public class DataSupplierMetaData {
// 
//     @Getter
//     private final List<Object[]> testData;
//     private final boolean transpose;
//     private final boolean flatMap;
//     private final int[] indices;
//     @Getter
//     private final TestNGMethod testNGMethod;
// 
//     public DataSupplierMetaData(final ITestContext context, final ITestNGMethod testMethod) {
//         this.testNGMethod = new TestNGMethod(context, testMethod);
//         this.transpose = testNGMethod.getDataSupplierArg(DataSupplier::transpose, false);
//         this.flatMap = testNGMethod.getDataSupplierArg(DataSupplier::flatMap, false);
//         this.indices = testNGMethod.getDataSupplierArg(DataSupplier::indices, new int[0]);
//         this.testData = transform();
//     }
// 
//     private List<Object[]> transform() {
//         var data = streamOf(obtainReturnValue()).toList();
//         var indicesList = indicesList(data.size());
//         var wrappedReturnValue = EntryStream.of(data).filterKeys(indicesList::contains).values();
// 
//         if (transpose) {
//             return singletonList(flatMap
//                     ? wrappedReturnValue.flatMap(ReflectionUtils::streamOf).toArray()
//                     : wrappedReturnValue.toArray());
//         }
// 
//         return wrappedReturnValue.map(ob -> flatMap ? streamOf(ob).toArray() : new Object[]{ob}).toList();
//     }
// 
//     private Object obtainReturnValue() {
//         return invokeDataSupplier(testNGMethod.getDataSupplierMetaData());
//     }
// 
//     private List<Integer> indicesList(final int collectionSize) {
//         return ofNullable(indices)
//                 .filter(indicesArray -> indicesArray.length > 0)
//                 .map(IntStreamEx::of)
//                 .orElseGet(() -> IntStreamEx.range(0, collectionSize))
//                 .boxed()
//                 .toList();
//     }
// }


import io.github.sskorol.model.DataSupplierMetaData;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import java.util.Collection;
import java.util.Collections;
package io.github.sskorol.core;



/**
 * A listener which allows retrieving useful meta-data. Should be implemented on client side, and linked via SPI.
 */
public interface DataSupplierInterceptor {

    default void beforeDataPreparation(final ITestContext context, final ITestNGMethod method) {
        // not implemented
    }

    default void afterDataPreparation(final ITestContext context, final ITestNGMethod method) {
        // not implemented
    }

    default void onDataPreparation(final DataSupplierMetaData metaData) {
        // not implemented
    }

// Path: src/main/java/io/github/sskorol/model/DataSupplierMetaData.java
// public class DataSupplierMetaData {
// 
//     @Getter
//     private final List<Object[]> testData;
//     private final boolean transpose;
//     private final boolean flatMap;
//     private final int[] indices;
//     @Getter
//     private final TestNGMethod testNGMethod;
// 
//     public DataSupplierMetaData(final ITestContext context, final ITestNGMethod testMethod) {
//         this.testNGMethod = new TestNGMethod(context, testMethod);
//         this.transpose = testNGMethod.getDataSupplierArg(DataSupplier::transpose, false);
//         this.flatMap = testNGMethod.getDataSupplierArg(DataSupplier::flatMap, false);
//         this.indices = testNGMethod.getDataSupplierArg(DataSupplier::indices, new int[0]);
//         this.testData = transform();
//     }
// 
//     private List<Object[]> transform() {
//         var data = streamOf(obtainReturnValue()).toList();
//         var indicesList = indicesList(data.size());
//         var wrappedReturnValue = EntryStream.of(data).filterKeys(indicesList::contains).values();
// 
//         if (transpose) {
//             return singletonList(flatMap
//                     ? wrappedReturnValue.flatMap(ReflectionUtils::streamOf).toArray()
//                     : wrappedReturnValue.toArray());
//         }
// 
//         return wrappedReturnValue.map(ob -> flatMap ? streamOf(ob).toArray() : new Object[]{ob}).toList();
//     }
// 
//     private Object obtainReturnValue() {
//         return invokeDataSupplier(testNGMethod.getDataSupplierMetaData());
//     }
// 
//     private List<Integer> indicesList(final int collectionSize) {
//         return ofNullable(indices)
//                 .filter(indicesArray -> indicesArray.length > 0)
//                 .map(IntStreamEx::of)
//                 .orElseGet(() -> IntStreamEx.range(0, collectionSize))
//                 .boxed()
//                 .toList();
//     }
// }


// Path: src/main/java/io/github/sskorol/core/DataSupplierInterceptor.java
import io.github.sskorol.model.DataSupplierMetaData;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import java.util.Collection;
import java.util.Collections;

package io.github.sskorol.core;



/**
 * A listener which allows retrieving useful meta-data. Should be implemented on client side, and linked via SPI.
 */
public interface DataSupplierInterceptor {

    default void beforeDataPreparation(final ITestContext context, final ITestNGMethod method) {
        // not implemented
    }

    default void afterDataPreparation(final ITestContext context, final ITestNGMethod method) {
        // not implemented
    }

    default void onDataPreparation(final DataSupplierMetaData metaData) {
        // not implemented
    }

    default Collection<DataSupplierMetaData> getMetaData() {