package ee.cybernetica.uxp.securityserverloadtesting.service.test;

import org.springframework.stereotype.Component;

import java.util.*;

@Component
public class BinaryDataRepository {

    private byte[] binaryData = new byte[0];


    private void generateBinaryData(int size) {
        byte[] bytes = new byte[size];
        for(int i = 0; i < size; ++i) {
            bytes[i] = (byte)i;
        }
        binaryData = bytes;
    }

    public byte[] getBinaryData(int size) {
        if(size > binaryData.length) {
            generateBinaryData(size);
        }
        if(size < binaryData.length) {
            return Arrays.copyOfRange(binaryData, 0, size + 1);
        }
        return binaryData;
    }


}
