Create an instance of {@link Bytes} that is created and stored in
memory.

@param creator
the creator of byte data
@param expectedSize
the expected size of the created byte data, used to allocate memory
for the data
@return
instance of bytes
8506
static Bytes createViaDataOutput(@NonNull IOConsumer<ExtendedDataOutput> creator, int expectedSize)
		throws IOException
	{
		Objects.requireNonNull(creator);
		if(expectedSize <= 0) throw new IllegalArgumentException("expectedSize should be larger than 0");

		ByteArrayOutputStream out = new ByteArrayOutputStream(expectedSize);
		try(ExtendedDataOutput dataOut = new ExtendedDataOutputStream(out))
		{
			creator.accept(dataOut);
		}
		return Bytes.create(out.toByteArray());
	}
1204804
public static <K, V> Map<K, V> createHashMapAdapter(int expectedMapSize) {
        final int initialCapacity = calculateInitialCapacity(expectedMapSize);
        return new HashMapAdapter<K, V>(initialCapacity, HASHMAP_DEFAULT_LOAD_FACTOR);
    }
858622
protected void init(int initialMaxSize, Class<T> type, Factory<T> factory) {
		this.size = 0;
		this.type = type;
		this.factory = factory;

		data = (T[]) Array.newInstance(type, initialMaxSize);

		if( factory != null ) {
			for( int i = 0; i < initialMaxSize; i++ ) {
				try {
					data[i] = createInstance();
				} catch( RuntimeException e ) {
					throw new RuntimeException("declareInstances is true, but createInstance() can't create a new instance.  Maybe override createInstance()?");
				}
			}
		}
	}
426665
public static final byte[] generateBytes(final Random rand, final int bytes)
	{
		if (bytes < 1)
			throw new IllegalArgumentException("bytes must be >= 1");

		final byte[] buffer = new byte[bytes];
		rand.nextBytes(buffer);
		return buffer;
	}
45767
public static <IN, OUT> OUT create(IN obj, Creator<IN, OUT> creator) {
        return obj == null ? null : creator.create(obj);
    }
1337203
public Blob createNewBlob(int blockSize) throws PersistException {
        StoredLob lob = mLobStorage.prepare();
        lob.setLocator(mLocatorSequence.nextLongValue());
        lob.setBlockSize(blockSize);
        lob.setLength(0);
        lob.insert();
        return new BlobImpl(lob.getLocator());
    }
796869
public long expectSigned(int bytes) throws IOException {
        switch (bytes) {
            case 8:
                return expectLong();
            case 4:
                return expectInt();
            case 2:
                return expectShort();
            case 1:
                return expectByte();
        }
        throw new IllegalArgumentException("Unsupported byte count for signed: " + bytes);
    }
428365
public static BitVector createBitVector(byte[] data, int size) {
        BitVector bv = new BitVector(data.length * 8);
        bv.setBytes(data);
        bv.size = size;
        return bv;
    }
975444
private byte[] requestChunk(int requestedSize)
	{
		mPosInChunk = 0;
		if (mCurrentChunkIndex++ < mChunkList.size() - 1)
		{
			// there is one more unused buffer in the list, return it
			return mCurrentChunk = mChunkList.get(mCurrentChunkIndex);
		}

		mChunkList.add(mCurrentChunk = new byte[Math.max(requestedSize, mMinChunkSize)]);
		return mCurrentChunk;
	}
361128
@SuppressWarnings("unchecked")
  protected final void initialize(int maxSize) {
    size = 0;
    int heapSize = maxSize + 1;
    heap = (T[]) new Object[heapSize];
    this.maxSize = maxSize;
  }
821259
private byte[] bytesWithInstanceCreationCaptured(byte[] bytes, String classToCall, String methodToCall) {
		ClassReader cr = new ClassReader(bytes);
		ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender(classToCall, methodToCall);
		cr.accept(ca, 0);
		byte[] newbytes = ca.getBytes();
		return newbytes;
	}
1295240
@Nonnull
	public static <T, R> LObjByteFunctionBuilder<T, R> objByteFunction(Consumer<LObjByteFunction<T, R>> consumer) {
		return new LObjByteFunctionBuilder(consumer);
	}
980889
@Nonnull
	public static <T, R> LObjIntByteFunctionBuilder<T, R> objIntByteFunction(Consumer<LObjIntByteFunction<T, R>> consumer) {
		return new LObjIntByteFunctionBuilder(consumer);
	}
1110137
public static <S> PAreaSizeBIGenerator<S> create()
  {
    final LongGenerator gen = new LongGenerator(0L, Long.MAX_VALUE);
    return new PAreaSizeBIGenerator<>(() -> new BigInteger(gen.next().toString()));
  }
843868
public static MutableDoubleTuple createRandom(int size, Random random)
    {
       MutableDoubleTuple t = create(size);
       randomize(t, random);
       return t;
    }
113414
public int byteSize() throws IonException
    {
        // TODO this is horrible, users will end up encoding multiple times!
        ReverseBinaryEncoder encoder =
            new ReverseBinaryEncoder(REVERSE_BINARY_ENCODER_INITIAL_SIZE);
        encoder.serialize(this);
        return encoder.byteSize();
    }
259483
public static DataBuffer create(final int type, final int size, final int numBanks) throws IOException {
        switch (type) {
            case DataBuffer.TYPE_BYTE:
                return new DataBufferByte(size, numBanks);
            case DataBuffer.TYPE_USHORT:
                return new DataBufferUShort(size, numBanks);
            case DataBuffer.TYPE_INT:
                return new DataBufferInt(size, numBanks);
            default:
                throw new IllegalArgumentException("Unsupported data type: " + type);
        }
    }