Home / File/ TestsuitePermutation.java — netty Source File

TestsuitePermutation.java — netty Source File

Architecture documentation for TestsuitePermutation.java, a java file in the netty codebase.

File java Buffer Search 1 classes

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2014 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.testsuite.transport;

import io.netty.bootstrap.AbstractBootstrap;
import io.netty.buffer.AdaptiveByteBufAllocator;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.Unpooled;
import io.netty.buffer.UnpooledByteBufAllocator;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public final class TestsuitePermutation {
    private static final AdaptiveByteBufAllocator DEFAULT_ADAPTIVE_ALLOCATOR = new AdaptiveByteBufAllocator();

    public static List<ByteBufAllocator> allocator() {
        List<ByteBufAllocator> allocators = new ArrayList<ByteBufAllocator>();
        allocators.add(UnpooledByteBufAllocator.DEFAULT);
        allocators.add(PooledByteBufAllocator.DEFAULT);
        allocators.add(DEFAULT_ADAPTIVE_ALLOCATOR);
        return allocators;
    }

    private TestsuitePermutation() { }

    public interface BootstrapFactory<CB extends AbstractBootstrap<?, ?>> {
        CB newInstance();
    }

    public interface BootstrapComboFactory<SB extends AbstractBootstrap<?, ?>, CB extends AbstractBootstrap<?, ?>> {
        SB newServerInstance();
        CB newClientInstance();
    }

    public static ByteBuf randomBufferType(ByteBufAllocator allocator, byte[] data, int offset, int length) {
        if (ThreadLocalRandom.current().nextBoolean()) {
            return allocator.directBuffer().writeBytes(data, offset, length);
        }
        return Unpooled.wrappedBuffer(data, offset, length);
    }
}

Domain

Subdomains

Frequently Asked Questions

What does TestsuitePermutation.java do?
TestsuitePermutation.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Search subdomain.
Where is TestsuitePermutation.java in the architecture?
TestsuitePermutation.java is located at testsuite/src/main/java/io/netty/testsuite/transport/TestsuitePermutation.java (domain: Buffer, subdomain: Search, directory: testsuite/src/main/java/io/netty/testsuite/transport).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free